Back to index

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

#include <InfoCache.h>

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

List of all members.

Public Member Functions

 InfoCacheInterface (Config &cfg, std::string &service_id)
virtual ~InfoCacheInterface (void)
InfoCacheCache (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

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

Detailed Description

Definition at line 39 of file InfoCache.h.


Constructor & Destructor Documentation

Arc::InfoCacheInterface::InfoCacheInterface ( Config cfg,
std::string &  service_id 
)

Definition at line 227 of file InfoCache.cpp.

                                                                        :
                                       cache(cfg,service_id)
{
}

Definition at line 232 of file InfoCache.cpp.

{
}

Member Function Documentation

Definition at line 47 of file InfoCache.h.

{ return cache; };
void Arc::InfoCacheInterface::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 236 of file InfoCache.cpp.

{
    std::string xml_path;
    for(std::list<std::string>::const_iterator cur_name = path.begin();
        cur_name != path.end(); ++cur_name) {
        xml_path+="/"+(*cur_name);
    };
    if(xml_path.empty()) xml_path="/";
    cache.Get(xml_path,result);
}

Here is the call graph for this function:

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

Reimplemented from Arc::InformationInterface.

Definition at line 247 of file InfoCache.cpp.

{
    std::string query = xpath;
    if(!cache.Query("/",query.c_str(),result)) return;
    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:


Member Data Documentation

Definition at line 41 of file InfoCache.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: