Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Protected Member Functions | Protected Attributes
Arc::InformationContainer Class Reference

Information System document container and processor. More...

#include <InformationInterface.h>

Inheritance diagram for Arc::InformationContainer:
Inheritance graph
[legend]
Collaboration diagram for Arc::InformationContainer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 InformationContainer (void)
 InformationContainer (XMLNode doc, bool copy=false)
 Creates an instance with XML document .
virtual ~InformationContainer (void)
XMLNode Acquire (void)
 Get a lock on contained XML document.
void Release (void)
void Assign (XMLNode doc, bool copy=false)
 Replaces internal XML document with .
SOAPEnvelope * Process (SOAPEnvelope &in)
SOAPEnvelope * Process (SOAPEnvelope &in, const InfoFilter &filter, const InfoFilterPolicies &policies=InfoFilterPolicies(), const NS &ns=NS())

Protected Member Functions

virtual void Get (const std::list< std::string > &path, XMLNodeContainer &result)
 This method is called by this object's Process method.
virtual void Get (XMLNode xpath, XMLNodeContainer &result)

Protected Attributes

XMLNode doc_
 Either link or container of XML document.
Glib::Mutex lock_
 Mutex used to protect access to Get methods in multi-threaded env.
bool to_lock_

Detailed Description

Information System document container and processor.

This class inherits form InformationInterface and offers container for storing informational XML document.

Definition at line 49 of file InformationInterface.h.


Constructor & Destructor Documentation

Definition at line 150 of file InformationInterface.cpp.

Arc::InformationContainer::InformationContainer ( XMLNode  doc,
bool  copy = false 
)

Creates an instance with XML document .

If is true this method makes a copy of for internal use.

Definition at line 153 of file InformationInterface.cpp.

                                                               :InformationInterface(true) {
  if(copy) {
    doc.New(doc_);
  } else {
    doc_=doc;
  };
}

Here is the call graph for this function:

Definition at line 161 of file InformationInterface.cpp.

                                                {
}

Member Function Documentation

Get a lock on contained XML document.

To be used in multi-threaded environment. Do not forget to release it with Release()

Definition at line 164 of file InformationInterface.cpp.

                                          {
  lock_.lock();
  return doc_;
}

Here is the caller graph for this function:

void Arc::InformationContainer::Assign ( XMLNode  doc,
bool  copy = false 
)

Replaces internal XML document with .

If is true this method makes a copy of for internal use.

