Back to index

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

Information System message processor. More...

#include <InformationInterface.h>

Inheritance diagram for Arc::InformationInterface:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 InformationInterface (bool safe=true)
 Constructor.
virtual ~InformationInterface (void)
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

Glib::Mutex lock_
 Mutex used to protect access to Get methods in multi-threaded env.
bool to_lock_

Detailed Description

Information System message processor.

This class provides callback for 2 operations of WS-ResourceProperties and convenient parsing/generation of corresponding SOAP mesages. In a future it may extend range of supported specifications.

Definition at line 18 of file InformationInterface.h.


Constructor & Destructor Documentation

Constructor.

If 'safe' is true all calls to Get will be locked.

Definition at line 33 of file InformationInterface.cpp.

                                                   :to_lock_(safe) {
}

Definition at line 36 of file InformationInterface.cpp.

                                                {
}

Member Function Documentation

void Arc::InformationInterface::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 in Arc::InformationContainer, and Arc::InfoCacheInterface.

Definition at line 25 of file InformationInterface.cpp.

                                                                          {
  return;
}

Here is the caller graph for this function:

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

Reimplemented in Arc::InformationContainer, and Arc::InfoCacheInterface.

Definition at line 29 of file InformationInterface.cpp.

                                                        {
  return;
}
SOAPEnvelope * Arc::InformationInterface::Process ( SOAPEnvelope &  in)

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() 
)

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:


Member Data Documentation

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

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

Definition at line 21 of file InformationInterface.h.

Definition at line 22 of file InformationInterface.h.


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