Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
ARex::ARexService Class Reference

#include <arex.h>

Inheritance diagram for ARex::ARexService:
Inheritance graph
[legend]
Collaboration diagram for ARex::ARexService:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ARexService (Arc::Config *cfg)
virtual ~ARexService (void)
virtual Arc::MCC_Status process (Arc::Message &inmsg, Arc::Message &outmsg)
 Method for processing of requests and responses.
void InformationCollector (void)
virtual bool RegistrationCollector (Arc::XMLNode &doc)
 Service specific registartion collector, used for generate service registartions.
virtual std::string getID ()
 Service may implement own service identitifer gathering method.
void StopChildThreads (void)
 operator bool (void)
bool operator! (void)
virtual void AddSecHandler (Config *cfg, ArcSec::SecHandler *sechandler, const std::string &label="")
 Add security components/handlers to this MCC.

Protected Member Functions

ARexConfigContextget_configuration (Arc::Message &inmsg)
Arc::MCC_Status CreateActivity (ARexGMConfig &config, Arc::XMLNode in, Arc::XMLNode out, const std::string &clientid)
Arc::MCC_Status GetActivityStatuses (ARexGMConfig &config, Arc::XMLNode in, Arc::XMLNode out)
Arc::MCC_Status TerminateActivities (ARexGMConfig &config, Arc::XMLNode in, Arc::XMLNode out)
Arc::MCC_Status GetActivityDocuments (ARexGMConfig &config, Arc::XMLNode in, Arc::XMLNode out)
Arc::MCC_Status GetFactoryAttributesDocument (ARexGMConfig &config, Arc::XMLNode in, Arc::XMLNode out)
Arc::MCC_Status StopAcceptingNewActivities (ARexGMConfig &config, Arc::XMLNode in, Arc::XMLNode out)
Arc::MCC_Status StartAcceptingNewActivities (ARexGMConfig &config, Arc::XMLNode in, Arc::XMLNode out)
Arc::MCC_Status ChangeActivityStatus (ARexGMConfig &config, Arc::XMLNode in, Arc::XMLNode out)
Arc::MCC_Status MigrateActivity (ARexGMConfig &config, Arc::XMLNode in, Arc::XMLNode out, const std::string &clientid)
Arc::MCC_Status CacheCheck (ARexGMConfig &config, Arc::XMLNode in, Arc::XMLNode out)
Arc::MCC_Status UpdateCredentials (ARexGMConfig &config, Arc::XMLNode in, Arc::XMLNode out, const std::string &credentials)
Arc::MCC_Status make_response (Arc::Message &outmsg)
Arc::MCC_Status make_fault (Arc::Message &outmsg)
Arc::MCC_Status make_soap_fault (Arc::Message &outmsg)
Arc::MCC_Status Get (Arc::Message &inmsg, Arc::Message &outmsg, ARexGMConfig &config, const std::string &id, const std::string &subpath)
Arc::MCC_Status Put (Arc::Message &inmsg, Arc::Message &outmsg, ARexGMConfig &config, const std::string &id, const std::string &subpath)
void GenericFault (Arc::SOAPFault &fault)
void NotAuthorizedFault (Arc::XMLNode fault)
void NotAuthorizedFault (Arc::SOAPFault &fault)
void NotAcceptingNewActivitiesFault (Arc::XMLNode fault)
void NotAcceptingNewActivitiesFault (Arc::SOAPFault &fault)
void UnsupportedFeatureFault (Arc::XMLNode fault, const std::string &feature)
void UnsupportedFeatureFault (Arc::SOAPFault &fault, const std::string &feature)
void CantApplyOperationToCurrentStateFault (Arc::XMLNode fault, const std::string &gm_state, bool failed, const std::string &message)
void CantApplyOperationToCurrentStateFault (Arc::SOAPFault &fault, const std::string &gm_state, bool failed, const std::string &message)
void OperationWillBeAppliedEventuallyFault (Arc::XMLNode fault, const std::string &gm_state, bool failed, const std::string &message)
void OperationWillBeAppliedEventuallyFault (Arc::SOAPFault &fault, const std::string &gm_state, bool failed, const std::string &message)
void UnknownActivityIdentifierFault (Arc::XMLNode fault, const std::string &message)
void UnknownActivityIdentifierFault (Arc::SOAPFault &fault, const std::string &message)
void InvalidRequestMessageFault (Arc::XMLNode fault, const std::string &element, const std::string &message)
void InvalidRequestMessageFault (Arc::SOAPFault &fault, const std::string &element, const std::string &message)
bool ProcessSecHandlers (Message &message, const std::string &label="") const
 Executes security handlers of specified queue.

Protected Attributes

Arc::ThreadRegistry thread_count_
Arc::NS ns_
Arc::Logger logger_
Arc::DelegationContainerSOAP delegations_
OptimizedInformationContainer infodoc_
Arc::InfoRegisters inforeg_
CountedResource infolimit_
CountedResource beslimit_
CountedResource datalimit_
std::string endpoint_
std::string uname_
std::string gmconfig_
bool gmconfig_temporary_
std::string common_name_
std::string long_description_
std::string lrms_name_
std::string os_name_
unsigned int infoprovider_wakeup_period_
std::map< std::string,
std::string > 
glue_states_
GridManagergm_
bool valid_
std::map< std::string,
std::list< ArcSec::SecHandler * > > 
sechandlers_
 Set of labeled authentication and authorization handlers.

Static Protected Attributes

static Logger logger
 Logger object used to print messages generated by this class.

Detailed Description

Definition at line 49 of file arex.h.


Constructor & Destructor Documentation

