Back to index

nordugrid-arc-nox  1.1.0~rc6
get_activity_statuses.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include <arc/message/SOAPEnvelope.h>
00006 #include <arc/ws-addressing/WSA.h>
00007 #include "job.h"
00008 #include "tools.h"
00009 
00010 #include "arex.h"
00011 
00012 namespace ARex {
00013 
00014 
00015 Arc::MCC_Status ARexService::GetActivityStatuses(ARexGMConfig& config,Arc::XMLNode in,Arc::XMLNode out) {
00016   /*
00017   GetActivityStatuses
00018     ActivityIdentifier (wsa:EndpointReferenceType, unbounded)
00019 
00020   GetActivityStatusesResponse
00021     Response (unbounded)
00022       ActivityIdentifier
00023       ActivityStatus
00024         attribute = state (bes-factory:ActivityStateEnumeration)
00025           Pending,Running,Cancelled,Failed,Finished
00026       Fault (soap:Fault)
00027   UnknownActivityIdentifierFault
00028   */
00029   {
00030     std::string s;
00031     in.GetXML(s);
00032     logger.msg(Arc::VERBOSE, "GetActivityStatuses: request = \n%s", s);
00033   };
00034   for(int n = 0;;++n) {
00035     Arc::XMLNode id = in["ActivityIdentifier"][n];
00036     if(!id) break;
00037     // Create place for response
00038     Arc::XMLNode resp = out.NewChild("bes-factory:Response");
00039     resp.NewChild(id);
00040     std::string jobid = Arc::WSAEndpointReference(id).ReferenceParameters()["a-rex:JobID"];
00041     if(jobid.empty()) {
00042       // EPR is wrongly formated or not an A-REX EPR
00043       logger_.msg(Arc::ERROR, "GetActivityStatuses: job %s - can't understand EPR", jobid);
00044       Arc::SOAPFault fault(resp,Arc::SOAPFault::Sender,"Missing a-rex:JobID in ActivityIdentifier");
00045       UnknownActivityIdentifierFault(fault,"Unrecognized EPR in ActivityIdentifier");
00046       continue;
00047     };
00048     // Look for obtained ID
00049     ARexJob job(jobid,config,logger_);
00050     if(!job) {
00051       // There is no such job
00052       logger_.msg(Arc::ERROR, "GetActivityStatuses: job %s - %s", jobid, job.Failure());
00053       Arc::SOAPFault fault(resp,Arc::SOAPFault::Sender,"No corresponding activity found");
00054       UnknownActivityIdentifierFault(fault,("No activity "+jobid+" found: "+job.Failure()).c_str());
00055       continue;
00056     };
00057     /*
00058     // TODO: Check permissions on that ID
00059     */
00060     bool job_pending = false;
00061     std::string gm_state = job.State(job_pending);
00062     addActivityStatus(resp,gm_state,glue_states_[job.ID()],job.Failed(),job_pending);
00063   };
00064   {
00065     std::string s;
00066     out.GetXML(s);
00067     logger.msg(Arc::VERBOSE, "GetActivityStatuses: response = \n%s", s);
00068   };
00069   return Arc::MCC_Status(Arc::STATUS_OK);
00070 }
00071 
00072 } // namespace ARex
00073