Definition at line 173 of file InformationInterface.cpp.

                                                       {
  lock_.lock();
  if(copy) {
    doc.New(doc_);
  } else {
    doc_=doc;
  };
  lock_.unlock();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Arc::InformationContainer::Get ( const std::list< std::string > &  path,
XMLNodeContainer result 
) [protected, virtual]

This method is called by this object's Process method.

Real implementation of this class should return (sub)tree of XML document. This method may be called multiple times per single Process call. Here is a set on XML element names specifying how to reach requested node(s).

Reimplemented from Arc::InformationInterface.

Definition at line 184 of file InformationInterface.cpp.

                                                                                      {
  std::list<XMLNode> cur_list;
  std::list<std::string>::const_iterator cur_name = path.begin();
  cur_list.push_back(doc_);
  for(;cur_name != path.end(); ++cur_name) {
    std::list<XMLNode> new_list;
    for(std::list<XMLNode>::iterator cur_node = cur_list.begin();
                       cur_node != cur_list.end(); ++cur_node) {
      // TODO: namespaces
      std::string name = *cur_name;
      std::string::size_type p = name.find(':');
      if(p != std::string::npos) name=name.substr(p+1);
      XMLNode new_node = (*cur_node)[name];
      for(;;new_node=new_node[1]) {
        if(!new_node) break;
        new_list.push_back(new_node);
      };
    };
    cur_list=new_list;
  };
  result.Add(cur_list);
  return;
}

Here is the call graph for this function:

void Arc::InformationContainer::Get ( XMLNode  xpath,
XMLNodeContainer result 
) [protected, virtual]

Reimplemented from Arc::InformationInterface.

Definition at line 208 of file InformationInterface.cpp.

                                                                     {
  std::string q = query;
  NS ns = query.Namespaces();
  result.Add(doc_.XPathLookup(q,ns));
  return;
}

Here is the call graph for this function:

SOAPEnvelope * Arc::InformationInterface::Process ( SOAPEnvelope &  in) [inherited]

Definition at line 39 of file InformationInterface.cpp.

                                                            {
  // Try to extract WSRP object from message
  WSRF& wsrp = CreateWSRP(in);
  if(!wsrp) { delete &wsrp; return NULL; };
  // Check if operation is supported
  MutexSLock(lock_,to_lock_);
  try {
    WSRPGetResourcePropertyDocumentRequest* req = 
         dynamic_cast<WSRPGetResourcePropertyDocumentRequest*>(&wsrp);
    if(!req) throw std::exception();
    if(!(*req)) throw std::exception();
    // Requesting whole document
    XMLNodeContainer presp; Get(std::list<std::string>(),presp);
    XMLNode xresp; if(presp.Size() > 0) xresp=presp[0];
    WSRPGetResourcePropertyDocumentResponse resp(xresp);
    SOAPEnvelope* out = NULL;
    if(resp) {
      NS ns;
      (out = new SOAPEnvelope(ns))->Swap(resp.SOAP());
    };
    delete &wsrp;
    return out;
  } catch(std::exception& e) { };
  try {
    WSRPGetResourcePropertyRequest* req = 
         dynamic_cast<WSRPGetResourcePropertyRequest*>(&wsrp);
    if(!req) throw std::exception();
    if(!(*req)) throw std::exception();
    std::list<std::string> name; name.push_back(req->Name());
    XMLNodeContainer presp; Get(name,presp); // Requesting sub-element
    WSRPGetResourcePropertyResponse resp;
    for(int n = 0;n<presp.Size();++n) {
      XMLNode xresp = presp[n];
      // TODO: avoid copy
      resp.Property(xresp);
    };
    SOAPEnvelope* out = NULL;
    if(resp) {
      NS ns;
      (out = new SOAPEnvelope(ns))->Swap(resp.SOAP());
    };
    delete &wsrp;
    return out;
  } catch(std::exception& e) { };
  try {
    WSRPGetMultipleResourcePropertiesRequest* req = 
         dynamic_cast<WSRPGetMultipleResourcePropertiesRequest*>(&wsrp);
    if(!req) throw std::exception();
    if(!(*req)) throw std::exception();
    WSRPGetMultipleResourcePropertiesResponse resp;
    std::vector<std::string> names = req->Names();
    for(std::vector<std::string>::iterator iname = names.begin();
                              iname != names.end(); ++iname) {
      std::list<std::string> name; name.push_back(*iname);
      XMLNodeContainer presp; Get(name,presp); // Requesting sub-element
      for(int n = 0;n<presp.Size();++n) {
        XMLNode xresp = presp[n];
        resp.Property(xresp);
      };
    };
    SOAPEnvelope* out = NULL;
    if(resp) {
      NS ns;
      (out = new SOAPEnvelope(ns))->Swap(resp.SOAP());
    };
    delete &wsrp;
    return out;
  } catch(std::exception& e) { };
  try {
    WSRPQueryResourcePropertiesRequest* req = 
         dynamic_cast<WSRPQueryResourcePropertiesRequest*>(&wsrp);
    if(!req) throw std::exception();
    if(!(*req)) throw std::exception();
    if(req->Dialect() != XPATH_1_0_URI) {
      // TODO: generate proper fault
      delete &wsrp;
      return SOAPFault::MakeSOAPFault(SOAPFault::Sender,"Query dialect not supported");
    }
    XMLNodeContainer presp; Get(req->Query(),presp);
    WSRPQueryResourcePropertiesResponse resp;
    for(int n = 0;n<presp.Size();++n) {
      XMLNode xresp = presp[n];
      resp.Properties().NewChild(xresp);
    };
    SOAPEnvelope* out = NULL;
    if(resp) {
      NS ns;
      (out = new SOAPEnvelope(ns))->Swap(resp.SOAP());
    };
    delete &wsrp;
    return out;
  } catch(std::exception& e) { };
  if(to_lock_) lock_.unlock();
  delete &wsrp;
  return SOAPFault::MakeSOAPFault(SOAPFault::Sender,"Operation not supported");
}

Here is the call graph for this function:

Here is the caller graph for this function:

SOAPEnvelope * Arc::InformationInterface::Process ( SOAPEnvelope &  in,
const InfoFilter filter,
const InfoFilterPolicies policies = InfoFilterPolicies(),
const NS ns = NS() 
) [inherited]

Definition at line 136 of file InformationInterface.cpp.

                                                                                                                                     {
  SOAPEnvelope* out = Process(in);
  // If error or fault - leave
  if(!out) return out;
  if(!(*out)) return out;
  if(out->IsFault()) return out;
  // Otherwise filter body of result
  if(filter.Filter(out->Body(),policies,ns)) return out;
  // If filtering failed it is safer to return SOAP fault
  delete out;
  return SOAPFault::MakeSOAPFault(SOAPFault::Sender,"Operation not supported");
}

Here is the call graph for this function:

Definition at line 169 of file InformationInterface.cpp.

                                       {
  lock_.unlock();
}

Here is the caller graph for this function:


Member Data Documentation

Either link or container of XML document.

Reimplemented in ARex::OptimizedInformationContainer.

Definition at line 52 of file InformationInterface.h.

Glib::Mutex Arc::InformationInterface::lock_ [protected, inherited]

Mutex used to protect access to Get methods in multi-threaded env.

Definition at line 21 of file InformationInterface.h.

bool Arc::InformationInterface::to_lock_ [protected, inherited]

Definition at line 22 of file InformationInterface.h.


The documentation for this class was generated from the following files: