1 //%LICENSE////////////////////////////////////////////////////////////////
3 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //////////////////////////////////////////////////////////////////////////
30 //%/////////////////////////////////////////////////////////////////////////////
32 #include "CMPI_Version.h"
34 #include "CMPIProviderManager.h"
36 #include "CMPI_Object.h"
37 #include "CMPI_Instance.h"
38 #include "CMPI_ObjectPath.h"
39 #include "CMPI_Result.h"
40 #include "CMPI_SelectExp.h"
41 #include "CMPISCMOUtilities.h"
42 #include "CMPI_Value.h"
43 #include "CMPIMsgHandleManager.h"
46 #include <Pegasus/Common/CIMMessage.h>
47 #include <Pegasus/Common/OperationContext.h>
48 #include <Pegasus/Common/OperationContextInternal.h>
49 #include <Pegasus/Common/Tracer.h>
50 #include <Pegasus/Common/StatisticalData.h>
51 #include <Pegasus/Common/Logger.h>
52 #include <Pegasus/Common/LanguageParser.h>
53 #include <Pegasus/Common/MessageLoader.h> //l10n
54 #include <Pegasus/Common/Constants.h>
55 #include <Pegasus/Common/FileSystem.h>
57 #include <Pegasus/Config/ConfigManager.h>
59 #include <Pegasus/Provider/CIMOMHandleQueryContext.h>
60 #include <Pegasus/ProviderManager2/CIMOMHandleContext.h>
61 #include <Pegasus/ProviderManager2/ProviderName.h>
62 #include <Pegasus/ProviderManager2/AutoPThreadSecurity.h>
63 #include <Pegasus/ProviderManager2/CMPI/CMPIProviderModule.h>
64 #include <Pegasus/ProviderManager2/CMPI/CMPIProvider.h>
65 #include <Pegasus/ProviderManager2/CMPI/CMPI_ThreadContext.h>
66 #include <Pegasus/Query/QueryExpression/QueryExpression.h>
67 #include <Pegasus/Query/QueryCommon/QueryException.h>
71 PEGASUS_NAMESPACE_BEGIN
74 ReadWriteSem CMPIProviderManager::rwSemProvTab;
75 CMPIProviderManager::IndProvTab CMPIProviderManager::indProvTab;
77 class CMPIPropertyList
82 CMPIPropertyList(CIMPropertyList &propertyList) : props(0), pCount(0)
86 "CMPIPropertyList::CMPIPropertyList()");
87 if (!propertyList.isNull())
89 Array<CIMName> p=propertyList.getPropertyNameArray();
91 props = new char*[1+pCount];
92 for (int i=0; i<pCount; i++)
94 props[i]=strdup(p[i].getString().getCString());
105 "CMPIPropertyList::~CMPIPropertyList()");
108 for (int i=0; i<pCount; i++)
120 CMPIProviderManager::CMPIProviderManager()
124 "CMPIProviderManager::CMPIProviderManager()");
126 _subscriptionInitComplete = false;
130 "-- CMPI Provider Manager activated");
134 CMPIProviderManager::~CMPIProviderManager()
138 "CMPIProviderManager::~CMPIProviderManager()");
140 IndProvRecord *indProvRec = 0;
142 WriteLock lock(rwSemProvTab);
144 for (IndProvTab::Iterator i = indProvTab.start(); i; i++)
146 indProvTab.lookup(i.key(), indProvRec);
154 SCMOInstance* CMPIProviderManager::getSCMOClassFromRequest(
158 SCMOClass* scmoClass = mbGetSCMOClass(
159 (const char*)nameSpace,
160 strlen((const char*)nameSpace),
161 (const char*)className,
162 strlen((const char*)className));
166 // This indicates a severe error, since we should't have come
167 // here at all, if the class is invalid
168 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL2,
169 "CMPIProviderManager::getSCMOClassFromRequest - "
170 "Failed to obtain SCMOClass for Namespace: %s Classname: %s",
171 (const char*) nameSpace,
172 (const char*) className));
174 CIMException cimException(CIM_ERR_NOT_FOUND);
178 return new SCMOInstance(*scmoClass);
181 SCMOInstance* CMPIProviderManager::getSCMOObjectPathFromRequest(
184 CIMObjectPath& cimObjPath )
186 SCMOClass* scmoClass = mbGetSCMOClass(
187 (const char*)nameSpace,
188 strlen((const char*)nameSpace),
189 (const char*)className,
190 strlen((const char*)className));
194 // This indicates a severe error, since we should't have come
195 // here at all, if the class is invalid
196 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL1,
197 "CMPIProviderManager::getSCMOObjectPathFromRequest - "
198 "Failed to obtain CIMClass for Namespace: %s Classname: %s",
199 (const char*) nameSpace,
200 (const char*) className));
202 CIMException cimException(CIM_ERR_NOT_FOUND);
206 SCMOInstance * objectPath = new SCMOInstance(*scmoClass,cimObjPath);
207 objectPath->setHostName((const char*)System::getHostName().getCString());
211 SCMOInstance* CMPIProviderManager::getSCMOInstanceFromRequest(
214 CIMInstance& cimInstance )
216 SCMOClass* scmoClass = mbGetSCMOClass(
217 (const char*)nameSpace,
218 strlen((const char*)nameSpace),
219 (const char*)className,
220 strlen((const char*)className));
224 // This indicates a severe error, since we should't have come
225 // here at all, if the class is invalid
226 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL1,
227 "CMPIProviderManager::getSCMOInstanceFromRequest - "
228 "Failed to obtain CIMClass for Namespace: %s Classname: %s",
229 (const char*) nameSpace,
230 (const char*) className));
232 CIMException cimException(CIM_ERR_NOT_FOUND);
236 SCMOInstance * newInstance = new SCMOInstance(*scmoClass, cimInstance);
237 newInstance->setHostName((const char*)System::getHostName().getCString());
244 Message * CMPIProviderManager::processMessage(Message * request)
248 "CMPIProviderManager::processMessage()");
250 Message * response = 0;
252 // pass the request message to a handler method based on message type
253 switch (request->getType())
255 case CIM_GET_INSTANCE_REQUEST_MESSAGE:
256 response = handleGetInstanceRequest(request);
259 case CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE:
260 response = handleEnumerateInstancesRequest(request);
263 case CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE:
264 response = handleEnumerateInstanceNamesRequest(request);
267 case CIM_CREATE_INSTANCE_REQUEST_MESSAGE:
268 response = handleCreateInstanceRequest(request);
271 case CIM_MODIFY_INSTANCE_REQUEST_MESSAGE:
272 response = handleModifyInstanceRequest(request);
275 case CIM_DELETE_INSTANCE_REQUEST_MESSAGE:
276 response = handleDeleteInstanceRequest(request);
279 case CIM_EXEC_QUERY_REQUEST_MESSAGE:
280 response = handleExecQueryRequest(request);
283 case CIM_ASSOCIATORS_REQUEST_MESSAGE:
284 response = handleAssociatorsRequest(request);
287 case CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE:
288 response = handleAssociatorNamesRequest(request);
291 case CIM_REFERENCES_REQUEST_MESSAGE:
292 response = handleReferencesRequest(request);
295 case CIM_REFERENCE_NAMES_REQUEST_MESSAGE:
296 response = handleReferenceNamesRequest(request);
299 case CIM_INVOKE_METHOD_REQUEST_MESSAGE:
300 response = handleInvokeMethodRequest(request);
303 case CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE:
304 response = handleCreateSubscriptionRequest(request);
307 /* case CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE:
308 response = handleModifySubscriptionRequest(request);
312 case CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE:
313 response = handleDeleteSubscriptionRequest(request);
316 /* case CIM_EXPORT_INDICATION_REQUEST_MESSAGE:
317 response = handleExportIndicationRequest(request);
320 case CIM_DISABLE_MODULE_REQUEST_MESSAGE:
321 response = handleDisableModuleRequest(request);
324 case CIM_ENABLE_MODULE_REQUEST_MESSAGE:
325 response = handleEnableModuleRequest(request);
328 case CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE:
329 response = handleStopAllProvidersRequest(request);
332 case CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE:
333 response = handleSubscriptionInitCompleteRequest (request);
336 case CIM_INDICATION_SERVICE_DISABLED_REQUEST_MESSAGE:
337 response = handleIndicationServiceDisabledRequest (request);
339 case CIM_GET_PROPERTY_REQUEST_MESSAGE:
340 response = handleGetPropertyRequest(request);
343 case CIM_SET_PROPERTY_REQUEST_MESSAGE:
344 response = handleSetPropertyRequest(request);
348 response = handleUnsupportedRequest(request);
358 Boolean CMPIProviderManager::hasActiveProviders()
360 return providerManager.hasActiveProviders();
363 void CMPIProviderManager::unloadIdleProviders()
365 providerManager.unloadIdleProviders();
369 #define CHARS(cstring) (char*)(strlen(cstring)?(const char*)cstring:NULL)
372 #define HandlerIntroBase(type,type1,message,request,response,handler) \
373 CIM##type##RequestMessage * request = \
374 dynamic_cast<CIM##type##RequestMessage *>(const_cast<Message *> \
376 PEGASUS_ASSERT(request != 0); \
377 CIM##type##ResponseMessage * response = \
378 dynamic_cast<CIM##type##ResponseMessage*>(request->buildResponse()); \
379 PEGASUS_ASSERT(response != 0); \
380 type1##ResponseHandler handler(request, response, _responseChunkCallback);
382 #define HandlerIntroInd(type,message,request,response,handler) \
383 HandlerIntroBase(type,Operation,message,request,response,handler)
385 #define HandlerIntroInit(type,message,request,response,handler) \
386 HandlerIntroBase(type,Operation,message,request,response,handler)
388 #define HandlerIntro(type,message,request,response,handler) \
389 HandlerIntroBase(type,type,message,request,response,handler)
391 #define HandlerCatch(handler) \
392 catch(const CIMException & e) \
393 { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1, \
394 "CIMException: %s",(const char*)e.getMessage().getCString())); \
395 handler.setCIMException(e); \
397 catch(const Exception & e) \
398 { PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1, \
399 "Exception: %s",(const char*)e.getMessage().getCString())); \
400 handler.setStatus(CIM_ERR_FAILED, e.getContentLanguages(), \
404 { PEG_TRACE_CSTRING(TRC_PROVIDERMANAGER, Tracer::LEVEL1, \
405 "Exception: Unknown"); \
406 handler.setStatus(CIM_ERR_FAILED, "Unknown error."); \
409 /* setup the CMPI context based on the requests OperationContext
411 nameSpace and remoteInfo are used by pointer instead of by reference to
412 avoid copies being generated, both CStrings are anchored on the stack in the
413 scope of the calling function to keep them valid across the lifetime of the
414 CMPI processing of a request
416 void CMPIProviderManager::_setupCMPIContexts(
417 CMPI_ContextOnStack * eCtx,
418 OperationContext * context,
419 const CString * nameSpace,
420 const CString * remoteInfo,
422 Boolean includeQualifiers,
423 Boolean includeClassOrigin,
428 // set CMPI invocation flags
431 if (includeQualifiers) value.uint32 |= CMPI_FLAG_IncludeQualifiers;
432 if (includeClassOrigin) value.uint32 |= CMPI_FLAG_IncludeClassOrigin;
440 // add identity context
441 const IdentityContainer container =
442 context->get(IdentityContainer::NAME);
446 (CMPIValue*)(const char*)container.getUserName().getCString(),
449 // add AcceptLanguages to CMPI context
450 const AcceptLanguageListContainer accept_language=
451 context->get(AcceptLanguageListContainer::NAME);
452 const AcceptLanguageList acceptLangs = accept_language.getLanguages();
457 (CMPIValue*)(const char*)
458 LanguageParser::buildAcceptLanguageHeader(acceptLangs).getCString(),
461 // add initial namespace to context
465 (CMPIValue*)(const char*)(*nameSpace),
468 // add remote info to context
473 "CMPIRRemoteInfo",(CMPIValue*)(const char*)(*remoteInfo),
479 Function resolves the provider name and gets the cached or loads new
480 provider module, also returns if operation is remote and the remote
483 CMPIProvider & CMPIProviderManager::_resolveAndGetProvider(
484 OperationContext * context,
485 OpProviderHolder * ph,
486 CString * remoteInfo,
491 // resolve provider name
492 ProviderIdContainer pidc =
493 context->get(ProviderIdContainer::NAME);
495 ProviderName name = _resolveProviderName(pidc);
497 if ((isRemote=pidc.isRemoteNameSpace()))
499 *ph = providerManager.getRemoteProvider(
501 name.getLogicalName(),
502 name.getModuleName());
506 // get cached or load new provider module
507 *ph = providerManager.getProvider(
508 name.getPhysicalName(),
509 name.getLogicalName(),
510 name.getModuleName());
512 *remoteInfo = pidc.getRemoteInfo().getCString();
515 return ph->GetProvider();
518 Message * CMPIProviderManager::handleGetInstanceRequest(
519 const Message * message)
523 "CMPIProviderManager::handleGetInstanceRequest()");
525 HandlerIntro(GetInstance,message,request,response,handler);
529 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
530 "CMPIProviderManager::handleGetInstanceRequest - Host name:"
531 " %s Name space: %s Class name: %s",
532 (const char*) System::getHostName().getCString(),
533 (const char*) request->nameSpace.getString().getCString(),
535 request->instanceName.getClassName().getString().getCString()));
537 Boolean remote=false;
541 CMPIProvider & pr = _resolveAndGetProvider(
542 &(request->operationContext),
547 CMPIStatus rc={CMPI_RC_OK,NULL};
548 CMPI_ContextOnStack eCtx(request->operationContext);
549 CMPI_ResultOnStack eRes(handler,pr.getBroker());
550 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
552 CMPIPropertyList props(request->propertyList);
553 CString nameSpace = request->nameSpace.getString().getCString();
554 CString className = request->className.getString().getCString();
558 &(request->operationContext),
562 request->includeQualifiers,
563 request->includeClassOrigin,
567 SCMOInstance * objectPath = getSCMOObjectPathFromRequest(
568 nameSpace, className, request->instanceName);
570 CMPI_ObjectPathOnStack eRef(objectPath);
572 CMPIProvider::pm_service_op_lock op_lock(&pr);
577 "Calling provider.getInstance: %s",
578 (const char*)pr.getName().getCString()));
581 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
583 StatProviderTimeMeasurement providerTime(response);
585 rc = pr.getInstMI()->ft->getInstance(
590 (const char **)props.getList());
596 "Returning from provider.getInstance: %s",
597 (const char*)pr.getName().getCString()));
599 // Need to save ContentLanguage value into operation context of response
600 // Do this before checking rc from provider to throw exception in case
601 // rc.msg is also localized.
602 CMPIStatus tmprc={CMPI_RC_OK,NULL};
604 eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);
605 if (tmprc.rc == CMPI_RC_OK)
607 response->operationContext.set(
608 ContentLanguageListContainer(
610 LanguageParser::parseContentLanguageHeader(
611 CMGetCharsPtr(cldata.value.string, NULL)))));
612 handler.setContext(response->operationContext);
615 _throwCIMException(rc, eRes.resError);
617 HandlerCatch(handler);
624 Message * CMPIProviderManager::handleEnumerateInstancesRequest(
625 const Message * message)
629 "CMPIProviderManager::handleEnumerateInstanceRequest()");
631 HandlerIntro(EnumerateInstances,message,request,response,handler);
634 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
635 "CMPIProviderManager::handleEnumerateInstancesRequest - Host name:"
636 " %s Name space: %s Class name: %s",
637 (const char*) System::getHostName().getCString(),
638 (const char*) request->nameSpace.getString().getCString(),
639 (const char*) request->className.getString().getCString()));
642 Boolean remote=false;
646 CMPIProvider & pr = _resolveAndGetProvider(
647 &(request->operationContext),
652 CIMPropertyList propertyList(request->propertyList);
654 CMPIStatus rc={CMPI_RC_OK,NULL};
655 CMPI_ContextOnStack eCtx(request->operationContext);
656 CMPI_ResultOnStack eRes(handler,pr.getBroker());
657 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
658 CMPIPropertyList props(propertyList);
659 CString nameSpace = request->nameSpace.getString().getCString();
660 CString className = request->className.getString().getCString();
664 &(request->operationContext),
668 request->includeQualifiers,
669 request->includeClassOrigin,
672 SCMOInstance * objectPath =
673 getSCMOClassFromRequest(nameSpace, className);
675 CMPI_ObjectPathOnStack eRef(objectPath);
677 CMPIProvider::pm_service_op_lock op_lock(&pr);
682 "Calling provider.enumerateInstances: %s",
683 (const char*)pr.getName().getCString()));
686 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
688 StatProviderTimeMeasurement providerTime(response);
690 rc = pr.getInstMI()->ft->enumerateInstances(
695 (const char **)props.getList());
701 "Returning from provider.enumerateInstances: %s",
702 (const char*)pr.getName().getCString()));
704 // Need to save ContentLanguage value into operation context of response
705 // Do this before checking rc from provider to throw exception in case
706 // rc.msg is also localized.
707 CMPIStatus tmprc={CMPI_RC_OK,NULL};
709 eCtx.ft->getEntry(&eCtx, CMPIContentLanguage, &tmprc);
710 if (tmprc.rc == CMPI_RC_OK)
712 response->operationContext.set(
713 ContentLanguageListContainer(
715 LanguageParser::parseContentLanguageHeader(
716 CMGetCharsPtr(cldata.value.string, NULL)))));
717 handler.setContext(response->operationContext);
720 _throwCIMException(rc, eRes.resError);
722 HandlerCatch(handler);
729 Message * CMPIProviderManager::handleEnumerateInstanceNamesRequest(
730 const Message * message)
734 "CMPIProviderManager::handleEnumerateInstanceNamesRequest()");
736 HandlerIntro(EnumerateInstanceNames,message,request,response,handler);
739 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
740 "CMPIProviderManager::handleEnumerateInstanceNamesRequest"
741 " - Host name: %s Name space: %s Class name: %s",
742 (const char*) System::getHostName().getCString(),
743 (const char*) request->nameSpace.getString().getCString(),
744 (const char*) request->className.getString().getCString()));
746 Boolean remote=false;
750 CMPIProvider & pr = _resolveAndGetProvider(
751 &(request->operationContext),
756 CMPIStatus rc={CMPI_RC_OK,NULL};
757 CMPI_ContextOnStack eCtx(request->operationContext);
758 CMPI_ResultOnStack eRes(handler,pr.getBroker());
759 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
761 CString nameSpace = request->nameSpace.getString().getCString();
762 CString className = request->className.getString().getCString();
766 &(request->operationContext),
774 SCMOInstance * objectPath =
775 getSCMOClassFromRequest(nameSpace, className);
777 CMPI_ObjectPathOnStack eRef(objectPath);
779 CMPIProvider::pm_service_op_lock op_lock(&pr);
784 "Calling provider.enumerateInstanceNames: %s",
785 (const char*)pr.getName().getCString()));
788 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
790 StatProviderTimeMeasurement providerTime(response);
792 rc = pr.getInstMI()->ft->enumerateInstanceNames(
802 "Returning from provider.enumerateInstanceNames: %s",
803 (const char*)pr.getName().getCString()));
805 // Need to save ContentLanguage value into operation context of response
806 // Do this before checking rc from provider to throw exception in case
807 // rc.msg is also localized.
808 CMPIStatus tmprc={CMPI_RC_OK,NULL};
810 eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);
811 if (tmprc.rc == CMPI_RC_OK)
813 response->operationContext.set(
814 ContentLanguageListContainer(
816 LanguageParser::parseContentLanguageHeader(
817 CMGetCharsPtr(cldata.value.string, NULL)))));
818 handler.setContext(response->operationContext);
820 _throwCIMException(rc, eRes.resError);
822 HandlerCatch(handler);
829 Message * CMPIProviderManager::handleCreateInstanceRequest(
830 const Message * message)
834 "CMPIProviderManager::handleCreateInstanceRequest()");
836 HandlerIntro(CreateInstance,message,request,response,handler);
839 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
840 "CMPIProviderManager::handleCreateInstanceRequest"
841 " - Host name: %s Name space: %s Class name: %s",
842 (const char*) System::getHostName().getCString(),
843 (const char*) request->nameSpace.getString().getCString(),
845 request->newInstance.getPath().getClassName().getString().getCString()
848 Boolean remote=false;
852 CMPIProvider & pr = _resolveAndGetProvider(
853 &(request->operationContext),
858 CMPIStatus rc={CMPI_RC_OK,NULL};
859 CMPI_ContextOnStack eCtx(request->operationContext);
860 CMPI_ResultOnStack eRes(handler,pr.getBroker());
861 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
863 CString nameSpace = request->nameSpace.getString().getCString();
864 CString className = request->newInstance.getPath().getClassName().
865 getString().getCString();
869 &(request->operationContext),
877 SCMOInstance * newInstance = getSCMOInstanceFromRequest(
878 nameSpace, className, request->newInstance);
879 CMPI_InstanceOnStack eInst(newInstance);
881 // This will create a second reference for the same SCMOInstance
882 CMPI_ObjectPathOnStack eRef(*newInstance);
884 CMPIProvider::pm_service_op_lock op_lock(&pr);
889 "Calling provider.createInstance: %s",
890 (const char*)ph.GetProvider().getName().getCString()));
893 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
895 StatProviderTimeMeasurement providerTime(response);
897 rc = pr.getInstMI()->ft->createInstance(
908 "Returning from provider.createInstance: %s",
909 (const char*)ph.GetProvider().getName().getCString()));
911 // Need to save ContentLanguage value into operation context of response
912 // Do this before checking rc from provider to throw exception in case
913 // rc.msg is also localized.
914 CMPIStatus tmprc={CMPI_RC_OK,NULL};
916 eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);
917 if (tmprc.rc == CMPI_RC_OK)
919 response->operationContext.set(
920 ContentLanguageListContainer(
922 LanguageParser::parseContentLanguageHeader(
923 CMGetCharsPtr(cldata.value.string, NULL)))));
924 handler.setContext(response->operationContext);
926 _throwCIMException(rc, eRes.resError);
928 HandlerCatch(handler);
935 Message * CMPIProviderManager::handleModifyInstanceRequest(
936 const Message * message)
940 "CMPIProviderManager::handleModifyInstanceRequest()");
942 HandlerIntro(ModifyInstance,message,request,response,handler);
945 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
946 "CMPIProviderManager::handleModifyInstanceRequest"
947 " - Host name: %s Name space: %s Class name: %s",
948 (const char*) System::getHostName().getCString(),
949 (const char*) request->nameSpace.getString().getCString(),
950 (const char*) request->modifiedInstance.\
951 getPath().getClassName().getString().getCString()));
953 Boolean remote=false;
957 CMPIProvider & pr = _resolveAndGetProvider(
958 &(request->operationContext),
963 CMPIStatus rc={CMPI_RC_OK,NULL};
964 CMPI_ContextOnStack eCtx(request->operationContext);
965 CMPI_ResultOnStack eRes(handler,pr.getBroker());
966 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
968 CMPIPropertyList props(request->propertyList);
970 CString nameSpace = request->nameSpace.getString().getCString();
971 CString className = request->modifiedInstance.getPath().getClassName().
972 getString().getCString();
976 &(request->operationContext),
980 request->includeQualifiers,
985 SCMOInstance * modInstance = getSCMOInstanceFromRequest(
986 nameSpace, className, request->modifiedInstance);
987 CMPI_InstanceOnStack eInst(modInstance);
989 // This will create a second reference for the same SCMOInstance
990 CMPI_ObjectPathOnStack eRef(*modInstance);
992 CMPIProvider::pm_service_op_lock op_lock(&pr);
997 "Calling provider.modifyInstance: %s",
998 (const char*)pr.getName().getCString()));
1001 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
1003 StatProviderTimeMeasurement providerTime(response);
1005 rc = pr.getInstMI()->ft->modifyInstance(
1011 (const char **)props.getList());
1015 TRC_PROVIDERMANAGER,
1017 "Returning from provider.modifyInstance: %s",
1018 (const char*)pr.getName().getCString()));
1020 // Need to save ContentLanguage value into operation context of response
1021 // Do this before checking rc from provider to throw exception in case
1022 // rc.msg is also localized.
1023 CMPIStatus tmprc={CMPI_RC_OK,NULL};
1025 eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);
1026 if (tmprc.rc == CMPI_RC_OK)
1028 response->operationContext.set(
1029 ContentLanguageListContainer(
1030 ContentLanguageList(
1031 LanguageParser::parseContentLanguageHeader(
1032 CMGetCharsPtr(cldata.value.string, NULL)))));
1033 handler.setContext(response->operationContext);
1035 _throwCIMException(rc, eRes.resError);
1037 HandlerCatch(handler);
1044 Message * CMPIProviderManager::handleDeleteInstanceRequest(
1045 const Message * message)
1048 TRC_PROVIDERMANAGER,
1049 "CMPIProviderManager::handleDeleteInstanceRequest()");
1051 HandlerIntro(DeleteInstance,message,request,response,handler);
1054 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
1055 "CMPIProviderManager::handleDeleteInstanceRequest"
1056 " - Host name: %s Name space: %s Class name: %s",
1057 (const char*) System::getHostName().getCString(),
1058 (const char*) request->nameSpace.getString().getCString(),
1060 request->instanceName.getClassName().getString().getCString()));
1062 Boolean remote=false;
1063 OpProviderHolder ph;
1066 CMPIProvider & pr = _resolveAndGetProvider(
1067 &(request->operationContext),
1072 CMPIStatus rc={CMPI_RC_OK,NULL};
1073 CMPI_ContextOnStack eCtx(request->operationContext);
1074 CMPI_ResultOnStack eRes(handler,pr.getBroker());
1075 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
1077 CString nameSpace = request->nameSpace.getString().getCString();
1078 CString className = request->instanceName.getClassName().
1079 getString().getCString();
1083 &(request->operationContext),
1091 SCMOInstance * objectPath = getSCMOObjectPathFromRequest(
1092 nameSpace, className, request->instanceName);
1094 CMPI_ObjectPathOnStack eRef(objectPath);
1096 CMPIProvider::pm_service_op_lock op_lock(&pr);
1099 TRC_PROVIDERMANAGER,
1101 "Calling provider.deleteInstance: %s",
1102 (const char*)pr.getName().getCString()));
1105 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
1107 StatProviderTimeMeasurement providerTime(response);
1109 rc = pr.getInstMI()->ft->deleteInstance(
1117 TRC_PROVIDERMANAGER,
1119 "Returning from provider.deleteInstance: %s",
1120 (const char*)pr.getName().getCString()));
1122 // Need to save ContentLanguage value into operation context of response
1123 // Do this before checking rc from provider to throw exception in case
1124 // rc.msg is also localized.
1125 CMPIStatus tmprc={CMPI_RC_OK,NULL};
1127 eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);
1128 if (tmprc.rc == CMPI_RC_OK)
1130 response->operationContext.set(
1131 ContentLanguageListContainer(
1132 ContentLanguageList(
1133 LanguageParser::parseContentLanguageHeader(
1134 CMGetCharsPtr(cldata.value.string, NULL)))));
1135 handler.setContext(response->operationContext);
1137 _throwCIMException(rc, eRes.resError);
1139 HandlerCatch(handler);
1146 Message * CMPIProviderManager::handleExecQueryRequest(const Message * message)
1149 TRC_PROVIDERMANAGER,
1150 "CMPIProviderManager::handleExecQueryRequest()");
1152 HandlerIntro(ExecQuery,message,request,response,handler);
1156 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
1157 "CMPIProviderManager::ExecQueryRequest"
1158 " - Host name: %s Name space: %s Class name: %s",
1159 (const char*) System::getHostName().getCString(),
1160 (const char*) request->nameSpace.getString().getCString(),
1161 (const char*) request->className.getString().getCString()));
1163 Boolean remote=false;
1164 OpProviderHolder ph;
1167 CMPIProvider & pr = _resolveAndGetProvider(
1168 &(request->operationContext),
1173 const char **props=NULL;
1175 CMPIStatus rc={CMPI_RC_OK,NULL};
1176 CMPI_ContextOnStack eCtx(request->operationContext);
1177 CMPI_ResultOnStack eRes(handler,pr.getBroker());
1178 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
1180 const CString queryLan=request->queryLanguage.getCString();
1181 const CString query=request->query.getCString();
1182 CString nameSpace = request->nameSpace.getString().getCString();
1183 CString className = request->className.getString().getCString();
1187 &(request->operationContext),
1195 SCMOInstance * classPath = getSCMOClassFromRequest(nameSpace,className);
1196 CMPI_ObjectPathOnStack eRef(classPath);
1198 CMPIProvider::pm_service_op_lock op_lock(&pr);
1201 TRC_PROVIDERMANAGER,
1203 "Calling provider.execQuery: %s",
1204 (const char*)pr.getName().getCString()));
1207 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
1209 StatProviderTimeMeasurement providerTime(response);
1211 rc = pr.getInstMI()->ft->execQuery(
1221 TRC_PROVIDERMANAGER,
1223 "Returning from provider.execQuery: %s",
1224 (const char*)pr.getName().getCString()));
1226 // Need to save ContentLanguage value into operation context of response
1227 // Do this before checking rc from provider to throw exception in case
1228 // rc.msg is also localized.
1229 CMPIStatus tmprc={CMPI_RC_OK,NULL};
1231 eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);
1232 if (tmprc.rc == CMPI_RC_OK)
1234 response->operationContext.set(
1235 ContentLanguageListContainer(
1236 ContentLanguageList(
1237 LanguageParser::parseContentLanguageHeader(
1238 CMGetCharsPtr(cldata.value.string, NULL)))));
1239 handler.setContext(response->operationContext);
1241 _throwCIMException(rc, eRes.resError);
1244 HandlerCatch(handler);
1251 Message * CMPIProviderManager::handleAssociatorsRequest(const Message * message)
1254 TRC_PROVIDERMANAGER,
1255 "CMPIProviderManager::handleAssociatorsRequest()");
1257 HandlerIntro(Associators,message,request,response,handler);
1260 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
1261 "CMPIProviderManager::handleAssociatorsRequest"
1262 " - Host name: %s Name space: %s Class name: %s",
1263 (const char*) System::getHostName().getCString(),
1264 (const char*) request->nameSpace.getString().getCString(),
1266 request->objectName.getClassName().getString().getCString()));
1268 Boolean remote=false;
1269 OpProviderHolder ph;
1272 CMPIProvider & pr = _resolveAndGetProvider(
1273 &(request->operationContext),
1278 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL4,
1279 "--- CMPIProviderManager::associators < role: > %s%s",
1280 (const char*)request->role.getCString(),
1281 (const char*)request->assocClass.getString().getCString()));
1283 CMPIStatus rc={CMPI_RC_OK,NULL};
1284 CMPI_ContextOnStack eCtx(request->operationContext);
1285 CMPI_ResultOnStack eRes(handler,pr.getBroker());
1286 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
1287 const CString aClass=request->assocClass.getString().getCString();
1288 const CString rClass=request->resultClass.getString().getCString();
1289 const CString rRole=request->role.getCString();
1290 const CString resRole=request->resultRole.getCString();
1291 CString nameSpace = request->nameSpace.getString().getCString();
1293 request->objectName.getClassName().getString().getCString();
1295 CMPIPropertyList props(request->propertyList);
1299 &(request->operationContext),
1303 request->includeQualifiers,
1304 request->includeClassOrigin,
1307 SCMOInstance * objectPath = getSCMOObjectPathFromRequest(
1308 nameSpace, className, request->objectName);
1310 CMPI_ObjectPathOnStack eRef(objectPath);
1312 CMPIProvider::pm_service_op_lock op_lock(&pr);
1315 TRC_PROVIDERMANAGER,
1317 "Calling provider.associators: %s",
1318 (const char*)pr.getName().getCString()));
1321 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
1323 StatProviderTimeMeasurement providerTime(response);
1325 rc = pr.getAssocMI()->ft->associators(
1334 (const char **)props.getList());
1338 TRC_PROVIDERMANAGER,
1340 "Returning from provider.associators: %s",
1341 (const char*)pr.getName().getCString()));
1343 // Need to save ContentLanguage value into operation context of response
1344 // Do this before checking rc from provider to throw exception in case
1345 // rc.msg is also localized.
1346 CMPIStatus tmprc={CMPI_RC_OK,NULL};
1347 CMPIData cldata = eCtx.ft->getEntry (
1349 CMPIContentLanguage,
1351 if (tmprc.rc == CMPI_RC_OK)
1353 response->operationContext.set(
1354 ContentLanguageListContainer(
1355 ContentLanguageList(
1356 LanguageParser::parseContentLanguageHeader(
1357 CMGetCharsPtr(cldata.value.string, NULL)))));
1358 handler.setContext(response->operationContext);
1360 _throwCIMException(rc, eRes.resError);
1362 HandlerCatch(handler);
1369 Message * CMPIProviderManager::handleAssociatorNamesRequest(
1370 const Message * message)
1373 TRC_PROVIDERMANAGER,
1374 "CMPIProviderManager::handleAssociatorNamesRequest()");
1376 HandlerIntro(AssociatorNames,message,request,response,handler);
1379 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
1380 "CMPIProviderManager::handleAssociatorNamesRequest"
1381 " - Host name: %s Name space: %s Class name: %s",
1382 (const char*) System::getHostName().getCString(),
1383 (const char*) request->nameSpace.getString().getCString(),
1385 request->objectName.getClassName().getString().getCString()));
1387 Boolean remote=false;
1388 OpProviderHolder ph;
1391 CMPIProvider & pr = _resolveAndGetProvider(
1392 &(request->operationContext),
1397 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL4,
1398 "--- CMPIProviderManager::associatorNames -- role: %s< aCls %s",
1399 (const char*)request->role.getCString(),
1400 (const char*)request->assocClass.getString().getCString()));
1402 CMPIStatus rc={CMPI_RC_OK,NULL};
1403 CMPI_ContextOnStack eCtx(request->operationContext);
1404 CMPI_ResultOnStack eRes(handler,pr.getBroker());
1405 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
1406 const CString aClass=request->assocClass.getString().getCString();
1407 const CString rClass=request->resultClass.getString().getCString();
1408 const CString rRole=request->role.getCString();
1409 const CString resRole=request->resultRole.getCString();
1410 CString nameSpace = request->nameSpace.getString().getCString();
1412 request->objectName.getClassName().getString().getCString();
1416 &(request->operationContext),
1424 SCMOInstance * objectPath = getSCMOObjectPathFromRequest(
1425 nameSpace, className, request->objectName);
1427 CMPI_ObjectPathOnStack eRef(objectPath);
1429 CMPIProvider::pm_service_op_lock op_lock(&pr);
1432 TRC_PROVIDERMANAGER,
1434 "Calling provider.associatorNames: %s",
1435 (const char*)pr.getName().getCString()));
1438 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
1440 StatProviderTimeMeasurement providerTime(response);
1442 rc = pr.getAssocMI()->ft->associatorNames(
1454 TRC_PROVIDERMANAGER,
1456 "Returning from provider.associatorNames: %s",
1457 (const char*)pr.getName().getCString()));
1459 // Need to save ContentLanguage value into operation context of response
1460 // Do this before checking rc from provider to throw exception in case
1461 // rc.msg is also localized.
1462 CMPIStatus tmprc={CMPI_RC_OK,NULL};
1464 eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);
1465 if (tmprc.rc == CMPI_RC_OK)
1467 response->operationContext.set(
1468 ContentLanguageListContainer(
1469 ContentLanguageList(
1470 LanguageParser::parseContentLanguageHeader(
1471 CMGetCharsPtr(cldata.value.string, NULL)))));
1472 handler.setContext(response->operationContext);
1474 _throwCIMException(rc, eRes.resError);
1476 HandlerCatch(handler);
1483 Message * CMPIProviderManager::handleReferencesRequest(const Message * message)
1486 TRC_PROVIDERMANAGER,
1487 "CMPIProviderManager::handleReferencesRequest()");
1489 HandlerIntro(References,message,request,response,handler);
1492 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
1493 "CMPIProviderManager::handleReferencesRequest"
1494 " - Host name: %s Name space: %s Class name: %s",
1495 (const char*) System::getHostName().getCString(),
1496 (const char*) request->nameSpace.getString().getCString(),
1498 request->objectName.getClassName().getString().getCString()));
1500 Boolean remote=false;
1501 OpProviderHolder ph;
1504 CMPIProvider & pr = _resolveAndGetProvider(
1505 &(request->operationContext),
1510 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL4,
1511 "--- CMPIProviderManager::references -- role:%s< aCls %s",
1512 (const char*)request->role.getCString(),
1513 (const char*)request->resultClass.getString().getCString()));
1515 CMPIStatus rc={CMPI_RC_OK,NULL};
1516 CMPI_ContextOnStack eCtx(request->operationContext);
1517 CMPI_ResultOnStack eRes(handler,pr.getBroker());
1518 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
1519 const CString rClass=request->resultClass.getString().getCString();
1520 const CString rRole=request->role.getCString();
1521 CString nameSpace = request->nameSpace.getString().getCString();
1523 request->objectName.getClassName().getString().getCString();
1525 CMPIPropertyList props(request->propertyList);
1529 &(request->operationContext),
1533 request->includeQualifiers,
1534 request->includeClassOrigin,
1537 SCMOInstance * objectPath = getSCMOObjectPathFromRequest(
1538 nameSpace, className, request->objectName);
1540 CMPI_ObjectPathOnStack eRef(objectPath);
1542 CMPIProvider::pm_service_op_lock op_lock(&pr);
1545 TRC_PROVIDERMANAGER,
1547 "Calling provider.references: %s",
1548 (const char*)pr.getName().getCString()));
1551 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
1553 StatProviderTimeMeasurement providerTime(response);
1555 rc = pr.getAssocMI()->ft->references(
1562 (const char **)props.getList());
1566 TRC_PROVIDERMANAGER,
1568 "Returning from provider.references: %s",
1569 (const char*)pr.getName().getCString()));
1571 // Need to save ContentLanguage value into operation context of response
1572 // Do this before checking rc from provider to throw exception in case
1573 // rc.msg is also localized.
1574 CMPIStatus tmprc={CMPI_RC_OK,NULL};
1576 eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);
1577 if (tmprc.rc == CMPI_RC_OK)
1579 response->operationContext.set(
1580 ContentLanguageListContainer(
1581 ContentLanguageList(
1582 LanguageParser::parseContentLanguageHeader(
1583 CMGetCharsPtr(cldata.value.string, NULL)))));
1584 handler.setContext(response->operationContext);
1586 _throwCIMException(rc, eRes.resError);
1588 HandlerCatch(handler);
1595 Message * CMPIProviderManager::handleReferenceNamesRequest(
1596 const Message * message)
1599 TRC_PROVIDERMANAGER,
1600 "CMPIProviderManager::handleReferenceNamesRequest()");
1602 HandlerIntro(ReferenceNames,message,request,response,handler);
1605 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
1606 "CMPIProviderManager::handleReferenceNamesRequest"
1607 " - Host name: %s Name space: %s Class name: %s",
1608 (const char*) System::getHostName().getCString(),
1609 (const char*) request->nameSpace.getString().getCString(),
1611 request->objectName.getClassName().getString().getCString()));
1613 Boolean remote=false;
1614 OpProviderHolder ph;
1617 CMPIProvider & pr = _resolveAndGetProvider(
1618 &(request->operationContext),
1623 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL4,
1624 "--- CMPIProviderManager::referenceNames -- role: %s< aCls %s",
1625 (const char*)request->role.getCString(),
1626 (const char*)request->resultClass.getString().getCString()));
1628 CMPIStatus rc={CMPI_RC_OK,NULL};
1629 CMPI_ContextOnStack eCtx(request->operationContext);
1630 CMPI_ResultOnStack eRes(handler,pr.getBroker());
1631 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
1632 const CString rClass=request->resultClass.getString().getCString();
1633 const CString rRole=request->role.getCString();
1635 CString nameSpace = request->nameSpace.getString().getCString();
1637 request->objectName.getClassName().getString().getCString();
1641 &(request->operationContext),
1649 SCMOInstance * objectPath = getSCMOObjectPathFromRequest(
1650 nameSpace, className, request->objectName);
1652 CMPI_ObjectPathOnStack eRef(objectPath);
1654 CMPIProvider::pm_service_op_lock op_lock(&pr);
1657 TRC_PROVIDERMANAGER,
1659 "Calling provider.referenceNames: %s",
1660 (const char*)pr.getName().getCString()));
1663 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
1665 StatProviderTimeMeasurement providerTime(response);
1667 rc = pr.getAssocMI()->ft->referenceNames(
1677 TRC_PROVIDERMANAGER,
1679 "Returning from provider.referenceNames: %s",
1680 (const char*)pr.getName().getCString()));
1682 // Need to save ContentLanguage value into operation context of response
1683 // Do this before checking rc from provider to throw exception in case
1684 // rc.msg is also localized.
1685 CMPIStatus tmprc={CMPI_RC_OK,NULL};
1687 eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);
1688 if (tmprc.rc == CMPI_RC_OK)
1690 response->operationContext.set(
1691 ContentLanguageListContainer(
1692 ContentLanguageList(
1693 LanguageParser::parseContentLanguageHeader(
1694 CMGetCharsPtr(cldata.value.string, NULL)))));
1695 handler.setContext(response->operationContext);
1697 _throwCIMException(rc, eRes.resError);
1699 HandlerCatch(handler);
1706 Message * CMPIProviderManager::handleInvokeMethodRequest(
1707 const Message * message)
1710 TRC_PROVIDERMANAGER,
1711 "CMPIProviderManager::handleInvokeMethodRequest()");
1713 HandlerIntro(InvokeMethod,message,request,response,handler);
1716 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
1717 "CMPIProviderManager::handleInvokeMethodRequest"
1718 " - Host name: %s Name space: %s Class name: %s",
1719 (const char*) System::getHostName().getCString(),
1720 (const char*) request->nameSpace.getString().getCString(),
1722 request->instanceName.getClassName().getString().getCString()));
1724 Boolean remote=false;
1725 OpProviderHolder ph;
1728 CMPIProvider & pr = _resolveAndGetProvider(
1729 &(request->operationContext),
1734 CMPIStatus rc={CMPI_RC_OK,NULL};
1735 CMPI_ContextOnStack eCtx(request->operationContext);
1736 CMPI_ResultOnStack eRes(handler,pr.getBroker());
1737 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
1738 CMPI_ArgsOnStack eArgsIn(request->inParameters);
1739 Array<CIMParamValue> outArgs;
1740 CMPI_ArgsOnStack eArgsOut(outArgs);
1741 CString mName=request->methodName.getString().getCString();
1742 CString nameSpace = request->nameSpace.getString().getCString();
1743 CString className = request->className.getString().getCString();
1747 &(request->operationContext),
1756 SCMOInstance * objectPath = getSCMOObjectPathFromRequest(
1757 nameSpace, className, request->instanceName);
1759 CMPI_ObjectPathOnStack eRef(objectPath);
1761 CMPIProvider::pm_service_op_lock op_lock(&pr);
1764 TRC_PROVIDERMANAGER,
1766 "Calling provider.invokeMethod: %s",
1767 (const char*)pr.getName().getCString()));
1770 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
1772 StatProviderTimeMeasurement providerTime(response);
1774 rc = pr.getMethMI()->ft->invokeMethod(
1785 TRC_PROVIDERMANAGER,
1787 "Returning from provider.invokeMethod: %s",
1788 (const char*)pr.getName().getCString()));
1790 // Need to save ContentLanguage value into operation context of response
1791 // Do this before checking rc from provider to throw exception in case
1792 // rc.msg is also localized.
1793 CMPIStatus tmprc={CMPI_RC_OK,NULL};
1795 eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);
1796 if (tmprc.rc == CMPI_RC_OK)
1798 response->operationContext.set(
1799 ContentLanguageListContainer(
1800 ContentLanguageList(
1801 LanguageParser::parseContentLanguageHeader(
1802 CMGetCharsPtr(cldata.value.string, NULL)))));
1803 handler.setContext(response->operationContext);
1805 _throwCIMException(rc, eRes.resError);
1807 // Even if external normalization is enabled we don't normalize the
1808 // Embedded instances present in output args. Normalize them here.
1810 // There is no try catch here because if there is no external
1811 // normalization, then these containers were added by this method.
1812 const CachedClassDefinitionContainer * classCont =
1813 dynamic_cast<const CachedClassDefinitionContainer *>(
1814 &request->operationContext.get(
1815 CachedClassDefinitionContainer::NAME));
1816 PEGASUS_ASSERT(classCont != 0);
1818 CIMConstClass classDef(classCont->getClass());
1819 Uint32 methodIndex = classDef.findMethod(request->methodName);
1820 CIMConstMethod methodDef;
1821 if (methodIndex != PEG_NOT_FOUND)
1823 methodDef = classDef.getMethod(methodIndex);
1825 for (unsigned int i = 0, n = outArgs.size(); i < n; ++i)
1827 CIMParamValue currentParam(outArgs[i]);
1828 CIMValue paramValue(currentParam.getValue());
1829 // If the parameter value is an EmbeddedObject type, we have
1830 // to check against the type of the parameter definition.
1831 // CMPI does not distinguish between EmbeddedObjects and
1832 // EmbeddedInstances, so if the parameter definition has a type
1833 // of EmbeddedInstance, the type of the output parameter must
1835 if (paramValue.getType() == CIMTYPE_OBJECT &&
1836 methodIndex != PEG_NOT_FOUND)
1838 String currentParamName(currentParam.getParameterName());
1839 Uint32 paramIndex = methodDef.findParameter(
1840 CIMName(currentParamName));
1841 if (paramIndex == PEG_NOT_FOUND)
1843 MessageLoaderParms msg("ProviderManager.CMPI."
1844 "CMPIProviderManager.PARAMETER_NOT_FOUND",
1845 "Parameter $0 not found in definition for "
1846 "method $1.", currentParamName,
1847 request->methodName.getString());
1849 PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1,
1850 "Parameter %s not found in definition for "
1852 (const char*)currentParamName.getCString(),
1854 request->methodName.getString().getCString()));
1856 handler.setStatus(CIM_ERR_FAILED,
1857 MessageLoader::getMessage(msg));
1861 CIMConstParameter paramDef(
1862 methodDef.getParameter(paramIndex));
1863 if (paramDef.findQualifier(
1864 PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE)
1867 if (paramValue.isArray())
1869 Array<CIMInstance> paramInstArr;
1870 Array<CIMObject> paramObjectArr;
1871 paramValue.get(paramObjectArr);
1873 j < paramObjectArr.size() ; ++j)
1875 paramInstArr.append(
1876 CIMInstance(paramObjectArr[j]));
1878 currentParam = CIMParamValue(currentParamName,
1879 CIMValue(paramInstArr));
1883 CIMObject paramObject;
1884 paramValue.get(paramObject);
1885 CIMInstance paramInst(paramObject);
1886 currentParam = CIMParamValue(currentParamName,
1887 CIMValue(paramInst));
1892 currentParam = CIMParamValue(currentParamName,
1896 handler.deliverParamValue(currentParam);
1901 handler.deliverParamValue(currentParam);
1907 HandlerCatch(handler);
1914 int LocateIndicationProviderNames(
1915 const CIMInstance& pInstance,
1916 const CIMInstance& pmInstance,
1917 String& providerName,
1921 TRC_PROVIDERMANAGER,
1922 "CMPIProviderManager:LocateIndicationProviderNames()");
1923 Uint32 pos = pInstance.findProperty(PEGASUS_PROPERTYNAME_NAME);
1924 pInstance.getProperty(pos).getValue().get(providerName);
1926 pos = pmInstance.findProperty(CIMName ("Location"));
1927 pmInstance.getProperty(pos).getValue().get(location);
1932 String CMPIProviderManager::_getClassNameFromQuery(
1933 CIMOMHandleQueryContext *context,
1941 QueryExpression qe(lang, query, *context);
1942 // Neither WQL nor CQL support joins, we should get only
1943 // one class path here.
1944 PEGASUS_ASSERT(qe.getClassPathList().size() == 1);
1945 className = qe.getClassPathList()[0].getClassName().getString();
1947 catch(QueryException&)
1949 // We should never get query parsing exceptions, IndicationService
1950 // already performed this checking.
1956 void CMPIProviderManager::_throwCIMException(
1958 CMPI_Error* cmpiError)
1960 if (rc.rc!=CMPI_RC_OK)
1962 CIMException cimException(
1963 (CIMStatusCode)rc.rc,
1964 rc.msg ? CMGetCharsPtr(rc.msg, NULL) : String::EMPTY);
1967 for (CMPI_Error* currErr=cmpiError;
1969 currErr=currErr->nextError)
1971 cimException.addError(
1972 ((CIMError*)currErr->hdl)->getInstance());
1980 Message * CMPIProviderManager::handleCreateSubscriptionRequest(
1981 const Message * message)
1984 TRC_PROVIDERMANAGER,
1985 "CMPIProviderManager::handleCreateSubscriptionRequest()");
1987 HandlerIntroInd(CreateSubscription,message,request,response,
1991 CIMInstance req_provider, req_providerModule;
1992 ProviderIdContainer pidc =
1993 (ProviderIdContainer)request->operationContext.get(
1994 ProviderIdContainer::NAME);
1995 req_provider = pidc.getProvider();
1996 req_providerModule = pidc.getModule();
1998 String providerName,providerLocation;
1999 LocateIndicationProviderNames(req_provider, req_providerModule,
2000 providerName,providerLocation);
2002 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
2003 "CMPIProviderManager::handleCreateSubscriptionRequest"
2004 " - Host name: %s Name space: %s Provider name(s): %s",
2005 (const char*) System::getHostName().getCString(),
2006 (const char*) request->nameSpace.getString().getCString(),
2007 (const char*) providerName.getCString()));
2009 Boolean remote=false;
2010 OpProviderHolder ph;
2013 CMPIProvider & pr = _resolveAndGetProvider(
2014 &(request->operationContext),
2020 // Save the provider instance from the request
2022 pr.setProviderInstance (req_provider);
2024 CIMObjectPath subscriptionName =
2025 request->subscriptionInstance.getPath();
2027 CMPIStatus rc={CMPI_RC_OK,NULL};
2028 CMPI_ContextOnStack eCtx(request->operationContext);
2029 SubscriptionFilterConditionContainer sub_cntr =
2030 request->operationContext.get(
2031 SubscriptionFilterConditionContainer::NAME);
2033 CIMOMHandleQueryContext _context(
2035 request->nameSpace.getString()),
2036 *pr.getCIMOMHandle());
2038 CMPI_SelectExp *eSelx=new CMPI_SelectExp(
2039 request->operationContext,
2042 sub_cntr.getQueryLanguage());
2044 IndProvRecord *indProvRec=NULL;
2045 const CIMObjectPath &sPath=request->subscriptionInstance.getPath();
2048 WriteLock lock(rwSemProvTab);
2049 indProvTab.lookup(pr.getName(), indProvRec);
2050 if (indProvRec == NULL)
2052 indProvRec = new IndProvRecord();
2053 #ifdef PEGASUS_ENABLE_REMOTE_CMPI
2056 indProvRec->setRemoteInfo((const char*)remoteInfo);
2059 indProvTab.insert(pr.getName(), indProvRec);
2061 // Note that per provider subscription path MUST be unique.
2062 Boolean ok = indProvRec->addSelectExp(sPath, eSelx);
2067 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
2069 String lang(sub_cntr.getQueryLanguage());
2070 CString className = _getClassNameFromQuery(
2074 CString nameSpace = request->nameSpace.getString().getCString();
2076 CIMObjectPath indClassPath(
2077 System::getHostName(),
2079 (const char*)className);
2081 eSelx->classNames.append(indClassPath);
2083 SCMOInstance * indClassPathSCMO =
2084 getSCMOClassFromRequest(nameSpace, className);
2085 indClassPathSCMO->setHostName(
2086 (const char*)System::getHostName().getCString());
2087 eSelx->classNamesSCMO.append(*indClassPathSCMO);
2088 delete indClassPathSCMO;
2090 CIMPropertyList propertyList = request->propertyList;
2091 if (!propertyList.isNull())
2093 Array<CIMName> p=propertyList.getPropertyNameArray();
2094 int pCount=p.size();
2095 eSelx->props = new const char*[1+pCount];
2096 for (int i=0; i<pCount; i++)
2098 eSelx->props[i]=strdup(p[i].getString().getCString());
2100 eSelx->props[pCount]=NULL;
2103 // includeQualifiers and includeClassOrigin not of interest for
2104 // this type of request
2107 &(request->operationContext),
2112 CMPIProvider::pm_service_op_lock op_lock(&pr);
2115 TRC_PROVIDERMANAGER,
2117 "Calling provider.createSubscriptionRequest: %s",
2118 (const char*)pr.getName().getCString()));
2120 Boolean filterActivated = false;
2122 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
2124 StatProviderTimeMeasurement providerTime(response);
2126 // Call activateFilter() on each subclass name, Check if atleast one
2127 // filter can be activated for any of the subclasses.
2128 for (Uint32 i = 0, n = request->classNames.size(); i < n; i++)
2130 CString subClassName =
2131 request->classNames[i].getString().getCString();
2133 // make target object paths
2134 CIMObjectPath classPath(
2135 System::getHostName(),
2137 request->classNames[i]);
2139 SCMOInstance * classPathSCMO =
2140 getSCMOClassFromRequest(nameSpace, className);
2141 classPathSCMO->setHostName(
2142 (const char*)System::getHostName().getCString());
2143 CMPI_ObjectPathOnStack eRef(classPathSCMO);
2145 if (pr.getIndMI()->ft->ftVersion >= 100)
2147 rc = pr.getIndMI()->ft->activateFilter(
2157 // Older version of (pre 1.00) also pass in a CMPIResult
2159 rc = ((CMPIStatus (*)(
2166 CMPIBoolean))pr.getIndMI()->ft->activateFilter)
2176 if (rc.rc == CMPI_RC_OK)
2178 filterActivated = true;
2179 eSelx->classNames.append(classPath);
2180 eSelx->classNamesSCMO.append(*classPathSCMO);
2185 TRC_PROVIDERMANAGER,
2187 "activateFilter() for class %s in namespace %s "
2188 "failed. Error : %s",
2189 CHARS(classPath.getClassName().
2190 getString().getCString()),
2191 CHARS(request->nameSpace.getString().getCString()),
2192 rc.msg ? CMGetCharsPtr(rc.msg, NULL) : "Unknown"));
2198 TRC_PROVIDERMANAGER,
2200 "Returning from provider.createSubscriptionRequest: %s",
2201 (const char*)pr.getName().getCString()));
2203 // Need to save ContentLanguage value into operation context of response
2204 // Do this before checking rc from provider to throw exception in case
2205 // rc.msg is also localized.
2206 CMPIStatus tmprc={CMPI_RC_OK,NULL};
2208 eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);
2209 if (tmprc.rc == CMPI_RC_OK)
2211 response->operationContext.set(
2212 ContentLanguageListContainer(
2213 ContentLanguageList(
2214 LanguageParser::parseContentLanguageHeader(
2215 CMGetCharsPtr(cldata.value.string, NULL)))));
2218 if (!filterActivated)
2220 // Remove the select expression from the cache
2221 WriteLock lock(rwSemProvTab);
2222 Boolean ok = indProvRec->deleteSelectExp(sPath);
2225 throw CIMException((CIMStatusCode)rc.rc,
2226 rc.msg ? CMGetCharsPtr(rc.msg, NULL) : String::EMPTY);
2231 // Increment count of current subscriptions for this provider
2233 if (ph.GetProvider ().testIfZeroAndIncrementSubscriptions ())
2236 // If there were no current subscriptions before the increment,
2237 // the first subscription has been created
2238 // Call the provider's enableIndications method
2240 if (_subscriptionInitComplete)
2242 _callEnableIndications (req_provider, _indicationCallback,
2243 ph, (const char*)pidc.getRemoteInfo().getCString());
2248 HandlerCatch(handler);
2255 Message * CMPIProviderManager::handleDeleteSubscriptionRequest(
2256 const Message * message)
2259 TRC_PROVIDERMANAGER,
2260 "CMPIProviderManager::handleDeleteSubscriptionRequest()");
2262 HandlerIntroInd(DeleteSubscription,message,request,response,
2266 String providerName,providerLocation;
2268 CIMInstance req_provider, req_providerModule;
2269 ProviderIdContainer pidc =
2270 (ProviderIdContainer)request->operationContext.get(
2271 ProviderIdContainer::NAME);
2272 req_provider = pidc.getProvider();
2273 req_providerModule = pidc.getModule();
2275 LocateIndicationProviderNames(req_provider, req_providerModule,
2276 providerName,providerLocation);
2278 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
2279 "CMPIProviderManager::handleDeleteSubscriptionRequest"
2280 " - Host name: %s Name space: %s Provider name(s): %s",
2281 (const char*) System::getHostName().getCString(),
2282 (const char*) request->nameSpace.getString().getCString(),
2283 (const char*) providerName.getCString()));
2285 Boolean remote=false;
2286 OpProviderHolder ph;
2289 CMPIProvider & pr = _resolveAndGetProvider(
2290 &(request->operationContext),
2295 const CIMObjectPath &sPath=request->subscriptionInstance.getPath();
2296 IndProvRecord *indProvRec=NULL;
2297 CMPI_SelectExp *eSelx=NULL;
2299 WriteLock lock(rwSemProvTab);
2300 indProvTab.lookup(pr.getName(),indProvRec);
2301 if (!indProvRec->lookupSelectExp(sPath, eSelx))
2303 MessageLoaderParms parms(
2304 "ProviderManager.CMPI.CMPIProviderManager."
2305 "FAILED_LOCATE_SUBSCRIPTION_FILTER",
2306 "Failed to locate the subscription filter.");
2307 // failed to get select expression from hash table
2308 throw CIMException(CIM_ERR_FAILED, parms);
2310 Boolean ok = indProvRec->deleteSelectExp(sPath);
2314 CString className = eSelx->classNames[0].getClassName().
2315 getString().getCString();
2317 CIMObjectPath subscriptionName =
2318 request->subscriptionInstance.getPath();
2320 CMPIStatus rc={CMPI_RC_OK,NULL};
2321 CMPI_ContextOnStack eCtx(request->operationContext);
2322 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
2324 CString nameSpace = request->nameSpace.getString().getCString();
2326 // includeQualifiers and includeClassOrigin not of interest for
2327 // this type of request
2330 &(request->operationContext),
2335 CMPIProvider::pm_service_op_lock op_lock(&pr);
2338 TRC_PROVIDERMANAGER,
2340 "Calling provider.deleteSubscriptionRequest: %s",
2341 (const char*)pr.getName().getCString()));
2344 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
2346 StatProviderTimeMeasurement providerTime(response);
2348 // Call deactivateFilter() for each subclass name those were
2349 // activated previously using activateFilter().
2350 // Note: Start from Index 1, first name is actual class name in
2351 // the FROM clause of filter query.
2352 for (Uint32 i = 1, n = eSelx->classNames.size(); i < n ; ++i)
2354 CMPI_ObjectPathOnStack eRef(eSelx->classNamesSCMO[i]);
2355 if (pr.getIndMI()->ft->ftVersion >= 100)
2357 rc = pr.getIndMI()->ft->deActivateFilter(
2367 // Older version of (pre 1.00) also pass in a CMPIResult
2369 rc = ((CMPIStatus (*)(
2376 CMPIBoolean)) pr.getIndMI()->ft->deActivateFilter)(
2385 if (rc.rc != CMPI_RC_OK)
2388 TRC_PROVIDERMANAGER,
2390 "deactivateFilter() for class %s in namespace %s"
2391 "failed. Error : %s",
2392 CHARS(eSelx->classNames[i].getClassName().
2393 getString().getCString()),
2394 CHARS(request->nameSpace.getString().getCString()),
2395 rc.msg ? CMGetCharsPtr(rc.msg, NULL) : "Unknown"));
2401 TRC_PROVIDERMANAGER,
2403 "Returning from provider.deleteSubscriptionRequest: %s",
2404 (const char*)pr.getName().getCString()));
2408 // Need to save ContentLanguage value into operation context of response
2409 // Do this before checking rc from provider to throw exception in case
2410 // rc.msg is also localized.
2411 CMPIStatus tmprc={CMPI_RC_OK,NULL};
2413 eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);
2414 if (tmprc.rc == CMPI_RC_OK)
2416 response->operationContext.set(
2417 ContentLanguageListContainer(
2418 ContentLanguageList(
2419 LanguageParser::parseContentLanguageHeader(
2420 CMGetCharsPtr(cldata.value.string, NULL)))));
2423 if (rc.rc!=CMPI_RC_OK)
2425 throw CIMException((CIMStatusCode)rc.rc,
2426 rc.msg ? CMGetCharsPtr(rc.msg, NULL) : String::EMPTY);
2431 // Decrement count of current subscriptions for this provider
2433 if (pr.decrementSubscriptionsAndTestIfZero ())
2435 Boolean callDisable = false;
2437 WriteLock lock(rwSemProvTab);
2438 if (!indProvRec->getSelectExpCount())
2440 indProvTab.remove(pr.getName());
2447 // If there are no current subscriptions after the decrement,
2448 // the last subscription has been deleted
2449 // Call the provider's disableIndications method
2451 if (_subscriptionInitComplete && callDisable)
2453 _callDisableIndications(
2455 (const char*)pidc.getRemoteInfo().getCString());
2460 HandlerCatch(handler);
2467 Message * CMPIProviderManager::handleDisableModuleRequest(
2468 const Message * message)
2471 TRC_PROVIDERMANAGER,
2472 "CMPIProviderManager::handleDisableModuleRequest()");
2474 CIMDisableModuleRequestMessage * request =
2475 dynamic_cast<CIMDisableModuleRequestMessage *>(
2476 const_cast<Message *>(message));
2478 PEGASUS_ASSERT(request != 0);
2480 //Set to false when provider refused to unload due to pending operations.
2481 Boolean disableModuleOk = true;
2483 // get provider module name
2484 Boolean disableProviderOnly = request->disableProviderOnly;
2489 Array<CIMInstance> _pInstances = request->providers;
2490 Array <Boolean> _indicationProviders = request->indicationProviders;
2491 /* The CIMInstances on request->providers array is completly _different_
2492 than the request->providerModule CIMInstance. Hence */
2494 String physicalName=(request->providerModule.getProperty(
2496 providerModule.findProperty("Location")).getValue().toString());
2498 String moduleName= request->providerModule.getProperty(
2499 request->providerModule.findProperty("Name")).getValue().toString();
2501 for (Uint32 i = 0, n = _pInstances.size(); i < n; i++)
2503 String providerName;
2504 _pInstances[i].getProperty(_pInstances [i].findProperty
2505 (PEGASUS_PROPERTYNAME_NAME)).getValue().get(providerName);
2507 Uint32 pos = _pInstances[i].findProperty(PEGASUS_PROPERTYNAME_NAME);
2509 if (!providerManager.isProviderActive(providerName, moduleName))
2514 Boolean unloadOk = providerManager.unloadProvider(
2516 _pInstances[i].getProperty(
2517 _pInstances[i].findProperty(PEGASUS_PROPERTYNAME_NAME)
2518 ).getValue ().toString (),
2523 disableModuleOk = false;
2527 // Reset the indication provider's count of current
2528 // subscriptions since it has been disabled
2530 if (_indicationProviders [i])
2532 if (physicalName.size () > 0)
2536 OpProviderHolder ph =
2537 providerManager.getProvider(
2541 ph.GetProvider ().resetSubscriptions ();
2543 // Remove from IndProvRecord table
2544 IndProvRecord *rec = 0;
2545 WriteLock lock(rwSemProvTab);
2546 indProvTab.lookup(ph.GetProvider().getName(), rec);
2548 indProvTab.remove(ph.GetProvider().getName());
2550 catch (const Exception &e)
2552 PEG_TRACE((TRC_PROVIDERMANAGER, Tracer::LEVEL1,
2553 "Exception during reset subscriptions on indication "
2555 (const char*)providerName.getCString(),
2556 (const char*)e.getMessage().getCString()));
2562 CIMDisableModuleResponseMessage* response =
2563 dynamic_cast<CIMDisableModuleResponseMessage*>(
2564 request->buildResponse());
2565 PEGASUS_ASSERT(response != 0);
2567 if (disableModuleOk)
2569 response->operationalStatus.append(
2570 CIM_MSE_OPSTATUS_VALUE_STOPPED);
2574 response->operationalStatus.append(
2575 CIM_MSE_OPSTATUS_VALUE_OK);
2583 Message * CMPIProviderManager::handleEnableModuleRequest(
2584 const Message * message)
2587 TRC_PROVIDERMANAGER,
2588 "CMPIProviderManager::handleEnableModuleRequest()");
2590 CIMEnableModuleRequestMessage * request =
2591 dynamic_cast<CIMEnableModuleRequestMessage *>(
2592 const_cast<Message *>(message));
2594 PEGASUS_ASSERT(request != 0);
2596 Array<Uint16> operationalStatus;
2597 operationalStatus.append(CIM_MSE_OPSTATUS_VALUE_OK);
2599 CIMEnableModuleResponseMessage* response =
2600 dynamic_cast<CIMEnableModuleResponseMessage*>(
2601 request->buildResponse());
2602 PEGASUS_ASSERT(response != 0);
2603 response->operationalStatus = operationalStatus;
2610 Message * CMPIProviderManager::handleStopAllProvidersRequest(
2611 const Message * message)
2614 TRC_PROVIDERMANAGER,
2615 "CMPIProviderManager::handleStopAllProvidersRequest()");
2617 CIMStopAllProvidersRequestMessage * request =
2618 dynamic_cast<CIMStopAllProvidersRequestMessage *>(
2619 const_cast<Message *>(message));
2621 PEGASUS_ASSERT(request != 0);
2623 CIMStopAllProvidersResponseMessage* response =
2624 dynamic_cast<CIMStopAllProvidersResponseMessage*>(
2625 request->buildResponse());
2626 PEGASUS_ASSERT(response != 0);
2628 // tell the provider manager to shutdown all the providers
2629 providerManager.shutdownAllProviders();
2636 Message* CMPIProviderManager::handleIndicationServiceDisabledRequest(
2639 PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,
2640 "CMPIProviderManager::_handleIndicationServiceDisabledRequest");
2642 CIMIndicationServiceDisabledRequestMessage* request =
2643 dynamic_cast<CIMIndicationServiceDisabledRequestMessage*>(message);
2644 PEGASUS_ASSERT(request != 0);
2646 CIMIndicationServiceDisabledResponseMessage* response =
2647 dynamic_cast<CIMIndicationServiceDisabledResponseMessage*>(
2648 request->buildResponse());
2649 PEGASUS_ASSERT(response != 0);
2651 _subscriptionInitComplete = false;
2657 Message * CMPIProviderManager::handleSubscriptionInitCompleteRequest(
2658 const Message * message)
2661 TRC_PROVIDERMANAGER,
2662 "CMPIProviderManager::handleSubscriptionInitCompleteRequest()");
2664 CIMSubscriptionInitCompleteRequestMessage * request =
2665 dynamic_cast <CIMSubscriptionInitCompleteRequestMessage *>
2666 (const_cast <Message *> (message));
2668 PEGASUS_ASSERT (request != 0);
2670 CIMSubscriptionInitCompleteResponseMessage * response =
2671 dynamic_cast <CIMSubscriptionInitCompleteResponseMessage *>
2672 (request->buildResponse ());
2674 PEGASUS_ASSERT (response != 0);
2679 _subscriptionInitComplete = true;
2682 // For each provider that has at least one subscription, call
2683 // provider's enableIndications method
2685 Array <CMPIProvider *> enableProviders;
2686 enableProviders = providerManager.getIndicationProvidersToEnable ();
2688 Uint32 numProviders = enableProviders.size ();
2689 for (Uint32 i = 0; i < numProviders; i++)
2693 CIMInstance provider;
2694 provider = enableProviders [i]->getProviderInstance ();
2697 #ifdef PEGASUS_ENABLE_REMOTE_CMPI
2698 IndProvRecord *provRec = 0;
2699 if (indProvTab.lookup (enableProviders [i]->getName(), provRec))
2701 if (provRec->getRemoteInfo() != String::EMPTY)
2703 info = provRec->getRemoteInfo().getCString();
2708 // Get cached or load new provider module
2710 OpProviderHolder ph;
2711 if ((const char*)info)
2713 ph = providerManager.getRemoteProvider
2714 (enableProviders [i]->getModule ()->getFileName (),
2715 enableProviders [i]->getName (),
2716 enableProviders[i]->getModuleName());
2720 ph = providerManager.getProvider
2721 (enableProviders [i]->getModule ()->getFileName (),
2722 enableProviders [i]->getName (),
2723 enableProviders[i]->getModuleName());
2725 _callEnableIndications(
2727 _indicationCallback,
2731 catch (const CIMException & e)
2733 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL1,
2734 "CIMException: %s",(const char*)e.getMessage().getCString()));
2736 catch (const Exception & e)
2738 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL1,
2739 "Exception: %s",(const char*)e.getMessage().getCString()));
2744 TRC_PROVIDERMANAGER,
2746 "Unknown error in handleSubscriptionInitCompleteRequest");
2754 Message * CMPIProviderManager::handleGetPropertyRequest(
2755 const Message * message)
2758 TRC_PROVIDERMANAGER,
2759 "CMPIProviderManager::handleGetPropertyRequest()");
2761 HandlerIntro(GetProperty,message,request,response,handler);
2763 // We're only going to be interested in the specific property from this
2765 Array<CIMName> localPropertyListArray;
2766 localPropertyListArray.append(request->propertyName);
2767 CIMPropertyList localPropertyList(localPropertyListArray);
2769 // NOTE: GetProperty will use the CIMInstanceProvider interface, so we
2770 // must manually define a request, response, and handler (emulate
2771 // HandlerIntro macro)
2772 CIMGetInstanceRequestMessage * GI_request =
2773 new CIMGetInstanceRequestMessage(
2776 request->instanceName,
2785 PEGASUS_ASSERT(GI_request != 0);
2787 CIMGetInstanceResponseMessage * GI_response =
2788 dynamic_cast<CIMGetInstanceResponseMessage*>
2789 (GI_request->buildResponse());
2791 PEGASUS_ASSERT(GI_response != 0);
2793 GetInstanceResponseHandler GI_handler(
2796 _responseChunkCallback);
2800 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
2801 "CMPIProviderManager::handleGetPropertyRequest"
2802 " - Host name: %s Name space: %s "
2803 "Class name: %s Property name: %s",
2804 (const char*) System::getHostName().getCString(),
2805 (const char*) request->nameSpace.getString().getCString(),
2807 request->instanceName.getClassName().getString().getCString(),
2808 (const char*) request->propertyName.getString().getCString()));
2810 Boolean remote=false;
2811 OpProviderHolder ph;
2814 CMPIProvider & pr = _resolveAndGetProvider(
2815 &(request->operationContext),
2820 AutoPtr<NormalizerContext> tmpNormalizerContext(
2821 new CIMOMHandleContext(*pr.getCIMOMHandle()));
2822 request->operationContext.insert(
2823 NormalizerContextContainer(tmpNormalizerContext));
2825 CMPIStatus rc={CMPI_RC_OK,NULL};
2826 CMPI_ContextOnStack eCtx(request->operationContext);
2827 CMPI_ResultOnStack eRes(GI_handler,pr.getBroker());
2828 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
2830 // For the getInstance provider call, use the property list that we
2831 // created containing the single property from the getProperty call.
2832 CMPIPropertyList props(localPropertyList);
2834 CString nameSpace = request->nameSpace.getString().getCString();
2836 request->instanceName.getClassName().getString().getCString();
2838 // Leave includeQualifiers and includeClassOrigin as false for this
2839 // call to getInstance
2842 &(request->operationContext),
2850 SCMOInstance * objectPath = getSCMOObjectPathFromRequest(
2851 nameSpace, className, request->instanceName);
2852 CMPI_ObjectPathOnStack eRef(objectPath);
2854 CMPIProvider::pm_service_op_lock op_lock(&pr);
2857 TRC_PROVIDERMANAGER,
2859 "Calling provider.getInstance via getProperty: %s",
2860 (const char*)pr.getName().getCString()));
2863 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
2865 StatProviderTimeMeasurement providerTime(response);
2867 rc = pr.getInstMI()->ft->getInstance(
2872 (const char **)props.getList());
2876 TRC_PROVIDERMANAGER,
2878 "Returning from provider.getInstance via getProperty: %s",
2879 (const char*)pr.getName().getCString()));
2881 // Need to save ContentLanguage value into operation context of response
2882 // Do this before checking rc from provider to throw exception in case
2883 // rc.msg is also localized.
2884 CMPIStatus tmprc={CMPI_RC_OK,NULL};
2886 eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);
2887 if (tmprc.rc == CMPI_RC_OK)
2889 response->operationContext.set(
2890 ContentLanguageListContainer(
2891 ContentLanguageList(
2892 LanguageParser::parseContentLanguageHeader(
2893 CMGetCharsPtr(cldata.value.string, NULL)))));
2894 handler.setContext(response->operationContext);
2896 _throwCIMException(rc, eRes.resError);
2898 // Copy property value from instance to getProperty response
2899 Array<SCMOInstance>& arInstance =
2900 GI_response->getResponseData().getSCMO();
2901 if (arInstance.size() > 0)
2903 SCMOInstance& instance = arInstance[0];
2904 if(!(instance.isUninitialized()))
2907 request->propertyName.getString().getCString();
2909 // Construct a temporary CMPI Instance object, on which we
2910 // can use the encapsulation functions to retrieve the property.
2911 CMPI_InstanceOnStack tmpInst(instance);
2915 CMGetProperty(&tmpInst, (const char*)pName, &trc);
2917 if (trc.rc == CMPI_RC_OK)
2919 // Convert the CMPIData to a CIMValue
2921 value2CIMValue(&(data.value), data.type, &(trc.rc));
2923 response->value = val;
2925 // Else property not found. Return CIM_ERR_NO_SUCH_PROPERTY.
2928 throw PEGASUS_CIM_EXCEPTION(
2929 CIM_ERR_NO_SUCH_PROPERTY,
2930 request->propertyName.getString());
2935 HandlerCatch(handler);
2945 Message * CMPIProviderManager::handleSetPropertyRequest(
2946 const Message * message)
2949 TRC_PROVIDERMANAGER,
2950 "CMPIProviderManager::handleSetPropertyRequest()");
2952 HandlerIntro(SetProperty,message,request,response,handler);
2954 // We're only going to be interested in the specific property from this
2956 Array<CIMName> localPropertyListArray;
2957 localPropertyListArray.append(request->propertyName);
2958 CIMPropertyList localPropertyList(localPropertyListArray);
2960 // Build a modified instance with just the specific property and its
2962 CIMInstance localModifiedInstance(request->instanceName.getClassName());
2963 localModifiedInstance.setPath(request->instanceName);
2964 localModifiedInstance.addProperty(
2965 CIMProperty(request->propertyName, request->newValue));
2967 // NOTE: SetProperty will use the CIMInstanceProvider interface, so we must
2968 // manually define a request, response, and handler.
2969 CIMModifyInstanceRequestMessage * MI_request =
2970 new CIMModifyInstanceRequestMessage(
2973 localModifiedInstance,
2981 PEGASUS_ASSERT(MI_request != 0);
2983 CIMModifyInstanceResponseMessage * MI_response =
2984 dynamic_cast<CIMModifyInstanceResponseMessage*>(
2985 MI_request->buildResponse());
2987 PEGASUS_ASSERT(MI_response != 0);
2989 ModifyInstanceResponseHandler MI_handler(
2992 _responseChunkCallback);
2996 CString nameSpace = request->nameSpace.getString().getCString();
2998 request->instanceName.getClassName().getString().getCString();
3000 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL3,
3001 "CMPIProviderManager::handleSetPropertyRequest"
3002 " - Host name: %s Name space: %s "
3003 "Class name: %s Property name: %s",
3004 (const char*) System::getHostName().getCString(),
3005 (const char*) nameSpace,
3006 (const char*) className,
3007 (const char*) request->propertyName.getString().getCString()));
3009 Boolean remote=false;
3010 OpProviderHolder ph;
3013 CMPIProvider & pr = _resolveAndGetProvider(
3014 &(request->operationContext),
3019 CMPIStatus rc={CMPI_RC_OK,NULL};
3020 CMPI_ContextOnStack eCtx(request->operationContext);
3021 CMPI_ResultOnStack eRes(MI_handler,pr.getBroker());
3022 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
3024 CMPIPropertyList props(localPropertyList);
3026 // Leave includeQualifiers as false for this call to modifyInstance
3029 &(request->operationContext),
3038 SCMOInstance * modInst = getSCMOInstanceFromRequest(
3039 nameSpace, className, localModifiedInstance);
3040 modInst->setPropertyFilter((const char **)props.getList());
3041 CMPI_InstanceOnStack eInst(modInst);
3043 // This will create a second reference for the same SCMOInstance
3044 CMPI_ObjectPathOnStack eRef(*modInst);
3046 CMPIProvider::pm_service_op_lock op_lock(&pr);
3049 TRC_PROVIDERMANAGER,
3051 "Calling provider.modifyInstance via setProperty: %s",
3052 (const char*)pr.getName().getCString()));
3055 AutoPThreadSecurity threadLevelSecurity(request->operationContext);
3057 StatProviderTimeMeasurement providerTime(response);
3059 rc = pr.getInstMI()->ft->modifyInstance(
3065 (const char **)props.getList());
3069 TRC_PROVIDERMANAGER,
3071 "Returning from provider.modifyInstance via setProperty: %s",
3072 (const char*)pr.getName().getCString()));
3074 // Need to save ContentLanguage value into operation context of response
3075 // Do this before checking rc from provider to throw exception in case
3076 // rc.msg is also localized.
3077 CMPIStatus tmprc={CMPI_RC_OK,NULL};
3079 eCtx.ft->getEntry (&eCtx, CMPIContentLanguage, &tmprc);
3080 if (tmprc.rc == CMPI_RC_OK)
3082 response->operationContext.set(
3083 ContentLanguageListContainer(
3084 ContentLanguageList(
3085 LanguageParser::parseContentLanguageHeader(
3086 CMGetCharsPtr(cldata.value.string, NULL)))));
3087 handler.setContext(response->operationContext);
3089 _throwCIMException(rc, eRes.resError);
3091 HandlerCatch(handler);
3101 Message * CMPIProviderManager::handleUnsupportedRequest(
3102 const Message * message)
3105 TRC_PROVIDERMANAGER,
3106 "CMPIProviderManager::handleUnsupportedRequest()");
3107 CIMRequestMessage* request =
3108 dynamic_cast<CIMRequestMessage *>(const_cast<Message *>(message));
3109 PEGASUS_ASSERT(request != 0 );
3111 CIMResponseMessage* response = request->buildResponse();
3112 response->cimException =
3113 PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, String::EMPTY);
3119 ProviderName CMPIProviderManager::_resolveProviderName(
3120 const ProviderIdContainer & providerId)
3122 String providerName;
3126 CIMValue genericValue;
3129 TRC_PROVIDERMANAGER,
3130 "CMPIProviderManager::_resolveProviderName()");
3132 genericValue = providerId.getModule().getProperty(
3133 providerId.getModule().findProperty(
3134 PEGASUS_PROPERTYNAME_NAME)).getValue();
3135 genericValue.get(moduleName);
3137 genericValue = providerId.getProvider().getProperty(
3138 providerId.getProvider().findProperty(
3139 PEGASUS_PROPERTYNAME_NAME)).getValue();
3140 genericValue.get(providerName);
3142 genericValue = providerId.getModule().getProperty(
3143 providerId.getModule().findProperty("Location")).getValue();
3144 genericValue.get(location);
3145 fileName = _resolvePhysicalName(location);
3147 // An empty file name is only for interest if we are in the
3148 // local name space. So the message is only issued if not
3149 // in the remote Name Space.
3150 if (fileName == String::EMPTY && (!providerId.isRemoteNameSpace()))
3152 genericValue.get(location);
3153 String fullName = FileSystem::buildLibraryFileName(location);
3154 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
3156 "ProviderManager.CMPI.CMPIProviderManager.CANNOT_FIND_LIBRARY",
3157 "For provider $0 library $1 was not found.",
3158 providerName, fullName));
3161 ProviderName name(moduleName, providerName, fileName);
3162 name.setLocation(location);
3167 void CMPIProviderManager::_callEnableIndications
3168 (CIMInstance & req_provider,
3169 PEGASUS_INDICATION_CALLBACK_T _indicationCallback,
3170 OpProviderHolder & ph,
3171 const char* remoteInfo)
3174 TRC_PROVIDERMANAGER,
3175 "CMPIProviderManager::_callEnableIndications()");
3179 IndProvRecord *indProvRec =0;
3181 WriteLock lock(rwSemProvTab);
3183 if (indProvTab.lookup (ph.GetProvider ().getName (),indProvRec))
3185 CIMRequestMessage * request = 0;
3186 CIMResponseMessage * response = 0;
3187 indProvRec->setHandler(new EnableIndicationsResponseHandler(
3191 _indicationCallback,
3192 _responseChunkCallback));
3196 CMPIProvider & pr=ph.GetProvider();
3199 // Versions prior to 86 did not include enableIndications routine
3201 if (pr.getIndMI()->ft->ftVersion >= 86)
3203 OperationContext context;
3204 #ifdef PEGASUS_ZOS_THREADLEVEL_SECURITY
3205 // For the z/OS security model we always need an Identity container
3206 // in the operation context. Since we don't have a client request
3207 // ID here we have to use the cim servers identity for the time
3209 IdentityContainer idContainer(System::getEffectiveUserName());
3210 context.insert(idContainer);
3213 CMPIStatus rc={CMPI_RC_OK,NULL};
3214 CMPI_ContextOnStack eCtx(context);
3215 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
3217 // Add RemoteInformation -V 5245
3220 eCtx.ft->addEntry(&eCtx,"CMPIRRemoteInfo",
3221 (CMPIValue*)(const char*)remoteInfo,CMPI_chars);
3225 TRC_PROVIDERMANAGER,
3227 "Calling provider.enableIndications: %s",
3228 (const char*)pr.getName().getCString()));
3232 // enableIndications() is defined by the CMPI standard as
3233 // returning a CMPIStatus return value. Unfortunately, Pegasus
3234 // originally implemented enableIndications() with a void
3235 // return type, and this incompatibility was not detected for
3236 // some time. Since exceptions thrown from enableIndications()
3237 // are not reported (other than via logging), it was decided to
3238 // discard the returned CMPIStatus here. This will prevent us from
3239 // breaking existing CMPI Indication providers. This is ok since
3240 // there really isn't a user to which the problem should be
3242 pr.getIndMI()->ft->enableIndications(pr.getIndMI(),&eCtx);
3245 TRC_PROVIDERMANAGER,
3247 "Returning from provider.enableIndications: %s",
3248 (const char*)pr.getName().getCString()));
3254 TRC_PROVIDERMANAGER,
3256 "Not calling provider.enableIndications: %s routine as it is "
3257 "an earlier version that does not support this function",
3258 (const char*)pr.getName().getCString()));
3261 catch (const Exception & e)
3263 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::WARNING,
3265 "ProviderManager.CMPI.CMPIProviderManager."
3266 "ENABLE_INDICATIONS_FAILED",
3267 "Failed to enable indications for provider $0: $1.",
3268 ph.GetProvider().getName(), e.getMessage()));
3272 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::WARNING,
3274 "ProviderManager.CMPI.CMPIProviderManager."
3275 "ENABLE_INDICATIONS_FAILED_UNKNOWN",
3276 "Failed to enable indications for provider $0.",
3277 ph.GetProvider().getName()));
3283 void CMPIProviderManager::_callDisableIndications
3284 (OpProviderHolder & ph, const char *remoteInfo)
3287 TRC_PROVIDERMANAGER,
3288 "CMPIProviderManager::_callDisableIndications()");
3292 CMPIProvider & pr=ph.GetProvider();
3295 // Versions prior to 86 did not include disableIndications routine
3297 if (pr.getIndMI()->ft->ftVersion >= 86)
3299 OperationContext context;
3300 CMPIStatus rc={CMPI_RC_OK,NULL};
3301 CMPI_ContextOnStack eCtx(context);
3305 eCtx.ft->addEntry(&eCtx,"CMPIRRemoteInfo",
3306 (CMPIValue*)(const char*)remoteInfo,CMPI_chars);
3308 CMPI_ThreadContext thr(pr.getBroker(),&eCtx);
3310 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL2,
3311 "Calling provider.disableIndications: %s",
3312 (const char*)pr.getName().getCString()));
3314 // disableIndications() is defined by the CMPI standard as
3315 // returning a CMPIStatus return value. Unfortunately, Pegasus
3316 // originally implemented disableIndications() with a void
3317 // return type, and this incompatibility was not detected for
3318 // some time. For consistency with the enableIndications()
3319 // interface, it was decided to discard the returned CMPIStatus
3320 // here. This will prevent us from breaking existing CMPI
3321 // Indication providers. This is ok since there really isn't a
3322 // user to which the problem should be reported.
3323 pr.getIndMI()->ft->disableIndications(
3329 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL2,
3330 "Returning from provider.disableIndications: %s",
3331 (const char*)pr.getName().getCString()));
3336 PEG_TRACE((TRC_PROVIDERMANAGER,Tracer::LEVEL2,
3337 "Not calling provider.disableIndications: %s routine as it is "
3338 "an earlier version that does not support this function",
3339 (const char*)pr.getName().getCString()));
3342 catch (const Exception & e)
3344 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::WARNING,
3346 "ProviderManager.CMPI.CMPIProviderManager."
3347 "DISABLE_INDICATIONS_FAILED",
3348 "Failed to disable indications for provider $0: $1.",
3349 ph.GetProvider().getName(), e.getMessage()));
3353 Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::WARNING,
3355 "ProviderManager.CMPI.CMPIProviderManager."
3356 "DISABLE_INDICATIONS_FAILED_UNKNOWN",
3357 "Failed to disable indications for provider $0.",
3358 ph.GetProvider().getName()));
3364 PEGASUS_NAMESPACE_END