00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00036 #include "OW_config.h"
00037 #include "OW_BinaryCIMOMHandle.hpp"
00038 #include "OW_Format.hpp"
00039 #include "OW_CIMNameSpace.hpp"
00040 #include "OW_CIMValue.hpp"
00041 #include "OW_CIMProperty.hpp"
00042 #include "OW_CIMParameter.hpp"
00043 #include "OW_CIMMethod.hpp"
00044 #include "OW_CIMUrl.hpp"
00045 #include "OW_CIMObjectPath.hpp"
00046 #include "OW_BinarySerialization.hpp"
00047 #include "OW_IOException.hpp"
00048 #include "OW_CIMParamValue.hpp"
00049 #include "OW_CIMInstanceEnumeration.hpp"
00050 #include "OW_CIMNameSpaceUtils.hpp"
00051 #include "OW_CIMException.hpp"
00052 #include "OW_HTTPClient.hpp"
00053 #include "OW_HTTPChunkedIStream.hpp"
00054
00055 #if defined(OW_HAVE_ISTREAM) && defined(OW_HAVE_OSTREAM)
00056 #include <istream>
00057 #include <ostream>
00058 #else
00059 #include <iostream>
00060 #endif
00061
00062 namespace OW_NAMESPACE
00063 {
00064
00065 using std::ostream;
00066 using std::iostream;
00067 using std::istream;
00068 using namespace WBEMFlags;
00069 namespace
00070 {
00071 void
00072 _getHTTPTrailers(const CIMProtocolIStreamIFCRef& istr_, Map<String,String>& trailers)
00073 {
00074 IntrusiveReference<HTTPChunkedIStream> istr =
00075 istr_.cast_to<HTTPChunkedIStream>();
00076 if (istr)
00077 {
00078 Map<String,String> itrailers = istr->getTrailers();
00079 Map<String,String>::iterator it = itrailers.begin();
00080 while (it != itrailers.end())
00081 {
00082 trailers[it->first] = it->second;
00083 it++;
00084 }
00085 }
00086 }
00087
00088 inline void
00089 checkError(std::istream& istrm)
00090 {
00091 UInt8 rc;
00092 BinarySerialization::read(istrm, rc);
00093 if (rc != BIN_OK)
00094 {
00095 switch (rc)
00096 {
00097 case BIN_ERROR:
00098 {
00099 String msg;
00100 BinarySerialization::read(istrm, msg);
00101 OW_THROW(IOException, msg.c_str());
00102 }
00103 case BIN_EXCEPTION:
00104 {
00105 UInt16 cimerrno;
00106 String cimMsg;
00107 BinarySerialization::read(istrm, cimerrno);
00108 BinarySerialization::read(istrm, cimMsg);
00109 OW_THROWCIMMSG(CIMException::ErrNoType(cimerrno), cimMsg.c_str());
00110 }
00111 default:
00112 OW_THROW(IOException,
00113 "Unexpected value received from server.");
00114 }
00115 }
00116 }
00117 inline void
00118 checkError(const CIMProtocolIStreamIFCRef& istr, Map<String,String>& trailers)
00119 {
00120 try
00121 {
00122 checkError(*istr);
00123 }
00124 catch (IOException& e)
00125 {
00126 while (*istr)
00127 {
00128 istr->get();
00129 }
00130 _getHTTPTrailers(istr, trailers);
00131 istr->checkForError();
00132 throw e;
00133 }
00134 }
00135 inline void
00136 readCIMObject(CIMProtocolIStreamIFCRef& istr, CIMClass& cc)
00137 {
00138 cc = BinarySerialization::readClass(*istr);
00139 }
00140 inline void
00141 readCIMObject(CIMProtocolIStreamIFCRef& istr, CIMClassResultHandlerIFC& result)
00142 {
00143 BinarySerialization::readClassEnum(*istr, result);
00144 }
00145 inline void
00146 readCIMObject(CIMProtocolIStreamIFCRef& istr, CIMInstance& ci)
00147 {
00148 ci = BinarySerialization::readInstance(*istr);
00149 }
00150 inline void
00151 readCIMObject(CIMProtocolIStreamIFCRef& istr, CIMObjectPath& cop)
00152 {
00153 cop = BinarySerialization::readObjectPath(*istr);
00154 }
00155 inline void
00156 readCIMObject(CIMProtocolIStreamIFCRef& istr, CIMObjectPathResultHandlerIFC& result)
00157 {
00158 BinarySerialization::readObjectPathEnum(*istr, result);
00159 }
00160 inline void
00161 readCIMObject(CIMProtocolIStreamIFCRef& istr, CIMInstanceResultHandlerIFC& result)
00162 {
00163 BinarySerialization::readInstanceEnum(*istr, result);
00164 }
00165 inline void
00166 readCIMObject(CIMProtocolIStreamIFCRef& istr, CIMQualifierType& arg)
00167 {
00168 arg = BinarySerialization::readQualType(*istr);
00169 }
00170 inline void
00171 readCIMObject(CIMProtocolIStreamIFCRef& istr, CIMQualifierTypeResultHandlerIFC& result)
00172 {
00173 BinarySerialization::readQualifierTypeEnum(*istr, result);
00174 }
00175 inline void
00176 readCIMObject(CIMProtocolIStreamIFCRef& istr, StringResultHandlerIFC& result)
00177 {
00178 BinarySerialization::readStringEnum(*istr, result);
00179 }
00180 template<class T>
00181 inline T
00182 readCIMObject(CIMProtocolIStreamIFCRef& istr, Map<String,String>& trailers)
00183 {
00184 T rval;
00185 try
00186 {
00187 checkError(istr, trailers);
00188 readCIMObject(istr, rval);
00189 }
00190 catch (IOException& e)
00191 {
00192 while (*istr)
00193 {
00194 istr->get();
00195 }
00196 _getHTTPTrailers(istr, trailers);
00197 istr->checkForError();
00198 throw e;
00199 }
00200 while (*istr)
00201 {
00202 istr->get();
00203 }
00204 _getHTTPTrailers(istr, trailers);
00205 istr->checkForError();
00206 return rval;
00207 }
00208
00209 template<class T>
00210 inline void
00211 readAndDeliver(CIMProtocolIStreamIFCRef& istr, T& result,
00212 Map<String,String>& trailers)
00213 {
00214 try
00215 {
00216 checkError(istr, trailers);
00217 readCIMObject(istr,result);
00218 }
00219 catch (IOException& e)
00220 {
00221 while (*istr)
00222 {
00223 istr->get();
00224 }
00225 _getHTTPTrailers(istr, trailers);
00226 istr->checkForError();
00227 throw e;
00228 }
00229 while (*istr)
00230 {
00231 istr->get();
00232 }
00233 _getHTTPTrailers(istr, trailers);
00234 istr->checkForError();
00235 }
00236
00237
00238
00239 const String PROTOCOL_VERSION_1_0("1.0");
00240 const String PROTOCOL_VERSION_1_1("1.1");
00241
00242 }
00244 BinaryCIMOMHandle::BinaryCIMOMHandle(const CIMProtocolIFCRef& prot)
00245 : ClientCIMOMHandle(), m_protocol(prot)
00246 {
00247 m_protocol->setContentType("application/x-owbinary");
00248 }
00249
00251 CIMProtocolIFCRef
00252 BinaryCIMOMHandle::getWBEMProtocolHandler() const
00253 {
00254 return m_protocol;
00255 }
00256
00258 void BinaryCIMOMHandle::close()
00259 {
00260 m_protocol->close();
00261 }
00262
00264 void
00265 BinaryCIMOMHandle::enumClassNames(
00266 const String& ns_,
00267 const String& className,
00268 StringResultHandlerIFC& result,
00269 EDeepFlag deep)
00270 {
00271 m_trailers.clear();
00272 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00273 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00274 "EnumerateClassNames", ns);
00275 std::iostream& strm = *strmRef;
00276 BinarySerialization::write(strm, BinaryProtocolVersion);
00277 BinarySerialization::write(strm, BIN_ENUMCLSNAMES);
00278 BinarySerialization::writeString(strm, ns);
00279 BinarySerialization::writeString(strm, className);
00280 BinarySerialization::writeBool(strm, deep);
00281 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00282 "EnumerateClassNames", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00283 readAndDeliver(in, result, m_trailers);
00284 }
00286 void
00287 BinaryCIMOMHandle::enumClass(const String& ns_,
00288 const String& className,
00289 CIMClassResultHandlerIFC& result,
00290 EDeepFlag deep,
00291 ELocalOnlyFlag localOnly, EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin)
00292 {
00293 m_trailers.clear();
00294 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00295 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00296 "EnumerateClasses", ns);
00297 std::iostream& strm = *strmRef;
00298 BinarySerialization::write(strm, BinaryProtocolVersion);
00299 BinarySerialization::write(strm, BIN_ENUMCLSS);
00300 BinarySerialization::writeString(strm, ns);
00301 BinarySerialization::writeString(strm, className);
00302 BinarySerialization::writeBool(strm, deep);
00303 BinarySerialization::writeBool(strm, localOnly);
00304 BinarySerialization::writeBool(strm, includeQualifiers);
00305 BinarySerialization::writeBool(strm, includeClassOrigin);
00306 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00307 "EnumerateClasses", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00308 readAndDeliver(in, result, m_trailers);
00309 }
00311 void
00312 BinaryCIMOMHandle::enumInstanceNames(
00313 const String& ns_,
00314 const String& className,
00315 CIMObjectPathResultHandlerIFC& result)
00316 {
00317 m_trailers.clear();
00318 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00319 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00320 "EnumerateInstanceNames", ns);
00321 std::iostream& strm = *strmRef;
00322 BinarySerialization::write(strm, BinaryProtocolVersion);
00323 BinarySerialization::write(strm, BIN_ENUMINSTNAMES);
00324 BinarySerialization::writeString(strm, ns);
00325 BinarySerialization::writeString(strm, className);
00326 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00327 "EnumerateInstanceNames", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00328 readAndDeliver(in, result, m_trailers);
00329 }
00331 void
00332 BinaryCIMOMHandle::enumInstances(
00333 const String& ns_,
00334 const String& className,
00335 CIMInstanceResultHandlerIFC& result, EDeepFlag deep,
00336 ELocalOnlyFlag localOnly, EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
00337 const StringArray* propertyList)
00338 {
00339 m_trailers.clear();
00340 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00341 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00342 "EnumerateInstances", ns);
00343 std::iostream& strm = *strmRef;
00344 BinarySerialization::write(strm, BinaryProtocolVersion);
00345 BinarySerialization::write(strm, BIN_ENUMINSTS);
00346 BinarySerialization::writeString(strm, ns);
00347 BinarySerialization::writeString(strm, className);
00348 BinarySerialization::writeBool(strm, deep);
00349 BinarySerialization::writeBool(strm, localOnly);
00350 BinarySerialization::writeBool(strm, includeQualifiers);
00351 BinarySerialization::writeBool(strm, includeClassOrigin);
00352 BinarySerialization::writeStringArray(strm, propertyList);
00353 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00354 "EnumerateInstances", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00355 readAndDeliver(in, result, m_trailers);
00356 }
00358 CIMClass
00359 BinaryCIMOMHandle::getClass(
00360 const String& ns_,
00361 const String& className,
00362 ELocalOnlyFlag localOnly,
00363 EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
00364 const StringArray* propertyList)
00365 {
00366 m_trailers.clear();
00367 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00368 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00369 "GetClass", ns);
00370 std::iostream& strm = *strmRef;
00371 BinarySerialization::write(strm, BinaryProtocolVersion);
00372 BinarySerialization::write(strm, BIN_GETCLS);
00373 BinarySerialization::writeString(strm, ns);
00374 BinarySerialization::writeString(strm, className);
00375 BinarySerialization::writeBool(strm, localOnly);
00376 BinarySerialization::writeBool(strm, includeQualifiers);
00377 BinarySerialization::writeBool(strm, includeClassOrigin);
00378 BinarySerialization::writeStringArray(strm, propertyList);
00379 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00380 "GetClass", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00381 return readCIMObject<CIMClass>(in, m_trailers);
00382 }
00384 CIMInstance
00385 BinaryCIMOMHandle::getInstance(
00386 const String& ns_,
00387 const CIMObjectPath& instanceName,
00388 ELocalOnlyFlag localOnly, EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
00389 const StringArray* propertyList)
00390 {
00391 m_trailers.clear();
00392 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00393 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00394 "GetInstance", ns);
00395 std::iostream& strm = *strmRef;
00396 BinarySerialization::write(strm, BinaryProtocolVersion);
00397 BinarySerialization::write(strm, BIN_GETINST);
00398 BinarySerialization::writeString(strm, ns);
00399 BinarySerialization::writeObjectPath(strm, instanceName);
00400 BinarySerialization::writeBool(strm, localOnly);
00401 BinarySerialization::writeBool(strm, includeQualifiers);
00402 BinarySerialization::writeBool(strm, includeClassOrigin);
00403 BinarySerialization::writeStringArray(strm, propertyList);
00404 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00405 "GetInstance", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00406 return readCIMObject<CIMInstance>(in, m_trailers);
00407 }
00409 CIMValue
00410 BinaryCIMOMHandle::invokeMethod(
00411 const String& ns_,
00412 const CIMObjectPath& path,
00413 const String& methodName,
00414 const CIMParamValueArray& inParams,
00415 CIMParamValueArray& outParams)
00416 {
00417 m_trailers.clear();
00418 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00419 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00420 methodName, ns);
00421 std::iostream& strm = *strmRef;
00422 BinarySerialization::write(strm, BinaryProtocolVersion);
00423 BinarySerialization::write(strm, BIN_INVMETH);
00424 BinarySerialization::writeString(strm, ns);
00425 BinarySerialization::writeObjectPath(strm, path);
00426 BinarySerialization::writeString(strm, methodName);
00427 BinarySerialization::write(strm, BINSIG_PARAMVALUEARRAY);
00428 BinarySerialization::writeArray(strm, inParams);
00429 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00430 methodName, ns + ":" + path.modelPath(), CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00431 checkError(in, m_trailers);
00432 CIMValue cv(CIMNULL);
00433 try
00434 {
00435 Bool isrv(BinarySerialization::readBool(*in));
00436 if (isrv)
00437 {
00438 cv = BinarySerialization::readValue(*in);
00439 }
00440 BinarySerialization::verifySignature(*in, BINSIG_PARAMVALUEARRAY);
00441 BinarySerialization::readArray(*in, outParams);
00442 }
00443 catch(IOException& e)
00444 {
00445 while (*in)
00446 {
00447 in->get();
00448 }
00449 _getHTTPTrailers(in, m_trailers);
00450 in->checkForError();
00451 throw e;
00452 }
00453 _getHTTPTrailers(in, m_trailers);
00454 return cv;
00455 }
00457 CIMQualifierType
00458 BinaryCIMOMHandle::getQualifierType(const String& ns_,
00459 const String& qualifierName)
00460 {
00461 m_trailers.clear();
00462 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00463 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00464 "GetQualifier", ns);
00465 std::iostream& strm = *strmRef;
00466 BinarySerialization::write(strm, BinaryProtocolVersion);
00467 BinarySerialization::write(strm, BIN_GETQUAL);
00468 BinarySerialization::writeString(strm, ns);
00469 BinarySerialization::writeString(strm, qualifierName);
00470
00471 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00472 "GetQualifier", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00473 return readCIMObject<CIMQualifierType>(in, m_trailers);
00474 }
00475 #ifndef OW_DISABLE_QUALIFIER_DECLARATION
00476
00477 void
00478 BinaryCIMOMHandle::setQualifierType(const String& ns_,
00479 const CIMQualifierType& qt)
00480 {
00481 m_trailers.clear();
00482 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00483 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00484 "SetQualifier", ns);
00485 std::iostream& strm = *strmRef;
00486 BinarySerialization::write(strm, BinaryProtocolVersion);
00487 BinarySerialization::write(strm, BIN_SETQUAL);
00488 BinarySerialization::writeString(strm, ns);
00489 BinarySerialization::writeQualType(strm, qt);
00490 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00491 "SetQualifier", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00492 checkError(in, m_trailers);
00493 _getHTTPTrailers(in, m_trailers);
00494 }
00496 void
00497 BinaryCIMOMHandle::enumQualifierTypes(
00498 const String& ns_,
00499 CIMQualifierTypeResultHandlerIFC& result)
00500 {
00501 m_trailers.clear();
00502 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00503 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00504 "EnumerateQualifiers", ns);
00505 std::iostream& strm = *strmRef;
00506 BinarySerialization::write(strm, BinaryProtocolVersion);
00507 BinarySerialization::write(strm, BIN_ENUMQUALS);
00508 BinarySerialization::writeString(strm, ns);
00509 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00510 "EnumerateQualifiers", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00511 readAndDeliver(in, result, m_trailers);
00512 }
00514 void
00515 BinaryCIMOMHandle::deleteQualifierType(const String& ns_, const String& qualName)
00516 {
00517 m_trailers.clear();
00518 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00519 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00520 "DeleteQualifier", ns);
00521 std::iostream& strm = *strmRef;
00522 BinarySerialization::write(strm, BinaryProtocolVersion);
00523 BinarySerialization::write(strm, BIN_DELETEQUAL);
00524 BinarySerialization::writeString(strm, ns);
00525 BinarySerialization::writeString(strm, qualName);
00526 checkError(m_protocol->endRequest(strmRef, "DeleteQualifier", ns,
00527 CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0), m_trailers);
00528 }
00529 #endif // #ifndef OW_DISABLE_QUALIFIER_DECLARATION
00530 #ifndef OW_DISABLE_SCHEMA_MANIPULATION
00531
00532 void
00533 BinaryCIMOMHandle::modifyClass(const String &ns_,
00534 const CIMClass& cc)
00535 {
00536 m_trailers.clear();
00537 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00538 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00539 "ModifyClass", ns);
00540 std::iostream& strm = *strmRef;
00541 BinarySerialization::write(strm, BinaryProtocolVersion);
00542 BinarySerialization::write(strm, BIN_MODIFYCLS);
00543 BinarySerialization::writeString(strm, ns);
00544 BinarySerialization::writeClass(strm, cc);
00545 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00546 "ModifyClass", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00547 checkError(in, m_trailers);
00548 _getHTTPTrailers(in, m_trailers);
00549 }
00551 void
00552 BinaryCIMOMHandle::createClass(const String& ns_,
00553 const CIMClass& cc)
00554 {
00555 m_trailers.clear();
00556 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00557 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00558 "CreateClass", ns);
00559 std::iostream& strm = *strmRef;
00560 BinarySerialization::write(strm, BinaryProtocolVersion);
00561 BinarySerialization::write(strm, BIN_CREATECLS);
00562 BinarySerialization::writeString(strm, ns);
00563 BinarySerialization::writeClass(strm, cc);
00564 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00565 "CreateClass", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00566 checkError(in, m_trailers);
00567 _getHTTPTrailers(in, m_trailers);
00568 }
00570 void
00571 BinaryCIMOMHandle::deleteClass(const String& ns_, const String& className)
00572 {
00573 m_trailers.clear();
00574 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00575 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00576 "DeleteClass", ns);
00577 std::iostream& strm = *strmRef;
00578 BinarySerialization::write(strm, BinaryProtocolVersion);
00579 BinarySerialization::write(strm, BIN_DELETECLS);
00580 BinarySerialization::writeString(strm, ns);
00581 BinarySerialization::writeString(strm, className);
00582 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00583 "DeleteClass", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00584 checkError(in, m_trailers);
00585 _getHTTPTrailers(in, m_trailers);
00586 }
00587 #endif // #ifndef OW_DISABLE_SCHEMA_MANIPULATION
00588 #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00589
00590 void
00591 BinaryCIMOMHandle::modifyInstance(
00592 const String& ns_,
00593 const CIMInstance& modifiedInstance,
00594 EIncludeQualifiersFlag includeQualifiers,
00595 const StringArray* propertyList)
00596 {
00597 m_trailers.clear();
00598 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00599 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00600 "ModifyInstance", ns);
00601 std::iostream& strm = *strmRef;
00602 BinarySerialization::write(strm, BinaryProtocolVersion);
00603 BinarySerialization::write(strm, BIN_MODIFYINST);
00604 BinarySerialization::writeString(strm, ns);
00605 BinarySerialization::writeInstance(strm, modifiedInstance);
00606 BinarySerialization::writeBool(strm, includeQualifiers);
00607 BinarySerialization::writeStringArray(strm, propertyList);
00608
00609 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00610 "ModifyInstance", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_1);
00611 checkError(in, m_trailers);
00612 _getHTTPTrailers(in, m_trailers);
00613 }
00615 CIMObjectPath
00616 BinaryCIMOMHandle::createInstance(const String& ns_,
00617 const CIMInstance& ci)
00618 {
00619 m_trailers.clear();
00620 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00621 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00622 "CreateInstance", ns);
00623 std::iostream& strm = *strmRef;
00624 BinarySerialization::write(strm, BinaryProtocolVersion);
00625 BinarySerialization::write(strm, BIN_CREATEINST);
00626 BinarySerialization::writeString(strm, ns);
00627 BinarySerialization::writeInstance(strm, ci);
00628
00629 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00630 "CreateInstance", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00631 CIMObjectPath rval = readCIMObject<CIMObjectPath>(in, m_trailers);
00632 rval.setNameSpace(ns);
00633 return rval;
00634 }
00636 void
00637 BinaryCIMOMHandle::deleteInstance(const String& ns_, const CIMObjectPath& inst)
00638 {
00639 m_trailers.clear();
00640 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00641 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00642 "DeleteInstance", ns);;
00643 std::iostream& strm = *strmRef;
00644 BinarySerialization::write(strm, BinaryProtocolVersion);
00645 BinarySerialization::write(strm, BIN_DELETEINST);
00646 BinarySerialization::writeString(strm, ns);
00647 BinarySerialization::writeObjectPath(strm, inst);
00648 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef, "DeleteInstance", ns,
00649 CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00650 checkError(in, m_trailers);
00651 _getHTTPTrailers(in, m_trailers);
00652 }
00653 #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00654
00655 void
00656 BinaryCIMOMHandle::setProperty(
00657 const String& ns_,
00658 const CIMObjectPath& path,
00659 const String& propName,
00660 const CIMValue& cv)
00661 {
00662 m_trailers.clear();
00663 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00664 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00665 "SetProperty", ns);
00666 std::iostream& strm = *strmRef;
00667 BinarySerialization::write(strm, BinaryProtocolVersion);
00668 BinarySerialization::write(strm, BIN_SETPROP);
00669 BinarySerialization::writeString(strm, ns);
00670 BinarySerialization::writeObjectPath(strm, path);
00671 BinarySerialization::writeString(strm, propName);
00672 Bool isValue = (cv) ? true : false;
00673 BinarySerialization::writeBool(strm, isValue);
00674 if (isValue)
00675 {
00676 BinarySerialization::writeValue(strm, cv);
00677 }
00678 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00679 "SetProperty", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00680 checkError(in, m_trailers);
00681 _getHTTPTrailers(in, m_trailers);
00682 }
00683 #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00684 #endif // #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00685 #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00686
00687 CIMValue
00688 BinaryCIMOMHandle::getProperty(
00689 const String& ns_,
00690 const CIMObjectPath& path,
00691 const String& propName)
00692 {
00693 m_trailers.clear();
00694 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00695 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00696 "GetProperty", ns);
00697 std::iostream& strm = *strmRef;
00698 BinarySerialization::write(strm, BinaryProtocolVersion);
00699 BinarySerialization::write(strm, BIN_GETPROP);
00700 BinarySerialization::writeString(strm, ns);
00701 BinarySerialization::writeObjectPath(strm, path);
00702 BinarySerialization::writeString(strm, propName);
00703 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00704 "GetProperty", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00705 checkError(in, m_trailers);
00706 CIMValue cv(CIMNULL);
00707 try
00708 {
00709 Bool isValue(BinarySerialization::readBool(*in));
00710 if (isValue)
00711 {
00712 cv = BinarySerialization::readValue(*in);
00713 }
00714 }
00715 catch (IOException& e)
00716 {
00717 while (*in)
00718 {
00719 in->get();
00720 }
00721 _getHTTPTrailers(in, m_trailers);
00722 in->checkForError();
00723 throw e;
00724 }
00725 _getHTTPTrailers(in, m_trailers);
00726 return cv;
00727 }
00728 #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00729 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00730
00731 void
00732 BinaryCIMOMHandle::associatorNames(
00733 const String& ns_,
00734 const CIMObjectPath& path,
00735 CIMObjectPathResultHandlerIFC& result,
00736 const String& assocClass, const String& resultClass,
00737 const String& role, const String& resultRole)
00738 {
00739 m_trailers.clear();
00740 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00741 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00742 "AssociatorNames", ns);
00743 std::iostream& strm = *strmRef;
00744 BinarySerialization::write(strm, BinaryProtocolVersion);
00745 BinarySerialization::write(strm, BIN_ASSOCNAMES);
00746 BinarySerialization::writeString(strm, ns);
00747 BinarySerialization::writeObjectPath(strm, path);
00748 BinarySerialization::writeString(strm, assocClass);
00749 BinarySerialization::writeString(strm, resultClass);
00750 BinarySerialization::writeString(strm, role);
00751 BinarySerialization::writeString(strm, resultRole);
00752 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00753 "AssociatorNames", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00754 readAndDeliver(in, result, m_trailers);
00755 }
00757 void
00758 BinaryCIMOMHandle::associators(
00759 const String& ns_,
00760 const CIMObjectPath& path,
00761 CIMInstanceResultHandlerIFC& result,
00762 const String& assocClass, const String& resultClass,
00763 const String& role, const String& resultRole,
00764 EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
00765 const StringArray* propertyList)
00766 {
00767 m_trailers.clear();
00768 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00769 if (!path.isInstancePath())
00770 {
00771 OW_THROWCIMMSG(CIMException::INVALID_PARAMETER,
00772 "associators requires an instance path not a class path");
00773 }
00774 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00775 "Associators", ns);
00776 std::iostream& strm = *strmRef;
00777 BinarySerialization::write(strm, BinaryProtocolVersion);
00778 BinarySerialization::write(strm, BIN_ASSOCIATORS);
00779 BinarySerialization::writeString(strm, ns);
00780 BinarySerialization::writeObjectPath(strm, path);
00781 BinarySerialization::writeString(strm, assocClass);
00782 BinarySerialization::writeString(strm, resultClass);
00783 BinarySerialization::writeString(strm, role);
00784 BinarySerialization::writeString(strm, resultRole);
00785 BinarySerialization::writeBool(strm, includeQualifiers);
00786 BinarySerialization::writeBool(strm, includeClassOrigin);
00787 BinarySerialization::writeStringArray(strm, propertyList);
00788 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00789 "Associators", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00790 readAndDeliver(in, result, m_trailers);
00791 }
00793 void
00794 BinaryCIMOMHandle::associatorsClasses(
00795 const String& ns_,
00796 const CIMObjectPath& path,
00797 CIMClassResultHandlerIFC& result,
00798 const String& assocClass, const String& resultClass,
00799 const String& role, const String& resultRole,
00800 EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
00801 const StringArray* propertyList)
00802 {
00803 m_trailers.clear();
00804 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00805 if (!path.isClassPath())
00806 {
00807 OW_THROWCIMMSG(CIMException::INVALID_PARAMETER,
00808 "associatorsClasses requires a class path not an instance path");
00809 }
00810 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00811 "Associators", ns);
00812 std::iostream& strm = *strmRef;
00813 BinarySerialization::write(strm, BinaryProtocolVersion);
00814 BinarySerialization::write(strm, BIN_ASSOCIATORS);
00815 BinarySerialization::writeString(strm, ns);
00816 BinarySerialization::writeObjectPath(strm, path);
00817 BinarySerialization::writeString(strm, assocClass);
00818 BinarySerialization::writeString(strm, resultClass);
00819 BinarySerialization::writeString(strm, role);
00820 BinarySerialization::writeString(strm, resultRole);
00821 BinarySerialization::writeBool(strm, includeQualifiers);
00822 BinarySerialization::writeBool(strm, includeClassOrigin);
00823 BinarySerialization::writeStringArray(strm, propertyList);
00824 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00825 "Associators", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00826 readAndDeliver(in, result, m_trailers);
00827 }
00829 void
00830 BinaryCIMOMHandle::referenceNames(
00831 const String& ns_,
00832 const CIMObjectPath& path,
00833 CIMObjectPathResultHandlerIFC& result,
00834 const String& resultClass,
00835 const String& role)
00836 {
00837 m_trailers.clear();
00838 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00839 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00840 "ReferenceNames", ns);
00841 std::iostream& strm = *strmRef;
00842 BinarySerialization::write(strm, BinaryProtocolVersion);
00843 BinarySerialization::write(strm, BIN_REFNAMES);
00844 BinarySerialization::writeString(strm, ns);
00845 BinarySerialization::writeObjectPath(strm, path);
00846 BinarySerialization::writeString(strm, resultClass);
00847 BinarySerialization::writeString(strm, role);
00848
00849 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00850 "ReferenceNames", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00851 readAndDeliver(in, result, m_trailers);
00852 }
00854 void
00855 BinaryCIMOMHandle::references(
00856 const String& ns_,
00857 const CIMObjectPath& path,
00858 CIMInstanceResultHandlerIFC& result,
00859 const String& resultClass, const String& role,
00860 EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
00861 const StringArray* propertyList)
00862 {
00863 m_trailers.clear();
00864 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00865 if (!path.isInstancePath())
00866 {
00867 OW_THROWCIMMSG(CIMException::INVALID_PARAMETER,
00868 "references requires an instance path not a class path");
00869 }
00870 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00871 "ReferenceNames", ns);
00872 std::iostream& strm = *strmRef;
00873 BinarySerialization::write(strm, BinaryProtocolVersion);
00874 BinarySerialization::write(strm, BIN_REFERENCES);
00875 BinarySerialization::writeString(strm, ns);
00876 BinarySerialization::writeObjectPath(strm, path);
00877 BinarySerialization::writeString(strm, resultClass);
00878 BinarySerialization::writeString(strm, role);
00879 BinarySerialization::writeBool(strm, includeQualifiers);
00880 BinarySerialization::writeBool(strm, includeClassOrigin);
00881 BinarySerialization::writeStringArray(strm, propertyList);
00882 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00883 "ReferenceNames", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00884 readAndDeliver(in, result, m_trailers);
00885 }
00887 void
00888 BinaryCIMOMHandle::referencesClasses(
00889 const String& ns_,
00890 const CIMObjectPath& path,
00891 CIMClassResultHandlerIFC& result,
00892 const String& resultClass, const String& role,
00893 EIncludeQualifiersFlag includeQualifiers, EIncludeClassOriginFlag includeClassOrigin,
00894 const StringArray* propertyList)
00895 {
00896 m_trailers.clear();
00897 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00898 if (!path.isClassPath())
00899 {
00900 OW_THROWCIMMSG(CIMException::INVALID_PARAMETER,
00901 "referencesClasses requires a class path not an instance path");
00902 }
00903 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00904 "ReferenceNames", ns);
00905 std::iostream& strm = *strmRef;
00906 BinarySerialization::write(strm, BinaryProtocolVersion);
00907 BinarySerialization::write(strm, BIN_REFERENCES);
00908 BinarySerialization::writeString(strm, ns);
00909 BinarySerialization::writeObjectPath(strm, path);
00910 BinarySerialization::writeString(strm, resultClass);
00911 BinarySerialization::writeString(strm, role);
00912 BinarySerialization::writeBool(strm, includeQualifiers);
00913 BinarySerialization::writeBool(strm, includeClassOrigin);
00914 BinarySerialization::writeStringArray(strm, propertyList);
00915 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00916 "ReferenceNames", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00917 readAndDeliver(in, result, m_trailers);
00918 }
00919 #endif // #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00920
00921 CIMInstanceEnumeration
00922 BinaryCIMOMHandle::execQuery(
00923 const String& ns,
00924 const String& query, int wqlLevel)
00925 {
00926 m_trailers.clear();
00927
00928
00929
00930 return CIMOMHandleIFC::execQueryE(ns, query,
00931 String("WQL") + String(wqlLevel));
00932 }
00934 void
00935 BinaryCIMOMHandle::execQuery(
00936 const String& ns_,
00937 CIMInstanceResultHandlerIFC& result,
00938 const String& query, const String& queryLanguage)
00939 {
00940 m_trailers.clear();
00941 String ns(CIMNameSpaceUtils::prepareNamespace(ns_));
00942 Reference<std::iostream> strmRef = m_protocol->beginRequest(
00943 "ExecQuery", ns);
00944 std::iostream& strm = *strmRef;
00945 BinarySerialization::write(strm, BinaryProtocolVersion);
00946 BinarySerialization::write(strm, BIN_EXECQUERY);
00947 BinarySerialization::writeString(strm, ns);
00948 BinarySerialization::writeString(strm, query);
00949 BinarySerialization::writeString(strm, queryLanguage);
00950 CIMProtocolIStreamIFCRef in = m_protocol->endRequest(strmRef,
00951 "ExecQuery", ns, CIMProtocolIFC::E_CIM_OPERATION_REQUEST, PROTOCOL_VERSION_1_0);
00952 readAndDeliver(in, result, m_trailers);
00953 }
00954
00956 bool
00957 BinaryCIMOMHandle::setHTTPRequestHeader(const String& hdrName,
00958 const String& hdrValue)
00959 {
00960 bool cc = false;
00961 IntrusiveReference<HTTPClient> httpClient =
00962 m_protocol.cast_to<HTTPClient>();
00963 if (httpClient)
00964 {
00965 httpClient->addCustomHeader(hdrName, hdrValue);
00966 cc = true;
00967 }
00968 return cc;
00969 }
00970
00972 bool
00973 BinaryCIMOMHandle::getHTTPResponseHeader(const String& hdrName,
00974 String& valueOut) const
00975 {
00976 bool cc = false;
00977 IntrusiveReference<HTTPClient> httpClient =
00978 m_protocol.cast_to<HTTPClient>();
00979 if (httpClient)
00980 {
00981 if (!(cc = httpClient->getResponseHeader(hdrName, valueOut)))
00982 {
00983 if (HTTPUtils::headerHasKey(m_trailers, hdrName))
00984 {
00985 cc = true;
00986 valueOut = HTTPUtils::getHeaderValue(m_trailers, hdrName);
00987 }
00988 }
00989 }
00990 return cc;
00991 }
00992
00994 CIMFeatures
00995 BinaryCIMOMHandle::getServerFeatures()
00996 {
00997 return m_protocol->getFeatures();
00998 }
01000
01001 }
01002