cmpiBroker.cpp

Go to the documentation of this file.
00001 /*
00002  *
00003  * cmpiBroker.cpp
00004  *
00005  * (C) Copyright IBM Corp. 2003
00006  *
00007  * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE
00008  * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
00009  * CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
00010  *
00011  * You can obtain a current copy of the Common Public License from
00012  * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html
00013  *
00014  * Author:        Adrian Schuur <schuur@de.ibm.com>
00015  *
00016  * Contributor:   Markus Mueller <sedgewick_de@yahoo.de>
00017  *
00018  * Description: CMPIBroker up-call support
00019  *
00020  */
00021 
00022 #include <iostream>
00023 #include "cmpisrv.h"
00024 #include "OW_Format.hpp"
00025 #include "OW_CIMException.hpp"
00026 #include "OW_CIMProperty.hpp"
00027 #include "OW_CIMObjectPath.hpp"
00028 #include "OW_ProviderEnvironmentIFC.hpp"
00029 #include "OW_ResultHandlers.hpp"
00030 #include "OW_String.hpp"
00031 #include "OW_Logger.hpp"
00032 #include "OW_CIMOMHandleIFC.hpp"
00033 
00034 using namespace OpenWBEM::WBEMFlags;
00035 using OpenWBEM::Format;
00036 //extern int traceAdapter;
00037 
00038 namespace
00039 {
00040    const OpenWBEM::String COMPONENT_NAME("ow.provider.cmpi.ifc");
00041 }
00042 
00043 #define CM_CIMOM() \
00044 (* static_cast<OpenWBEM::ProviderEnvironmentIFCRef *>(CMPI_ThreadContext::getBroker()->hdl))->getCIMOMHandle()
00045 #define CM_LOGGER() \
00046 (* static_cast<OpenWBEM::ProviderEnvironmentIFCRef *>(CMPI_ThreadContext::getBroker()->hdl))->getLogger(COMPONENT_NAME)
00047 #define CM_Context(ctx) (((CMPI_Context*)ctx)->ctx)
00048 #define CM_Instance(ci) ((OpenWBEM::CIMInstance*)ci->hdl)
00049 #define CM_ObjectPath(cop) ((OpenWBEM::CIMObjectPath*)cop->hdl)
00050 #define CM_LocalOnly(flgs) (((flgs) & CMPI_FLAG_LocalOnly)!=0)
00051 #define CM_ClassOrigin(flgs) \
00052 (((flgs) & CMPI_FLAG_IncludeClassOrigin)!=0)
00053 #define CM_IncludeQualifiers(flgs) \
00054 (((flgs) & CMPI_FLAG_IncludeQualifiers) !=0)
00055 #define CM_DeepInheritance(flgs) (((flgs) & CMPI_FLAG_DeepInheritance)!=0)
00056 
00057 
00058 #define DDD(X) X
00059 
00061 // Convert a an array of null terminated strings to an OpenWBEM::StringArray
00062 // It is assumed the 'l' parm is a pointer to a NULL terminated array of
00063 // C strings.
00064 //
00065 OpenWBEM::StringArray* getList(const char** l, OpenWBEM::StringArray& sra)
00066 {
00067    OpenWBEM::StringArray *pRa = NULL;
00068    sra.clear();
00069    if(l)
00070    {
00071       for(int i = 0; l[i]; i++)
00072       {
00073          sra.append(l[i]);
00074       }
00075 
00076       pRa = &sra;
00077    }
00078 
00079    return pRa;
00080 }
00081 
00082 
00083 OpenWBEM::CIMClass* mbGetClass(const CMPIBroker *, const OpenWBEM::CIMObjectPath &cop)
00084 {
00085 
00086    OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker: mbGetClass()");
00087 
00088    OpenWBEM::String clsId = cop.getNameSpace()+":"+cop.getClassName();
00089    OpenWBEM::CIMClass ccp;
00090 
00091    try
00092    {
00093       OpenWBEM::CIMClass cc=CM_CIMOM()->getClass(
00094          cop.getNameSpace(),
00095          cop.getClassName(),
00096          E_NOT_LOCAL_ONLY,
00097          E_INCLUDE_QUALIFIERS,
00098          E_EXCLUDE_CLASS_ORIGIN);
00099 
00100       return new OpenWBEM::CIMClass(cc);
00101    }
00102    catch(const OpenWBEM::CIMException &e)
00103    {
00104       OW_LOG_DEBUG(CM_LOGGER(), Format("CMPIBroker Exception in "
00105          "mbGetClass code: %1, msg %2",
00106          e.type(), e.getMessage()));
00107    }
00108    catch(...)
00109    {
00110       OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker Exception in mbGetClass");
00111    }
00112 
00113    return NULL;
00114 }
00115 
00116 static CMPIInstance* mbGetInstance(const CMPIBroker *, const CMPIContext *ctx,
00117    const CMPIObjectPath *cop, const char **properties, CMPIStatus *rc)
00118 {
00119    OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker: mbGetInstance()");
00120 
00121    CMPIFlags flgs =
00122       ctx->ft->getEntry(ctx,const_cast<char*>(CMPIInvocationFlags),NULL).value.uint32;
00123 
00124    OpenWBEM::StringArray props;
00125    const OpenWBEM::StringArray *pProps = getList(properties, props);
00126 
00127    OpenWBEM::CIMObjectPath qop(*CM_ObjectPath(cop));
00128 
00129    try
00130    {
00131       OpenWBEM::CIMInstance ci = CM_CIMOM()->getInstance(
00132          CM_ObjectPath(cop)->getNameSpace(),
00133          qop,
00134          CM_LocalOnly(flgs) ? E_LOCAL_ONLY : E_NOT_LOCAL_ONLY,
00135          CM_IncludeQualifiers(flgs) ? E_INCLUDE_QUALIFIERS : E_EXCLUDE_QUALIFIERS,
00136          CM_ClassOrigin(flgs) ? E_INCLUDE_CLASS_ORIGIN : E_EXCLUDE_CLASS_ORIGIN,
00137          pProps
00138          );
00139 
00140       CMSetStatus(rc,CMPI_RC_OK);
00141 
00142       return (CMPIInstance*) new CMPI_Object(new OpenWBEM::CIMInstance(ci));
00143    }
00144    catch(const OpenWBEM::CIMException &e)
00145    {
00146       OW_LOG_DEBUG(CM_LOGGER(), Format("CMPIBroker Exception in "
00147          "mbGetInstance code: %1, msg %2",
00148          e.type(), e.getMessage()));
00149 
00150       CMSetStatus(rc,(CMPIrc)e.getErrNo());
00151    }
00152    catch(...)
00153    {
00154       OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker Exception in mbGetInstance");
00155       CMSetStatus(rc,CMPI_RC_ERROR_SYSTEM);
00156    }
00157 
00158    return NULL;
00159 }
00160 
00161 static CMPIObjectPath* mbCreateInstance(const CMPIBroker *, const CMPIContext *ctx,
00162    const CMPIObjectPath *cop, const CMPIInstance *ci, CMPIStatus *rc)
00163 {
00164    (void) ctx;
00165 
00166    CMSetStatus(rc,CMPI_RC_ERR_NOT_SUPPORTED);
00167    OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker: mbCreateInstance()");
00168 
00169 #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00170    try
00171    {
00172       OpenWBEM::CIMObjectPath ncop=CM_CIMOM()->createInstance(
00173          CM_ObjectPath(cop)->getNameSpace(),
00174          *CM_Instance(ci));
00175 
00176       CMSetStatus(rc,CMPI_RC_OK);
00177 
00178       return (CMPIObjectPath*)
00179          new CMPI_Object(new OpenWBEM::CIMObjectPath(ncop));
00180    }
00181    catch(const OpenWBEM::CIMException &e)
00182    {
00183       OW_LOG_DEBUG(CM_LOGGER(), Format("CMPIBroker Exception in "
00184          "mCreateInstance code: %1, msg %2",
00185          e.type(), e.getMessage()));
00186 
00187       CMSetStatus(rc,(CMPIrc)e.getErrNo());
00188    }
00189    catch(...)
00190    {
00191       OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker Exception in mbCreateInstance");
00192 
00193       CMSetStatus(rc,CMPI_RC_ERROR_SYSTEM);
00194    }
00195 
00196 #endif
00197 
00198    return NULL;
00199 }
00200 
00201 static CMPIStatus mbModifyInstance(const CMPIBroker *, const CMPIContext *ctx,
00202    const CMPIObjectPath *cop, const CMPIInstance *ci, const char**)
00203 {
00204    // TODO handle propertylist
00205    OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker: mbSetInstance()");
00206 
00207 #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00208    CMPIFlags flgs =
00209       ctx->ft->getEntry(ctx,const_cast<char*>(CMPIInvocationFlags),NULL).value.uint32;
00210    OpenWBEM::StringArray sProps;
00211    try
00212    {
00213 
00214       CM_CIMOM()->modifyInstance(
00215          CM_ObjectPath(cop)->getNameSpace(),
00216          *CM_Instance(ci),
00217          CM_IncludeQualifiers(flgs) ? E_INCLUDE_QUALIFIERS : E_EXCLUDE_QUALIFIERS,
00218          &sProps);
00219       CMReturn(CMPI_RC_OK);
00220    }
00221    catch(OpenWBEM::CIMException &e)
00222    {
00223       OW_LOG_DEBUG(CM_LOGGER(), Format("CMPIBroker Exception in "
00224          "mbSetInstance code: %1, msg %2",
00225          e.type(), e.getMessage()));
00226       CMReturn((CMPIrc)e.getErrNo());
00227    }
00228    catch(...)
00229    {
00230       OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker Exception in mbSetInstance");
00231       CMReturn(CMPI_RC_ERROR_SYSTEM);
00232    }
00233 #endif
00234 
00235    CMReturn(CMPI_RC_ERR_FAILED);
00236 }
00237 
00238 static CMPIStatus mbDeleteInstance (const CMPIBroker *, const CMPIContext *ctx,
00239    const CMPIObjectPath *cop)
00240 {
00241    (void) ctx;
00242 
00243    OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker: mbDeleteInstance()");
00244 
00245 #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00246 
00247    OpenWBEM::CIMObjectPath qop(*CM_ObjectPath(cop));
00248 
00249    try
00250    {
00251       CM_CIMOM()->deleteInstance(
00252          CM_ObjectPath(cop)->getNameSpace(),
00253          qop);
00254 
00255       CMReturn(CMPI_RC_OK);
00256    }
00257    catch(OpenWBEM::CIMException &e)
00258    {
00259       OW_LOG_DEBUG(CM_LOGGER(), Format("CMPIBroker Exception in "
00260          "mbDeleteInstance code: %1, msg %2",
00261          e.type(), e.getMessage()));
00262       CMReturn((CMPIrc)e.getErrNo());
00263    }
00264    catch(...)
00265    {
00266       OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker Exception in mbDeleteInstance");
00267       CMReturn(CMPI_RC_ERROR_SYSTEM);
00268    }
00269 
00270 #endif
00271 
00272    CMReturn(CMPI_RC_ERROR);
00273 }
00274 
00275 static CMPIEnumeration* mbExecQuery(const CMPIBroker *, const CMPIContext *ctx,
00276    const CMPIObjectPath *cop, const char *query, const char *lang, CMPIStatus *rc)
00277 {
00278    (void) ctx;
00279    OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker: mbExecQuery()");
00280 
00281    try
00282    {
00283       OpenWBEM::CIMInstanceArray cia;
00284       OpenWBEM::CIMInstanceArrayBuilder result(cia);
00285 
00286       CM_CIMOM()->execQuery(
00287          CM_ObjectPath(cop)->getNameSpace(),
00288          result,
00289          OpenWBEM::String(query),
00290          OpenWBEM::String(lang));
00291 
00292       CMSetStatus(rc,CMPI_RC_OK);
00293 
00294       return new CMPI_ObjEnumeration(
00295          new OpenWBEM::Array<OpenWBEM::CIMInstance>(cia));
00296    }
00297    catch(OpenWBEM::CIMException &e)
00298    {
00299       OW_LOG_DEBUG(CM_LOGGER(), Format("CMPIBroker Exception in "
00300          "mbExecQuery code: %1, msg %2",
00301          e.type(), e.getMessage()));
00302 
00303       CMSetStatus(rc,(CMPIrc)e.getErrNo());
00304    }
00305    catch(...)
00306    {
00307       OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker Exception in mbExecQuery");
00308 
00309       CMSetStatus(rc,CMPI_RC_ERROR_SYSTEM);
00310    }
00311    return NULL;
00312 }
00313 
00314 static CMPIEnumeration* mbEnumInstances(const CMPIBroker *, const CMPIContext *ctx,
00315    const CMPIObjectPath *cop, const char **properties, CMPIStatus *rc)
00316 {
00317    OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker: mbEnumInstances()");
00318    CMPIFlags flgs = ctx->ft->getEntry(
00319       ctx,const_cast<char*>(CMPIInvocationFlags),NULL).value.uint32;
00320 
00321    OpenWBEM::StringArray props;
00322    OpenWBEM::StringArray *pProps = getList(properties, props);
00323 
00324    OpenWBEM::CIMInstanceArray cia;
00325    OpenWBEM::CIMInstanceArrayBuilder result(cia);
00326 
00327    try
00328    {
00329       CM_CIMOM()->enumInstances(
00330          CM_ObjectPath(cop)->getNameSpace(),
00331          CM_ObjectPath(cop)->getClassName(),
00332          result,
00333          CM_DeepInheritance(flgs) ? E_DEEP : E_SHALLOW,
00334          CM_LocalOnly(flgs) ? E_LOCAL_ONLY : E_NOT_LOCAL_ONLY,
00335          CM_IncludeQualifiers(flgs) ? E_INCLUDE_QUALIFIERS : E_EXCLUDE_QUALIFIERS,
00336          CM_ClassOrigin(flgs) ? E_INCLUDE_CLASS_ORIGIN : E_EXCLUDE_CLASS_ORIGIN,
00337          pProps
00338          );
00339       CMSetStatus(rc,CMPI_RC_OK);
00340       return new CMPI_InstEnumeration( new OpenWBEM::CIMInstanceArray(cia));
00341    }
00342    catch(OpenWBEM::CIMException &e)
00343    {
00344       OW_LOG_DEBUG(CM_LOGGER(), Format("CMPIBroker Exception in "
00345          "mbEnumInstances code: %1, msg %2",
00346          e.type(), e.getMessage()));
00347 
00348       CMSetStatus(rc,(CMPIrc)e.getErrNo());
00349       rc = NULL;  // Ensure rc doesn't get changed later
00350    }
00351    catch(...)
00352    {
00353       OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker Exception in mbEnumInstances");
00354       CMSetStatus(rc, CMPI_RC_ERROR_SYSTEM);
00355       rc = NULL;  // Ensure rc doesn't get changed later
00356    }
00357 
00358    CMSetStatus(rc, CMPI_RC_ERR_FAILED);
00359    return NULL;
00360 }
00361 
00362 static CMPIEnumeration* mbEnumInstanceNames(const CMPIBroker *, const CMPIContext *ctx,
00363    const CMPIObjectPath *cop, CMPIStatus *rc)
00364 {
00365    (void) ctx;
00366 
00367    OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker: mbEnumInstanceNames()");
00368 
00369    OpenWBEM::CIMObjectPathArray cia;
00370    OpenWBEM::CIMObjectPathArrayBuilder result(cia);
00371 
00372    try
00373    {
00374       CM_CIMOM()->enumInstanceNames(
00375          CM_ObjectPath(cop)->getNameSpace(),
00376          CM_ObjectPath(cop)->getClassName(),
00377          result);
00378 
00379       CMSetStatus(rc,CMPI_RC_OK);
00380       return new CMPI_OpEnumeration( new OpenWBEM::CIMObjectPathArray(cia));
00381    }
00382    catch(OpenWBEM::CIMException &e)
00383    {
00384       OW_LOG_DEBUG(CM_LOGGER(), Format("CMPIBroker Exception in "
00385          "mbEnumInstanceNames code: %1, msg %2",
00386          e.type(), e.getMessage()));
00387       CMSetStatus(rc,(CMPIrc)e.getErrNo());
00388       rc = NULL;  // Ensure rc doesn't get changed later
00389    }
00390    catch(...)
00391    {
00392       OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker Exception in mbEnumInstanceNames");
00393       CMSetStatus(rc,CMPI_RC_ERROR_SYSTEM);
00394       rc = NULL;  // Ensure rc doesn't get changed later
00395    }
00396 
00397    CMSetStatus(rc,CMPI_RC_ERR_FAILED);
00398    return NULL;
00399 }
00400 
00401 static CMPIEnumeration* mbAssociators(const CMPIBroker *, const CMPIContext *ctx,
00402    const CMPIObjectPath *cop, const char *assocClass, const char *resultClass,
00403    const char *role, const char *resultRole, const char **properties, CMPIStatus *rc)
00404 {
00405    OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker: mbAssociators()");
00406 
00407 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00408 
00409    CMPIFlags flgs = ctx->ft->getEntry(
00410       ctx,const_cast<char*>(CMPIInvocationFlags),NULL).value.uint32;
00411 
00412    OpenWBEM::StringArray props;
00413    OpenWBEM::StringArray *pProps = getList(properties, props);
00414 
00415    OpenWBEM::CIMInstanceArray cia;
00416    OpenWBEM::CIMInstanceArrayBuilder result(cia);
00417 
00418    try
00419    {
00420       CM_CIMOM()->associators(
00421          CM_ObjectPath(cop)->getNameSpace(),
00422          *CM_ObjectPath(cop),
00423          result,
00424          OpenWBEM::String(assocClass),
00425          OpenWBEM::String(resultClass),
00426          OpenWBEM::String(role),
00427          OpenWBEM::String(resultRole),
00428          CM_IncludeQualifiers(flgs) ? E_INCLUDE_QUALIFIERS : E_EXCLUDE_QUALIFIERS,
00429          CM_ClassOrigin(flgs) ? E_INCLUDE_CLASS_ORIGIN : E_EXCLUDE_CLASS_ORIGIN,
00430          pProps);
00431 
00432       CMSetStatus(rc,CMPI_RC_OK);
00433       return new CMPI_ObjEnumeration( new OpenWBEM::CIMInstanceArray(cia));
00434    }
00435    catch(OpenWBEM::CIMException &e)
00436    {
00437       OW_LOG_DEBUG(CM_LOGGER(), Format("CMPIBroker Exception in "
00438          "mbAssociators code: %1, msg %2",
00439          e.type(), e.getMessage()));
00440 
00441       CMSetStatus(rc,(CMPIrc)e.getErrNo());
00442       rc = NULL;  // Ensure rc doesn't get changed later
00443    }
00444    catch(...)
00445    {
00446       OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker Exception in mbAssociators");
00447       CMSetStatus(rc,CMPI_RC_ERROR_SYSTEM);
00448       rc = NULL;  // Ensure rc doesn't get changed later
00449    }
00450 
00451 #endif
00452 
00453    CMSetStatus(rc, CMPI_RC_ERR_FAILED);
00454    return NULL;
00455 }
00456 
00457 static CMPIEnumeration* mbAssociatorNames(const CMPIBroker *, const CMPIContext *ctx,
00458    const CMPIObjectPath *cop, const char *assocClass, const char *resultClass,
00459    const char *role, const char *resultRole, CMPIStatus *rc)
00460 {
00461    (void) ctx;
00462    OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker: mbAssociatorNames()");
00463 
00464 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00465 
00466    OpenWBEM::CIMObjectPathArray cia;
00467    OpenWBEM::CIMObjectPathArrayBuilder result(cia);
00468 
00469    try
00470    {
00471       CM_CIMOM()->associatorNames(
00472          CM_ObjectPath(cop)->getNameSpace(),
00473          *CM_ObjectPath(cop),
00474          result,
00475          OpenWBEM::String(assocClass),
00476          OpenWBEM::String(resultClass),
00477          OpenWBEM::String(role),
00478          OpenWBEM::String(resultRole));
00479 
00480       CMSetStatus(rc,CMPI_RC_OK);
00481       return new CMPI_OpEnumeration(new OpenWBEM::CIMObjectPathArray(cia));
00482    }
00483    catch(OpenWBEM::CIMException &e)
00484    {
00485       OW_LOG_DEBUG(CM_LOGGER(), Format("CMPIBroker Exception in "
00486          "mbAssociatorNames code: %1, msg %2",
00487          e.type(), e.getMessage()));
00488 
00489       CMSetStatus(rc,(CMPIrc)e.getErrNo());
00490       rc = NULL;  // Ensure rc doesn't get changed later
00491    }
00492    catch(...)
00493    {
00494       OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker Exception in mbAssociatorNames");
00495 
00496       CMSetStatus(rc,CMPI_RC_ERROR_SYSTEM);
00497       rc = NULL;  // Ensure rc doesn't get changed later
00498    }
00499 
00500 #endif
00501 
00502    CMSetStatus(rc,CMPI_RC_ERR_FAILED);
00503    return NULL;
00504 }
00505 
00506 static CMPIEnumeration* mbReferences(const CMPIBroker *, const CMPIContext *ctx,
00507    const CMPIObjectPath *cop,  const char *resultClass, const char *role ,
00508    const char **properties, CMPIStatus *rc)
00509 {
00510    OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker: mbReferences()");
00511 
00512 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00513 
00514    CMPIFlags flgs = ctx->ft->getEntry(
00515       ctx,const_cast<char*>(CMPIInvocationFlags),NULL).value.uint32;
00516 
00517    OpenWBEM::StringArray props;
00518    OpenWBEM::StringArray *pProps = getList(properties, props);
00519 
00520    OpenWBEM::CIMInstanceArray cia;
00521    OpenWBEM::CIMInstanceArrayBuilder result(cia);
00522 
00523    try
00524    {
00525       CM_CIMOM()->references(
00526          CM_ObjectPath(cop)->getNameSpace(),
00527          *CM_ObjectPath(cop),
00528          result,
00529          OpenWBEM::String(resultClass),
00530          OpenWBEM::String(role),
00531          CM_IncludeQualifiers(flgs) ? E_INCLUDE_QUALIFIERS : E_EXCLUDE_QUALIFIERS,
00532          CM_ClassOrigin(flgs) ? E_INCLUDE_CLASS_ORIGIN : E_EXCLUDE_CLASS_ORIGIN,
00533          pProps);
00534 
00535       CMSetStatus(rc,CMPI_RC_OK);
00536       return new CMPI_ObjEnumeration(new OpenWBEM::CIMInstanceArray(cia));
00537    }
00538    catch(OpenWBEM::CIMException &e)
00539    {
00540       OW_LOG_DEBUG(CM_LOGGER(), Format("CMPIBroker Exception in "
00541          "mbReferences code: %1, msg %2",
00542          e.type(), e.getMessage()));
00543 
00544       CMSetStatus(rc,(CMPIrc)e.getErrNo());
00545       rc = NULL;  // Ensure rc doesn't get changed later
00546    }
00547    catch(...)
00548    {
00549       OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker Exception in mbReferences");
00550       CMSetStatus(rc,CMPI_RC_ERROR_SYSTEM);
00551       rc = NULL;  // Ensure rc doesn't get changed later
00552    }
00553 
00554 
00555 #endif
00556 
00557    CMSetStatus(rc,CMPI_RC_ERR_FAILED);
00558    return NULL;
00559 }
00560 
00561 static CMPIEnumeration* mbReferenceNames(const CMPIBroker *, const CMPIContext *ctx,
00562    const CMPIObjectPath *cop, const char *resultClass, const char *role,
00563    CMPIStatus *rc)
00564 {
00565    (void) ctx;
00566 
00567    OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker: mbReferenceNames()");
00568 
00569 #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
00570    OpenWBEM::CIMObjectPathArray cia;
00571    OpenWBEM::CIMObjectPathArrayBuilder result(cia);
00572 
00573    try
00574    {
00575       CM_CIMOM()->referenceNames(
00576          CM_ObjectPath(cop)->getNameSpace(),
00577          *CM_ObjectPath(cop),
00578          result,
00579          OpenWBEM::String(resultClass),
00580          OpenWBEM::String(role));
00581 
00582       CMSetStatus(rc,CMPI_RC_OK);
00583       return new CMPI_OpEnumeration(new OpenWBEM::CIMObjectPathArray(cia));
00584    }
00585    catch(OpenWBEM::CIMException &e)
00586    {
00587       OW_LOG_DEBUG(CM_LOGGER(), Format("CMPIBroker Exception in "
00588          "mbReferenceNames code: %1, msg %2",
00589          e.type(), e.getMessage()));
00590 
00591       CMSetStatus(rc,(CMPIrc)e.getErrNo());
00592       rc = NULL;  // Ensure rc doesn't get changed later
00593    }
00594    catch(...)
00595    {
00596       OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker Exception in mbReferenceNames");
00597       CMSetStatus(rc,CMPI_RC_ERROR_SYSTEM);
00598       rc = NULL;  // Ensure rc doesn't get changed later
00599    }
00600 
00601 #endif
00602 
00603    CMSetStatus(rc,CMPI_RC_ERR_FAILED);
00604    return NULL;
00605 }
00606 
00607 static CMPIData mbInvokeMethod(const CMPIBroker *, const CMPIContext *ctx,
00608    const CMPIObjectPath *cop, const char *method, const CMPIArgs *in, CMPIArgs *out,
00609    CMPIStatus *rc)
00610 {
00611    (void) ctx;
00612    (void) cop;
00613    (void) method;
00614    (void) in;
00615    (void) out;
00616 
00617    OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker: mbInvokeMethod()");
00618    CMPIData data={(CMPIType) 0, CMPI_nullValue, {0} };
00619    CMSetStatus(rc,CMPI_RC_ERR_NOT_SUPPORTED);
00620    return data;
00621 }
00622 
00623 static CMPIStatus mbSetProperty(const CMPIBroker *, const CMPIContext *ctx,
00624    const CMPIObjectPath *cop, const char *name, const CMPIValue *val,
00625    CMPIType type)
00626 {
00627    (void) ctx;
00628 
00629    OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker: mbSetProperty()");
00630 
00631 #ifndef OW_DISABLE_INSTANCE_MANIPULATION
00632 #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00633 
00634    CMPIrc rc;
00635    OpenWBEM::CIMValue v=value2CIMValue(val,type,&rc);
00636 
00637    try
00638    {
00639       CM_CIMOM()->setProperty(
00640          CM_ObjectPath(cop)->getNameSpace(),
00641          *CM_ObjectPath(cop),
00642          OpenWBEM::String(name),
00643          v);
00644 
00645       CMReturn(CMPI_RC_OK);
00646    }
00647    catch(OpenWBEM::CIMException &e)
00648    {
00649       OW_LOG_DEBUG(CM_LOGGER(), Format("CMPIBroker Exception in "
00650          "mbSetProperty code: %1, msg %2",
00651          e.type(), e.getMessage()));
00652       CMReturn((CMPIrc)e.getErrNo());
00653    }
00654    catch(...)
00655    {
00656       OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker Exception in mbSetProperty");
00657       CMReturn(CMPI_RC_ERROR_SYSTEM);
00658    }
00659 #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00660 #endif
00661    CMReturn(CMPI_RC_ERR_FAILED);
00662 }
00663 
00664 static CMPIData mbGetProperty(const CMPIBroker *, const CMPIContext *ctx,
00665    const CMPIObjectPath *cop,const char *name, CMPIStatus *rc)
00666 {
00667    (void) ctx;
00668 
00669    OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker: mbGetProperty()");
00670 
00671    CMPIData data={(CMPIType) 0, CMPI_nullValue, {0} };
00672 #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00673    try
00674    {
00675       OpenWBEM::CIMValue v = CM_CIMOM()->getProperty(
00676          CM_ObjectPath(cop)->getNameSpace(),
00677          *CM_ObjectPath(cop),
00678          OpenWBEM::String(name));
00679 
00680       OpenWBEM::CIMDataType vType=v.getType();
00681       CMPIType t=type2CMPIType(vType,v.isArray());
00682       value2CMPIData(v,t,&data);
00683       CMSetStatus(rc,CMPI_RC_OK);
00684       return data;
00685    }
00686    catch(OpenWBEM::CIMException &e)
00687    {
00688       OW_LOG_DEBUG(CM_LOGGER(), Format("CMPIBroker Exception in "
00689          "mbGetProperty code: %1, msg %2",
00690          e.type(), e.getMessage()));
00691       CMSetStatus(rc,(CMPIrc)e.getErrNo());
00692    }
00693    catch(...)
00694    {
00695       OW_LOG_DEBUG(CM_LOGGER(), "CMPIBroker Exception in mbGetProperty");
00696       CMSetStatus(rc,CMPI_RC_ERROR_SYSTEM);
00697    }
00698 #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS)
00699    return data;
00700 }
00701 
00702 
00703 
00704 
00705 
00706 static CMPIBrokerFT broker_FT={
00707    0, // brokerClassification;
00708    CMPICurrentVersion,
00709    const_cast<char*>("OpenWBEM"),
00710    NULL,
00711    NULL,
00712    NULL,
00713    NULL,
00714    mbEnumInstanceNames,
00715    mbGetInstance,
00716    mbCreateInstance,
00717    mbModifyInstance,
00718    mbDeleteInstance,
00719    mbExecQuery,
00720    mbEnumInstances,
00721    mbAssociators,
00722    mbAssociatorNames,
00723    mbReferences,
00724    mbReferenceNames,
00725    mbInvokeMethod,
00726    mbSetProperty,
00727    mbGetProperty,
00728 };
00729 
00730 CMPIBrokerFT *CMPI_Broker_Ftab=& broker_FT;
00731 
00732 //CMPIBroker *CMPI_Broker::staticBroker=NULL;

Generated on Thu Feb 9 08:47:48 2006 for openwbem by  doxygen 1.4.6