static CMPIData mbGetProperty( const CMPIBroker *mb, const CMPIContext *ctx, const CMPIObjectPath *cop, const char *name, CMPIStatus *rc) { PEG_METHOD_ENTER( TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbGetProperty()"); mb = CM_BROKER; CMPIData data = {0,CMPI_nullValue,{0}}; SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop); CIMObjectPath qop; scmoObjPath->getCIMObjectPath(qop); try { CIMValue v = CM_CIMOM(mb)->getProperty( *CM_Context(ctx), SCMO_ObjectPath(cop)->getNameSpace(), qop, String(name)); CIMType vType = v.getType(); CMPIType t = type2CMPIType(vType,v.isArray()); value2CMPIData(v,t,&data); CMSetStatus(rc,CMPI_RC_OK); } HandlerCatchSetStatus(rc, data); PEG_METHOD_EXIT(); return data; // "data" will be valid data or nullValue (in error case) }
static CMPIStatus mbDeleteInstance( const CMPIBroker *mb, const CMPIContext *ctx, const CMPIObjectPath *cop) { PEG_METHOD_ENTER( TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbDeleteInstance()"); mb = CM_BROKER; SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop); CIMObjectPath qop; try { scmoObjPath->getCIMObjectPath(qop); CM_CIMOM(mb)->deleteInstance( *CM_Context(ctx), SCMO_ObjectPath(cop)->getNameSpace(), qop); } HandlerCatchReturnStatus(); PEG_METHOD_EXIT(); CMReturn(CMPI_RC_OK); }
static CMPIStatus mbSetProperty( const CMPIBroker *mb, const CMPIContext *ctx, const CMPIObjectPath *cop, const char *name, const CMPIValue *val, CMPIType type) { PEG_METHOD_ENTER( TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbSetProperty()"); mb = CM_BROKER; CMPIrc rc; CIMValue v = value2CIMValue(val,type,&rc); SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop); CIMObjectPath qop; try { scmoObjPath->getCIMObjectPath(qop); CM_CIMOM(mb)->setProperty( *CM_Context(ctx), SCMO_ObjectPath(cop)->getNameSpace(), qop, String(name), v); } HandlerCatchReturnStatus(); PEG_METHOD_EXIT(); CMReturn(CMPI_RC_OK); }
static CMPIStatus mbModifyInstance( const CMPIBroker *mb, const CMPIContext *ctx, const CMPIObjectPath *cop, const CMPIInstance *ci, const char ** properties) { PEG_METHOD_ENTER( TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbModifyInstance()"); mb = CM_BROKER; CMPIFlags flgs = ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32; const CIMPropertyList props = getList(properties); SCMOInstance* scmoInst = SCMO_Instance(ci); CIMInstance inst; try { scmoInst->getCIMInstance(inst); CM_CIMOM(mb)->modifyInstance( *CM_Context(ctx), SCMO_ObjectPath(cop)->getNameSpace(), inst, CM_IncludeQualifiers(flgs), props); } HandlerCatchReturnStatus(); PEG_METHOD_EXIT(); CMReturn(CMPI_RC_OK); }
static CMPIEnumeration* mbReferenceNames( const CMPIBroker *mb, const CMPIContext *ctx, const CMPIObjectPath *cop, const char *resultClass, const char *role, CMPIStatus *rc) { PEG_METHOD_ENTER( TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbReferenceNames()"); mb = CM_BROKER; // ATTN-CAKG-P2-20020726: The following condition does not correctly // distinguish instanceNames from classNames in every case // The instanceName of a singleton instance of a keyless class has no // key bindings if (!SCMO_ObjectPath(cop)->getKeyBindingCount()) { CMSetStatus(rc, CMPI_RC_ERR_FAILED); PEG_METHOD_EXIT(); return 0; } SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop); CIMObjectPath qop; try { scmoObjPath->getCIMObjectPath(qop); // For compatibility with previous implementations have empty ns qop.setNameSpace(CIMNamespaceName()); CIMResponseData resData = CM_CIMOM(mb)->referenceNames( *CM_Context(ctx), scmoObjPath->getNameSpace(), qop, resultClass ? CIMName(resultClass) : CIMName(), role ? String(role) : String::EMPTY); // Add the namespace from the input parameters when neccessary resData.completeNamespace(scmoObjPath); Array<SCMOInstance>* aRef = new Array<SCMOInstance>(resData.getSCMO()); CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>( new CMPI_Object(new CMPI_OpEnumeration(aRef))); CMSetStatus(rc,CMPI_RC_OK); PEG_METHOD_EXIT(); return cmpiEnum; } HandlerCatchSetStatus(rc, NULL); // Code flow should never get here. }
static CMPIInstance* mbGetInstance( const CMPIBroker *mb, const CMPIContext *ctx, const CMPIObjectPath *cop, const char **properties, CMPIStatus *rc) { PEG_METHOD_ENTER( TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbGetInstance()"); mb = CM_BROKER; CMPIFlags flgs = ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32; const CIMPropertyList props = getList(properties); SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop); CIMObjectPath qop; try { scmoObjPath->getCIMObjectPath(qop); CIMResponseData resData = CM_CIMOM(mb)->getInstance( *CM_Context(ctx), scmoObjPath->getNameSpace(), qop, CM_IncludeQualifiers(flgs), CM_ClassOrigin(flgs), props); // When running out of process the returned instances don't contain // a namespace. // Add the namespace from the input parameters where neccessary resData.completeNamespace(SCMO_ObjectPath(cop)); SCMOInstance& scmoOrgInst = resData.getSCMO()[0]; SCMOInstance* scmoInst = new SCMOInstance(scmoOrgInst); // Rebuild the objectPath scmoInst->buildKeyBindingsFromProperties(); CMPIInstance* cmpiInst = reinterpret_cast<CMPIInstance*>( new CMPI_Object(scmoInst,CMPI_Object::ObjectTypeInstance)); CMSetStatus(rc,CMPI_RC_OK); PEG_METHOD_EXIT(); return cmpiInst; } HandlerCatchSetStatus(rc, NULL); // Code flow should never get here. }
static CMPIData mbInvokeMethod( const CMPIBroker *mb, const CMPIContext *ctx, const CMPIObjectPath *cop, const char *method, const CMPIArgs *in, CMPIArgs *out, CMPIStatus *rc) { PEG_METHOD_ENTER( TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbInvokeMethod()"); CMPIData data = {0,CMPI_nullValue,{0}}; mb = CM_BROKER; SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop); CIMObjectPath qop; try { scmoObjPath->getCIMObjectPath(qop); CIMValue v = CM_CIMOM(mb)->invokeMethod( *CM_Context(ctx), SCMO_ObjectPath(cop)->getNameSpace(), qop, method ? String(method) : String::EMPTY, *CM_Args(in), *CM_Args(out)); CIMType vType=v.getType(); CMPIType t = type2CMPIType(vType,v.isArray()); value2CMPIData(v,t,&data); if (rc) { CMSetStatus(rc,CMPI_RC_OK); } } HandlerCatchSetStatus(rc, data); PEG_METHOD_EXIT(); return data; // "data" will be valid data or nullValue (in error case) }
void AssociatorsResponseHandler::deliver(const SCMOInstance& scmoObject) { if (scmoObject.isUninitialized()) { MessageLoaderParms message( "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION", "The object is not initialized."); throw CIMException(CIM_ERR_FAILED, message); } SimpleObjectResponseHandler::deliver(scmoObject); }
static CMPIObjectPath* mbCreateInstance( const CMPIBroker *mb, const CMPIContext *ctx, const CMPIObjectPath *cop, const CMPIInstance *ci, CMPIStatus *rc) { PEG_METHOD_ENTER( TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbCreateInstance()"); mb = CM_BROKER; SCMOInstance* scmoInst = SCMO_Instance(ci); CIMInstance inst; try { scmoInst->getCIMInstance(inst); CIMObjectPath ncop = CM_CIMOM(mb)->createInstance( *CM_Context(ctx), scmoInst->getNameSpace(), inst); SCMOInstance* newScmoInst= CMPISCMOUtilities::getSCMOFromCIMObjectPath( ncop, scmoInst->getNameSpace()); CMPIObjectPath* cmpiObjPath = reinterpret_cast<CMPIObjectPath*>( new CMPI_Object(newScmoInst,CMPI_Object::ObjectTypeObjectPath)); CMSetStatus(rc,CMPI_RC_OK); PEG_METHOD_EXIT(); return cmpiObjPath; } HandlerCatchSetStatus(rc, NULL); // Code flow should never get here. }
void EnumerateInstanceNamesResponseHandler::deliver( const SCMOInstance& scmoObjectPath) { if (scmoObjectPath.getClassName()==NULL) { MessageLoaderParms message( "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION", "The object is not initialized."); throw CIMException(CIM_ERR_FAILED, message); } SimpleObjectPathResponseHandler::deliver(scmoObjectPath); }
void GetInstanceResponseHandler::deliver(const SCMOInstance& cimInstance) { if (cimInstance.isUninitialized()) { MessageLoaderParms message( "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION", "The object is not initialized."); throw CIMException(CIM_ERR_FAILED, message); } if (SimpleInstanceResponseHandler::size() != 0) { MessageLoaderParms message( "Server.OperationResponseHandler.TOO_MANY_OBJECTS_DELIVERED", "Too many objects delivered."); throw CIMException(CIM_ERR_FAILED, message); } SimpleInstanceResponseHandler::deliver(cimInstance); }
/** Function to convert CMPIValue to CIMValue */ CIMValue value2CIMValue(const CMPIValue* data, const CMPIType type, CMPIrc *rc) { CIMValue v; if( rc ) { *rc=CMPI_RC_OK; } /** check data for NULL if type is not CMPIArray. */ if( !(type & CMPI_ARRAY) && !data ) { return CIMValue(type2CIMType(type), false); } /** Case when type is CMPIArray */ if( type & CMPI_ARRAY ) { //Return if data itself is NULL or Array is NULL if( data == NULL || data->array == NULL ) { CMPIType aType=type&~CMPI_ARRAY; return CIMValue(type2CIMType(aType),true); } // When data is not NULL and data->array is also set CMPIArray *ar=data->array; CMPIData *aData=(CMPIData*)((CMPI_Array*)ar->hdl)->hdl; //Get the type of the elements in the array CMPIType aType=aData->type&~CMPI_ARRAY; int aSize=aData->value.sint32; aData++; // Checks for Signed Integers if( (aType & (CMPI_UINT|CMPI_SINT))==CMPI_SINT ) { switch( aType ) { case CMPI_sint32: CopyToArray(Sint32,sint32); break; case CMPI_sint16: CopyToArray(Sint16,sint16); break; case CMPI_sint8: CopyToArray(Sint8,sint8); break; case CMPI_sint64: CopyToArray(Sint64,sint64); break; default: ; } } else if( aType == CMPI_chars ) { CopyToStringArray(String,string->hdl) } else if( aType == CMPI_charsptr ) { CopyCharsptrToStringArray(String,chars) } else if( aType == CMPI_string ) { CopyToStringArray(String,string->hdl) } // Checks for Unsigned Integers else if( (aType & (CMPI_UINT|CMPI_SINT))==CMPI_UINT ) { switch( aType ) { case CMPI_uint32: CopyToArray(Uint32,uint32); break; case CMPI_uint16: CopyToArray(Uint16,uint16); break; case CMPI_uint8: CopyToArray(Uint8,uint8); break; case CMPI_uint64: CopyToArray(Uint64,uint64); break; default: ; } } else { switch( aType ) { case CMPI_ref: { Array<CIMObjectPath> arCIMObjectPath(aSize); ArrayIterator<CIMObjectPath> iterator(arCIMObjectPath); for (int i=0; i<aSize; i++) { SCMOInstance* scmoInst = (SCMOInstance*)aData[i].value.ref->hdl; scmoInst->getCIMObjectPath(iterator[i]); } v.set(arCIMObjectPath); } break; case CMPI_dateTime: CopyToEncArray(CIMDateTime,dateTime); break; case CMPI_instance: { Array<CIMObject> arCIMInstance(aSize); ArrayIterator<CIMObject> iterator(arCIMInstance); for (int i=0; i<aSize; i++) { SCMOInstance* scmoInst = (SCMOInstance*)aData[i].value.inst->hdl; CIMInstance inst; scmoInst->getCIMInstance(inst); CIMObject obj(inst); iterator[i]=obj; } v.set(arCIMInstance); } break; case CMPI_boolean: CopyToArray(Boolean,boolean); break; case CMPI_char16: CopyToArray(Char16,char16); break; case CMPI_real32: CopyToArray(Real32,real32); break; case CMPI_real64: CopyToArray(Real64,real64); break; default: if( rc ) { *rc=CMPI_RC_ERR_NOT_SUPPORTED; } } } return CIMValue(v); } // end of array processing //Start of non - array types processing else if( type == CMPI_chars )
static CMPIStatus mbDeliverIndication( const CMPIBroker* eMb, const CMPIContext* ctx, const char *ns, const CMPIInstance* ind) { PEG_METHOD_ENTER( TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbDeliverIndication()"); eMb = CM_BROKER; CMPI_Broker *mb = (CMPI_Broker*)eMb; IndProvRecord *indProvRec; OperationContext* context = CM_Context(ctx); SCMOInstance* scmoInst = SCMO_Instance(ind); CIMInstance indInst; scmoInst->getCIMInstance(indInst); // When an indication to be delivered comes from Remote providers, // the CMPIBroker contains the name of the provider in the form // of physical-name:logical-name. Search using logical-name. -V 5884 String provider_name; CMPIUint32 n; if ( (n = mb->name.find(':') ) != PEG_NOT_FOUND) { provider_name = mb->name.subString (n + 1); } else { provider_name = mb->name; } ReadLock readLock(CMPIProviderManager::rwSemProvTab); if (CMPIProviderManager::indProvTab.lookup(provider_name, indProvRec)) { if (indProvRec->isEnabled()) { try { context->get(SubscriptionInstanceNamesContainer::NAME); } catch (const Exception &e) { PEG_TRACE((TRC_CMPIPROVIDERINTERFACE,Tracer::LEVEL1, "Exception: %s", (const char*)e.getMessage().getCString())); Array<CIMObjectPath> subscriptionInstanceNames; context->insert( SubscriptionInstanceNamesContainer( subscriptionInstanceNames)); } CIMIndication cimIndication(indInst); try { indProvRec->getHandler()->deliver( *context, // OperationContext(*CM_Context(ctx)), cimIndication); PEG_METHOD_EXIT(); CMReturn(CMPI_RC_OK); } HandlerCatchReturnStatus(); } } PEG_METHOD_EXIT(); CMReturn(CMPI_RC_ERR_FAILED); }
static CMPIEnumeration* mbAssociators( const CMPIBroker *mb, const CMPIContext *ctx, const CMPIObjectPath *cop, const char *assocClass, const char *resultClass, const char *role, const char *resultRole, const char **properties, CMPIStatus *rc) { PEG_METHOD_ENTER( TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbAssociators()"); mb = CM_BROKER; // ATTN-CAKG-P2-20020726: The following condition does not correctly // distinguish instanceNames from classNames in every case // The instanceName of a singleton instance of a keyless class has no // key bindings if (!SCMO_ObjectPath(cop)->getKeyBindingCount()) { CMSetStatus(rc, CMPI_RC_ERR_FAILED); PEG_METHOD_EXIT(); return 0; } CMPIFlags flgs = ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32; const CIMPropertyList props = getList(properties); SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop); CIMObjectPath qop; try { scmoObjPath->getCIMObjectPath(qop); // For compatibility with previous implementations have empty ns qop.setNameSpace(CIMNamespaceName()); CIMResponseData resData = CM_CIMOM(mb)->associators( *CM_Context(ctx), SCMO_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); // When running out of process the returned instances don't contain // a namespace. // Add the namespace from the input parameters where neccessary resData.completeNamespace(scmoObjPath); Array<SCMOInstance>* aObj = new Array<SCMOInstance>(resData.getSCMO()); CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>( new CMPI_Object(new CMPI_ObjEnumeration(aObj))); CMSetStatus(rc,CMPI_RC_OK); PEG_METHOD_EXIT(); return cmpiEnum; } HandlerCatchSetStatus(rc, NULL); // Code flow should never get here. }
PEGASUS_NAMESPACE_BEGIN void SCMOInternalXmlEncoder::_putXMLInstance( CIMBuffer& out, const SCMOInstance& ci, const CIMPropertyList& propertyList ) { if (ci.isUninitialized()) { out.putUint32(0); out.putUint32(0); out.putString(String()); out.putNamespaceName(CIMNamespaceName()); } else { Buffer buf(4096); // Serialize instance as XML. if (propertyList.isNull()) { Array<Uint32> emptyNodes; SCMOXmlWriter::appendInstanceElement( buf, ci, false, emptyNodes); } else { Array<propertyFilterNodesArray_t> propFilterNodesArrays; // This searches for an already created array of nodes, // if not found, creates it inside propFilterNodesArrays const Array<Uint32> & nodes= SCMOXmlWriter::getFilteredNodesArray( propFilterNodesArrays, ci, propertyList); SCMOXmlWriter::appendInstanceElement( buf, ci, true, nodes); } buf.append('\0'); out.putUint32(buf.size()); out.putBytes(buf.getData(), buf.size()); buf.clear(); if (0 == ci.getClassName()) { out.putUint32(0); out.putString(String()); out.putNamespaceName(CIMNamespaceName()); } else { // Serialize object path as XML. SCMOXmlWriter::appendValueReferenceElement(buf, ci); buf.append('\0'); out.putUint32(buf.size()); out.putBytes(buf.getData(), buf.size()); // Write hostname and namespace in UTF-16 format Uint32 len=0; const char* hn = ci.getHostName_l(len); out.putUTF8AsString(hn, len); const char * ns = ci.getNameSpace_l(len); out.putUTF8AsString(ns, len); } } }