Definition at line 460 of file arex.cpp.

                                      :RegisteredService(cfg),
              logger_(Arc::Logger::rootLogger, "A-REX"),
              inforeg_(*cfg,this),
              gmconfig_temporary_(false),
              gm_(NULL),
              valid_(false) {
  // logger_.addDestination(logcerr);
  // Define supported namespaces
  ns_[BES_ARC_NPREFIX]=BES_ARC_NAMESPACE;
  ns_[BES_GLUE_NPREFIX]=BES_GLUE_NAMESPACE;
  ns_[BES_FACTORY_NPREFIX]=BES_FACTORY_NAMESPACE;
  ns_[BES_MANAGEMENT_NPREFIX]=BES_MANAGEMENT_NAMESPACE;
  ns_["deleg"]="http://www.nordugrid.org/schemas/delegation";
  ns_["wsa"]="http://www.w3.org/2005/08/addressing";
  ns_["jsdl"]="http://schemas.ggf.org/jsdl/2005/11/jsdl";
  ns_["wsrf-bf"]="http://docs.oasis-open.org/wsrf/bf-2";
  ns_["wsrf-r"]="http://docs.oasis-open.org/wsrf/r-2";
  ns_["wsrf-rw"]="http://docs.oasis-open.org/wsrf/rw-2";
  // Obtain information from configuration

  endpoint_=(std::string)((*cfg)["endpoint"]);
  uname_=(std::string)((*cfg)["usermap"]["defaultLocalName"]);
  gmconfig_=(std::string)((*cfg)["gmconfig"]);

  JobUsers users;
  if(gmconfig_.empty()) {
    // No external configuration file means configuration is
    // directly embedded into this configuration node.
    // TODO: merge external and internal configuration elements
    // Configuration is stored into temporary file and file is 
    // deleted in destructor. File is created in one of configured
    // control directories. There is still a problem if destructor
    // is not called. So code must be changed to use 
    // some better approach - maybe like creating file with service
    // id in its name.
    try {
      if(!configure_users_dirs(*cfg,users)) {
        logger_.msg(Arc::ERROR, "Failed to process service configuration");
        return;
      }
      // create control and session directories if not yet done
      // extract control directories to be used for temp configuration
      std::list<std::string> tmp_dirs;
      for(JobUsers::iterator user = users.begin();user != users.end();++user) {
        std::string tmp_dir = user->ControlDir();
        std::list<std::string>::iterator t = tmp_dirs.begin();
        for(;t != tmp_dirs.end();++t) {
          if(*t == tmp_dir) break;
        };
        if(t == tmp_dirs.end()) {
          tmp_dirs.push_back(tmp_dir);
        };
        if(!user->CreateDirectories()) {
          logger_.msg(Arc::ERROR, "Failed to create control (%s) or session (%s) directories",user->ControlDir(),user->SessionRoot());
          return;
        };
      };
      if(tmp_dirs.size() <= 0) {
        throw Glib::FileError(Glib::FileError::FAILED,"Failed to find control directories in configuration");
      };
      int h = -1;
      for(std::list<std::string>::iterator t = tmp_dirs.begin();
                                         t != tmp_dirs.end();++t) {
        std::string tmp_path = Glib::build_filename(*t,"arexcfgXXXXXX");
        h = Glib::mkstemp(tmp_path);
        if(h != -1) {
          gmconfig_ = tmp_path;
          ::chmod(gmconfig_.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
          break;
        };
        logger_.msg(Arc::DEBUG, "Failed to create temporary file in %s - %s",*t,Arc::StrError(errno));
      };
      if(h == -1) {
        throw Glib::FileError(Glib::FileError::FAILED,"Failed to create temporary file in any of control directories");
      };
      logger_.msg(Arc::DEBUG, "Storing configuration into temporary file - %s",gmconfig_);
      Arc::XMLNode gmxml;
      cfg->New(gmxml);
      // Storing configuration into temporary file
      // Maybe XMLNode needs method SaveToHandle ?
      std::string gmstr;
      gmxml.GetDoc(gmstr);
      // Candidate for common function ?
      for(int p = 0;p<gmstr.length();) {
        int l = write(h,gmstr.c_str()+p,gmstr.length()-p);
        if(l == -1) throw Glib::FileError(Glib::FileError::IO_ERROR,""); // TODO: process error
        p+=l;
      };
      close(h);
      gmconfig_temporary_=true;
      nordugrid_config_loc(gmconfig_);
    } catch(Glib::FileError& e) {
      logger_.msg(Arc::ERROR, "Failed to store configuration into temporary file: %s",e.what());
      if(!gmconfig_.empty()) {
        ::unlink(gmconfig_.c_str());
        gmconfig_.resize(0);
      };
      return; // GM configuration file is required
    };
  } else {
    // External configuration file
    nordugrid_config_loc(gmconfig_);
    if(!configure_users_dirs(users)) {
      logger_.msg(Arc::ERROR, "Failed to process configuration in %s",gmconfig_);
    }
    // create control and session directories if not yet done
    for(JobUsers::iterator user = users.begin();user != users.end();++user) {
      if(!user->CreateDirectories()) {
        logger_.msg(Arc::ERROR, "Failed to create control (%s) or session (%s) directories",user->ControlDir(),user->SessionRoot());
      };
    };
  };
  std::string gmrun_ = (std::string)((*cfg)["gmrun"]);
  common_name_ = (std::string)((*cfg)["commonName"]);
  long_description_ = (std::string)((*cfg)["longDescription"]);
  lrms_name_ = (std::string)((*cfg)["LRMSName"]);
  os_name_ = (std::string)((*cfg)["OperatingSystem"]);
  int valuei;
  if ((!(*cfg)["InfoproviderWakeupPeriod"]) ||
      (!Arc::stringto((std::string)((*cfg)["InfoproviderWakeupPeriod"]),infoprovider_wakeup_period_))) {
    infoprovider_wakeup_period_ = DEFAULT_INFOPROVIDER_WAKEUP_PERIOD;
  };
  if ((!(*cfg)["InfosysInterfaceMaxClients"]) ||
      (!Arc::stringto((std::string)((*cfg)["InfosysInterfaceMaxClients"]),valuei))) {
    valuei = DEFAULT_INFOSYS_MAX_CLIENTS;
  };
  infolimit_.MaxConsumers(valuei);
  if ((!(*cfg)["JobControlInterfaceMaxClients"]) ||
      (!Arc::stringto((std::string)((*cfg)["JobControlInterfaceMaxClients"]),valuei))) {
    valuei = DEFAULT_JOBCONTROL_MAX_CLIENTS;
  };
  beslimit_.MaxConsumers(valuei);
  if ((!(*cfg)["DataTransferInterfaceMaxClients"]) ||
      (!Arc::stringto((std::string)((*cfg)["DataTransferInterfaceMaxClients"]),valuei))) {
    valuei = DEFAULT_DATATRANSFER_MAX_CLIENTS;
  };
  datalimit_.MaxConsumers(valuei);

  // Run grid-manager in thread
  if((gmrun_.empty()) || (gmrun_ == "internal")) {
    gm_=new GridManager(gmconfig_.empty()?NULL:gmconfig_.c_str());
    if(!(*gm_)) { delete gm_; gm_=NULL; return; };
  };
  CreateThreadFunction(&information_collector_starter,this);
  valid_=true;
}

Here is the call graph for this function:

ARex::ARexService::~ARexService ( void  ) [virtual]

Definition at line 607 of file arex.cpp.

                              {
  thread_count_.RequestCancel();
  if(gm_) delete gm_;
  if(gmconfig_temporary_) {
    if(!gmconfig_.empty()) unlink(gmconfig_.c_str());
  };
  thread_count_.WaitForExit();
}

Here is the call graph for this function:


Member Function Documentation

void Arc::Service::AddSecHandler ( Config cfg,
ArcSec::SecHandler sechandler,
const std::string &  label = "" 
) [virtual, inherited]

Add security components/handlers to this MCC.

For more information please see description of MCC::AddSecHandler

Definition at line 14 of file Service.cpp.

                                                                                           {
    if(sechandler) {
        sechandlers_[label].push_back(sechandler); //need polishing to put the SecHandlerFactory->getinstance here
        XMLNode cn = (*cfg)["SecHandler"];
        Config cfg_(cn);
    }
}

Here is the caller graph for this function:

Definition at line 26 of file cachecheck.cpp.

                                                                                       {

      // We are supporting only this cachedir format for checking: cachedir="/tmp/cache"
         //
         // The cachedir="/tmp/%U/cache" format cannot be implemented at the moment 
         // but maybe at the future 


  uid_t uid = getuid();
  gid_t gid = getgid();
 
  std::string file_owner_username = "";

  JobUser user(uid);

  std::vector<std::string> caches;

    struct passwd pw_;
    struct passwd *pw;
    char buf[BUFSIZ];
    getpwuid_r(getuid(),&pw_,buf,BUFSIZ,&pw);
    if(pw == NULL) {
     logger.msg(Arc::ERROR, "Error with cache configuration"); 
     Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Error with cache configuration");  
     fault.Detail(true).NewChild("CacheConfigurationFault");
        out.Destroy();
        return Arc::MCC_Status();
    }
    if(pw->pw_name) file_owner_username=pw->pw_name;

    // use cache dir(s) from conf file
    try {
      CacheConfig * cache_config = new CacheConfig(std::string(file_owner_username));
      std::vector<std::string> conf_caches = cache_config->getCacheDirs();
      // add each cache to our list
      for (std::vector<std::string>::iterator i = conf_caches.begin(); i != conf_caches.end(); i++) {
        user.substitute(*i);
        caches.push_back(*i);
      }
    }
    catch (CacheConfigException e) {
     logger.msg(Arc::ERROR, "Error with cache configuration: %s", e.what()); 
     Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Error with cache configuration");  
     fault.Detail(true).NewChild("CacheConfigurationFault");
        out.Destroy();
        return Arc::MCC_Status();
    }

  if (caches.empty()) {
     Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Cache is disabled");  
     fault.Detail(true).NewChild("CacheDisabledFault");
        out.Destroy();
        return Arc::MCC_Status();
  }


  Arc::FileCache * cache;
  if(!caches.empty()) {

    cache = new Arc::FileCache(caches, CACHE_CHECK_SESSION_DIR_ID ,uid,gid);
    if (!(*cache)) {
     logger.msg(Arc::ERROR, "Error with cache configuration"); 
     Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Error with cache configuration");  
     fault.Detail(true).NewChild("CacheConfigurationFault");
        out.Destroy();
        return Arc::MCC_Status();
    }
  }

  bool fileexist;

  Arc::XMLNode resp = out.NewChild("CacheCheckResponse");

  Arc::XMLNode results = resp.NewChild("CacheCheckResult");

   for(int n = 0;;++n) {
      Arc::XMLNode id = in["CacheCheck"]["TheseFilesNeedToCheck"]["FileURL"][n];
      
      if (!id) break;
    
      fileexist = false;

         std::string fileurl = (std::string)in["CacheCheck"]["TheseFilesNeedToCheck"]["FileURL"][n];
 
      std::string file_lfn;

      Arc::UserConfig usercfg(true);
      Arc::DataHandle d(fileurl, usercfg);

      file_lfn = (*cache).File(d->str());

         struct stat fileStat;
         fileexist = (stat(file_lfn.c_str(), &fileStat) == 0) ? true : false;

      Arc::XMLNode resultelement = results.NewChild("Result");

         resultelement.NewChild("FileURL") = fileurl;
         resultelement.NewChild("ExistInTheCache") = (fileexist ? "true": "false");
  
      if (fileexist) 
            resultelement.NewChild("FileSize") = inttostring(fileStat.st_size);
         else
            resultelement.NewChild("FileSize") = "0";


   }
  
   return Arc::MCC_Status(Arc::STATUS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ARex::ARexService::CantApplyOperationToCurrentStateFault ( Arc::XMLNode  fault,
const std::string &  gm_state,
bool  failed,
const std::string &  message 
) [protected]

Definition at line 80 of file faults.cpp.

                                                                                                                                       {
  fault.Name("bes-factory:CantApplyOperationToCurrentStateFault");
  addActivityStatus(fault,gm_state,"",failed);
  fault.NewChild("bes-factory:Message")=message;
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ARex::ARexService::CantApplyOperationToCurrentStateFault ( Arc::SOAPFault &  fault,
const std::string &  gm_state,
bool  failed,
const std::string &  message 
) [protected]

Definition at line 87 of file faults.cpp.

                                                                                                                                          {
  CantApplyOperationToCurrentStateFault(fault.Detail(true).NewChild("dummy"),gm_state,failed,message);
  SetFaultResponse(fault);
}

Here is the call graph for this function:

Definition at line 15 of file change_activity_status.cpp.

                                                                                                 {
  /*
  ChangeActivityStatus
    ActivityIdentifier (wsa:EndpointReferenceType)
    OldStatus (a-rex,optional)
        attribute = state (bes-factory:ActivityStateEnumeration)
    NewStatus (a-rex)
        attribute = state (bes-factory:ActivityStateEnumeration)

  ChangeActivityStatusResponse
    NewStatus (a-rex)
        attribute = state (bes-factory:ActivityStateEnumeration)

  NotAuthorizedFault
  InvalidActivityIdentifierFault
  CantApplyOperationToCurrentStateFault
  */
  {
    std::string s;
    in.GetXML(s);
    logger_.msg(Arc::VERBOSE, "ChangeActivityStatus: request = \n%s", s);
  };
  Arc::WSAEndpointReference id(in["ActivityIdentifier"]);
  if(!(Arc::XMLNode)id) {
    // Wrong request
    logger_.msg(Arc::ERROR, "ChangeActivityStatus: no ActivityIdentifier found");
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Can't find ActivityIdentifier element in request");
    InvalidRequestMessageFault(fault,"jsdl:ActivityIdentifier","Element is missing");
    out.Destroy();
    return Arc::MCC_Status();
  };
  std::string jobid = Arc::WSAEndpointReference(id).ReferenceParameters()["a-rex:JobID"];
  if(jobid.empty()) {
    // EPR is wrongly formated or not an A-REX EPR
    logger_.msg(Arc::ERROR, "ChangeActivityStatus: EPR contains no JobID");
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Can't find JobID element in ActivityIdentifier");
    InvalidRequestMessageFault(fault,"a-rex:JobID","Element is missing");
    out.Destroy();
    return Arc::MCC_Status();
  };
  ARexJob job(jobid,config,logger_);
  if(!job) {
    // There is no such job
    std::string failure = job.Failure();
    logger_.msg(Arc::ERROR, "ChangeActivityStatus: no job found: %s",failure);
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Can't find requested Activity");
    UnknownActivityIdentifierFault(fault,"No corresponding Activity found");
    out.Destroy();
    return Arc::MCC_Status();
  };

  // Old State
  Arc::XMLNode old_state = in["OldStatus"];
  std::string old_bes_state = old_state.Attribute("state");
  std::string old_arex_state = old_state["a-rex:state"];

  // New state
  Arc::XMLNode new_state = in["NewStatus"];
  if(!new_state) {
    // Wrong request
    logger_.msg(Arc::ERROR, "ChangeActivityStatus: missing NewStatus element");
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Missing NewStatus element in request");
    InvalidRequestMessageFault(fault,"a-rex:NewStatus","Element is missing");
    out.Destroy();
    return Arc::MCC_Status();
  };
  std::string new_bes_state = new_state.Attribute("state");
  std::string new_arex_state = new_state["a-rex:state"];
  // Take renewed proxy if supplied
  std::string delegation;
  Arc::XMLNode delegated_token = new_state["deleg:DelegatedToken"];
  if(delegated_token) {
    if(!delegations_.DelegatedToken(delegation,delegated_token)) {
      // Failed to accept delegation (report as bad request)
      logger_.msg(Arc::ERROR, "ChangeActivityStatus: Failed to accept delegation");
      Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Failed to accept delegation");
      InvalidRequestMessageFault(fault,"deleg:DelegatedToken","This token does not exist");
      out.Destroy();
      return Arc::MCC_Status();
    };
  };

  bool pending = false;
  std::string gm_state = job.State(pending);
  bool failed = job.Failed();
  std::string bes_state("");
  std::string arex_state("");
  convertActivityStatus(gm_state,bes_state,arex_state,failed,pending);
  // Old state in request must be checked against current one
  if((!old_bes_state.empty()) && (old_bes_state != bes_state)) {
    logger_.msg(Arc::ERROR, "ChangeActivityStatus: old BES state does not match");
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"OldStatus is not same ass current status");
    CantApplyOperationToCurrentStateFault(fault,gm_state,failed,"OldStatus does not match");
    out.Destroy();
    return Arc::MCC_Status();
  };
  if((!old_arex_state.empty()) && (old_arex_state != arex_state)) {
    logger_.msg(Arc::ERROR, "ChangeActivityStatus: old A-Rex state does not match");
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"OldStatus is not same ass current status");
    CantApplyOperationToCurrentStateFault(fault,gm_state,failed,"OldStatus does not match");
    out.Destroy();
    return Arc::MCC_Status();
  };

  // Check for allowed combinations
  if((new_bes_state == "Finished") &&
     ((new_arex_state.empty()) || (new_arex_state == "Killing"))) {
    // Request to cancel job
    if((gm_state != "FINISHED") &&
       (gm_state != "CANCELING") &&
       (gm_state != "DELETED")) job.Cancel();
  } else
  if((new_bes_state == "Finished") &&
     (new_arex_state == "Deleted")) {
     // Request to clean job
    if((gm_state != "FINISHED") &&
       (gm_state != "CANCELING") &&
       (gm_state != "DELETED")) job.Cancel();
    job.Clean();
  } else 
  if((new_bes_state == "Running") &&
     (new_arex_state.empty())) { // Not supporting resume into user-defined state
    // Request to resume job
    if(!job.UpdateCredentials(delegation)) {
      logger_.msg(Arc::ERROR, "ChangeActivityStatus: failed to update credentials");
      Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Internal error: Failed to update credentials");
      out.Destroy();
      return Arc::MCC_Status();
    };
    if(!job.Resume()) {
      logger_.msg(Arc::ERROR, "ChangeActivityStatus: failed to resume job");
      Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Internal error: Failed to resume activity");
      out.Destroy();
      return Arc::MCC_Status();
    };
  } else {
    logger_.msg(Arc::ERROR, "ChangeActivityStatus: state change not allowed: from %s/%s to %s/%s",
                bes_state.c_str(),arex_state.c_str(),new_bes_state.c_str(),new_arex_state.c_str());
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Requested status transition is not supported");
    CantApplyOperationToCurrentStateFault(fault,gm_state,failed,"Requested status transition is not supported");
    out.Destroy();
    return Arc::MCC_Status();
  };
  // Make response
  // TODO: 
  // Updating currenst job state
  gm_state=job.State(pending);
  failed=job.Failed();
  convertActivityStatus(gm_state,bes_state,arex_state,failed,pending);
  Arc::XMLNode state = out.NewChild("a-rex:NewStatus");
  state.NewAttribute("bes-factory:state")=bes_state;
  state.NewChild("a-rex:state")=arex_state;
  {
    std::string s;
    out.GetXML(s);
    logger_.msg(Arc::VERBOSE, "ChangeActivityStatus: response = \n%s", s);
  };
  return Arc::MCC_Status(Arc::STATUS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Arc::MCC_Status ARex::ARexService::CreateActivity ( ARexGMConfig config,
Arc::XMLNode  in,
Arc::XMLNode  out,
const std::string &  clientid 
) [protected]

Definition at line 14 of file create_activity.cpp.

                                                                                                                     {
  /*
  CreateActivity
    ActivityDocument
      jsdl:JobDefinition

  CreateActivityResponse
    ActivityIdentifier (wsa:EndpointReferenceType)
    ActivityDocument
      jsdl:JobDefinition

  NotAuthorizedFault
  NotAcceptingNewActivitiesFault
  UnsupportedFeatureFault
  InvalidRequestMessageFault
  */
  {
    std::string s;
    in.GetXML(s);
    logger_.msg(Arc::VERBOSE, "CreateActivity: request = \n%s", s);
  };
  Arc::XMLNode jsdl = in["ActivityDocument"]["JobDefinition"];
  if(!jsdl) {
    // Wrongly formated request
    logger_.msg(Arc::ERROR, "CreateActivity: no job description found");
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Can't find JobDefinition element in request");
    InvalidRequestMessageFault(fault,"jsdl:JobDefinition","Element is missing");
    out.Destroy();
    return Arc::MCC_Status();
  };

  // HPC Basic Profile 1.0 comply (these fault handlings are defined in the KnowARC standards 
  // conformance roadmap 2nd release)

 // End of the HPC BP 1.0 fault handling part

  std::string delegation;
  Arc::XMLNode delegated_token = in["deleg:DelegatedToken"];
  if(delegated_token) {
    // Client wants to delegate credentials
    if(!delegations_.DelegatedToken(delegation,delegated_token)) {
      // Failed to accept delegation (report as bad request)
      logger_.msg(Arc::ERROR, "CreateActivity: Failed to accept delegation");
      Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Failed to accept delegation");
      InvalidRequestMessageFault(fault,"deleg:DelegatedToken","This token does not exist");
      out.Destroy();
      return Arc::MCC_Status();
    };
  };
  ARexJob job(jsdl,config,delegation,clientid,logger_);
  if(!job) {
    ARexJobFailure failure_type = job;
    std::string failure = job.Failure();
    switch(failure_type) {
      case ARexJobDescriptionUnsupportedError: {
        Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Unsupported feature in job description");
        UnsupportedFeatureFault(fault,failure);
      }; break;
      case ARexJobDescriptionMissingError: {
        Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Missing needed element in job description");
        UnsupportedFeatureFault(fault,failure);
      }; break;
      case ARexJobDescriptionLogicalError: {
        std::string element;
        std::string::size_type pos = failure.find(' ');
        if(pos != std::string::npos) {
          element=failure.substr(0,pos);
          failure=failure.substr(pos+1);
        };
        Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Logical error in job description");
        InvalidRequestMessageFault(fault,element,failure);
      }; break;
      default: {
        logger_.msg(Arc::ERROR, "CreateActivity: Failed to create new job: %s",failure);
        // Failed to create new job (no corresponding BES fault defined - using generic SOAP error)
        logger_.msg(Arc::ERROR, "CreateActivity: Failed to create new job");
        Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,("Failed to create new activity: "+failure).c_str());
        GenericFault(fault);
      };
    };
    out.Destroy();
    return Arc::MCC_Status();
  };
  // Make SOAP response
  Arc::WSAEndpointReference identifier(out.NewChild("bes-factory:ActivityIdentifier"));
  // Make job's ID
  identifier.Address(config.Endpoint()); // address of service
  identifier.ReferenceParameters().NewChild("a-rex:JobID")=job.ID();
  identifier.ReferenceParameters().NewChild("a-rex:JobSessionDir")=config.Endpoint()+"/"+job.ID();
  out.NewChild(in["ActivityDocument"]);
  logger_.msg(Arc::VERBOSE, "CreateActivity finished successfully");
  {
    std::string s;
    out.GetXML(s);
    logger_.msg(Arc::VERBOSE, "CreateActivity: response = \n%s", s);
  };
  return Arc::MCC_Status(Arc::STATUS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ARex::ARexService::GenericFault ( Arc::SOAPFault &  fault) [protected]

Definition at line 44 of file faults.cpp.

                                                  {
  Arc::XMLNode fault_node = fault;
  Arc::SOAPEnvelope res(fault_node.Parent().Parent()); // Fault->Body->Envelope
  Arc::WSAHeader(res).Action("");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Arc::MCC_Status ARex::ARexService::Get ( Arc::Message inmsg,
Arc::Message outmsg,
ARexGMConfig config,
const std::string &  id,
const std::string &  subpath 
) [protected]

Definition at line 27 of file get.cpp.

                                                                                                                                     {
  size_t range_start = 0;
  size_t range_end = (size_t)(-1);
  {
    std::string val;
    val=inmsg.Attributes()->get("HTTP:RANGESTART");
    if(!val.empty()) { // Negative ranges not supported
      if(!Arc::stringto<size_t>(val,range_start)) {
        range_start=0;
      } else {
        val=inmsg.Attributes()->get("HTTP:RANGEEND");
        if(!val.empty()) {
          if(!Arc::stringto<size_t>(val,range_end)) {
            range_end=(size_t)(-1);
          };
        };
      };
    };
  };
  if(id.empty()) {
    // Make list of jobs
    std::string html;
    html="<HTML>\r\n<HEAD>\r\n<TITLE>ARex: Jobs list</TITLE>\r\n</HEAD>\r\n<BODY>\r\n<UL>\r\n";
    std::list<std::string> jobs = ARexJob::Jobs(config,logger_);
    for(std::list<std::string>::iterator job = jobs.begin();job!=jobs.end();++job) {
      std::string line = "<LI><I>job</I> <A HREF=\"";
      line+=config.Endpoint()+"/"+(*job);
      line+="\">";
      line+=(*job);
      line+="</A>\r\n";
      html+=line;
    };
    html+="</UL>\r\n";
    // Service description access
    html+="<A HREF=\""+config.Endpoint()+"/?info>SERVICE DESCRIPTION</A>";
    html+="</BODY>\r\n</HTML>";
    Arc::PayloadRaw* buf = NULL;
    buf=new Arc::PayloadRaw;
    if(buf) buf->Insert(html.c_str(),0,html.length());
    outmsg.Payload(buf);
    outmsg.Attributes()->set("HTTP:content-type","text/html");
    return Arc::MCC_Status(Arc::STATUS_OK);
  };
  if(id == "?info") {
    int h = infodoc_.OpenDocument();
    if(h == -1) return Arc::MCC_Status();
    Arc::MessagePayload* payload = newFileRead(h);
    if(!payload) {
      ::close(h);
      return Arc::MCC_Status();
    };
    outmsg.Payload(payload);
    outmsg.Attributes()->set("HTTP:content-type","text/xml");
    return Arc::MCC_Status(Arc::STATUS_OK);
  };
  ARexJob job(id,config,logger_);
  if(!job) {
    // There is no such job
    logger_.msg(Arc::ERROR, "Get: there is no job %s - %s", id, job.Failure());
    // TODO: make proper html message
    return Arc::MCC_Status();
  };
  if(!http_get(outmsg,config.Endpoint()+"/"+id,job,subpath,range_start,range_end)) {
    // Can't get file
    logger.msg(Arc::ERROR, "Get: can't process file %s", subpath);
    // TODO: make proper html message
    return Arc::MCC_Status();
  };
  return Arc::MCC_Status(Arc::STATUS_OK);
} 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 165 of file arex.cpp.

                                                                   {
  ARexConfigContext* config = NULL;
  Arc::MessageContextElement* mcontext = (*inmsg.Context())["arex.gmconfig"];
  if(mcontext) {
    try {
      config = dynamic_cast<ARexConfigContext*>(mcontext);
    } catch(std::exception& e) { };
  };
  if(config) return config;
  // TODO: do configuration detection
  // TODO: do mapping to local unix name
  std::string uname;
  uname=inmsg.Attributes()->get("SEC:LOCALID");
  if(uname.empty()) uname=uname_;
  if(uname.empty()) {
    if(getuid() == 0) {
      logger_.msg(Arc::ERROR, "Will not map to 'root' account by default");
      return NULL;
    };
    struct passwd pwbuf;
    char buf[4096];
    struct passwd* pw;
    if(getpwuid_r(getuid(),&pwbuf,buf,sizeof(buf),&pw) == 0) {
      if(pw && pw->pw_name) {
        uname = pw->pw_name;
      };
    };
  };
  if(uname.empty()) {
    logger_.msg(Arc::ERROR, "No local account name specified");
    return NULL;
  };
  logger_.msg(Arc::DEBUG,"Using local account '%s'",uname);
  std::string grid_name = inmsg.Attributes()->get("TLS:IDENTITYDN");
  std::string endpoint = endpoint_;
  if(endpoint.empty()) {
    std::string http_endpoint = inmsg.Attributes()->get("HTTP:ENDPOINT");
    std::string tcp_endpoint = inmsg.Attributes()->get("TCP:ENDPOINT");
    bool https_proto = !grid_name.empty();
    endpoint = tcp_endpoint;
    if(https_proto) {
      endpoint="https"+endpoint;
    } else {
      endpoint="http"+endpoint;
    };
    endpoint+=GetPath(http_endpoint);
  };
  config=new ARexConfigContext(gmconfig_,uname,grid_name,endpoint);
  if(config) {
    if(*config) {
      inmsg.Context()->Add("arex.gmconfig",config);
    } else {
      delete config; config=NULL;
      logger_.msg(Arc::ERROR, "Failed to acquire grid-manager's configuration");
    };
  };
  return config;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 14 of file get_activity_documents.cpp.

                                                                                                 {
  /*
  GetActivityDocuments
    ActivityIdentifier (wsa:EndpointReferenceType, unbounded)

  GetActivityDocumentsResponse
    Response (unbounded)
      ActivityIdentifier
      JobDefinition (jsdl:JobDefinition)
      Fault (soap:Fault)
  UnknownActivityIdentifierFault
  */
  {
    std::string s;
    in.GetXML(s);
    logger.msg(Arc::VERBOSE, "GetActivityDocuments: request = \n%s", s);
  };
  for(int n = 0;;++n) {
    Arc::XMLNode id = in["ActivityIdentifier"][n];
    if(!id) break;
    // Create place for response
    Arc::XMLNode resp = out.NewChild("bes-factory:Response");
    resp.NewChild(id);
    std::string jobid = Arc::WSAEndpointReference(id).ReferenceParameters()["a-rex:JobID"];
    if(jobid.empty()) {
      // EPR is wrongly formated or not an A-REX EPR
      logger_.msg(Arc::ERROR, "GetActivityDocuments: non-ARex job requested");
      Arc::SOAPFault fault(resp,Arc::SOAPFault::Sender,"Missing a-rex:JobID in ActivityIdentifier");
      UnknownActivityIdentifierFault(fault,"Unrecognized EPR in ActivityIdentifier");
      continue;
    };
    // Look for obtained ID
    ARexJob job(jobid,config,logger_);
    if(!job) {
      // There is no such job
      logger_.msg(Arc::ERROR, "GetActivityDocuments: job %s - %s", jobid, job.Failure());
      Arc::SOAPFault fault(resp,Arc::SOAPFault::Sender,"No corresponding activity found");
      UnknownActivityIdentifierFault(fault,("No activity "+jobid+" found: "+job.Failure()).c_str());
      continue;
    };
    /*
    // TODO: Check permissions on that ID
    */
    // Read JSDL of job
    Arc::XMLNode jsdl = resp.NewChild("bes-factory:JobDefinition");
    if(!job.GetDescription(jsdl)) {
      logger_.msg(Arc::ERROR, "GetActivityDocuments: job %s - %s", jobid, job.Failure());
      // Processing failure
      jsdl.Destroy();
      Arc::SOAPFault fault(resp,Arc::SOAPFault::Sender,"Failed processing activity");
      UnknownActivityIdentifierFault(fault,("Failed processing activity "+jobid+": "+job.Failure()).c_str());
      continue;
    };
    jsdl.Name("bes-factory:JobDefinition"); // Recovering namespace of element
  };
  {
    std::string s;
    out.GetXML(s);
    logger_.msg(Arc::VERBOSE, "GetActivityDocuments: response = \n%s", s);
  };
  return Arc::MCC_Status(Arc::STATUS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 15 of file get_activity_statuses.cpp.

                                                                                                {
  /*
  GetActivityStatuses
    ActivityIdentifier (wsa:EndpointReferenceType, unbounded)

  GetActivityStatusesResponse
    Response (unbounded)
      ActivityIdentifier
      ActivityStatus
        attribute = state (bes-factory:ActivityStateEnumeration)
          Pending,Running,Cancelled,Failed,Finished
      Fault (soap:Fault)
  UnknownActivityIdentifierFault
  */
  {
    std::string s;
    in.GetXML(s);
    logger.msg(Arc::VERBOSE, "GetActivityStatuses: request = \n%s", s);
  };
  for(int n = 0;;++n) {
    Arc::XMLNode id = in["ActivityIdentifier"][n];
    if(!id) break;
    // Create place for response
    Arc::XMLNode resp = out.NewChild("bes-factory:Response");
    resp.NewChild(id);
    std::string jobid = Arc::WSAEndpointReference(id).ReferenceParameters()["a-rex:JobID"];
    if(jobid.empty()) {
      // EPR is wrongly formated or not an A-REX EPR
      logger_.msg(Arc::ERROR, "GetActivityStatuses: job %s - can't understand EPR", jobid);
      Arc::SOAPFault fault(resp,Arc::SOAPFault::Sender,"Missing a-rex:JobID in ActivityIdentifier");
      UnknownActivityIdentifierFault(fault,"Unrecognized EPR in ActivityIdentifier");
      continue;
    };
    // Look for obtained ID
    ARexJob job(jobid,config,logger_);
    if(!job) {
      // There is no such job
      logger_.msg(Arc::ERROR, "GetActivityStatuses: job %s - %s", jobid, job.Failure());
      Arc::SOAPFault fault(resp,Arc::SOAPFault::Sender,"No corresponding activity found");
      UnknownActivityIdentifierFault(fault,("No activity "+jobid+" found: "+job.Failure()).c_str());
      continue;
    };
    /*
    // TODO: Check permissions on that ID
    */
    bool job_pending = false;
    std::string gm_state = job.State(job_pending);
    addActivityStatus(resp,gm_state,glue_states_[job.ID()],job.Failed(),job_pending);
  };
  {
    std::string s;
    out.GetXML(s);
    logger.msg(Arc::VERBOSE, "GetActivityStatuses: response = \n%s", s);
  };
  return Arc::MCC_Status(Arc::STATUS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 15 of file get_factory_attributes_document.cpp.

                                                                                                         {
  /*
  GetFactoryAttributesDocument

  GetFactoryAttributesDocumentResponse
    FactoryResourceAttributesDocument
      BasicResourceAttributesDocument (optional)
      IsAcceptingNewActivities (boolean)
      CommonName (optional,string)
      LongDescription (optional,string)
      TotalNumberOfActivities (long)
      ActivityReference (wsa:EndpointReferenceType,unbounded)
      TotalNumberOfContainedResources (long)
      ContainedResource (anyType,unbounded)
      NamingProfile (anyURI,unbounded)
      BESExtension (anyURI,unbounded)
      LocalResourceManagerType (anyURI)
      OperatingSystem (optional,string)
  */
  {
    std::string s;
    in.GetXML(s);
    logger.msg(Arc::VERBOSE, "GetFactoryAttributesDocument: request = \n%s", s);
  };
  Arc::XMLNode doc = out.NewChild("bes-factory:FactoryResourceAttributesDocument");
  //doc.NewChild("bes-factory:BasicResourceAttributesDocument");
  doc.NewChild("bes-factory:IsAcceptingNewActivities")="true";
  //doc.NewChild("bes-factory:CommonName")=common_name_;
  //doc.NewChild("bes-factory:LongDescription")=long_description_;
  std::list<std::string> jobs = ARexJob::Jobs(config,logger_);
  doc.NewChild("bes-factory:TotalNumberOfActivities")=Arc::tostring(jobs.size());
  for(std::list<std::string>::iterator j = jobs.begin();j!=jobs.end();++j) {
    Arc::WSAEndpointReference identifier(doc.NewChild("bes-factory:ActivityReference"));
    // Make job's ID
    identifier.Address(config.Endpoint()); // address of service
    identifier.ReferenceParameters().NewChild("a-rex:JobID")=(*j);
    identifier.ReferenceParameters().NewChild("a-rex:JobSessionDir")=config.Endpoint()+"/"+(*j);
  };
  doc.NewChild("bes-factory:TotalNumberOfContainedResources")=Arc::tostring(0);
  doc.NewChild("bes-factory:NamingProfile")="http://schemas.ggf.org/bes/2006/08/bes/naming/BasicWSAddressing";
  doc.NewChild("bes-factory:BESExtension")="http://www.nordugrid.org/schemas/a-rex";
  doc.NewChild("bes-factory:LocalResourceManagerType")=lrms_name_;
  doc.NewChild("bes-factory:OperatingSystem")=os_name_;
  {
    std::string s;
    out.GetXML(s);
    logger.msg(Arc::VERBOSE, "GetFactoryAttributesDocument: response = \n%s", s);
  };
  return Arc::MCC_Status(Arc::STATUS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

std::string ARex::ARexService::getID ( ) [virtual]

Service may implement own service identitifer gathering method.

This method return identifier of service which is used for registering it Information Services.

Reimplemented from Arc::Service.

Definition at line 114 of file information_collector.cpp.

                             {
  return "ARC:AREX";
}

Definition at line 29 of file information_collector.cpp.

                                           {
  thread_count_.RegisterThread();
  for(;;) {
    // Run information provider
    std::string xml_str;
    int r = -1;
    {
      std::string cmd;
      cmd=nordugrid_libexec_loc()+"/CEinfo.pl --config "+nordugrid_config_loc();
      std::string stdin_str;
      std::string stderr_str;
      Arc::Run run(cmd);
      run.AssignStdin(stdin_str);
      run.AssignStdout(xml_str);
      run.AssignStderr(stderr_str);
      logger_.msg(Arc::DEBUG,"Cluster information provider: %s",cmd);
      if(!run.Start()) {
      };
      if(!run.Wait(infoprovider_wakeup_period_*10)) {
        logger_.msg(Arc::WARNING,"Cluster information provider timeout: %u seconds",
                    infoprovider_wakeup_period_*10);
      } else {
        r = run.Result();
        if (r!=0) logger_.msg(Arc::WARNING,"Cluster information provider failed with exit status: %i",r);
      };
      logger_.msg(Arc::DEBUG,"Cluster information provider log:\n%s",stderr_str);
    };
    if (r!=0) {
      logger_.msg(Arc::DEBUG,"No new informational document assigned");
    } else {
      logger_.msg(Arc::VERBOSE,"Obtained XML: %s",xml_str.substr(0,100));
      /*
      Arc::XMLNode root(xml_str);
      if(root) {
        // Collect job states
        GetGlueStates(root,glue_states_);
        // Put result into container
        infodoc_.Arc::InformationContainer::Assign(root,true);
        logger_.msg(Arc::DEBUG,"Assigned new informational document");
      } else {
        logger_.msg(Arc::ERROR,"Failed to create informational document");
      };
      */
      if(!xml_str.empty()) {
        infodoc_.Assign(xml_str);
        Arc::XMLNode root = infodoc_.Acquire();
        if(root) {
          logger_.msg(Arc::DEBUG,"Assigned new informational document");
          // Collect job states
          GetGlueStates(root,glue_states_);
        } else {
          logger_.msg(Arc::ERROR,"Failed to create informational document");
        };
        infodoc_.Release();
      } else {
        logger_.msg(Arc::ERROR,"Informational document is empty");
      };
    };
    if(thread_count_.WaitOrCancel(infoprovider_wakeup_period_*1000)) break;
  };
  thread_count_.UnregisterThread();
}

Here is the call graph for this function:

void ARex::ARexService::InvalidRequestMessageFault ( Arc::XMLNode  fault,
const std::string &  element,
const std::string &  message 
) [protected]

Definition at line 115 of file faults.cpp.

                                                                                                               {
  fault.Name("bes-factory:InvalidRequestMessageFaultType");
  if(!element.empty()) fault.NewChild("bes-factory:InvalidElement")=element;
  fault.NewChild("bes-factory:Message")=message;
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ARex::ARexService::InvalidRequestMessageFault ( Arc::SOAPFault &  fault,
const std::string &  element,
const std::string &  message 
) [protected]

Definition at line 122 of file faults.cpp.

                                                                                                                  {
  InvalidRequestMessageFault(fault.Detail(true).NewChild("dummy"),element,message);
  SetFaultResponse(fault);
}

Here is the call graph for this function:

Definition at line 155 of file arex.cpp.

                                                   {
  return Arc::MCC_Status();
}

Here is the caller graph for this function:

Definition at line 159 of file arex.cpp.

                                                           {
  Arc::PayloadRaw* outpayload = new Arc::PayloadRaw();
  outmsg.Payload(outpayload);
  return Arc::MCC_Status(Arc::STATUS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 144 of file arex.cpp.

                                                             {
  Arc::PayloadSOAP* outpayload = new Arc::PayloadSOAP(ns_,true);
  Arc::SOAPFault* fault = outpayload?outpayload->Fault():NULL;
  if(fault) {
    fault->Code(Arc::SOAPFault::Sender);
    fault->Reason("Failed processing request");
  };
  outmsg.Payload(outpayload);
  return Arc::MCC_Status(Arc::STATUS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Arc::MCC_Status ARex::ARexService::MigrateActivity ( ARexGMConfig config,
Arc::XMLNode  in,
Arc::XMLNode  out,
const std::string &  clientid 
) [protected]

Definition at line 16 of file migrate_activity.cpp.

                                                                                                                      {
  /*
  MigrateActivity
    ActivityIdentifier (wsa:EndpointReferenceType)
    ActivityDocument
      jsdl:JobDefinition
    ForceMigration

  MigrateActivityResponse
    ActivityIdentifier (wsa:EndpointReferenceType)
    ActivityDocument
      jsdl:JobDefinition

  NotAuthorizedFault
  NotAcceptingNewActivitiesFault
  UnsupportedFeatureFault
  InvalidRequestMessageFault
  */
  {
    std::string s;
    in.GetXML(s);
    logger_.msg(Arc::VERBOSE, "MigrateActivity: request = \n%s", s);
  };
  Arc::WSAEndpointReference id(in["ActivityIdentifier"]);
  if(!(Arc::XMLNode)id) {
    // Wrong request
    logger_.msg(Arc::ERROR, "MigrateActivitys: no ActivityIdentifier found");
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Can't find ActivityIdentifier element in request");
    InvalidRequestMessageFault(fault,"jsdl:ActivityIdentifier","Element is missing");
    out.Destroy();
    return Arc::MCC_Status();
  };
  std::string migrateid = Arc::WSAEndpointReference(id).Address() + "/" + (std::string)Arc::WSAEndpointReference(id).ReferenceParameters()["a-rex:JobID"];
  if(migrateid.empty()) {
    // EPR is wrongly formated or not an A-REX EPR
    logger_.msg(Arc::ERROR, "MigrateActivity: EPR contains no JobID");
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Can't find JobID element in ActivityIdentifier");
    InvalidRequestMessageFault(fault,"a-rex:JobID","Element is missing");
    out.Destroy();
    return Arc::MCC_Status();
  };

  // HPC Basic Profile 1.0 comply (these fault handlings are defined in the KnowARC standards 
  // conformance roadmap 2nd release)

 // End of the HPC BP 1.0 fault handling part

  std::string delegation;
  Arc::XMLNode delegated_token = in["deleg:DelegatedToken"];
  if(delegated_token) {
    // Client wants to delegate credentials
    if(!delegations_.DelegatedToken(delegation,delegated_token)) {
      // Failed to accept delegation (report as bad request)
      logger_.msg(Arc::ERROR, "MigrateActivity: Failed to accept delegation");
      Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Failed to accept delegation");
      InvalidRequestMessageFault(fault,"deleg:DelegatedToken","This token does not exist");
      out.Destroy();
      return Arc::MCC_Status();
    };
  };

  if( !(in["ActivityDocument"]["JobDefinition"])) {
    /*
    // First try to get job desc from old cluster
    logger_.msg(Arc::VERBOSE, "MigrateActivity: no job description found try to get it from old cluster");
    Arc::MCCConfig cfg;
    // TODO:
    //if (!proxyPath.empty())
    cfg.AddProxy(delegation);
    //if (!certificatePath.empty())
      //cfg.AddCertificate(certificatePath);
    //if (!keyPath.empty())
      //cfg.AddPrivateKey(keyPath);
    //if (!caCertificatesDir.empty())
      //cfg.AddCADir(caCertificatesDir);
    Arc::URL url(migrateid);
    Arc::PathIterator pi(url.Path(), true);
    url.ChangePath(*pi);
    Arc::AREXClient ac(url, cfg);
    Arc::NS ns;
    ns["a-rex"] = "http://www.nordugrid.org/schemas/a-rex";
    ns["bes-factory"] = "http://schemas.ggf.org/bes/2006/08/bes-factory";
    ns["wsa"] = "http://www.w3.org/2005/08/addressing";
    ns["jsdl"] = "http://schemas.ggf.org/jsdl/2005/11/jsdl";
    ns["jsdl-posix"] = "http://schemas.ggf.org/jsdl/2005/11/jsdl-posix";
    ns["jsdl-arc"] = "http://www.nordugrid.org/ws/schemas/jsdl-arc";
    ns["jsdl-hpcpa"] = "http://schemas.ggf.org/jsdl/2006/07/jsdl-hpcpa";
    Arc::XMLNode id(ns, "ActivityIdentifier");
    id.NewChild("wsa:Address") = url.str();
    id.NewChild("wsa:ReferenceParameters").NewChild("a-rex:JobID") = pi.Rest();
    std::string idstr;
    id.GetXML(idstr);
    std::string desc_str;
    if (ac.getdesc(idstr,desc_str)){
      Arc::JobDescription desc;
      desc.setSource(desc_str);
      if (desc.isValid()) {
        logger_.msg(Arc::INFO,"Valid job description obtained");
        if ( !( in["ActivityDocument"] ) ) in.NewChild("bes-factory:ActivityDocument");
        Arc::XMLNode XMLdesc;
        desc.getXML(XMLdesc);
        in["ActivityDocument"].NewChild(XMLdesc);
      } else {
        // Wrongly formatted job description
        logger_.msg(Arc::ERROR, "MigrateActivity: job description could not be fetch from old cluster");
        Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Can't find JobDefinition element in request");
        InvalidRequestMessageFault(fault,"jsdl:JobDefinition","Element is missing");
        out.Destroy();
        return Arc::MCC_Status();
      }
    }
    */
    //else {
      // Not able to get job description
      logger_.msg(Arc::ERROR, "MigrateActivity: no job description found");
      //logger_.msg(Arc::ERROR, "MigrateActivity: job description could not be fetch from old cluster");
      Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Can't find JobDefinition element in request");
      InvalidRequestMessageFault(fault,"jsdl:JobDefinition","Element is missing");
      out.Destroy();
      return Arc::MCC_Status();
    //}
  };

  Arc::XMLNode jsdl = in["ActivityDocument"]["JobDefinition"];

  Arc::NS ns;
  // Creating migration XMLNode
  Arc::XMLNode migration(ns, "Migration");
  migration.NewChild("ActivityIdentifier") = migrateid;
  if( (bool)in["ForceMigration"]){
    migration.NewChild("ForceMigration") = (std::string)in["ForceMigration"];
  } else {
    migration.NewChild("ForceMigration") = "true";
  }

  std::string migrationStr;
  migration.GetDoc(migrationStr, true);
  logger_.msg(Arc::INFO, "Migration XML sent to AREXJob: %s", migrationStr);

  ARexJob job(jsdl,config,delegation,clientid,logger_,migration);
  if(!job) {
    ARexJobFailure failure_type = job;
    std::string failure = job.Failure();
    switch(failure_type) {
      case ARexJobDescriptionUnsupportedError: {
        Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Unsupported feature in job description");
        UnsupportedFeatureFault(fault,failure);
      }; break;
      case ARexJobDescriptionMissingError: {
        Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Missing needed element in job description");
        UnsupportedFeatureFault(fault,failure);
      }; break;
      case ARexJobDescriptionLogicalError: {
        std::string element;
        std::string::size_type pos = failure.find(' ');
        if(pos != std::string::npos) {
          element=failure.substr(0,pos);
          failure=failure.substr(pos+1);
        };
        Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Logical error in job description");
        InvalidRequestMessageFault(fault,element,failure);
      }; break;
      default: {
        logger_.msg(Arc::ERROR, "MigrateActivity: Failed to migrate new job: %s",failure);
        // Failed to migrate new job (no corresponding BES fault defined - using generic SOAP error)
        logger_.msg(Arc::ERROR, "MigrateActivity: Failed to migrate new job");
        Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,("Failed to migrate new activity: "+failure).c_str());
        GenericFault(fault);
      };
    };
    out.Destroy();
    return Arc::MCC_Status();
  };

  // Make SOAP response
  Arc::WSAEndpointReference identifier(out.NewChild("bes-factory:ActivityIdentifier"));
  // Make job's ID
  identifier.Address(config.Endpoint()); // address of service
  identifier.ReferenceParameters().NewChild("a-rex:JobID")=job.ID();
  identifier.ReferenceParameters().NewChild("a-rex:JobSessionDir")=config.Endpoint()+"/"+job.ID();
  out.NewChild(in["ActivityDocument"]);
  logger_.msg(Arc::VERBOSE, "MigrateActivity finished successfully");
  {
    std::string s;
    out.GetXML(s);
    logger_.msg(Arc::VERBOSE, "MigrateActivity: response = \n%s", s);
  };
  /* Needs to kill old job */

  return Arc::MCC_Status(Arc::STATUS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 59 of file faults.cpp.

                                                                 {
  fault.Name("bes-factory:NotAcceptingNewActivitiesFault");
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ARex::ARexService::NotAcceptingNewActivitiesFault ( Arc::SOAPFault &  fault) [protected]

Definition at line 64 of file faults.cpp.

                                                                    {
  NotAcceptingNewActivitiesFault(fault.Detail(true).NewChild("dummy"));
  SetFaultResponse(fault);
}

Here is the call graph for this function:

Definition at line 50 of file faults.cpp.

                                                     {
  fault.Name("bes-factory:NotAuthorizedFault");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ARex::ARexService::NotAuthorizedFault ( Arc::SOAPFault &  fault) [protected]

Definition at line 54 of file faults.cpp.

                                                        {
  NotAuthorizedFault(fault.Detail(true).NewChild("dummy"));
  SetFaultResponse(fault);
}

Here is the call graph for this function:

void ARex::ARexService::OperationWillBeAppliedEventuallyFault ( Arc::XMLNode  fault,
const std::string &  gm_state,
bool  failed,
const std::string &  message 
) [protected]

Definition at line 92 of file faults.cpp.

                                                                                                                                       {
  fault.Name("bes-factory:OperationWillBeAppliedEventuallyFault");
  addActivityStatus(fault,gm_state,"",failed);
  fault.NewChild("bes-factory:Message")=message;
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ARex::ARexService::OperationWillBeAppliedEventuallyFault ( Arc::SOAPFault &  fault,
const std::string &  gm_state,
bool  failed,
const std::string &  message 
) [protected]

Definition at line 99 of file faults.cpp.

                                                                                                                                          {
  OperationWillBeAppliedEventuallyFault(fault.Detail(true).NewChild("dummy"),gm_state,failed,message);
  SetFaultResponse(fault);
}

Here is the call graph for this function:

ARex::ARexService::operator bool ( void  ) [inline]

Definition at line 112 of file arex.h.

{ return valid_; };
bool ARex::ARexService::operator! ( void  ) [inline]

Definition at line 113 of file arex.h.

{ return !valid_; };
Arc::MCC_Status ARex::ARexService::process ( Arc::Message request,
Arc::Message response 
) [virtual]

Method for processing of requests and responses.

This method is called by preceeding MCC in chain when a request needs to be processed. This method must call similar method of next MCC in chain unless any failure happens. Result returned by call to next MCC should be processed and passed back to previous MCC. In case of failure this method is expected to generate valid error response and return it back to previous MCC without calling the next one.

Parameters:
requestThe request that needs to be processed.
responseA Message object that will contain the response of the request when the method returns.
Returns:
An object representing the status of the call.

Implements Arc::MCCInterface.

Definition at line 240 of file arex.cpp.

                                                                       {
  // Split request path into parts: service, job and file path. 
  // TODO: make it HTTP independent
  std::string endpoint;
  std::string method = inmsg.Attributes()->get("HTTP:METHOD");
  std::string id = GetPath(inmsg,endpoint);
  std::string clientid = (inmsg.Attributes()->get("TCP:REMOTEHOST"))+":"+(inmsg.Attributes()->get("TCP:REMOTEPORT"));
  if((inmsg.Attributes()->get("PLEXER:PATTERN").empty()) && id.empty()) id=endpoint;
  logger_.msg(Arc::VERBOSE, "process: method: %s", method);
  logger_.msg(Arc::VERBOSE, "process: endpoint: %s", endpoint);
  while(id[0] == '/') id=id.substr(1);
  std::string subpath;
  {
    std::string::size_type p = id.find('/');
    if(p != std::string::npos) {
      subpath = id.substr(p);
      id.resize(p);
      while(subpath[0] == '/') subpath=subpath.substr(1);
    };
  };
  logger_.msg(Arc::VERBOSE, "process: id: %s", id);
  logger_.msg(Arc::VERBOSE, "process: subpath: %s", subpath);

  // Process grid-manager configuration if not done yet
  ARexConfigContext* config = get_configuration(inmsg);
  if(!config) {
    logger_.msg(Arc::ERROR, "Can't obtain configuration");
    // Service is not operational
    return Arc::MCC_Status();
  };
  config->ClearAuths();
  config->AddAuth(inmsg.Auth());
  config->AddAuth(inmsg.AuthContext());

  // Collect any service specific Security Attributes here
  if(!ProcessSecHandlers(inmsg,"incoming")) {
    logger_.msg(Arc::ERROR, "Security Handlers processing failed");
    return Arc::MCC_Status();
  };

  // Identify which of served endpoints request is for.
  // Using simplified algorithm - POST for SOAP messages,
  // GET and PUT for data transfer
  if(method == "POST") {
    logger_.msg(Arc::VERBOSE, "process: POST");
    // Both input and output are supposed to be SOAP
    // Extracting payload
    Arc::PayloadSOAP* inpayload = NULL;
    try {
      inpayload = dynamic_cast<Arc::PayloadSOAP*>(inmsg.Payload());
    } catch(std::exception& e) { };
    if(!inpayload) {
      logger_.msg(Arc::ERROR, "input is not SOAP");
      return make_soap_fault(outmsg);
    };
    // Aplying known namespaces
    inpayload->Namespaces(ns_);
    if(logger_.getThreshold() <= Arc::VERBOSE) {
        std::string str;
        inpayload->GetDoc(str, true);
        logger_.msg(Arc::VERBOSE, "process: request=%s",str);
    };
    // Analyzing request
    Arc::XMLNode op = inpayload->Child(0);
    if(!op) {
      logger_.msg(Arc::ERROR, "input does not define operation");
      return make_soap_fault(outmsg);
    };
    logger_.msg(Arc::VERBOSE, "process: operation: %s",op.Name());
    // Check if request is for top of tree (BES factory) or particular 
    // job (listing activity)
    if(id.empty()) {
      // Factory operations
      logger_.msg(Arc::VERBOSE, "process: factory endpoint");
      Arc::PayloadSOAP* outpayload = new Arc::PayloadSOAP(ns_);
      Arc::PayloadSOAP& res = *outpayload;
      // Preparing known namespaces
      outpayload->Namespaces(ns_);
      if(MatchXMLName(op,"CreateActivity")) {
        CountedResourceLock cl_lock(beslimit_);
        CreateActivity(*config,op,BESFactoryResponse(res,"CreateActivity"),clientid);
      } else if(MatchXMLName(op,"GetActivityStatuses")) {
        CountedResourceLock cl_lock(beslimit_);
        GetActivityStatuses(*config,op,BESFactoryResponse(res,"GetActivityStatuses"));
      } else if(MatchXMLName(op,"TerminateActivities")) {
        CountedResourceLock cl_lock(beslimit_);
        TerminateActivities(*config,op,BESFactoryResponse(res,"TerminateActivities"));
      } else if(MatchXMLName(op,"GetActivityDocuments")) {
        CountedResourceLock cl_lock(beslimit_);
        GetActivityDocuments(*config,op,BESFactoryResponse(res,"GetActivityDocuments"));
      } else if(MatchXMLName(op,"GetFactoryAttributesDocument")) {
        CountedResourceLock cl_lock(beslimit_);
        GetFactoryAttributesDocument(*config,op,BESFactoryResponse(res,"GetFactoryAttributesDocument"));
      } else if(MatchXMLName(op,"StopAcceptingNewActivities")) {
        CountedResourceLock cl_lock(beslimit_);
        StopAcceptingNewActivities(*config,op,BESManagementResponse(res,"StopAcceptingNewActivities"));
      } else if(MatchXMLName(op,"StartAcceptingNewActivities")) {
        CountedResourceLock cl_lock(beslimit_);
        StartAcceptingNewActivities(*config,op,BESManagementResponse(res,"StartAcceptingNewActivities"));
      } else if(MatchXMLName(op,"ChangeActivityStatus")) {
        CountedResourceLock cl_lock(beslimit_);
        ChangeActivityStatus(*config,op,BESARCResponse(res,"ChangeActivityStatus"));
      } else if(MatchXMLName(op,"MigrateActivity")) {
        CountedResourceLock cl_lock(beslimit_);
        MigrateActivity(*config,op,BESFactoryResponse(res,"MigrateActivity"),clientid);
      } else if(MatchXMLName(op,"CacheCheck")) {
        CacheCheck(*config,*inpayload,*outpayload);
      } else if(MatchXMLName(op,"DelegateCredentialsInit")) {
        CountedResourceLock cl_lock(beslimit_);
        if(!delegations_.DelegateCredentialsInit(*inpayload,*outpayload)) {
          delete outpayload;
          return make_soap_fault(outmsg);
        };
      } else if(MatchXMLName(op,"UpdateCredentials")) {
        CountedResourceLock cl_lock(beslimit_);
        std::string credentials;
        if(!delegations_.UpdateCredentials(credentials,*inpayload,*outpayload)) {
          delete outpayload;
          return make_soap_fault(outmsg);
        };
        UpdateCredentials(*config,op,outpayload->Child(),credentials);
      } else if(MatchXMLNamespace(op,"http://docs.oasis-open.org/wsrf/rp-2")) {
        CountedResourceLock cl_lock(infolimit_);
        /*
        Arc::SOAPEnvelope* out_ = infodoc_.Arc::InformationInterface::Process(*inpayload);
        if(out_) {
          out_->Swap(*outpayload);
          delete out_;
        } else {
          delete outpayload;
          return make_soap_fault(outmsg);
        };
        */
        delete outpayload;
        Arc::MessagePayload* mpayload = infodoc_.Process(*inpayload);
        if(!mpayload) {
          return make_soap_fault(outmsg);
        };
        try {
          outpayload = dynamic_cast<Arc::PayloadSOAP*>(mpayload);
        } catch(std::exception& e) { };
        outmsg.Payload(mpayload);
        if(logger_.getThreshold() <= Arc::VERBOSE) {
          if(outpayload) {
            std::string str;
            outpayload->GetDoc(str, true);
            logger_.msg(Arc::VERBOSE, "process: response=%s",str);
          } else {
            logger_.msg(Arc::VERBOSE, "process: response is not SOAP");
          };
        };
        if(!ProcessSecHandlers(outmsg,"outgoing")) {
          logger_.msg(Arc::ERROR, "Security Handlers processing failed");
          delete outmsg.Payload(NULL);
          return Arc::MCC_Status();
        };
        return Arc::MCC_Status(Arc::STATUS_OK);
      } else {
        logger_.msg(Arc::ERROR, "SOAP operation is not supported: %s", op.Name());
        delete outpayload;
        return make_soap_fault(outmsg);
      };
      if(logger_.getThreshold() <= Arc::VERBOSE) {
        std::string str;
        outpayload->GetDoc(str, true);
        logger_.msg(Arc::VERBOSE, "process: response=%s",str);
      };
      outmsg.Payload(outpayload);
    } else {
      // Listing operations for session directories
      // TODO: proper failure like interface is not supported
    };
    if(!ProcessSecHandlers(outmsg,"outgoing")) {
      logger_.msg(Arc::ERROR, "Security Handlers processing failed");
      delete outmsg.Payload(NULL);
      return Arc::MCC_Status();
    };
    return Arc::MCC_Status(Arc::STATUS_OK);
  } else if(method == "GET") {
    // HTTP plugin either provides buffer or stream
    logger_.msg(Arc::VERBOSE, "process: GET");
    CountedResourceLock cl_lock(datalimit_);
    // TODO: in case of error generate some content
    Arc::MCC_Status ret = Get(inmsg,outmsg,*config,id,subpath);
    if(ret) {
      if(!ProcessSecHandlers(outmsg,"outgoing")) {
        logger_.msg(Arc::ERROR, "Security Handlers processing failed");
        delete outmsg.Payload(NULL);
        return Arc::MCC_Status();
      };
    };
    return ret;
  } else if(method == "PUT") {
    logger_.msg(Arc::VERBOSE, "process: PUT");
    CountedResourceLock cl_lock(datalimit_);
    Arc::MCC_Status ret = Put(inmsg,outmsg,*config,id,subpath);
    if(!ret) return make_fault(outmsg);
    // Put() does not generate response yet
    ret=make_response(outmsg);
    if(ret) {
      if(!ProcessSecHandlers(outmsg,"outgoing")) {
        logger_.msg(Arc::ERROR, "Security Handlers processing failed");
        delete outmsg.Payload(NULL);
        return Arc::MCC_Status();
      };
    };
    return ret;
  } else {
    logger_.msg(Arc::VERBOSE, "process: method %s is not supported",method);
    // TODO: make useful response
    return Arc::MCC_Status();
  };
  return Arc::MCC_Status();
}

Here is the call graph for this function:

bool Arc::Service::ProcessSecHandlers ( Message message,
const std::string &  label = "" 
) const [protected, inherited]

Executes security handlers of specified queue.

For more information please see description of MCC::ProcessSecHandlers

Definition at line 22 of file Service.cpp.

                                                                              {
    std::map<std::string,std::list<ArcSec::SecHandler*> >::const_iterator q = sechandlers_.find(label);
    if(q == sechandlers_.end()) {
        logger.msg(DEBUG, "No security processing/check requested for '%s'", label);
        return true;
    }

    std::list<ArcSec::SecHandler*>::const_iterator h = q->second.begin();
    for(;h!=q->second.end();++h) {
        const ArcSec::SecHandler* handler = *h;
        if(handler) if(!(handler->Handle(&message))) {
            logger.msg(DEBUG, "Security processing/check for '%s' failed", label);
            return false;
        }
    }
    logger.msg(DEBUG, "Security processing/check for '%s' passed", label);
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Arc::MCC_Status ARex::ARexService::Put ( Arc::Message inmsg,
Arc::Message outmsg,
ARexGMConfig config,
const std::string &  id,
const std::string &  subpath 
) [protected]

Definition at line 33 of file put.cpp.

                                                                                                                                {
  if(id.empty()) return Arc::MCC_Status();
  ARexJob job(id,config,logger_);
  if(!job) {
    // There is no such job
    logger_.msg(Arc::ERROR, "Put: there is no job: %s - %s", id, job.Failure());
    // TODO: make proper html message
    return Arc::MCC_Status();
  };
  Arc::MessagePayload* payload = inmsg.Payload();
  if(!payload) {
    logger_.msg(Arc::ERROR, "Put: there is no payload for file %s in job: %s", subpath, id);
    return Arc::MCC_Status();
  };
  Arc::PayloadStreamInterface* stream = NULL;
  try {
    stream = dynamic_cast<Arc::PayloadStreamInterface*>(payload);
  } catch(std::exception& e) { };
  if(stream) return http_put(job,subpath,logger_,*stream);
  Arc::PayloadRawInterface* buf = NULL;
  try {
    buf = dynamic_cast<Arc::PayloadRawInterface*>(payload);
  } catch(std::exception& e) { };
  if(buf) return http_put(job,subpath,logger_,*buf);
  logger_.msg(Arc::ERROR, "Put: unrecognized payload for file %s in job: %s", subpath, id);
  return Arc::MCC_Status();
} 

Here is the call graph for this function:

Here is the caller graph for this function:

Service specific registartion collector, used for generate service registartions.

In implemented service this method should generate GLUE2 document with part of service description which service wishes to advertise to Information Services.

Reimplemented from Arc::Service.

Definition at line 92 of file information_collector.cpp.

                                                       {
  //Arc::XMLNode root = infodoc_.Acquire();
  logger_.msg(Arc::VERBOSE,"Passing service's information from collector to registrator");
  Arc::XMLNode empty(ns_, "RegEntry");
  empty.New(doc);

  doc.NewChild("SrcAdv");
  doc.NewChild("MetaSrcAdv");

  doc["SrcAdv"].NewChild("Type") = "org.nordugrid.execution.arex";
  doc["SrcAdv"].NewChild("EPR").NewChild("Address") = endpoint_;
  //doc["SrcAdv"].NewChild("SSPair");

  return true;
  //
  // TODO: filter information here.
  //Arc::XMLNode regdoc("<Service/>");
  //regdoc.New(doc);
  //doc.NewChild(root);
  //infodoc_.Release();
}

Here is the call graph for this function:

Definition at line 140 of file arex.cpp.

                                                                                                {
  return Arc::MCC_Status();
}

Here is the caller graph for this function:

Definition at line 136 of file arex.cpp.

                                                                                               {
  return Arc::MCC_Status();
}

Here is the caller graph for this function:

Definition at line 14 of file terminate_activities.cpp.

                                                                                                {
  /*
  TerminateActivities
    ActivityIdentifier (wsa:EndpointReferenceType, unbounded)

  TerminateActivitiesResponse
    Response (unbounded)
      ActivityIdentifier
      Terminated (boolean)
      Fault (soap:Fault)

  */
  {
    std::string s;
    in.GetXML(s);
    logger_.msg(Arc::VERBOSE, "TerminateActivities: request = \n%s", s);
  };
  for(int n = 0;;++n) {
    Arc::XMLNode id = in["ActivityIdentifier"][n];
    if(!id) break;
    // Create place for response
    Arc::XMLNode resp = out.NewChild("bes-factory:Response");
    resp.NewChild(id);
    std::string jobid = Arc::WSAEndpointReference(id).ReferenceParameters()["a-rex:JobID"];
    if(jobid.empty()) {
      // EPR is wrongly formated or not an A-REX EPR
      logger_.msg(Arc::ERROR, "TerminateActivities: non-ARex job requested");
      Arc::SOAPFault fault(resp,Arc::SOAPFault::Sender,"Missing a-rex:JobID in ActivityIdentifier");
      UnknownActivityIdentifierFault(fault,"Unrecognized EPR in ActivityIdentifier");
      continue;
    };
    // Look for obtained ID
    ARexJob job(jobid,config,logger_);
    if(!job) {
      // There is no such job
      logger_.msg(Arc::ERROR, "TerminateActivities: job %s - %s", jobid, job.Failure());
      Arc::SOAPFault fault(resp,Arc::SOAPFault::Sender,"No corresponding activity found");
      UnknownActivityIdentifierFault(fault,("No activity "+jobid+" found: "+job.Failure()).c_str());
      continue;
    };
    /*
    // Check permissions on that ID
    */
    // Cancel job (put a mark)
    bool result = job.Cancel();
    if(result) {
      resp.NewChild("bes-factory:Terminated")="true";
    } else {
      resp.NewChild("bes-factory:Terminated")="false";
      // Or should it be a fault?
    };
  };
  {
    std::string s;
    out.GetXML(s);
    logger_.msg(Arc::VERBOSE, "TerminateActivities: response = \n%s", s);
  };
  return Arc::MCC_Status(Arc::STATUS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ARex::ARexService::UnknownActivityIdentifierFault ( Arc::XMLNode  fault,
const std::string &  message 
) [protected]

Definition at line 104 of file faults.cpp.

                                                                                          {
  fault.Name("bes-factory:UnknownActivityIdentifierFault");
  fault.NewChild("bes-factory:Message")=message;
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ARex::ARexService::UnknownActivityIdentifierFault ( Arc::SOAPFault &  fault,
const std::string &  message 
) [protected]

Definition at line 110 of file faults.cpp.

                                                                                             {
  UnknownActivityIdentifierFault(fault.Detail(true).NewChild("dummy"),message);
  SetFaultResponse(fault);
}

Here is the call graph for this function:

void ARex::ARexService::UnsupportedFeatureFault ( Arc::XMLNode  fault,
const std::string &  feature 
) [protected]

Definition at line 69 of file faults.cpp.

                                                                                   {
  fault.Name("bes-factory:UnsupportedFeatureFault");
  if(!feature.empty()) fault.NewChild("bes-factory:Feature")=feature;
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ARex::ARexService::UnsupportedFeatureFault ( Arc::SOAPFault &  fault,
const std::string &  feature 
) [protected]

Definition at line 75 of file faults.cpp.

                                                                                      {
  UnsupportedFeatureFault(fault.Detail(true).NewChild("dummy"),feature);
  SetFaultResponse(fault);
}

Here is the call graph for this function:

Arc::MCC_Status ARex::ARexService::UpdateCredentials ( ARexGMConfig config,
Arc::XMLNode  in,
Arc::XMLNode  out,
const std::string &  credentials 
) [protected]

Definition at line 15 of file update_credentials.cpp.

                                                                                                                           {
  /*
  UpdateCredentials (deleg)
    DelegatedToken
      Reference (multiple)

  UpdateCredentialsResponse (deleg)

  NotAuthorizedFault
  InvalidRequestMessageFault
  InvalidActivityIdentifierFault
  */
  {
    std::string s;
    in.GetXML(s);
    logger_.msg(Arc::VERBOSE, "UpdateCredentials: request = \n%s", s);
  };
  // Extract job id from references
  Arc::XMLNode refnode = in["DelegatedToken"]["Reference"];
  if(!refnode) {
    // Must refer to job
    logger_.msg(Arc::ERROR, "UpdateCredentials: missing Reference");
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Must have Activity specified in Reference");
    InvalidRequestMessageFault(fault,"deleg:Reference","Wrong multiplicity");
    out.Destroy();
    return Arc::MCC_Status();
  }
  if((bool)(refnode[1])) {
    // Only one job can be updated per operation (profile)
    logger_.msg(Arc::ERROR, "UpdateCredentials: wrong number of Reference");
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Can update credentials only for single Activity");
    InvalidRequestMessageFault(fault,"deleg:Reference","Wrong multiplicity");
    out.Destroy();
    return Arc::MCC_Status();
  };
  if(refnode.Size() != 1) {
    // Expecting single job EPR in Reference
    logger_.msg(Arc::ERROR, "UpdateCredentials: wrong number of elements inside Reference");
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Can update credentials only for single Activity");
    InvalidRequestMessageFault(fault,"deleg:Reference","Wrong content");
    out.Destroy();
    return Arc::MCC_Status();
  }
  std::string jobid = Arc::WSAEndpointReference(refnode.Child()).ReferenceParameters()["a-rex:JobID"];
  if(jobid.empty()) {
    // EPR is wrongly formated or not an A-REX EPR
    logger_.msg(Arc::ERROR, "UpdateCredentials: EPR contains no JobID");
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Can't find JobID element in ActivityIdentifier");
    InvalidRequestMessageFault(fault,"deleg:Reference","Wrong content");
    out.Destroy();
    return Arc::MCC_Status();
  };
  ARexJob job(jobid,config,logger_);
  if(!job) {
    // There is no such job
    std::string failure = job.Failure();
    logger_.msg(Arc::ERROR, "UpdateCredentials: no job found: %s",failure);
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Can't find requested Activity");
    UnknownActivityIdentifierFault(fault,"No corresponding Activity found");
    out.Destroy();
    return Arc::MCC_Status();
  };
  if(!job.UpdateCredentials(credentials)) {
    logger_.msg(Arc::ERROR, "UpdateCredentials: failed to update credentials");
    Arc::SOAPFault fault(out.Parent(),Arc::SOAPFault::Sender,"Internal error: Failed to update credentials");
    out.Destroy();
    return Arc::MCC_Status();
  };
  {
    std::string s;
    out.GetXML(s);
    logger_.msg(Arc::VERBOSE, "UpdateCredentials: response = \n%s", s);
  };
  return Arc::MCC_Status(Arc::STATUS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 58 of file arex.h.

std::string ARex::ARexService::common_name_ [protected]

Definition at line 64 of file arex.h.

Definition at line 59 of file arex.h.

Definition at line 54 of file arex.h.

std::string ARex::ARexService::endpoint_ [protected]

Definition at line 60 of file arex.h.

std::map<std::string,std::string> ARex::ARexService::glue_states_ [protected]

Definition at line 69 of file arex.h.

Definition at line 70 of file arex.h.

std::string ARex::ARexService::gmconfig_ [protected]

Definition at line 62 of file arex.h.

Definition at line 63 of file arex.h.

Definition at line 55 of file arex.h.

Definition at line 57 of file arex.h.

Definition at line 68 of file arex.h.

Definition at line 56 of file arex.h.

Logger Arc::Service::logger [static, protected, inherited]

Logger object used to print messages generated by this class.

Reimplemented in Echo::Service_Echo, Arc::Service_JavaWrapper, SPService::Service_SP, Compiler::Service_Compiler, Hopi::Hopi, and Arc::Service_PythonWrapper.

Definition at line 43 of file Service.h.

Definition at line 53 of file arex.h.

std::string ARex::ARexService::long_description_ [protected]

Definition at line 65 of file arex.h.

std::string ARex::ARexService::lrms_name_ [protected]

Definition at line 66 of file arex.h.

Definition at line 52 of file arex.h.

std::string ARex::ARexService::os_name_ [protected]

Definition at line 67 of file arex.h.

std::map<std::string,std::list<ArcSec::SecHandler*> > Arc::Service::sechandlers_ [protected, inherited]

Set of labeled authentication and authorization handlers.

MCC calls sequence of handlers at specific point depending on associated identifier. in most aces those are "in" and "out" for incoming and outgoing messages correspondingly.

Definition at line 40 of file Service.h.

Definition at line 51 of file arex.h.

std::string ARex::ARexService::uname_ [protected]

Definition at line 61 of file arex.h.

bool ARex::ARexService::valid_ [protected]

Definition at line 71 of file arex.h.


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