Back to index

nordugrid-arc-nox  1.1.0~rc6
WSRFBaseFault.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include "WSRFBaseFault.h"
00006 
00007 namespace Arc {
00008 
00009 const char* WSRFBaseFaultAction = "http://docs.oasis-open.org/wsrf/fault";
00010 
00011 void WSRFBaseFault::set_namespaces(void) {
00012   //XMLNode::NS ns;
00013   //ns["wsa"]="http://www.w3.org/2005/08/addressing";
00014   //ns["wsrf-bf"]="http://docs.oasis-open.org/wsrf/bf-2";
00015   //ns["wsrf-r"]="http://docs.oasis-open.org/wsrf/r-2";
00016   //ns["wsrf-rw"]="http://docs.oasis-open.org/wsrf/rw-2";
00017   //soap_.Namespaces(ns);
00018 }
00019 
00020 WSRFBaseFault::WSRFBaseFault(SOAPEnvelope& soap):WSRF(soap,WSRFBaseFaultAction) {
00021   if(!valid_) return;
00022   // Check if that is fault
00023   SOAPFault* fault = SOAP().Fault();
00024   if(!fault) { valid_=false; return; };
00025   // It must have timestamp
00026   XMLNode wsrf_fault = fault->Detail()[0];
00027   if(!(wsrf_fault["wsrf-bf:Timestamp"])) { valid_=false; return; };
00028 }
00029 
00030 WSRFBaseFault::WSRFBaseFault(const std::string& type):WSRF(true,WSRFBaseFaultAction) {
00031   if(!valid_) return;
00032   SOAPFault* fault = SOAP().Fault();
00033   if(!fault) return;
00034   fault->Detail(true).NewChild(type);
00035   // Timestamp(Time());
00036 }
00037 
00038 WSRFBaseFault::~WSRFBaseFault(void) {
00039 }
00040 
00041 std::string WSRFBaseFault::Type(void) {
00042   if(!valid_) return "";
00043   SOAPFault* fault = SOAP().Fault();
00044   if(!fault) return "";
00045   return fault->Detail()[0].Name();
00046 }
00047 
00048 /*
00049 Time WSRFBaseFault::Timestamp(void) {
00050   if(!valid_) return 0;
00051   SOAPFault* fault = SOAP().Fault();
00052   if(!fault) return 0;
00053   std::string time_s = fault->Detail()[0]["wsrf-bf:Timestamp"];
00054   return Time(time_s);
00055 } 
00056 
00057 void WSRFBaseFault::Timestamp(Time t) {
00058   if(!valid_) return;
00059   SOAPFault* fault = SOAP().Fault();
00060   if(!fault) return;
00061   XMLNode timestamp = fault->Detail()[0]["wsrf-bf:Timestamp"];
00062   if(!timestamp) timestamp = fault->Detail()[0].NewChild("wsrf-bf:Timestamp");
00063   timestamp = t.str(UTCTime);
00064 }
00065 */
00066 
00067 WSAEndpointReference WSRFBaseFault::Originator(void) {
00068   if(!valid_) return WSAEndpointReference();
00069   SOAPFault* fault = SOAP().Fault();
00070   if(!fault) return WSAEndpointReference();
00071   return WSAEndpointReference(fault->Detail()[0]["wsrf-bf:Originator"]);
00072 }
00073 
00074 void WSRFBaseFault::ErrorCode(const std::string&,const XMLNode&) {
00075 }
00076 
00077 XMLNode WSRFBaseFault::ErrorCode(void) {
00078   if(!valid_) return XMLNode();
00079   SOAPFault* fault = SOAP().Fault();
00080   if(!fault) return XMLNode();
00081   return fault->Detail()[0]["wsrf-bf:ErrorCode"];
00082 }
00083 
00084 std::string WSRFBaseFault::ErrorCodeDialect(void) {
00085   return ErrorCode().Attribute("wsrf-bf:dialect");
00086 }
00087 
00088 void WSRFBaseFault::FaultCause(int pos,const XMLNode& cause) {
00089   if(!valid_) return;
00090   SOAPFault* fault = SOAP().Fault();
00091   if(!fault) return;
00092   XMLNode fcause = fault->Detail()[0]["wsrf-bf:FaultCause"];
00093   if(!fcause) fcause=fault->Detail()[0].NewChild("wsrf-bf:FaultCause");
00094   fcause.NewChild(cause,pos);
00095 }
00096 
00097 XMLNode WSRFBaseFault::FaultCause(int pos) {
00098   if(!valid_) return XMLNode();
00099   SOAPFault* fault = SOAP().Fault();
00100   if(!fault) return XMLNode();
00101   XMLNode fcause = fault->Detail()[0]["wsrf-bf:FaultCause"];
00102   if(!fcause) return XMLNode();
00103   return fcause.Child(pos);
00104 }
00105 
00106 void WSRFBaseFault::Description(int pos,const std::string& desc,const std::string& lang) {
00107   if(!valid_) return;
00108   SOAPFault* fault = SOAP().Fault();
00109   if(!fault) return;
00110   XMLNode d = fault->Detail()[0].NewChild("wsrf-bf:Description",pos);
00111   d=desc;
00112   if(!lang.empty()) d.NewAttribute("wsrf-bf:lang")=lang;
00113 }
00114 
00115 std::string WSRFBaseFault::Description(int pos) {
00116   if(!valid_) return XMLNode();
00117   SOAPFault* fault = SOAP().Fault();
00118   if(!fault) return XMLNode();
00119   return fault->Detail()[0]["wsrf-bf:Description"][pos];
00120 }
00121 
00122 std::string WSRFBaseFault::DescriptionLang(int pos) {
00123   if(!valid_) return XMLNode();
00124   SOAPFault* fault = SOAP().Fault();
00125   if(!fault) return XMLNode();
00126   return fault->Detail()[0]["wsrf-bf:Description"][pos].Attribute("wsrf-bf:lang");
00127 }
00128 
00129 WSRF& CreateWSRFBaseFault(SOAPEnvelope& soap) {
00130   // Not the most efective way to extract type of message
00131   WSRFBaseFault& v = *(new WSRFBaseFault(soap));
00132   std::string type = v.Type();
00133   delete &v;
00134   if(v.Type() == "wsrf-r:ResourceUnknownFault") return *(new WSRFResourceUnknownFault(soap));
00135   if(v.Type() == "wsrf-r:ResourceUnavailableFault") return *(new WSRFResourceUnavailableFault(soap));
00136   return *(new WSRF());
00137 }
00138 
00139 /*
00140   
00141 
00142 };
00143 */
00144 
00145 } // namespace Arc
00146