//%2004//////////////////////////////////////////////////////////////////////// // // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; // IBM Corp.; EMC Corporation, The Open Group. // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // //============================================================================== // // Author: Adrian Schuur, schuur@de.ibm.com // // Modified By: // //%///////////////////////////////////////////////////////////////////////////// #include "CMPI_Version.h" #include "CMPI_Broker.h" #include "CMPI_Object.h" #include "CMPI_ContextArgs.h" #include "CMPI_Enumeration.h" #include "CMPI_Value.h" #include "CMPIProviderManager.h" #include "CMPI_String.h" #include #include #include #include #include PEGASUS_USING_STD; PEGASUS_NAMESPACE_BEGIN #define DDD(X) if (_cmpi_trace) X; extern int _cmpi_trace; static CIMPropertyList getList(char** l) { CIMPropertyList pl; if (l) { Array n; while (*l) { n.append(*l++); } pl.set(n); } return pl; } CIMClass* mbGetClass(CMPIBroker *mb, const CIMObjectPath &cop) { DDD(cout<<"--- mbGetClass()"<mtx); if (xBroker->clsCache) { if (xBroker->clsCache->lookup(clsId,ccp)) return ccp; } else xBroker->clsCache=new ClassCache(); try { CIMClass cc=CM_CIMOM(mb)->getClass( OperationContext(), cop.getNameSpace(), cop.getClassName(), (bool)0, (bool)1, (bool)0, CIMPropertyList()); ccp=new CIMClass(cc); xBroker->clsCache->insert(clsId,ccp); return ccp; } catch (CIMException &e) { DDD(cout<<"### exception: mbGetClass - code: "<ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32; CIMPropertyList props=getList(properties); CIMObjectPath qop(String::EMPTY,CIMNamespaceName(), CM_ObjectPath(cop)->getClassName(), CM_ObjectPath(cop)->getKeyBindings()); AutoMutex mtx(((CMPI_Broker*)mb)->mtx); try { CIMInstance ci=CM_CIMOM(mb)->getInstance( OperationContext(*CM_Context(ctx)), CM_ObjectPath(cop)->getNameSpace(), qop, //*CM_ObjectPath(cop), CM_LocalOnly(flgs), CM_IncludeQualifiers(flgs), CM_ClassOrigin(flgs), props); if (rc) CMSetStatus(rc,CMPI_RC_OK); return (CMPIInstance*)new CMPI_Object(new CIMInstance(ci)); } catch (CIMException &e) { DDD(cout<<"### exception: mbGetInstance - code: "<mtx); try { CIMObjectPath ncop=CM_CIMOM(mb)->createInstance( OperationContext(*CM_Context(ctx)), CM_ObjectPath(cop)->getNameSpace(), *CM_Instance(ci)); if (rc) CMSetStatus(rc,CMPI_RC_OK); return (CMPIObjectPath*)new CMPI_Object(new CIMObjectPath(ncop)); } catch (CIMException &e) { DDD(cout<<"### exception: mbCreateInstance - code: "<ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32; CIMPropertyList props=getList(properties); AutoMutex mtx(((CMPI_Broker*)mb)->mtx); try { CM_CIMOM(mb)->modifyInstance( OperationContext(*CM_Context(ctx)), CM_ObjectPath(cop)->getNameSpace(), *CM_Instance(ci), CM_IncludeQualifiers(flgs), props); CMReturn(CMPI_RC_OK); } catch (CIMException &e) { DDD(cout<<"### exception: mbSetInstance - code: "<getClassName(), CM_ObjectPath(cop)->getKeyBindings()); AutoMutex mtx(((CMPI_Broker*)mb)->mtx); try { CM_CIMOM(mb)->deleteInstance( OperationContext(*CM_Context(ctx)), CM_ObjectPath(cop)->getNameSpace(), qop); //*CM_ObjectPath(cop)); CMReturn(CMPI_RC_OK); } catch (CIMException &e) { DDD(cout<<"### exception: mbDeleteInstance - code: "<mtx); try { Array const &en=CM_CIMOM(mb)->execQuery( OperationContext(*CM_Context(ctx)), CM_ObjectPath(cop)->getNameSpace(), String(query), String(lang)); if (rc) CMSetStatus(rc,CMPI_RC_OK); return new CMPI_ObjEnumeration(new Array(en)); } catch (CIMException &e) { DDD(cout<<"### exception: mbExecQuery - code: "<ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32; CIMPropertyList props=getList(properties); AutoMutex mtx(((CMPI_Broker*)mb)->mtx); try { Array const &en=CM_CIMOM(mb)->enumerateInstances( OperationContext(*CM_Context(ctx)), CM_ObjectPath(cop)->getNameSpace(), CM_ObjectPath(cop)->getClassName(), CM_DeepInheritance(flgs), CM_LocalOnly(flgs), CM_IncludeQualifiers(flgs), CM_ClassOrigin(flgs), props); if (rc) CMSetStatus(rc,CMPI_RC_OK); return new CMPI_InstEnumeration(new Array(en)); } catch (CIMException &e) { DDD(cout<<"### exception: mbEnumInstances - code: "<mtx); try { Array const &en=CM_CIMOM(mb)->enumerateInstanceNames( OperationContext(*CM_Context(ctx)), CM_ObjectPath(cop)->getNameSpace(), CM_ObjectPath(cop)->getClassName()); if (rc) CMSetStatus(rc,CMPI_RC_OK); return new CMPI_OpEnumeration(new Array(en)); } catch (CIMException &e) { DDD(cout<<"### exception: mbEnumInstances - code: "<ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32; CIMPropertyList props=getList(properties); CIMObjectPath qop(String::EMPTY,CIMNamespaceName(), CM_ObjectPath(cop)->getClassName(), CM_ObjectPath(cop)->getKeyBindings()); AutoMutex mtx(((CMPI_Broker*)mb)->mtx); try { Array const &en=CM_CIMOM(mb)->associators( OperationContext(*CM_Context(ctx)), CM_ObjectPath(cop)->getNameSpace(), qop, assocClass ? CIMName(assocClass) : CIMName(), resultClass ? CIMName(resultClass) : CIMName(), role ? String(role) : String::EMPTY, resultRole ? String(resultRole) : String::EMPTY, CM_IncludeQualifiers(flgs), CM_ClassOrigin(flgs), props); if (rc) CMSetStatus(rc,CMPI_RC_OK); return new CMPI_ObjEnumeration(new Array(en)); } catch (CIMException &e) { DDD(cout<<"### exception: mbAssociators - code: "<getClassName(), CM_ObjectPath(cop)->getKeyBindings()); AutoMutex mtx(((CMPI_Broker*)mb)->mtx); try { Array const &en=CM_CIMOM(mb)->associatorNames( OperationContext(*CM_Context(ctx)), CM_ObjectPath(cop)->getNameSpace(), qop, assocClass ? CIMName(assocClass) : CIMName(), resultClass ? CIMName(resultClass) : CIMName(), role ? String(role) : String::EMPTY, resultRole ? String(resultRole) : String::EMPTY); if (rc) CMSetStatus(rc,CMPI_RC_OK); return new CMPI_OpEnumeration(new Array(en)); } catch (CIMException &e) { DDD(cout<<"### exception: mbAssociatorsNames - code: "<ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32; CIMPropertyList props=getList(properties); CIMObjectPath qop(String::EMPTY,CIMNamespaceName(), CM_ObjectPath(cop)->getClassName(), CM_ObjectPath(cop)->getKeyBindings()); AutoMutex mtx(((CMPI_Broker*)mb)->mtx); try { Array const &en=CM_CIMOM(mb)->references( OperationContext(*CM_Context(ctx)), CM_ObjectPath(cop)->getNameSpace(), qop, resultClass ? CIMName(resultClass) : CIMName(), role ? String(role) : String::EMPTY, CM_IncludeQualifiers(flgs), CM_ClassOrigin(flgs), props); if (rc) CMSetStatus(rc,CMPI_RC_OK); return new CMPI_ObjEnumeration(new Array(en)); } catch (CIMException &e) { DDD(cout<<"### exception: mbReferences - code: "<getClassName(), CM_ObjectPath(cop)->getKeyBindings()); AutoMutex mtx(((CMPI_Broker*)mb)->mtx); try { Array const &en=CM_CIMOM(mb)->referenceNames( OperationContext(*CM_Context(ctx)), CM_ObjectPath(cop)->getNameSpace(), qop, resultClass ? CIMName(resultClass) : CIMName(), role ? String(role) : String::EMPTY); if (rc) CMSetStatus(rc,CMPI_RC_OK); return new CMPI_OpEnumeration(new Array(en)); } catch (CIMException &e) { DDD(cout<<"### exception: mbReferencesNames - code: "<mtx); try { CM_CIMOM(mb)->setProperty( OperationContext(*CM_Context(ctx)), CM_ObjectPath(cop)->getNameSpace(), *CM_ObjectPath(cop), String(name), v); CMReturn(CMPI_RC_OK); } catch (CIMException &e) { DDD(cout<<"### exception: mbSetProperty - code: "<mtx); try { CIMValue v=CM_CIMOM(mb)->getProperty( OperationContext(*CM_Context(ctx)), CM_ObjectPath(cop)->getNameSpace(), *CM_ObjectPath(cop), String(name)); CIMType vType=v.getType(); CMPIType t=type2CMPIType(vType,v.isArray()); value2CMPIData(v,t,&data); if (rc) CMSetStatus(rc,CMPI_RC_OK); return data; } catch (CIMException &e) { DDD(cout<<"### exception: mbGetProperty - code: "<ctx; OperationContext nctx=*ctx; CMPIContext* neCtx=new CMPI_Context(*(new OperationContext(nctx))); CMPIString *name; for (int i=0,s=CMPI_Args_Ftab->getArgCount((CMPIArgs*)eCtx,NULL); igetArgAt((CMPIArgs*)eCtx,i,&name,NULL); CMPI_Args_Ftab->addArg((CMPIArgs*)neCtx,CMGetCharPtr(name),&data.value,data.type); } return neCtx; } static CMPIStatus mbAttachThread(CMPIBroker* mb, CMPIContext* eCtx) { DDD(cout<<"--- mbAttachThread()"<thr=new CMPI_ThreadContext(mb,eCtx); CMReturn(CMPI_RC_OK); } static CMPIStatus mbDetachThread(CMPIBroker* mb, CMPIContext* eCtx) { DDD(cout<<"--- mbDetachThread()"<thr; CMReturn(CMPI_RC_OK); } static CMPIStatus mbDeliverIndication(CMPIBroker* eMb, CMPIContext* ctx, const char *ns, CMPIInstance* ind) { DDD(cout<<"--- mbDeliverIndication()"<name,prec)) { if (prec->enabled) { try { context->get(SubscriptionInstanceNamesContainer::NAME); } catch (Exception& e) { Array subscriptionInstanceNames; context->insert(SubscriptionInstanceNamesContainer(subscriptionInstanceNames)); } CIMIndication cimIndication(*CM_Instance(ind)); AutoMutex mtx(((CMPI_Broker*)mb)->mtx); try { prec->handler->deliver( *context, // OperationContext(*CM_Context(ctx)), cimIndication); CMReturn(CMPI_RC_OK); } catch (CIMException &e) { DDD(cout<<"### exception: mbSetProperty - code: "<