Back to index

nordugrid-arc-nox  1.1.0~rc6
get_activity_documents.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 
00009 #include "arex.h"
00010 
00011 namespace ARex {
00012 
00013 
00014 Arc::MCC_Status ARexService::GetActivityDocuments(ARexGMConfig& config,Arc::XMLNode in,Arc::XMLNode out) {
00015   /*
00016   GetActivityDocuments
00017     ActivityIdentifier (wsa:EndpointReferenceType, unbounded)
00018 
00019   GetActivityDocumentsResponse
00020     Response (unbounded)
00021       ActivityIdentifier
00022       JobDefinition (jsdl:JobDefinition)
00023       Fault (soap:Fault)
00024   UnknownActivityIdentifierFault
00025   */
00026   {
00027     std::string s;
00028     in.GetXML(s);
00029     logger.msg(Arc::VERBOSE, "GetActivityDocuments: request = \n%s", s);
00030   };
00031   for(int n = 0;;++n) {
00032     Arc::XMLNode id = in["ActivityIdentifier"][n];
00033     if(!id) break;
00034     // Create place for response
00035     Arc::XMLNode resp = out.NewChild("bes-factory:Response");
00036     resp.NewChild(id);
00037     std::string jobid = Arc::WSAEndpointReference(id).ReferenceParameters()["a-rex:JobID"];
00038     if(jobid.empty()) {
00039       // EPR is wrongly formated or not an A-REX EPR
00040       logger_.msg(Arc::ERROR, "GetActivityDocuments: non-ARex job requested");
00041       Arc::SOAPFault fault(resp,Arc::SOAPFault::Sender,"Missing a-rex:JobID in ActivityIdentifier");
00042       UnknownActivityIdentifierFault(fault,"Unrecognized EPR in ActivityIdentifier");
00043       continue;
00044     };
00045     // Look for obtained ID
00046     ARexJob job(jobid,config,logger_);
00047     if(!job) {
00048       // There is no such job
00049       logger_.msg(Arc::ERROR, "GetActivityDocuments: job %s - %s", jobid, job.Failure());
00050       Arc::SOAPFault fault(resp,Arc::SOAPFault::Sender,"No corresponding activity found");
00051       UnknownActivityIdentifierFault(fault,("No activity "+jobid+" found: "+job.Failure()).c_str());
00052       continue;
00053     };
00054     /*
00055     // TODO: Check permissions on that ID
00056     */
00057     // Read JSDL of job
00058     Arc::XMLNode jsdl = resp.NewChild("bes-factory:JobDefinition");
00059     if(!job.GetDescription(jsdl)) {
00060       logger_.msg(Arc::ERROR, "GetActivityDocuments: job %s - %s", jobid, job.Failure());
00061       // Processing failure
00062       jsdl.Destroy();
00063       Arc::SOAPFault fault(resp,Arc::SOAPFault::Sender,"Failed processing activity");
00064       UnknownActivityIdentifierFault(fault,("Failed processing activity "+jobid+": "+job.Failure()).c_str());
00065       continue;
00066     };
00067     jsdl.Name("bes-factory:JobDefinition"); // Recovering namespace of element
00068   };
00069   {
00070     std::string s;
00071     out.GetXML(s);
00072     logger_.msg(Arc::VERBOSE, "GetActivityDocuments: response = \n%s", s);
00073   };
00074   return Arc::MCC_Status(Arc::STATUS_OK);
00075 }
00076 
00077 } // namespace ARex
00078