Back to index

nordugrid-arc-nox  1.1.0~rc6
WSResourceProperties.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include <arc/ws-addressing/WSA.h>
00006 #include "WSResourceProperties.h"
00007 
00008 namespace Arc {
00009 
00010 // ============= Actions ==============
00011 
00012 static const char* WSRPGetResourcePropertyDocumentRequestAction = "http://docs.oasis-open.org/wsrf/rpw-2/GetResourcePropertyDocument/GetResourcePropertyDocumentRequest";
00013 static const char* WSRPGetResourcePropertyDocumentResponseAction = "http://docs.oasis-open.org/wsrf/rpw-2/GetResourcePropertyDocument/GetResourcePropertyDocumentResponse";
00014 static const char* WSRPGetResourcePropertyRequestAction = "http://docs.oasis-open.org/wsrf/rpw-2/GetResourceProperty/GetResourcePropertyRequest";
00015 static const char* WSRPGetResourcePropertyResponseAction = "http://docs.oasis-open.org/wsrf/rpw-2/GetResourceProperty/GetResourcePropertyResponse";
00016 static const char* WSRPGetMultipleResourcePropertiesRequestAction = "http://docs.oasis-open.org/wsrf/rpw-2/GetMultipleResourceProperties/GetMultipleResourcePropertiesRequest";
00017 static const char* WSRPGetMultipleResourcePropertiesResponseAction = "http://docs.oasis-open.org/wsrf/rpw-2/GetMultipleResourceProperties/GetMultipleResourcePropertiesResponse";
00018 static const char* WSRPQueryResourcePropertiesRequestAction = "http://docs.oasis-open.org/wsrf/rpw-2/QueryResourceProperties/QueryResourcePropertiesRequest";
00019 static const char* WSRPQueryResourcePropertiesResponseAction = "http://docs.oasis-open.org/wsrf/rpw-2/QueryResourceProperties/QueryResourcePropertiesResponse";
00020 static const char* WSRPPutResourcePropertyDocumentRequestAction = "http://docs.oasis-open.org/wsrf/rpw-2/PutResourcePropertyDocument/PutResourcePropertyDocumentRequest";
00021 static const char* WSRPPutResourcePropertyDocumentResponseAction = "http://docs.oasis-open.org/wsrf/rpw-2/PutResourcePropertyDocument/PutResourcePropertyDocumentResponse";
00022 static const char* WSRPSetResourcePropertiesRequestAction = "http://docs.oasis-open.org/wsrf/rpw-2/SetResourceProperties/SetResourcePropertiesRequest";
00023 static const char* WSRPSetResourcePropertiesResponseAction = "http://docs.oasis-open.org/wsrf/rpw-2/SetResourceProperties/SetResourcePropertiesResponse";
00024 static const char* WSRPInsertResourcePropertiesRequestAction = "http://docs.oasis-open.org/wsrf/rpw-2/InsertResourceProperties/InsertResourcePropertiesRequest";
00025 static const char* WSRPInsertResourcePropertiesResponseAction = "http://docs.oasis-open.org/wsrf/rpw-2/InsertResourceProperties/InsertResourcePropertiesResponse";
00026 static const char* WSRPUpdateResourcePropertiesRequestAction = "http://docs.oasis-open.org/wsrf/rpw-2/UpdateResourceProperties/UpdateResourcePropertiesRequest";
00027 static const char* WSRPUpdateResourcePropertiesResponseAction = "http://docs.oasis-open.org/wsrf/rpw-2/UpdateResourceProperties/UpdateResourcePropertiesResponse";
00028 static const char* WSRPDeleteResourcePropertiesRequestAction = "http://docs.oasis-open.org/wsrf/rpw-2/DeleteResourceProperties/DeleteResourcePropertiesRequest";
00029 static const char* WSRPDeleteResourcePropertiesResponseAction = "http://docs.oasis-open.org/wsrf/rpw-2/DeleteResourceProperties/DeleteResourcePropertiesResponse";
00030 
00031 
00032 // ============= BaseClass ==============
00033 
00034 void WSRP::set_namespaces(void) {
00035   NS ns;
00036   ns["wsrf-bf"]="http://docs.oasis-open.org/wsrf/bf-2";
00037   ns["wsrf-rp"]="http://docs.oasis-open.org/wsrf/rp-2";
00038   ns["wsrf-rpw"]="http://docs.oasis-open.org/wsrf/rpw-2";
00039   ns["wsrf-rw"]="http://docs.oasis-open.org/wsrf/rw-2";
00040   soap_.Namespaces(ns);
00041 }
00042 
00043 WSRP::WSRP(bool fault,const std::string& action):WSRF(fault,action) {
00044   set_namespaces();
00045 }
00046 
00047 WSRP::WSRP(SOAPEnvelope& soap,const std::string& action):WSRF(soap,action) {
00048   set_namespaces();
00049 }
00050 
00051 // ============= ResourceProperties modifiers ==============
00052 
00053 WSRPModifyResourceProperties::WSRPModifyResourceProperties(XMLNode& node,bool create,const std::string& name) {
00054   if(create) {
00055     if(!name.empty()) element_=node.NewChild(name);
00056   } else {
00057     if(MatchXMLName(node,name)) element_=node;
00058   };
00059 }
00060 
00061 WSRPModifyResourceProperties::~WSRPModifyResourceProperties(void) {
00062 }
00063 
00064 WSRPInsertResourceProperties::~WSRPInsertResourceProperties(void) {
00065 }
00066 
00067 WSRPUpdateResourceProperties::~WSRPUpdateResourceProperties(void) {
00068 }
00069 
00070 WSRPDeleteResourceProperties::~WSRPDeleteResourceProperties(void) {
00071 }
00072 
00073 std::string WSRPDeleteResourceProperties::Property(void) {
00074   return (std::string)(element_.Attribute("wsrf-rp:ResourceProperty"));
00075 }
00076 
00077 void WSRPDeleteResourceProperties::Property(const std::string& name) {
00078   XMLNode property = element_.Attribute("wsrf-rp:ResourceProperty");
00079   if(!property) property=element_.NewAttribute("wsrf-rp:ResourceProperty");
00080   property=name;
00081 }
00082 
00083 
00084 // ============= GetResourcePropertyDocument ==============
00085 
00086 WSRPGetResourcePropertyDocumentRequest::WSRPGetResourcePropertyDocumentRequest(SOAPEnvelope& soap):WSRP(soap,WSRPGetResourcePropertyDocumentRequestAction) {
00087   if(!valid_) return;
00088   if(!MatchXMLName(soap_.Child(),"wsrf-rp:GetResourcePropertyDocument")) valid_=false;
00089 }
00090 
00091 WSRPGetResourcePropertyDocumentRequest::WSRPGetResourcePropertyDocumentRequest(void):WSRP(false,WSRPGetResourcePropertyDocumentRequestAction) {
00092   if(!soap_.NewChild("wsrf-rp:GetResourcePropertyDocument")) valid_=false;
00093 }
00094 
00095 WSRPGetResourcePropertyDocumentRequest::~WSRPGetResourcePropertyDocumentRequest(void) {
00096 }
00097 
00098 WSRPGetResourcePropertyDocumentResponse::WSRPGetResourcePropertyDocumentResponse(SOAPEnvelope& soap):WSRP(soap,WSRPGetResourcePropertyDocumentResponseAction) {
00099   if(!valid_) return;
00100   if(!MatchXMLName(soap_.Child(),"wsrf-rp:GetResourcePropertyDocumentResponse")) valid_=false;
00101 }
00102 
00103 WSRPGetResourcePropertyDocumentResponse::WSRPGetResourcePropertyDocumentResponse(const XMLNode& prop_doc):WSRP(false,WSRPGetResourcePropertyDocumentResponseAction) {
00104   XMLNode resp = soap_.NewChild("wsrf-rp:GetResourcePropertyDocumentResponse");
00105   if(!resp) { valid_=false; return; };
00106   if(prop_doc) resp.NewChild(prop_doc);
00107 }
00108 
00109 WSRPGetResourcePropertyDocumentResponse::~WSRPGetResourcePropertyDocumentResponse(void) {
00110 }
00111 
00112 void WSRPGetResourcePropertyDocumentResponse::Document(const XMLNode& prop_doc) {
00113   if(!valid_) return;
00114   XMLNode resp = soap_.Child();
00115   resp.Child().Destroy();
00116   if(prop_doc) resp.NewChild(prop_doc);
00117 }
00118 
00119 XMLNode WSRPGetResourcePropertyDocumentResponse::Document(void) {
00120   if(!valid_) return XMLNode();
00121   return soap_.Child().Child();
00122 }
00123 
00124 
00125 // ============= GetResourceProperty ==============
00126 
00127 WSRPGetResourcePropertyRequest::WSRPGetResourcePropertyRequest(SOAPEnvelope& soap):WSRP(soap,WSRPGetResourcePropertyRequestAction) {
00128   if(!valid_) return;
00129   if(!MatchXMLName(soap_.Child(),"wsrf-rp:GetResourceProperty")) valid_=false;
00130 }
00131 
00132 WSRPGetResourcePropertyRequest::WSRPGetResourcePropertyRequest(const std::string& name):WSRP(false,WSRPGetResourcePropertyRequestAction) {
00133   XMLNode req = soap_.NewChild("wsrf-rp:GetResourceProperty");
00134   if(!req) { valid_=false; return; };
00135   req=name; // QName
00136 }
00137 
00138 WSRPGetResourcePropertyRequest::~WSRPGetResourcePropertyRequest(void) {
00139 }
00140 
00141 std::string WSRPGetResourcePropertyRequest::Name(void) {
00142   if(!valid_) return "";
00143   return (std::string)(soap_.Child());
00144 }
00145 
00146 void WSRPGetResourcePropertyRequest::Name(const std::string& name) {
00147   if(!valid_) return;
00148   soap_.Child()=name;
00149 }
00150 
00151 WSRPGetResourcePropertyResponse::WSRPGetResourcePropertyResponse(SOAPEnvelope& soap):WSRP(soap,WSRPGetResourcePropertyResponseAction) {
00152   if(!valid_) return;
00153   if(!MatchXMLName(soap_.Child(),"wsrf-rp:GetResourcePropertyResponse")) valid_=false;
00154 }
00155 
00156 WSRPGetResourcePropertyResponse::WSRPGetResourcePropertyResponse(void):WSRP(false,WSRPGetResourcePropertyResponseAction) {
00157   XMLNode resp = soap_.NewChild("wsrf-rp:GetResourcePropertyResponse");
00158   if(!resp) valid_=false;
00159 }
00160 
00161 WSRPGetResourcePropertyResponse::~WSRPGetResourcePropertyResponse(void) {
00162 }
00163 
00164 int WSRPGetResourcePropertyResponse::Size(void) {
00165   if(!valid_) return 0;
00166   return soap_.Child().Size();  
00167 }
00168 
00169 void WSRPGetResourcePropertyResponse::Property(const XMLNode& prop,int pos) {
00170   if(!valid_) return;
00171   XMLNode resp = soap_.Child();
00172   if(resp) resp.NewChild(prop,pos);
00173 }
00174 
00175 XMLNode WSRPGetResourcePropertyResponse::Property(int pos) {
00176   if(!valid_) return XMLNode();
00177   return soap_.Child().Child(pos);
00178 }
00179 
00180 XMLNode WSRPGetResourcePropertyResponse::Properties(void) {
00181   if(!valid_) return XMLNode();
00182   return soap_.Child();
00183 }
00184 
00185 
00186 // ============= GetMultipleResourceProperties ==============
00187 
00188 WSRPGetMultipleResourcePropertiesRequest::WSRPGetMultipleResourcePropertiesRequest(SOAPEnvelope& soap):WSRP(soap,WSRPGetMultipleResourcePropertiesRequestAction) {
00189   if(!valid_) return;
00190   if(!MatchXMLName(soap_.Child(),"wsrf-rp:GetMultipleResourceProperties")) valid_=false;
00191 }
00192 
00193 WSRPGetMultipleResourcePropertiesRequest::WSRPGetMultipleResourcePropertiesRequest(void):WSRP(false,WSRPGetMultipleResourcePropertiesRequestAction) {
00194   XMLNode req = soap_.NewChild("wsrf-rp:GetMultipleResourceProperties");
00195   if(!req) valid_=false;
00196 }
00197 
00198 WSRPGetMultipleResourcePropertiesRequest::WSRPGetMultipleResourcePropertiesRequest(const std::vector<std::string>& names):WSRP(false,WSRPGetMultipleResourcePropertiesRequestAction) {
00199   XMLNode req = soap_.NewChild("wsrf-rp:GetMultipleResourceProperties");
00200   if(!req) { valid_=false; return; };
00201   for(std::vector<std::string>::const_iterator i = names.begin();i!=names.end();++i) {
00202     XMLNode new_node = req.NewChild("wsrf-rp:ResourceProperty");
00203     new_node=*i;
00204   };
00205 }
00206 
00207 WSRPGetMultipleResourcePropertiesRequest::~WSRPGetMultipleResourcePropertiesRequest(void) {
00208 }
00209 
00210 std::vector<std::string> WSRPGetMultipleResourcePropertiesRequest::Names(void) {
00211   std::vector<std::string> names;
00212   if(!valid_) return names;
00213   XMLNode props = soap_.Child()["wsrf-rp:ResourceProperty"];
00214   for(int n = 0;;++n) {
00215     XMLNode prop = props[n];
00216     if(!prop) break;
00217     names.push_back((std::string)prop);
00218   };
00219   return names;
00220 }
00221 
00222 void WSRPGetMultipleResourcePropertiesRequest::Names(const std::vector<std::string>& names) {
00223   if(!valid_) return;
00224   XMLNode req = soap_.Child();
00225   for(;;) {
00226     XMLNode prop = req["wsrf-rp:ResourceProperty"];
00227     if(!prop) break;
00228     prop.Destroy();
00229   };
00230   for(std::vector<std::string>::const_iterator i = names.begin();i!=names.end();++i) {
00231     XMLNode new_node = req.NewChild("wsrf-rp:ResourceProperty");
00232     new_node=*i;
00233   };
00234 }
00235 
00236 WSRPGetMultipleResourcePropertiesResponse::WSRPGetMultipleResourcePropertiesResponse(SOAPEnvelope& soap):WSRP(soap,WSRPGetMultipleResourcePropertiesResponseAction) {
00237   if(!valid_) return;
00238   if(!MatchXMLName(soap_.Child(),"wsrf-rp:GetMultipleResourcePropertiesResponse")) valid_=false;
00239 }
00240 
00241 WSRPGetMultipleResourcePropertiesResponse::WSRPGetMultipleResourcePropertiesResponse(void):WSRP(false,WSRPGetMultipleResourcePropertiesResponseAction) {
00242   XMLNode resp = soap_.NewChild("wsrf-rp:GetMultipleResourcePropertiesResponse");
00243   if(!resp) valid_=false;
00244 }
00245 
00246 WSRPGetMultipleResourcePropertiesResponse::~WSRPGetMultipleResourcePropertiesResponse(void) {
00247 }
00248 
00249 int WSRPGetMultipleResourcePropertiesResponse::Size(void) {
00250   if(!valid_) return 0;
00251   return soap_.Child().Size();  
00252 }
00253 
00254 void WSRPGetMultipleResourcePropertiesResponse::Property(const XMLNode& prop,int pos) {
00255   if(!valid_) return;
00256   XMLNode resp = soap_.Child();
00257   if(resp) resp.NewChild(prop,pos);
00258 }
00259 
00260 XMLNode WSRPGetMultipleResourcePropertiesResponse::Property(int pos) {
00261   if(!valid_) return XMLNode();
00262   return soap_.Child().Child(pos);
00263 }
00264 
00265 XMLNode WSRPGetMultipleResourcePropertiesResponse::Properties(void) {
00266   if(!valid_) return XMLNode();
00267   return soap_.Child();
00268 }
00269 
00270 
00271 // ============= PutResourcePropertiesDocument ==============
00272 
00273 WSRPPutResourcePropertyDocumentRequest::WSRPPutResourcePropertyDocumentRequest(SOAPEnvelope& soap):WSRP(soap,WSRPPutResourcePropertyDocumentRequestAction) {
00274   if(!valid_) return;
00275   if(!MatchXMLName(soap_.Child(),"wsrf-rp:PutResourcePropertyDocument")) valid_=false;
00276 }
00277 
00278 WSRPPutResourcePropertyDocumentRequest::WSRPPutResourcePropertyDocumentRequest(const XMLNode& prop_doc):WSRP(false,WSRPPutResourcePropertyDocumentRequestAction) {
00279   XMLNode resp = soap_.NewChild("wsrf-rp:PutResourcePropertyDocument");
00280   if(!resp) { valid_=false; return; };
00281   if(prop_doc) resp.NewChild(prop_doc);
00282 }
00283 
00284 WSRPPutResourcePropertyDocumentRequest::~WSRPPutResourcePropertyDocumentRequest(void) {
00285 }
00286 
00287 void WSRPPutResourcePropertyDocumentRequest::Document(const XMLNode& prop_doc) {
00288   if(!valid_) return;
00289   XMLNode resp = soap_.Child();
00290   resp.Child().Destroy();
00291   if(prop_doc) resp.NewChild(prop_doc);
00292 }
00293 
00294 XMLNode WSRPPutResourcePropertyDocumentRequest::Document(void) {
00295   if(!valid_) return XMLNode();
00296   return soap_.Child().Child();
00297 }
00298 
00299 WSRPPutResourcePropertyDocumentResponse::WSRPPutResourcePropertyDocumentResponse(SOAPEnvelope& soap):WSRP(soap,WSRPPutResourcePropertyDocumentResponseAction) {
00300   if(!valid_) return;
00301   if(!MatchXMLName(soap_.Child(),"wsrf-rp:PutResourcePropertyDocumentResponse")) valid_=false;
00302 }
00303 
00304 WSRPPutResourcePropertyDocumentResponse::WSRPPutResourcePropertyDocumentResponse(const XMLNode& prop_doc):WSRP(false,WSRPPutResourcePropertyDocumentResponseAction) {
00305   XMLNode resp = soap_.NewChild("wsrf-rp:PutResourcePropertyDocumentResponse");
00306   if(!resp) { valid_=false; return; };
00307   if(prop_doc) resp.NewChild(prop_doc);
00308 }
00309 
00310 WSRPPutResourcePropertyDocumentResponse::~WSRPPutResourcePropertyDocumentResponse(void) {
00311 }
00312 
00313 void WSRPPutResourcePropertyDocumentResponse::Document(const XMLNode& prop_doc) {
00314   if(!valid_) return;
00315   XMLNode resp = soap_.Child();
00316   resp.Child().Destroy();
00317   if(prop_doc) resp.NewChild(prop_doc);
00318 }
00319 
00320 XMLNode WSRPPutResourcePropertyDocumentResponse::Document(void) {
00321   if(!valid_) return XMLNode();
00322   return soap_.Child().Child();
00323 }
00324 
00325 
00326 // ============= SetResourceProperties ==============
00327 
00328 WSRPSetResourcePropertiesRequest::WSRPSetResourcePropertiesRequest(SOAPEnvelope& soap):WSRP(soap,WSRPSetResourcePropertiesRequestAction) {
00329   if(!valid_) return;
00330   if(!MatchXMLName(soap_.Child(),"wsrf-rp:SetResourceProperties")) valid_=false;}
00331 
00332 WSRPSetResourcePropertiesRequest::WSRPSetResourcePropertiesRequest(void):WSRP(false,WSRPSetResourcePropertiesRequestAction) {
00333   if(!soap_.NewChild("wsrf-rp:SetResourceProperties")) valid_=false;
00334 }
00335 
00336 WSRPSetResourcePropertiesRequest::~WSRPSetResourcePropertiesRequest(void) {
00337 }
00338 
00339 XMLNode WSRPSetResourcePropertiesRequest::Properties(void) {
00340   if(!valid_) return XMLNode();
00341   return soap_.Child();
00342 }
00343 
00344 WSRPSetResourcePropertiesResponse::WSRPSetResourcePropertiesResponse(SOAPEnvelope& soap):WSRP(soap,WSRPSetResourcePropertiesResponseAction) {
00345   if(!valid_) return;
00346   if(!MatchXMLName(soap_.Child(),"wsrf-rp:SetResourcePropertiesResponse")) valid_=false;
00347 }
00348 
00349 WSRPSetResourcePropertiesResponse::WSRPSetResourcePropertiesResponse(void):WSRP(false,WSRPSetResourcePropertiesResponseAction) {
00350   if(!soap_.NewChild("wsrf-rp:SetResourcePropertiesResponse")) valid_=false;
00351 }
00352 
00353 WSRPSetResourcePropertiesResponse::~WSRPSetResourcePropertiesResponse(void) {
00354 }
00355 
00356 // ============= InsertResourceProperties ==============
00357 
00358 WSRPInsertResourcePropertiesRequest::WSRPInsertResourcePropertiesRequest(SOAPEnvelope& soap):WSRP(soap,WSRPInsertResourcePropertiesRequestAction) {
00359   if(!valid_) return;
00360   if(!MatchXMLName(soap_.Child(),"wsrf-rp:InsertResourceProperties")) valid_=false;
00361 }
00362 
00363 WSRPInsertResourcePropertiesRequest::WSRPInsertResourcePropertiesRequest(void):WSRP(false,WSRPInsertResourcePropertiesRequestAction) {
00364   if(!soap_.NewChild("wsrf-rp:InsertResourceProperties")) valid_=false;
00365 }
00366 
00367 WSRPInsertResourcePropertiesRequest::~WSRPInsertResourcePropertiesRequest(void) {
00368 }
00369 
00370 WSRPInsertResourceProperties WSRPInsertResourcePropertiesRequest::Property(void) {
00371   if(!valid_) return WSRPInsertResourceProperties();
00372   return WSRPInsertResourceProperties(soap_.Child()["wsrf-rp:Insert"],false);
00373 }
00374 
00375 WSRPInsertResourcePropertiesResponse::WSRPInsertResourcePropertiesResponse(SOAPEnvelope& soap):WSRP(soap,WSRPInsertResourcePropertiesResponseAction) {
00376   if(!valid_) return;
00377   if(!MatchXMLName(soap_.Child(),"wsrf-rp:InsertResourcePropertiesResponse")) valid_=false;
00378 }
00379 
00380 WSRPInsertResourcePropertiesResponse::WSRPInsertResourcePropertiesResponse(void):WSRP(false,WSRPInsertResourcePropertiesResponseAction) {
00381   if(!soap_.NewChild("wsrf-rp:InsertResourcePropertiesResponse")) valid_=false;
00382 }
00383 
00384 WSRPInsertResourcePropertiesResponse::~WSRPInsertResourcePropertiesResponse(void) {
00385 }
00386 
00387 
00388 // ============= UpdateResourceProperties ==============
00389 
00390 WSRPUpdateResourcePropertiesRequest::WSRPUpdateResourcePropertiesRequest(SOAPEnvelope& soap):WSRP(soap,WSRPUpdateResourcePropertiesRequestAction) {
00391   if(!valid_) return;
00392   if(!MatchXMLName(soap_.Child(),"wsrf-rp:UpdateResourceProperties")) valid_=false;
00393 }
00394 
00395 WSRPUpdateResourcePropertiesRequest::WSRPUpdateResourcePropertiesRequest(void):WSRP(false,WSRPUpdateResourcePropertiesRequestAction) {
00396   XMLNode req = soap_.NewChild("wsrf-rp:UpdateResourceProperties");
00397   if(!req) valid_=false;
00398   XMLNode el = req.NewChild("wsrf-rp:Update");
00399   if(!el) valid_=false;
00400 }
00401 
00402 WSRPUpdateResourcePropertiesRequest::~WSRPUpdateResourcePropertiesRequest(void) {
00403 }
00404 
00405 WSRPUpdateResourceProperties WSRPUpdateResourcePropertiesRequest::Property(void) {
00406   if(!valid_) return WSRPUpdateResourceProperties();
00407   return WSRPUpdateResourceProperties(soap_.Child()["wsrf-rp:Update"],false);
00408 }
00409 
00410 WSRPUpdateResourcePropertiesResponse::WSRPUpdateResourcePropertiesResponse(SOAPEnvelope& soap):WSRP(soap,WSRPUpdateResourcePropertiesResponseAction) {
00411   if(!valid_) return;
00412   if(!MatchXMLName(soap_.Child(),"wsrf-rp:UpdateResourcePropertiesResponse")) valid_=false;
00413 }
00414 
00415 WSRPUpdateResourcePropertiesResponse::WSRPUpdateResourcePropertiesResponse(void):WSRP(false,WSRPUpdateResourcePropertiesResponseAction) {
00416   if(!soap_.NewChild("wsrf-rp:UpdateResourcePropertiesResponse")) valid_=false;
00417 }
00418 
00419 WSRPUpdateResourcePropertiesResponse::~WSRPUpdateResourcePropertiesResponse(void) {
00420 }
00421 
00422 
00423 // ============= DeleteResourceProperties ==============
00424 
00425 WSRPDeleteResourcePropertiesRequest::WSRPDeleteResourcePropertiesRequest(SOAPEnvelope& soap):WSRP(soap,WSRPDeleteResourcePropertiesRequestAction) {
00426   if(!valid_) return;
00427   if(!MatchXMLName(soap_.Child(),"wsrf-rp:DeleteResourceProperties")) valid_=false;
00428 }
00429 
00430 WSRPDeleteResourcePropertiesRequest::WSRPDeleteResourcePropertiesRequest(void):WSRP(false,WSRPDeleteResourcePropertiesRequestAction) {
00431   XMLNode req = soap_.NewChild("wsrf-rp:DeleteResourceProperties");
00432   if(!req) valid_=false;
00433   XMLNode el = req.NewChild("wsrf-rp:Delete");
00434   if(!el) valid_=false;
00435 }
00436 
00437 WSRPDeleteResourcePropertiesRequest::WSRPDeleteResourcePropertiesRequest(const std::string& name):WSRP(false,WSRPDeleteResourcePropertiesRequestAction) {
00438   XMLNode req = soap_.NewChild("wsrf-rp:DeleteResourceProperties");
00439   if(!req) valid_=false;
00440   Name(name);
00441 }
00442 
00443 WSRPDeleteResourcePropertiesRequest::~WSRPDeleteResourcePropertiesRequest(void) {
00444 }
00445 
00446 std::string WSRPDeleteResourcePropertiesRequest::Name(void) {
00447   if(!valid_) return "";
00448   return WSRPDeleteResourceProperties(soap_.Child()["wsrf-rp:Delete"],false).Property();
00449 }
00450 
00451 void WSRPDeleteResourcePropertiesRequest::Name(const std::string& name) {
00452   if(!valid_) return;
00453   WSRPDeleteResourceProperties prop(soap_.Child()["wsrf-rp:Delete"],false);
00454   if(prop) { prop.Property(name); return; };
00455   WSRPDeleteResourceProperties(soap_.Child()["wsrf-rp:Delete"],true).Property(name); 
00456 }
00457 
00458 WSRPDeleteResourcePropertiesResponse::WSRPDeleteResourcePropertiesResponse(SOAPEnvelope& soap):WSRP(soap,WSRPDeleteResourcePropertiesResponseAction) {
00459   if(!valid_) return;
00460   if(!MatchXMLName(soap_.Child(),"wsrf-rp:DeleteResourcePropertiesResponse")) valid_=false;
00461 }
00462 
00463 WSRPDeleteResourcePropertiesResponse::WSRPDeleteResourcePropertiesResponse(void):WSRP(false,WSRPDeleteResourcePropertiesResponseAction) {
00464   if(!soap_.NewChild("wsrf-rp:DeleteResourcePropertiesResponse")) valid_=false;
00465 }
00466 
00467 WSRPDeleteResourcePropertiesResponse::~WSRPDeleteResourcePropertiesResponse(void) {
00468 }
00469 
00470 
00471 // ==================== Faults ================================
00472 
00473 
00474 WSRPFault::WSRPFault(SOAPEnvelope& soap):WSRFBaseFault(soap) {
00475 }
00476 
00477 WSRPFault::WSRPFault(const std::string& type):WSRFBaseFault(type) {
00478 }
00479 
00480 WSRPFault::~WSRPFault(void) {
00481 }
00482 
00483 
00484 XMLNode WSRPResourcePropertyChangeFailure::CurrentProperties(bool create) {
00485   SOAPFault* fault = soap_.Fault();
00486   if(!fault) return XMLNode();
00487   XMLNode detail = fault->Detail(true);
00488   XMLNode failure = detail["wsrf-rp:ResourcePropertyChangeFailure"];
00489   if(!failure) {
00490     if(!create) return XMLNode();
00491     failure=detail.NewChild("wsrf-rp:ResourcePropertyChangeFailure");
00492   };
00493   XMLNode cur_value = failure["wsrf-rp:CurrentValue"];
00494   if(!cur_value) {
00495     if(!create) return XMLNode();
00496     cur_value=failure.NewChild("wsrf-rp:CurrentValue");
00497   };
00498   return cur_value;
00499 }
00500 
00501 XMLNode WSRPResourcePropertyChangeFailure::RequestedProperties(bool create) {
00502   SOAPFault* fault = soap_.Fault();
00503   if(!fault) return XMLNode();
00504   XMLNode detail = fault->Detail(true);
00505   XMLNode failure = detail["wsrf-rp:ResourcePropertyChangeFailure"];
00506   if(!failure) {
00507     if(!create) return XMLNode();
00508     failure=detail.NewChild("wsrf-rp:ResourcePropertyChangeFailure");
00509   };
00510   XMLNode req_value = failure["wsrf-rp:RequestedValue"];
00511   if(!req_value) {
00512     if(!create) return XMLNode();
00513     req_value=failure.NewChild("wsrf-rp:RequestedValue");
00514   };
00515   return req_value;
00516 }
00517 
00518 
00519 // ============= QueryResourceProperties ==============
00520 
00521 WSRPQueryResourcePropertiesRequest::WSRPQueryResourcePropertiesRequest(SOAPEnvelope& soap):WSRP(soap,WSRPQueryResourcePropertiesRequestAction) {
00522   if(!valid_) return;
00523   if(!MatchXMLName(soap_.Child(),"wsrf-rp:QueryResourceProperties")) valid_=false;
00524 }
00525 
00526 WSRPQueryResourcePropertiesRequest::WSRPQueryResourcePropertiesRequest(const std::string& dialect):WSRP(false,WSRPQueryResourcePropertiesRequestAction) {
00527   XMLNode req = soap_.NewChild("wsrf-rp:QueryResourceProperties");
00528   if(!req) valid_=false;
00529   Dialect(dialect);
00530 }
00531 
00532 WSRPQueryResourcePropertiesRequest::WSRPQueryResourcePropertiesRequest(void) {
00533   XMLNode req = soap_.NewChild("wsrf-rp:QueryResourceProperties");
00534   if(!req) valid_=false;
00535 }
00536 
00537 WSRPQueryResourcePropertiesRequest::~WSRPQueryResourcePropertiesRequest(void) {
00538 }
00539   
00540 std::string WSRPQueryResourcePropertiesRequest::Dialect(void) {
00541   if(!valid_) return "";
00542   return soap_.Child()["wsrf-rp:QueryExpression"].Attribute("Dialect");
00543 }
00544 
00545 
00546 void WSRPQueryResourcePropertiesRequest::Dialect(const std::string& dialect_uri) {
00547   if(!valid_) return;
00548   XMLNode query = soap_.Child()["wsrf-rp:QueryExpression"];
00549   if(!query) query=soap_.Child().NewChild("wsrf-rp:QueryExpression");
00550   XMLNode dialect = query.Attribute("Dialect");
00551   if(!dialect) dialect=query.NewAttribute("Dialect");
00552   dialect=dialect_uri;
00553 }
00554 
00555 XMLNode WSRPQueryResourcePropertiesRequest::Query(void) {
00556   XMLNode query = soap_.Child()["wsrf-rp:QueryExpression"];
00557   if(!query) {
00558     query=soap_.Child().NewChild("wsrf-rp:QueryExpression");
00559     query.NewAttribute("Dialect");
00560   };
00561   return query;
00562 }
00563 
00564 WSRPQueryResourcePropertiesResponse::WSRPQueryResourcePropertiesResponse(SOAPEnvelope& soap):WSRP(soap,WSRPQueryResourcePropertiesResponseAction) {
00565   if(!valid_) return;
00566   if(!MatchXMLName(soap_.Child(),"wsrf-rp:QueryResourcePropertiesResponse")) valid_=false;
00567 }
00568 
00569 WSRPQueryResourcePropertiesResponse::WSRPQueryResourcePropertiesResponse(void):WSRP(false,WSRPQueryResourcePropertiesResponseAction) {
00570   XMLNode req = soap_.NewChild("wsrf-rp:QueryResourcePropertiesResponse");
00571   if(!req) valid_=false;
00572 }
00573 
00574 WSRPQueryResourcePropertiesResponse::~WSRPQueryResourcePropertiesResponse(void) {
00575 }
00576 
00577 XMLNode WSRPQueryResourcePropertiesResponse::Properties(void) {
00578   if(!valid_) return XMLNode();
00579   return soap_.Child();
00580 }
00581 
00582 // =====================================================================
00583 
00584 WSRF& CreateWSRPFault(SOAPEnvelope& soap) {
00585   // Not the most efective way to extract type of message
00586   WSRPFault& v = *(new WSRPFault(soap));
00587   std::string type = v.Type();
00588   delete &v;
00589   if(v.Type() == "wsrf-rp:WSRPInvalidResourcePropertyQNameFault") return *(new WSRPInvalidResourcePropertyQNameFault(soap));
00590   if(v.Type() == "wsrf-rp:WSRPUnableToPutResourcePropertyDocumentFault") return *(new WSRPUnableToPutResourcePropertyDocumentFault(soap));
00591   if(v.Type() == "wsrf-rp:WSRPInvalidModificationFault") return *(new WSRPInvalidModificationFault(soap));
00592   if(v.Type() == "wsrf-rp:WSRPUnableToModifyResourcePropertyFault") return *(new WSRPUnableToModifyResourcePropertyFault(soap));
00593   if(v.Type() == "wsrf-rp:WSRPSetResourcePropertyRequestFailedFault") return *(new WSRPSetResourcePropertyRequestFailedFault(soap));
00594   if(v.Type() == "wsrf-rp:WSRPInsertResourcePropertiesRequestFailedFault") return *(new WSRPInsertResourcePropertiesRequestFailedFault(soap));
00595   if(v.Type() == "wsrf-rp:WSRPUpdateResourcePropertiesRequestFailedFault") return *(new WSRPUpdateResourcePropertiesRequestFailedFault(soap));
00596   if(v.Type() == "wsrf-rp:WSRPDeleteResourcePropertiesRequestFailedFault") return *(new WSRPDeleteResourcePropertiesRequestFailedFault(soap));
00597   return *(new WSRF());
00598 }
00599 
00600 WSRF& CreateWSRP(SOAPEnvelope& soap) {
00601   NS ns;
00602   ns["wsa"]="http://www.w3.org/2005/08/addressing";
00603   ns["wsrf-r"]="http://docs.oasis-open.org/wsrf/r-2";
00604   ns["wsrf-rw"]="http://docs.oasis-open.org/wsrf/rw-2";
00605   ns["wsrf-bf"]="http://docs.oasis-open.org/wsrf/bf-2";
00606   ns["wsrf-rp"]="http://docs.oasis-open.org/wsrf/rp-2";
00607   ns["wsrf-rpw"]="http://docs.oasis-open.org/wsrf/rpw-2";
00608   soap.Namespaces(ns);
00609 
00610   std::string action = WSAHeader(soap).Action();
00611 
00612   if(action == WSRFBaseFaultAction) {
00613     WSRF& fault = CreateWSRFBaseFault(soap);
00614     if(fault) return fault;
00615     return CreateWSRPFault(soap);
00616   };
00617   if(action == WSRPGetResourcePropertyDocumentRequestAction) return *(new WSRPGetResourcePropertyDocumentRequest(soap));
00618   if(action == WSRPGetResourcePropertyDocumentResponseAction) return *(new WSRPGetResourcePropertyDocumentResponse(soap));
00619   if(action == WSRPGetResourcePropertyRequestAction) return *(new WSRPGetResourcePropertyRequest(soap));
00620   if(action == WSRPGetResourcePropertyResponseAction) return *(new WSRPGetResourcePropertyResponse(soap));
00621   if(action == WSRPGetMultipleResourcePropertiesRequestAction) return *(new WSRPGetMultipleResourcePropertiesRequest(soap));
00622   if(action == WSRPGetMultipleResourcePropertiesResponseAction) return *(new WSRPGetMultipleResourcePropertiesResponse(soap));
00623   if(action == WSRPQueryResourcePropertiesRequestAction) return *(new WSRPQueryResourcePropertiesRequest(soap));
00624   if(action == WSRPQueryResourcePropertiesResponseAction) return *(new WSRPQueryResourcePropertiesResponse(soap));
00625   if(action == WSRPPutResourcePropertyDocumentRequestAction) return *(new WSRPPutResourcePropertyDocumentRequest(soap));
00626   if(action == WSRPPutResourcePropertyDocumentResponseAction) return *(new WSRPPutResourcePropertyDocumentResponse(soap));
00627   if(action == WSRPSetResourcePropertiesRequestAction) return *(new WSRPSetResourcePropertiesRequest(soap));
00628   if(action == WSRPSetResourcePropertiesResponseAction) return *(new WSRPSetResourcePropertiesResponse(soap));
00629   if(action == WSRPInsertResourcePropertiesRequestAction) return *(new WSRPInsertResourcePropertiesRequest(soap));
00630   if(action == WSRPInsertResourcePropertiesResponseAction) return *(new WSRPInsertResourcePropertiesResponse(soap));
00631   if(action == WSRPUpdateResourcePropertiesRequestAction) return *(new WSRPUpdateResourcePropertiesRequest(soap));
00632   if(action == WSRPUpdateResourcePropertiesResponseAction) return *(new WSRPUpdateResourcePropertiesResponse(soap));
00633   if(action == WSRPDeleteResourcePropertiesRequestAction) return *(new WSRPDeleteResourcePropertiesRequest(soap));
00634   if(action == WSRPDeleteResourcePropertiesResponseAction) return *(new WSRPDeleteResourcePropertiesResponse(soap));
00635   return *(new WSRP());
00636 }
00637 
00638 
00639 } // namespace Arc