(file) Return to ProviderRegistrationProvider.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ControlProviders / ProviderRegistrationProvider

Diff for /pegasus/src/Pegasus/ControlProviders/ProviderRegistrationProvider/ProviderRegistrationProvider.cpp between version 1.12 and 1.117

version 1.12, 2002/05/15 00:01:46 version 1.117, 2010/10/29 05:29:51
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%LICENSE////////////////////////////////////////////////////////////////
 //  
 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM  
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy  // Licensed to The Open Group (TOG) under one or more contributor license
 // of this software and associated documentation files (the "Software"), to  // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
 // deal in the Software without restriction, including without limitation the  // this work for additional information regarding copyright ownership.
 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  // Each contributor licenses this file to you under the OpenPegasus Open
 // sell copies of the Software, and to permit persons to whom the Software is  // Source License; you may not use this file except in compliance with the
 // furnished to do so, subject to the following conditions:  // License.
 //  //
 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN  // Permission is hereby granted, free of charge, to any person obtaining a
 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED  // copy of this software and associated documentation files (the "Software"),
 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT  // to deal in the Software without restriction, including without limitation
 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR  // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT  // and/or sell copies of the Software, and to permit persons to whom the
 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN  // Software is furnished to do so, subject to the following conditions:
 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  //
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  // The above copyright notice and this permission notice shall be included
 //  // in all copies or substantial portions of the Software.
 //==============================================================================  //
 //  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 // Author: Yi Zhou (yi_zhou@hp.com)  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 //  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 // Modified By: Chip Vincent (cvincent@us.ibm.com)  // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 //              Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)  // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)  // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // //
   //////////////////////////////////////////////////////////////////////////
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include "ProviderRegistrationProvider.h" #include "ProviderRegistrationProvider.h"
Line 34 
Line 34 
 #include <Pegasus/Common/XmlWriter.h> #include <Pegasus/Common/XmlWriter.h>
 #include <Pegasus/Common/Constants.h> #include <Pegasus/Common/Constants.h>
 #include <Pegasus/Common/CIMMessage.h> #include <Pegasus/Common/CIMMessage.h>
   #include <Pegasus/Common/OperationContextInternal.h>
   #include <Pegasus/Common/System.h>
   #include <Pegasus/Common/MessageLoader.h> //l10n
   #include <Pegasus/Common/Constants.h>
   #include <Pegasus/Common/Tracer.h>
   #include <Pegasus/Common/CIMNameCast.h>
  
 PEGASUS_NAMESPACE_BEGIN  #include <Pegasus/Server/ProviderRegistrationManager/ProviderManagerMap.h>
   
 /**  
    The name of the operational status property  
 */  
 static const char _PROPERTY_OPERATIONALSTATUS [] = "OperationalStatus";  
   
 /**  
    The name of the name property for PG_Provider class  
 */  
 static const char _PROPERTY_PROVIDER_NAME [] = "Name";  
   
 /**  
    The name of the Name property for PG_ProviderModule class  
 */  
 static const char _PROPERTY_PROVIDERMODULE_NAME [] = "Name";  
   
 /**  
    The name of the Vendor property for PG_ProviderModule class  
 */  
 static const char _PROPERTY_VENDOR [] = "Vendor";  
   
 /**  
    The name of the Version property for PG_ProviderModule class  
 */  
 static const char _PROPERTY_VERSION [] = "Version";  
   
 /**  
    The name of the interface type property for PG_ProviderModule class  
 */  
 static const char _PROPERTY_INTERFACETYPE [] = "InterfaceType";  
   
 /**  
    The name of the interface version property for PG_ProviderModule class  
 */  
 static const char _PROPERTY_INTERFACEVERSION [] = "InterfaceVersion";  
  
 /**  PEGASUS_NAMESPACE_BEGIN
    The name of the location property for PG_ProviderModule class  
 */  
 static const char _PROPERTY_LOCATION [] = "Location";  
  
 /** /**
    The name of the CapabilityID property for provider capabilities class    The name of the CapabilityID property for provider capabilities class
 */ */
 static const char _PROPERTY_CAPABILITYID [] = "CapabilityID";  static const CIMName _PROPERTY_CAPABILITYID = CIMNameCast("CapabilityID");
   
 /**  
    The name of the provider module name  property for provider capabilities class  
 */  
 static const char _PROPERTY_PROVIDERMODULENAME [] = "ProviderModuleName";  
   
 /**  
    The name of the provider name  property for provider capabilities class  
 */  
 static const char _PROPERTY_PROVIDERNAME [] = "ProviderName";  
   
 /**  
    The name of the classname property for provider capabilities class  
 */  
 static const char _PROPERTY_CLASSNAME [] = "ClassName";  
   
 /**  
    The name of the Namespace property for provider capabilities class  
 */  
 static const char _PROPERTY_NAMESPACES [] = "Namespaces";  
   
 /**  
    The name of the provider type  property for provider capabilities class  
 */  
 static const char _PROPERTY_PROVIDERTYPE [] = "ProviderType";  
   
 /**  
    The name of the supported properties property for provider capabilities class  
 */  
 static const char _PROPERTY_SUPPORTEDPROPERTIES [] = "SupportedProperties";  
   
 /**  
    The name of the supported methods property for provider capabilities class  
 */  
 static const char _PROPERTY_SUPPORTEDMETHODS [] = "SupportedMethods";  
   
 /**  
    Registered instance provider type  
 */  
 static const Uint16 _INSTANCE_PROVIDER    = 2;  
   
 /**  
    Registered association provider type  
 */  
 static const Uint16 _ASSOCIATION_PROVIDER    = 3;  
   
 /**  
    Registered indication provider type  
 */  
 static const Uint16 _INDICATION_PROVIDER    = 4;  
   
 /**  
    Registered method provider type  
 */  
 static const Uint16 _METHOD_PROVIDER    = 5;  
  
 /** /**
    stopping provider method    stopping provider method
 */ */
 static const char _STOP_PROVIDER[]     = "Stop";  static const CIMName _STOP_PROVIDER = CIMNameCast("Stop");
  
 /** /**
    starting provider method    starting provider method
 */ */
 static const char _START_PROVIDER[]   = "Start";  static const CIMName _START_PROVIDER = CIMNameCast("Start");
  
 /** /**
    Provider status     setting provider module group method
 */ */
 static const Uint16 _MODULE_UNKNOWN     = 0;  static const CIMName _SET_MODULEGROUPNAME = CIMNameCast("SetModuleGroupName");
  
 static const Uint16 _MODULE_OK        = 2;  /**
      input param for setModuleGroupName name method
   */
   static const CIMName _PARAM_MODULEGROUPNAME = CIMNameCast("ModuleGroupName");
  
 static const Uint16 _MODULE_STOPPED   = 10;  
  
 ProviderRegistrationProvider::ProviderRegistrationProvider( ProviderRegistrationProvider::ProviderRegistrationProvider(
     ProviderRegistrationManager * providerRegistrationManager)     ProviderRegistrationManager * providerRegistrationManager)
     :_id(peg_credential_types::PROVIDER)  
 { {
     _providerRegistrationManager = providerRegistrationManager;     _providerRegistrationManager = providerRegistrationManager;
  
     _controller = &(ModuleController::get_client_handle(_id, &_client_handle));      _controller = ModuleController::getModuleController();
     if(_client_handle == NULL)  
       ThrowUninitializedHandle();  
 } }
  
 ProviderRegistrationProvider::~ProviderRegistrationProvider(void) ProviderRegistrationProvider::~ProviderRegistrationProvider(void)
 { {
     if (_providerRegistrationManager)  
     {  
         delete _providerRegistrationManager;  
     }  
   
     if (_client_handle)  
     {  
         delete _client_handle;  
     }  
   
 }  
   
 void ProviderRegistrationProvider::initialize(CIMOMHandle & cimom)  
 {  
     // This method should not be called because this is a control provider  
     // and is not dynamically loaded through the provider manager  
 }  
   
 void ProviderRegistrationProvider::terminate(void)  
 {  
 } }
  
 // get registered provider // get registered provider
 void ProviderRegistrationProvider::getInstance( void ProviderRegistrationProvider::getInstance(
     const OperationContext & context,     const OperationContext & context,
     const CIMReference & instanceReference,      const CIMObjectPath & instanceReference,
     const Uint32 flags,      const Boolean includeQualifiers,
       const Boolean includeClassOrigin,
     const CIMPropertyList & propertyList,     const CIMPropertyList & propertyList,
     ResponseHandler<CIMInstance> & handler)      InstanceResponseHandler & handler)
 { {
  
     if(!String::equalNoCase(instanceReference.getNameSpace(),      if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
                             PEGASUS_NAMESPACENAME_INTEROP))  
     {     {
         throw CIMException (CIM_ERR_NOT_SUPPORTED, instanceReference.getNameSpace());          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
               instanceReference.getNameSpace().getString());
     }     }
  
     // ensure the class existing in the specified namespace     // ensure the class existing in the specified namespace
     String className = instanceReference.getClassName();      CIMName className = instanceReference.getClassName();
  
     if(!String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDER) &&      if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
        !String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&         !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
        !String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDERMODULE))         !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
          !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
     {     {
         throw CIMException(CIM_ERR_NOT_SUPPORTED, className);          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
               className.getString());
     }     }
  
     // begin processing the request     // begin processing the request
Line 221 
Line 116 
  
     CIMInstance instance;     CIMInstance instance;
  
     try      instance = _providerRegistrationManager->getInstance(
     {          instanceReference, includeQualifiers, includeClassOrigin, propertyList);
         instance = _providerRegistrationManager->getInstance(instanceReference);  
     }  
     catch(CIMException& e)  
     {  
         throw(e);  
     }  
  
     handler.deliver(instance);     handler.deliver(instance);
  
Line 239 
Line 128 
 // get all registered providers // get all registered providers
 void ProviderRegistrationProvider::enumerateInstances( void ProviderRegistrationProvider::enumerateInstances(
     const OperationContext & context,     const OperationContext & context,
     const CIMReference & classReference,      const CIMObjectPath & classReference,
     const Uint32 flags,      const Boolean includeQualifiers,
       const Boolean includeClassOrigin,
     const CIMPropertyList & propertyList,     const CIMPropertyList & propertyList,
     ResponseHandler<CIMInstance> & handler)      InstanceResponseHandler & handler)
 { {
     if(!String::equalNoCase(classReference.getNameSpace(),      if(!classReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
                             PEGASUS_NAMESPACENAME_INTEROP))  
     {     {
         throw CIMException (CIM_ERR_NOT_SUPPORTED, classReference.getNameSpace());          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
               classReference.getNameSpace().getString());
     }     }
  
     // ensure the class existing in the specified namespace     // ensure the class existing in the specified namespace
     String className = classReference.getClassName();      CIMName className = classReference.getClassName();
  
     if(!String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDER) &&      if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
        !String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&         !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
        !String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDERMODULE))         !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
          !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
     {     {
         throw CIMException(CIM_ERR_NOT_SUPPORTED, className);          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
               className.getString());
     }     }
  
     // begin processing the request     // begin processing the request
     handler.processing();     handler.processing();
  
     Array<CIMNamedInstance> enumInstances;      Array<CIMInstance> enumInstances;
  
     try      enumInstances =
     {          _providerRegistrationManager->enumerateInstancesForClass(
         enumInstances = _providerRegistrationManager->enumerateInstances(classReference);              classReference,
     }              includeQualifiers,
     catch(CIMException& e)              includeClassOrigin,
     {              propertyList);
         throw (e);  
     }  
  
     // ATTN: remove when CIMNamedInstance removed.      handler.deliver(enumInstances);
     for(Uint32 i = 0, n = enumInstances.size(); i < n; i++)  
     {  
         handler.deliver(enumInstances[i].getInstance());  
     }  
  
     // complete processing the request     // complete processing the request
     handler.complete();     handler.complete();
Line 287 
Line 173 
 // get all registered provider names // get all registered provider names
 void ProviderRegistrationProvider::enumerateInstanceNames( void ProviderRegistrationProvider::enumerateInstanceNames(
     const OperationContext & context,     const OperationContext & context,
     const CIMReference & classReference,      const CIMObjectPath & classReference,
     ResponseHandler<CIMReference> & handler)      ObjectPathResponseHandler & handler)
 { {
     if(!String::equalNoCase(classReference.getNameSpace(),      if(!classReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
                             PEGASUS_NAMESPACENAME_INTEROP))  
     {     {
         throw CIMException (CIM_ERR_NOT_SUPPORTED, classReference.getNameSpace());          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
               classReference.getNameSpace().getString());
     }     }
  
     // ensure the class existing in the specified namespace     // ensure the class existing in the specified namespace
     String className = classReference.getClassName();      CIMName className = classReference.getClassName();
  
     if(!String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDER) &&      if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
        !String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&         !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
        !String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDERMODULE))         !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
          !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
     {     {
         throw CIMException(CIM_ERR_NOT_SUPPORTED, className);          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
               className.getString());
     }     }
  
     // begin processing the request     // begin processing the request
     handler.processing();     handler.processing();
  
     Array<CIMReference> enumInstanceNames;      Array<CIMObjectPath> enumInstanceNames;
  
     // get all instance names from repository     // get all instance names from repository
     try  
     {  
         enumInstanceNames =         enumInstanceNames =
             _providerRegistrationManager->enumerateInstanceNames(classReference);          _providerRegistrationManager->enumerateInstanceNamesForClass(
     }              classReference);
     catch(CIMException& e)  
     {  
         throw (e);  
     }  
  
     handler.deliver(enumInstanceNames);     handler.deliver(enumInstanceNames);
  
Line 332 
Line 214 
 // only support to change property of Namespaces, property of // only support to change property of Namespaces, property of
 // SupportedProperties, and property of SupportedMethods // SupportedProperties, and property of SupportedMethods
 void ProviderRegistrationProvider::modifyInstance( void ProviderRegistrationProvider::modifyInstance(
         const OperationContext & _context,          const OperationContext & context,
         const CIMReference & instanceReference,          const CIMObjectPath & instanceReference,
         const CIMInstance & instanceObject,         const CIMInstance & instanceObject,
         const Uint32 flags,          const Boolean includeQualifiers,
         const CIMPropertyList & propertyList,         const CIMPropertyList & propertyList,
         ResponseHandler<CIMInstance> & handler)          ResponseHandler & handler)
   {
       // get userName and only privileged user can execute this operation
       String userName;
       try
 { {
     if(!String::equalNoCase(instanceReference.getNameSpace(),          IdentityContainer container = context.get(IdentityContainer::NAME);
                             PEGASUS_NAMESPACENAME_INTEROP))          userName = container.getUserName();
       }
       catch (...)
       {
           userName = String::EMPTY;
       }
   
   #ifndef PEGASUS_OS_ZOS
       if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
     {     {
         throw CIMException (CIM_ERR_NOT_SUPPORTED, instanceReference.getNameSpace());          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,MessageLoaderParms(
               "ControlProviders.ProviderRegistrationProvider."
                   "ProviderRegistrationProvider."
                   "SUPERUSER_PRIVILEGE_REQUIRED_MODIFY_REGISTRATION",
               "You must have superuser privilege to modify the"
                   " registration."));
       }
   #endif
   
       if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
       {
           throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
               instanceReference.getNameSpace().getString());
     }     }
  
     //     //
     // only support to modify the instance of PG_ProviderCapabilities     // only support to modify the instance of PG_ProviderCapabilities
     //     //
     if (!String::equalNoCase(instanceReference.getClassName(),      if (!instanceReference.getClassName().equal
                              PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))          (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))
     {     {
         throw CIMException (CIM_ERR_NOT_SUPPORTED, instanceReference.getClassName());          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
               instanceReference.getClassName().getString());
     }     }
  
     //     //
Line 360 
Line 267 
     //     //
     if (propertyList.isNull())     if (propertyList.isNull())
     {     {
         throw CIMException (CIM_ERR_NOT_SUPPORTED,          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED, MessageLoaderParms(
             "Only can modify Namespaces, SupportedProperties, and SupportedMethods.");              "ControlProviders.ProviderRegistrationProvider."
                   "ProviderRegistrationProvider."
               "CAN_ONLY_MODIFY_ERR",
               "Only can modify Namespaces, SupportedProperties,"
                   "and SupportedMethods."));
     }     }
  
     Array<String> propertyArray = propertyList.getPropertyNameArray();      Array<CIMName> propertyArray = propertyList.getPropertyNameArray();
     for (Uint32 i=0; i<propertyArray.size(); i++)     for (Uint32 i=0; i<propertyArray.size(); i++)
     {     {
         if (!String::equalNoCase(propertyArray[i], _PROPERTY_NAMESPACES) &&          if (!propertyArray[i].equal (_PROPERTY_NAMESPACES) &&
             !String::equalNoCase(propertyArray[i], _PROPERTY_SUPPORTEDPROPERTIES) &&              !propertyArray[i].equal (_PROPERTY_SUPPORTEDPROPERTIES) &&
             !String::equalNoCase(propertyArray[i], _PROPERTY_SUPPORTEDMETHODS))              !propertyArray[i].equal (_PROPERTY_SUPPORTEDMETHODS))
         {         {
             throw CIMException (CIM_ERR_NOT_SUPPORTED, propertyArray[i]);              throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
                   propertyArray[i].getString());
         }         }
     }     }
  
     // begin processing the request     // begin processing the request
     handler.processing();     handler.processing();
  
     try      _providerRegistrationManager->modifyInstance(
     {          instanceReference, instanceObject, includeQualifiers, propertyArray);
         _providerRegistrationManager->modifyInstance(instanceReference,  
             instanceObject, flags, propertyArray);  #ifdef PEGASUS_ENABLE_INTEROP_PROVIDER
     }      _sendUpdateCacheMessagetoInteropProvider(context);
     catch(CIMException& e)  #endif
     {  
         throw (e);  
     }  
  
     // complete processing the request     // complete processing the request
     handler.complete();     handler.complete();
Line 395 
Line 304 
 // register a provider // register a provider
 void ProviderRegistrationProvider::createInstance( void ProviderRegistrationProvider::createInstance(
     const OperationContext & context,     const OperationContext & context,
     const CIMReference & instanceReference,      const CIMObjectPath & instanceReference,
     const CIMInstance & instanceObject,     const CIMInstance & instanceObject,
     ResponseHandler<CIMReference> & handler)      ObjectPathResponseHandler & handler)
   {
       // get userName and only privileged user can execute this operation
       String userName;
       try
       {
           IdentityContainer container = context.get(IdentityContainer::NAME);
           userName = container.getUserName();
       }
       catch (...)
       {
           userName = String::EMPTY;
       }
   
   #ifndef PEGASUS_OS_ZOS
       if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
 { {
     String className = instanceReference.getClassName();          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, MessageLoaderParms(
     String nameSpace = instanceReference.getNameSpace();              "ControlProviders.ProviderRegistrationProvider."
                   "ProviderRegistrationProvider."
                   "SUPERUSER_PRIVILEGE_REQUIRED_REGISTER_PROVIDERS",
               "You must have superuser privilege to register providers."));
       }
   #endif
   
       CIMName className = instanceReference.getClassName();
       CIMNamespaceName nameSpace = instanceReference.getNameSpace();
  
     CIMReference returnReference;      CIMObjectPath returnReference;
  
     CIMInstance instance = instanceObject;     CIMInstance instance = instanceObject;
  
     if(!String::equalNoCase(nameSpace, PEGASUS_NAMESPACENAME_INTEROP))      if(!nameSpace.equal (PEGASUS_NAMESPACENAME_INTEROP))
     {     {
         throw CIMException (CIM_ERR_NOT_SUPPORTED, nameSpace);          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
               nameSpace.getString());
     }     }
  
     // ensure the class existing in the specified namespace     // ensure the class existing in the specified namespace
     if(!String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDER) &&      if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
        !String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&         !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
        !String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDERMODULE))         !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
          !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
     {     {
         throw CIMException(CIM_ERR_NOT_SUPPORTED, className);          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
               className.getString());
     }     }
  
     //     //
     // Check all required properties are set     // Check all required properties are set
     //     //
     if(String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDERMODULE))      if (className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
     {     {
         //         //
         // Name, Version, InterfaceType, InterfaceVersion, and Location         // Name, Version, InterfaceType, InterfaceVersion, and Location
         // properties must be set         // properties must be set
         // OperationalStatus property needs to be set. If not, set to default         // OperationalStatus property needs to be set. If not, set to default
         //         //
         if (!instanceObject.existsProperty(_PROPERTY_PROVIDERMODULE_NAME))          if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULE_NAME) ==
               PEG_NOT_FOUND)
           {
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                   MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "MISSING_NAME_IN_PG_PROVIDERMODULE",
                       "Missing Name which is required property in "
                           "PG_ProviderModule class."));
           }
   
           if (instanceObject.findProperty(_PROPERTY_VENDOR) == PEG_NOT_FOUND)
           {
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                   MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "MISSING_VENDOR_IN_PG_PROVIDERMODULE",
                       "Missing Vendor which is required property in"
                           " PG_ProviderModule class."));
           }
   
           Uint32 bitnessIndx = instanceObject.findProperty(
                PEGASUS_PROPERTYNAME_MODULE_BITNESS);
   
           if (bitnessIndx != PEG_NOT_FOUND)
           {
               CIMValue value = instanceObject.getProperty(bitnessIndx).getValue();
               if (!value.isNull())
               {
                   if (value.getType() != CIMTYPE_UINT16)
                   {
                       throw PEGASUS_CIM_EXCEPTION(CIM_ERR_TYPE_MISMATCH,
                           PEGASUS_PROPERTYNAME_MODULE_BITNESS.getString());
                   }
                   Uint16 bitness;
                   value.get(bitness);
                   if(bitness != PG_PROVMODULE_BITNESS_DEFAULT
   #ifdef PEGASUS_PLATFORM_FOR_32BIT_PROVIDER_SUPPORT
                       && bitness != PG_PROVMODULE_BITNESS_32
                       && bitness != PG_PROVMODULE_BITNESS_64
   #endif
                       )
                   {
                       throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
                           PEGASUS_PROPERTYNAME_MODULE_BITNESS.getString());
                   }
               }
           }
   
           if (instanceObject.findProperty(_PROPERTY_VERSION) == PEG_NOT_FOUND)
         {         {
             throw CIMException (CIM_ERR_FAILED,              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                 "Missing Name which is required property in PG_ProviderModule class.");                  MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "MISSING_VERSION_IN_PG_PROVIDERMODULE",
                       "Missing Version which is required property in"
                           " PG_ProviderModule class."));
         }         }
  
         if (!instanceObject.existsProperty(_PROPERTY_VENDOR))          Uint32 ifcTypeIndex =
               instanceObject.findProperty(_PROPERTY_INTERFACETYPE);
           if (ifcTypeIndex == PEG_NOT_FOUND)
         {         {
             throw CIMException (CIM_ERR_FAILED,              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                 "Missing Vendor which is required property in PG_ProviderModule class.");                  MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "MISSING_INTERFACETYPE_IN_PG_PROVIDERMODULE",
                       "Missing InterfaceType which is required property in"
                           " PG_ProviderModule class."));
         }         }
           String ifcTypeString;
           instanceObject.getProperty(ifcTypeIndex).getValue().
               get(ifcTypeString);
  
         if (!instanceObject.existsProperty(_PROPERTY_VERSION))          String ifcEmptyVersion;
           if (!ProviderManagerMap::instance().
                   isValidProvMgrIfc(ifcTypeString, ifcEmptyVersion))
         {         {
             throw CIMException (CIM_ERR_FAILED,              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
                 "Missing Version which is required property in PG_ProviderModule class.");                  MessageLoaderParms(
                   "ControlProviders.ProviderRegistrationProvider."
                       "ProviderRegistrationProvider."
                       "UNSUPPORTED_INTERFACETYPE_VALUE",
                   "Unsupported InterfaceType value: \"$0\"",ifcTypeString));
         }         }
  
         if (!instanceObject.existsProperty(_PROPERTY_INTERFACETYPE))          Uint32 ifcVersionIndex =
               instanceObject.findProperty(_PROPERTY_INTERFACEVERSION);
           if (ifcVersionIndex == PEG_NOT_FOUND)
         {         {
             throw CIMException (CIM_ERR_FAILED,              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                 "Missing InterfaceType which is required property in PG_ProviderModule class.");                  MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "MISSING_INTERFACEVERSION_IN_PG_PROVIDERMODULE",
                       "Missing InterfaceVersion which is required property "
                           "in PG_ProviderModule class."));
         }         }
           String ifcVersionString;
           instanceObject.getProperty(ifcVersionIndex).getValue().
               get(ifcVersionString);
  
         if (!instanceObject.existsProperty(_PROPERTY_INTERFACEVERSION))          if (!ProviderManagerMap::instance().isValidProvMgrIfc(
                       ifcTypeString, ifcVersionString))
         {         {
             throw CIMException (CIM_ERR_FAILED,              String unsupported = "InterfaceVersion";
                 "Missing InterfaceVersion which is required property in PG_ProviderModule class.");              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
                   MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                       "ProviderRegistrationProvider."
                       "UNSUPPORTED_INTERFACEVERSION_VALUE",
                       "Unsupported InterfaceVersion value: \"$0\"",
                   ifcVersionString));
         }         }
  
         if (!instanceObject.existsProperty(_PROPERTY_LOCATION))          if (instanceObject.findProperty(_PROPERTY_LOCATION) == PEG_NOT_FOUND)
         {         {
             throw CIMException (CIM_ERR_FAILED,              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                 "Missing Location which is required property in PG_ProviderModule class.");                  MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "MISSING_LOCATION_IN_PG_PROVIDERMODULE",
                       "Missing Location which is required property in"
                           " PG_ProviderModule class."));
         }         }
  
         if (!instanceObject.existsProperty(_PROPERTY_OPERATIONALSTATUS))          if (instanceObject.findProperty(_PROPERTY_OPERATIONALSTATUS) ==
               PEG_NOT_FOUND)
         {         {
             Array<Uint16> _operationalStatus;             Array<Uint16> _operationalStatus;
             _operationalStatus.append(_MODULE_UNKNOWN);              _operationalStatus.append(CIM_MSE_OPSTATUS_VALUE_OK);
             instance.addProperty (CIMProperty             instance.addProperty (CIMProperty
                 (_PROPERTY_OPERATIONALSTATUS, _operationalStatus));                 (_PROPERTY_OPERATIONALSTATUS, _operationalStatus));
         }         }
   
           //
           // Validate the UserContext property
           //
           CIMValue userContextValue;
           Uint32 userContextIndex = instanceObject.findProperty(
               PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT);
   
           if (userContextIndex != PEG_NOT_FOUND)
           {
               userContextValue =
                   instanceObject.getProperty(userContextIndex).getValue();
           }
   
           if (!userContextValue.isNull())
           {
               Uint16 userContext;
               userContextValue.get(userContext);
   
   #ifdef PEGASUS_DISABLE_PROV_USERCTXT
               if (userContext != PG_PROVMODULE_USERCTXT_CIMSERVER)
               {
                   throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
                       MessageLoaderParms(
                           "ControlProviders.ProviderRegistrationProvider."
                               "ProviderRegistrationProvider."
                               "USERCONTEXT_UNSUPPORTED",
                           "The UserContext property in the PG_ProviderModule "
                               "class is not supported."));
               }
   #else
               if (!((userContext == PG_PROVMODULE_USERCTXT_REQUESTOR) ||
   #ifndef PEGASUS_OS_ZOS
                     (userContext == PG_PROVMODULE_USERCTXT_CIMSERVER) ||
                     (userContext == PG_PROVMODULE_USERCTXT_PRIVILEGED) ||
   #endif
                     (userContext == PG_PROVMODULE_USERCTXT_DESIGNATED)))
               {
                   throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
                       MessageLoaderParms(
                           "ControlProviders.ProviderRegistrationProvider."
                               "ProviderRegistrationProvider."
                               "UNSUPPORTED_USERCONTEXT_VALUE",
                           "Unsupported UserContext value: \"$0\".",
                           userContext));
               }
   
               // DesignatedUserContext property is required when UserContext == 3
               if (userContext == PG_PROVMODULE_USERCTXT_DESIGNATED)
               {
                   Uint32 designatedUserIndex = instanceObject.findProperty(
                       PEGASUS_PROPERTYNAME_MODULE_DESIGNATEDUSER);
                   if ((designatedUserIndex == PEG_NOT_FOUND) ||
                       instanceObject.getProperty(designatedUserIndex).getValue()
                           .isNull())
                   {
                       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                           MessageLoaderParms(
                               "ControlProviders.ProviderRegistrationProvider."
                                   "ProviderRegistrationProvider."
                                   "MISSING_DESIGNATEDUSER_IN_PG_PROVIDERMODULE",
                               "Missing DesignatedUserContext property in "
                                   "PG_ProviderModule instance."));
                   }
                   else
                   {
                       // Validate that DesignatedUserContext is of String type
                       String designatedUser;
                       instanceObject.getProperty(designatedUserIndex).getValue()
                           .get(designatedUser);
                   }
               }
   #endif
           }
     }     }
     else if(String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))      else if (className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))
     {     {
         //         //
         // ProviderModuleName, ProviderName, InstanceID, ClassName,         // ProviderModuleName, ProviderName, InstanceID, ClassName,
         // Namespaces, and ProviderType properties must be set         // Namespaces, and ProviderType properties must be set
         //         //
  
         if (!instanceObject.existsProperty(_PROPERTY_PROVIDERMODULENAME))          if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
               PEG_NOT_FOUND)
         {         {
             throw CIMException (CIM_ERR_FAILED,              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                 "Missing ProviderModuleName which is required property in PG_ProviderCapabilities class.");                  MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "MISSING_PROVIDERMODULENAME_IN_PG_PROVIDERCAPABILITIES",
                       "Missing ProviderModuleName which is required property in"
                           " PG_ProviderCapabilities class."));
         }         }
  
         if (!instanceObject.existsProperty(_PROPERTY_PROVIDERNAME))          if (instanceObject.findProperty(_PROPERTY_PROVIDERNAME) ==
               PEG_NOT_FOUND)
         {         {
             throw CIMException (CIM_ERR_FAILED,              String missing = "ProviderName";
                 "Missing ProviderName which is required property in PG_ProviderCapabilities class.");              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                   MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "MISSING_PROVIDERNAME_IN_PG_PROVIDERCAPABILITIES",
                       "Missing the required ProviderName property in "
                           "PG_ProviderCapabilities class."));
         }         }
  
         if (!instanceObject.existsProperty(_PROPERTY_CAPABILITYID))          if (instanceObject.findProperty(_PROPERTY_CAPABILITYID) ==
               PEG_NOT_FOUND)
         {         {
             throw CIMException (CIM_ERR_FAILED,              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                 "Missing CapabilityID which is required property in PG_ProviderCapabilities class.");                  MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "MISSING_CAPABILITYID_IN_PG_PROVIDERCAPABILITIES",
                       "Missing the required CapabilityID property in "
                           "PG_ProviderCapabilities class."));
         }         }
  
         if (!instanceObject.existsProperty(_PROPERTY_CLASSNAME))          if (instanceObject.findProperty(_PROPERTY_CLASSNAME) == PEG_NOT_FOUND)
           {
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                   MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "MISSING_CLASSNAME_IN_PG_PROVIDERCAPABILITIES",
                       "Missing ClassName which is required property in"
                           " PG_ProviderCapabilities class."));
           }
   
           // Validate the Namespaces property
   
           Uint32 namespacesIndex =
               instanceObject.findProperty(_PROPERTY_NAMESPACES);
           Array<String> namespacesArray;
           if (namespacesIndex != PEG_NOT_FOUND)
         {         {
             throw CIMException (CIM_ERR_FAILED,              CIMValue namespacesValue =
                 "Missing ClassName which is required property in PG_ProviderCapabilities class.");                  instanceObject.getProperty(namespacesIndex).getValue();
               if (!namespacesValue.isNull())
               {
                   namespacesValue.get(namespacesArray);
               }
         }         }
  
         if (!instanceObject.existsProperty(_PROPERTY_NAMESPACES))          if (namespacesArray.size() == 0)
         {         {
             throw CIMException (CIM_ERR_FAILED,              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                 "Missing Namespaces which is required property in PG_ProviderCapabilities class.");                  MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "MISSING_NAMESPACES_IN_PG_PROVIDERCAPABILITIES",
                       "Missing Namespaces which is required property in "
                           "PG_ProviderCapabilities class."));
         }         }
  
         if (!instanceObject.existsProperty(_PROPERTY_PROVIDERTYPE))          // Validate the ProviderType property
   
           Uint32 providerTypeIndex =
               instanceObject.findProperty(_PROPERTY_PROVIDERTYPE);
           Array<Uint16> providerTypeArray;
           if (providerTypeIndex != PEG_NOT_FOUND)
           {
               CIMValue providerTypeValue =
                   instanceObject.getProperty(providerTypeIndex).getValue();
               if (!providerTypeValue.isNull())
         {         {
             throw CIMException (CIM_ERR_FAILED,                  providerTypeValue.get(providerTypeArray);
                 "Missing ProviderType which is required property in PG_ProviderCapabilities class.");  
         }         }
     }     }
     else // PEGASUS_CLASSNAME_PROVIDER  
           if (providerTypeArray.size() == 0)
           {
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                   MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "MISSING_PROVIDERTYPE_IN_PG_PROVIDERCAPABILITIES",
                       "Missing ProviderType which is required property in "
                           "PG_ProviderCapabilities class."));
           }
   
           for (Uint32 i = 0; i < providerTypeArray.size(); i++)
           {
               if ((providerTypeArray[i] < 2) ||
   #ifdef PEGASUS_DISABLE_EXECQUERY
                   (providerTypeArray[i] > 6)
   #else
                   (providerTypeArray[i] > 7)
   #endif
                                             )
               {
                   throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
                       MessageLoaderParms(
                           "ControlProviders.ProviderRegistrationProvider."
                               "ProviderRegistrationProvider.UNSUPPORTED_"
                               "PROVIDERTYPE_IN_PG_PROVIDERCAPABILITIES",
                           "Unsupported ProviderType value \"$0\" in "
                               "PG_ProviderCapabilities instance.",
                           providerTypeArray[i]));
               }
           }
       }
       else if (className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES))
     {     {
         //         //
         // Name and ProviderModuleName properties must be set          // ProviderModuleName, ProviderName, CapabilityID, ProviderType,
           // and Destinations properties must be set
         //         //
         if (!instanceObject.existsProperty(_PROPERTY_PROVIDER_NAME))  
           if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
               PEG_NOT_FOUND)
         {         {
             throw CIMException (CIM_ERR_FAILED,              MessageLoaderParms parms(
                 "Missing Name which is required property in PG_Provider class.");                  "ControlProviders.ProviderRegistrationProvider."
                       "ProviderRegistrationProvider."
                       "MISSING_PROVIDER_MODULE_NAME_WHICH_IS_REQUIRED",
                   "Missing ProviderModuleName which is required property in"
                       " PG_ConsumerCapabilities class.");
   
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER, parms);
         }         }
  
         if (!instanceObject.existsProperty(_PROPERTY_PROVIDERMODULENAME))          if (instanceObject.findProperty(_PROPERTY_PROVIDERNAME) ==
               PEG_NOT_FOUND)
         {         {
             throw CIMException (CIM_ERR_FAILED,  
                 "Missing ProviderModuleName which is required property in PG_Provider class.");              MessageLoaderParms parms(
                   "ControlProviders.ProviderRegistrationProvider."
                       "ProviderRegistrationProvider."
                       "MISSING_PROVIDER_NAME_WHICH_IS_REQUIRED",
                   "Missing ProviderName which is required property in"
                       " PG_ConsumerCapabilities class.");
   
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER, parms);
         }         }
   
           if (instanceObject.findProperty(_PROPERTY_CAPABILITYID) ==
               PEG_NOT_FOUND)
           {
   
               MessageLoaderParms parms(
                   "ControlProviders.ProviderRegistrationProvider."
                       "ProviderRegistrationProvider."
                       "MISSING_CAPABILITY_ID_WHICH_IS_REQUIRED",
                   "Missing the required CapabilityID property in "
                       "PG_ConsumerCapabilities class.");
   
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER, parms);
     }     }
  
     // begin processing the request          if (instanceObject.findProperty
     handler.processing();              (_PROPERTY_PROVIDERTYPE) == PEG_NOT_FOUND)
           {
  
     try              MessageLoaderParms parms(
                   "ControlProviders.ProviderRegistrationProvider."
                       "ProviderRegistrationProvider."
                       "MISSING_PROVIDER_TYPE_WHICH_IS_REQUIRED",
                   "Missing ProviderType which is required property in"
                       " PG_ConsumerCapabilities class.");
   
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER, parms);
           }
   
           if (instanceObject.findProperty(_PROPERTY_INDICATIONDESTINATIONS) ==
               PEG_NOT_FOUND)
     {     {
         returnReference =  
             _providerRegistrationManager->createInstance(instanceReference, instance);              MessageLoaderParms parms(
                   "ControlProviders.ProviderRegistrationProvider."
                       "ProviderRegistrationProvider."
                       "MISSING_DESTINATIONS_TYPE_WHICH_IS_REQUIRED",
                   "Missing Destinations which is required property in"
                       " PG_ConsumerCapabilities class.");
   
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER, parms);
     }     }
     catch(CIMException& e)      }
       else // PEGASUS_CLASSNAME_PROVIDER
     {     {
         throw (e);          //
           // Name and ProviderModuleName properties must be set
           //
           if (instanceObject.findProperty
                   (PEGASUS_PROPERTYNAME_NAME) == PEG_NOT_FOUND)
           {
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                   MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "MISSING_NAME_IN_PG_PROVIDER",
                       "Missing the required Name property in PG_Provider "
                           "class."));
           }
   
           if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
               PEG_NOT_FOUND)
           {
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                   MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "MISSING_PROVIDERMODULENAME_IN_PG_PROVIDER",
                       "Missing ProviderModuleName which is required property in "
                           "PG_Provider class."));
           }
     }     }
  
       // begin processing the request
       handler.processing();
   
       returnReference = _providerRegistrationManager->createInstance(
           instanceReference, instance);
   
   #ifdef PEGASUS_ENABLE_INTEROP_PROVIDER
       if(className.equal (PEGASUS_CLASSNAME_PROVIDER) ||
          className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))
       {
           _sendUpdateCacheMessagetoInteropProvider(context);
       }
   #endif
   
     handler.deliver(returnReference);     handler.deliver(returnReference);
  
     // complete processing request     // complete processing request
Line 556 
Line 834 
 // Unregister a provider // Unregister a provider
 void ProviderRegistrationProvider::deleteInstance( void ProviderRegistrationProvider::deleteInstance(
     const OperationContext & context,     const OperationContext & context,
     const CIMReference & instanceReference,      const CIMObjectPath & instanceReference,
     ResponseHandler<CIMInstance> & handler)      ResponseHandler & handler)
   {
       // get userName and only privileged user can execute this operation
       String userName;
       try
 { {
     if(!String::equalNoCase(instanceReference.getNameSpace(),          IdentityContainer container = context.get(IdentityContainer::NAME);
                             PEGASUS_NAMESPACENAME_INTEROP))          userName = container.getUserName();
       }
       catch (...)
     {     {
         throw CIMException (CIM_ERR_NOT_SUPPORTED, instanceReference.getNameSpace());          userName = String::EMPTY;
     }     }
  
     String className = instanceReference.getClassName();  #ifndef PEGASUS_OS_ZOS
       if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
       {
           throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,MessageLoaderParms(
               "ControlProviders.ProviderRegistrationProvider."
                   "ProviderRegistrationProvider."
                   "SUPERUSER_PRIVILEGE_REQUIRED_UNREGISTER_PROVIDERS",
               "You must have superuser privilege to unregister providers."));
       }
   #endif
  
     // ensure the class existing in the specified namespace      if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
     if(!String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDER) &&  
        !String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&  
        !String::equalNoCase(className, PEGASUS_CLASSNAME_PROVIDERMODULE))  
     {     {
         throw CIMException(CIM_ERR_NOT_SUPPORTED, className);          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
               instanceReference.getNameSpace().getString());
     }     }
  
     // begin processing the request  
     handler.processing();  
  
       AcceptLanguageList al;
     try     try
     {     {
         _providerRegistrationManager->deleteInstance(instanceReference);          AcceptLanguageListContainer al_container =
                   (AcceptLanguageListContainer)context.get
                   (AcceptLanguageListContainer::NAME);
           al = al_container.getLanguages();
     }     }
     catch(CIMException& e)      catch (...)
     {     {
         throw (e);          ;   // Leave AcceptLanguageList empty
     }     }
  
     // complete processing the request      CIMName className = instanceReference.getClassName();
     handler.complete();  
 }  
  
 // Block a provider, unblock a provider, and stop a provider      // ensure the class existing in the specified namespace
 void ProviderRegistrationProvider::invokeMethod(      if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
     const OperationContext & context,         !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
     const CIMReference & objectReference,         !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
     const String & methodName,         !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
     const Array<CIMParamValue> & inParameters,  
     Array<CIMParamValue> & outParameters,  
     ResponseHandler<CIMValue> & handler)  
 {  
     if(!String::equalNoCase(objectReference.getNameSpace(),  
                             PEGASUS_NAMESPACENAME_INTEROP))  
     {     {
         throw CIMException (CIM_ERR_NOT_SUPPORTED, objectReference.getNameSpace());          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
               className.getString());
     }     }
  
       // begin processing the request
       handler.processing();
   
     String moduleName;     String moduleName;
     Boolean moduleFound = false;     Boolean moduleFound = false;
       Array<CIMKeyBinding> keys = instanceReference.getKeyBindings();
  
       //
       // disable provider before delete provider
       // registration if the class is PG_Provider
       //
       if (className.equal (PEGASUS_CLASSNAME_PROVIDER))
       {
     // get module name from reference     // get module name from reference
     Array<KeyBinding> keys = objectReference.getKeyBindings();  
  
     for(Uint32 i=0; i<keys.size() ; i++)     for(Uint32 i=0; i<keys.size() ; i++)
     {     {
         if(String::equalNoCase(keys[i].getName(), _PROPERTY_PROVIDERMODULE_NAME))              if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULENAME))
         {         {
             moduleName = keys[i].getValue();             moduleName = keys[i].getValue();
             moduleFound = true;             moduleFound = true;
         }         }
     }     }
  
     // if _PROPERTY_PROVIDERMODULE_NAME key not found          // if _PROPERTY_PROVIDERMODULENAME key not found
     if( !moduleFound)     if( !moduleFound)
     {     {
         throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                 "key Name was not found");                      MessageLoaderParms(
                   "ControlProviders.ProviderRegistrationProvider."
                       "ProviderRegistrationProvider."
                       "PROVIDERMODULENAME_KEY_NOT_FOUND",
                   "key ProviderModuleName was not found"));
     }     }
  
     //     //
     // get module status          // disable the provider
     //     //
     Array<Uint16> _OperationalStatus =          Sint16 ret_value = _disableModule(
         _providerRegistrationManager->getProviderModuleStatus( moduleName);              instanceReference, moduleName, true, al);
  
     handler.processing();          //
           // if the provider disable failed
           //
           if (ret_value == -1)
           {
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                   MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "DISABLE_PROVIDER_FAILED",
                       "disable the provider failed."));
           }
  
     Sint16 ret_value;          //
           // The provider disable failed since there are pending requests
           //
           if (ret_value == -2)
           {
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                   MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "DISABLE_PROVIDER_FAILED_PROVIDER_BUSY",
                       "disable the provider failed: Provider is busy."));
           }
       }
   
       //
       // disable provider module before remove provider registration
       // if the class is PG_ProviderModule
       //
  
     if(String::equalNoCase(methodName, _STOP_PROVIDER))      if (className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
     {     {
         for (Uint32 i = 0; i<_OperationalStatus.size(); i++)          // get module name from reference
   
           for(Uint32 i=0; i<keys.size() ; i++)
         {         {
             // retValue equals 1 if module is already disabled              if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULE_NAME))
             if (_OperationalStatus[i] == _MODULE_STOPPED)  
             {             {
                 ret_value = 1;                  moduleName = keys[i].getValue();
                 CIMValue retValue(ret_value);                  moduleFound = true;
                 handler.deliver(retValue);  
                 handler.complete();  
                 return;  
             }             }
         }         }
  
         CIMInstance mInstance;          // if _PROPERTY_PROVIDERMODULE_NAME key not found
         CIMInstance instance;          if( !moduleFound)
         Array<CIMInstance> instances;  
         String _moduleName;  
   
         // get module instance  
         mInstance = _providerRegistrationManager->getInstance(objectReference);  
   
         // get all provider instances which have same module name as moduleName  
         CIMReference providerRef(objectReference.getHost(),  
                                  objectReference.getNameSpace(),  
                                  PEGASUS_CLASSNAME_PROVIDER,  
                                  objectReference.getKeyBindings());  
         Array<CIMNamedInstance> namedInstances;  
         namedInstances = _providerRegistrationManager->enumerateInstances(providerRef);  
         for(Uint32 i = 0, n=namedInstances.size(); i < n; i++)  
         {  
             instance = namedInstances[i].getInstance();  
             instance.getProperty(instance.findProperty  
             (_PROPERTY_PROVIDERMODULENAME)).getValue().get(_moduleName);  
             if (String::equalNoCase(_moduleName, moduleName))  
             {             {
                 instances.append(instance);              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                   MessageLoaderParms(
                   "ControlProviders.ProviderRegistrationProvider."
                   "ProviderRegistrationProvider.NAME_KEY_NOT_FOUND",
                   "key Name was not found"));
             }             }
  
           //
           // disable the provider module
           //
           Sint16 ret_value = _disableModule(
               instanceReference, moduleName, false, al);
   
           //
           // if the provider module disable failed
           //
           if (ret_value == -1)
           {
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                   MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "DISABLE_PROVIDER_MODULE_FAILED",
                       "disable the provider module failed."));
         }         }
  
         //         //
         // get provider manager service          // The provider module disable failed since there are
           // pending requests
         //         //
         MessageQueueService * _service = _getProviderManagerService();          if (ret_value == -2)
           {
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                   MessageLoaderParms(
                       "ControlProviders.ProviderRegistrationProvider."
                           "ProviderRegistrationProvider."
                           "DISABLE_PROVIDER_MODULE_FAILED_PROVIDER_BUSY",
                       "disable the provider module failed: Provider is busy."));
           }
       }
  
         // create CIMDisableModuleRequestMessage      _providerRegistrationManager->deleteInstance(instanceReference);
         CIMDisableModuleRequestMessage * disable_req =  
             new CIMDisableModuleRequestMessage(  
                 XmlWriter::getNextMessageId (),  
                 mInstance,  
                 instances,  
                 QueueIdStack(_service->getQueueId()));  
  
         Array<Uint16> _opStatus =  #ifdef PEGASUS_ENABLE_INTEROP_PROVIDER
             _sendDisableMessageToProviderManager(disable_req);      if(className.equal (PEGASUS_CLASSNAME_PROVIDER) ||
          className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) ||
          className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
       {
           _sendUpdateCacheMessagetoInteropProvider(context);
       }
   #endif
       // complete processing the request
       handler.complete();
   }
  
         for (Uint32 i = 0; i<_opStatus.size(); i++)  // Block a provider, unblock a provider, and stop a provider
   void ProviderRegistrationProvider::invokeMethod(
       const OperationContext & context,
       const CIMObjectPath & objectReference,
       const CIMName & methodName,
       const Array<CIMParamValue> & inParameters,
       MethodResultResponseHandler & handler)
         {         {
             if (_opStatus[i] == _MODULE_STOPPED)      // get userName and only privileged user can execute this operation
       String userName;
       try
             {             {
                 // module was disabled successfully          IdentityContainer container = context.get(IdentityContainer::NAME);
                 ret_value = 0;          userName = container.getUserName();
                 CIMValue retValue(ret_value);      }
                 handler.deliver(retValue);      catch (...)
                 handler.complete();      {
           userName = String::EMPTY;
       }
  
                 // send termination message to subscription service  #ifndef PEGASUS_OS_ZOS
                 _sendTerminationMessageToSubscription(objectReference, moduleName);      if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
                 return;      {
           throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,
               MessageLoaderParms(
               "ControlProviders.ProviderRegistrationProvider."
                   "ProviderRegistrationProvider."
                   "SUPERUSER_PRIVILEGE_REQUIRED_DISABLE_ENABLE_PROVIDERS",
               "You must have superuser privilege to disable or enable"
                   " providers."));
             }             }
   #endif
   
       if(!objectReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
       {
           throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
               objectReference.getNameSpace().getString());
         }         }
  
         // disable failed  
         ret_value = -1;      // l10n
         CIMValue retValue(ret_value);      // Get the client's list of preferred languages for the response
         handler.deliver(retValue);      AcceptLanguageList al;
         handler.complete();      try
         return;      {
           AcceptLanguageListContainer al_container =
                   (AcceptLanguageListContainer)context.get
                   (AcceptLanguageListContainer::NAME);
           al = al_container.getLanguages();
     }     }
     else if(String::equalNoCase(methodName, _START_PROVIDER))      catch (...)
     {     {
         for (Uint32 i = 0; i<_OperationalStatus.size(); i++)          ;   // Leave AcceptLanguageList empty
       }
   
       String moduleName;
       Boolean moduleFound = false;
   
       // get module name from reference
       Array<CIMKeyBinding> keys = objectReference.getKeyBindings();
   
       for(Uint32 i=0; i<keys.size() ; i++)
         {         {
             // retValue equals 1 if module is already enabled          if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULE_NAME))
             if (_OperationalStatus[i] == _MODULE_OK)  
             {             {
                 ret_value = 1;              moduleName = keys[i].getValue();
                 CIMValue retValue(ret_value);              moduleFound = true;
                 handler.deliver(retValue);  
                 handler.complete();  
                 return;  
             }             }
         }         }
  
         //  
         // get provider manager service  
         //  
         MessageQueueService * _service = _getProviderManagerService();  
  
         // create CIMEnableModuleRequestMessage      // if _PROPERTY_PROVIDERMODULE_NAME key not found
         CIMEnableModuleRequestMessage * enable_req =      if( !moduleFound)
             new CIMEnableModuleRequestMessage(      {
                 XmlWriter::getNextMessageId (),          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
                 moduleName,              MessageLoaderParms(
                 QueueIdStack(_service->getQueueId()));                  "ControlProviders.ProviderRegistrationProvider."
                       "ProviderRegistrationProvider.NAME_KEY_NOT_FOUND",
                   "key Name was not found"));
       }
  
         Array<Uint16> _opStatus;      handler.processing();
         _opStatus = _sendEnableMessageToProviderManager(enable_req);  
  
         for (Uint32 i = 0; i<_opStatus.size(); i++)      Sint16 ret_value;
   
       if (methodName.equal(_STOP_PROVIDER))
         {         {
             if (_opStatus[i] == _MODULE_OK)          // disable module
           ret_value = _disableModule(objectReference, moduleName, false, al);
       }
       else if (methodName.equal(_START_PROVIDER))
             {             {
                 // module was enabled successfully          // enable module
                 ret_value = 0;          ret_value = _enableModule(objectReference, moduleName, al);
                 CIMValue retValue(ret_value);      }
                 handler.deliver(retValue);      else if (methodName.equal(_SET_MODULEGROUPNAME))
                 handler.complete();      {
                 return;          String paramName;
           if (!inParameters.size() ||
               ((paramName = inParameters[0].getParameterName())
                   != _PARAM_MODULEGROUPNAME))
           {
               throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, paramName);
           }
           // set group
           String moduleGroupName;
           inParameters[0].getValue().get(moduleGroupName);
           ret_value = _setModuleGroupName(
               objectReference, moduleName, moduleGroupName, al);
             }             }
       else
       {
           throw PEGASUS_CIM_EXCEPTION(CIM_ERR_METHOD_NOT_AVAILABLE,
               String::EMPTY);
         }         }
   #ifdef PEGASUS_ENABLE_INTEROP_PROVIDER
       _sendUpdateCacheMessagetoInteropProvider(context);
   #endif
  
         // enable failed  
         ret_value = -1;  
         CIMValue retValue(ret_value);         CIMValue retValue(ret_value);
         handler.deliver(retValue);         handler.deliver(retValue);
         handler.complete();         handler.complete();
         return;  
     }     }
     else  
   Sint16 ProviderRegistrationProvider::_setModuleGroupName(
       const CIMObjectPath & moduleRef,
       const String & moduleName,
       const String & moduleGroupName,
       const AcceptLanguageList & al)
   {
       Sint32 disableRC = _disableModule (moduleRef, moduleName, false, al);
   
       if (disableRC == -1)
       {
           throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
               MessageLoaderParms(
                   "ControlProviders.ProviderRegistrationProvider."
                       "ProviderRegistrationProvider."
                       "DISABLE_PROVIDER_FAILED",
                   "disable the provider failed."));
       }
   
       if (disableRC == -2)
       {
           throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
               MessageLoaderParms(
                   "ControlProviders.ProviderRegistrationProvider."
                       "ProviderRegistrationProvider."
                       "DISABLE_PROVIDER_FAILED_PROVIDER_BUSY",
                   "disable the provider failed: Provider is busy."));
       }
   
       String errorMsg;
   
       if (!_providerRegistrationManager->setProviderModuleGroupName(
           moduleName, moduleGroupName, errorMsg))
       {
           throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
               MessageLoaderParms(
                   "ControlProviders.ProviderRegistrationProvider."
                       "ProviderRegistrationProvider."
                       "SET_PROVIDERMODULEGROUPNAME_FAILED",
                   "Failed to set the ModuleGroupName: $0.",
                   errorMsg));
       }
   
       // Enable the module only if it was previously enabled.
       if (disableRC == 0)
       {
           try
           {
               _enableModule(moduleRef, moduleName, al);
           }
           catch(const Exception &e)
           {
               PEG_TRACE((TRC_CONTROLPROVIDER,Tracer::LEVEL1,
                   "Exception caught while enabling the provider module %s : %s",
                   (const char*)moduleName.getCString(),
                   (const char*)e.getMessage().getCString()));
           }
           catch(...)
     {     {
         throw CIMException(CIM_ERR_METHOD_NOT_AVAILABLE);              PEG_TRACE((
                   TRC_CONTROLPROVIDER,
                   Tracer::LEVEL1,
                   "Unknown error occurred while"
                       " enabling the provider modules %s.",
                   (const char*)moduleName.getCString()));
           }
     }     }
   
       return 0;
 } }
  
   
 // get provider manager service // get provider manager service
 MessageQueueService * ProviderRegistrationProvider::_getProviderManagerService() MessageQueueService * ProviderRegistrationProvider::_getProviderManagerService()
 { {
     MessageQueue * queue = MessageQueue::lookup(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP);      MessageQueue * queue =
           MessageQueue::lookup(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP);
     MessageQueueService * _service = dynamic_cast<MessageQueueService *>(queue);     MessageQueueService * _service = dynamic_cast<MessageQueueService *>(queue);
  
     return(_service);     return(_service);
 } }
  
 ProviderRegistrationProvider & ProviderRegistrationProvider::operator=(const ProviderRegistrationProvider & handle)  ProviderRegistrationProvider & ProviderRegistrationProvider::operator=
       (const ProviderRegistrationProvider & handle)
 { {
     if(this == &handle)     if(this == &handle)
     {     {
Line 794 
Line 1252 
     return(*this);     return(*this);
 } }
  
 void ProviderRegistrationProvider::async_callback(Uint32 user_data,  Array<Uint16>
     Message *reply,      ProviderRegistrationProvider::_sendDisableMessageToProviderManager(
     void *parm)  
 {  
    callback_data *cb_data = reinterpret_cast<callback_data *>(parm);  
    cb_data->reply = reply;  
    cb_data->client_sem.signal();  
 }  
   
 Array<Uint16> ProviderRegistrationProvider::_sendDisableMessageToProviderManager(  
         CIMDisableModuleRequestMessage * disable_req)         CIMDisableModuleRequestMessage * disable_req)
 { {
     MessageQueueService * _service = _getProviderManagerService();     MessageQueueService * _service = _getProviderManagerService();
     Uint32 _queueId = _service->getQueueId();     Uint32 _queueId = _service->getQueueId();
  
     callback_data *cb_data = new callback_data(this);  
   
     // create request envelope     // create request envelope
     AsyncLegacyOperationStart * asyncRequest =     AsyncLegacyOperationStart * asyncRequest =
         new AsyncLegacyOperationStart (         new AsyncLegacyOperationStart (
             _service->get_next_xid(),  
             NULL,             NULL,
             _queueId,             _queueId,
             disable_req,              disable_req);
             _queueId);  
   
 // ATTN-YZ-P2-05032002: Temporarily removed, until asyn_callback fixed  
 /*  
     if( false  == _controller->ClientSendAsync(*_client_handle,  
                                                0,  
                                                _queueId,  
                                                asyncRequest,  
                                                ProviderRegistrationProvider::async_callback,  
                                                (void *)cb_data) )  
     {  
        delete asyncRequest;  
        delete cb_data;  
        throw CIMException(CIM_ERR_NOT_FOUND);  
   
     }  
   
     cb_data->client_sem.wait();  
     AsyncReply * asyncReply = static_cast<AsyncReply *>(cb_data->get_reply()) ;  
   
     CIMDisableModuleResponseMessage * response =  
         reinterpret_cast<CIMDisableModuleResponseMessage *>(  
              (static_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());  
     if (response->cimException.getCode() != CIM_ERR_SUCCESS)  
     {  
         CIMException e = response->cimException;  
   
         delete asyncRequest;  
         delete asyncReply;  
         delete response;  
         delete cb_data;  
   
         throw (e);  
     }  
   
     Array<Uint16> operationalStatus = response->operationalStatus;  
   
     delete asyncRequest;  
     delete asyncReply;  
     delete response;  
     delete cb_data;  
 */  
  
 // ATTN-YZ-P2-05032002: Temporarily use ClientSendWait, until asyn_callback fixed      AsyncReply * asyncReply =
           _controller->ClientSendWait(_queueId, asyncRequest);
     AsyncReply * asyncReply = _controller->ClientSendWait(*_client_handle,  
                                                           _queueId,  
                                                           asyncRequest);  
     CIMDisableModuleResponseMessage * response =     CIMDisableModuleResponseMessage * response =
         reinterpret_cast<CIMDisableModuleResponseMessage *>(         reinterpret_cast<CIMDisableModuleResponseMessage *>(
              (static_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());               (dynamic_cast<AsyncLegacyOperationResult
                     *>(asyncReply))->get_result());
     if (response->cimException.getCode() != CIM_ERR_SUCCESS)     if (response->cimException.getCode() != CIM_ERR_SUCCESS)
     {     {
         CIMException e = response->cimException;         CIMException e = response->cimException;
         delete asyncRequest;         delete asyncRequest;
         delete asyncReply;         delete asyncReply;
         delete response;         delete response;
         throw (e);          throw e;
     }     }
  
     Array<Uint16> operationalStatus = response->operationalStatus;     Array<Uint16> operationalStatus = response->operationalStatus;
Line 893 
Line 1296 
     MessageQueueService * _service = _getProviderManagerService();     MessageQueueService * _service = _getProviderManagerService();
     Uint32 _queueId = _service->getQueueId();     Uint32 _queueId = _service->getQueueId();
  
     callback_data *cb_data = new callback_data(this);  
   
     // create request envelope     // create request envelope
     AsyncLegacyOperationStart * asyncRequest =     AsyncLegacyOperationStart * asyncRequest =
         new AsyncLegacyOperationStart (         new AsyncLegacyOperationStart (
             _service->get_next_xid(),  
             NULL,             NULL,
             _queueId,             _queueId,
             enable_req,              enable_req);
             _queueId);  
   
 // ATTN-YZ-P2-05032002: Temporarily removed, until asyn_callback fixed  
 /*  
     if( false  == _controller->ClientSendAsync(*_client_handle,  
                                                0,  
                                                _queueId,  
                                                asyncRequest,  
                                                ProviderRegistrationProvider::async_callback,  
                                                (void *)cb_data) )  
     {  
        delete asyncRequest;  
        delete cb_data;  
        throw CIMException(CIM_ERR_NOT_FOUND);  
   
     }  
   
     cb_data->client_sem.wait();  
     AsyncReply * asyncReply = static_cast<AsyncReply *>(cb_data->get_reply()) ;  
   
     CIMEnableModuleResponseMessage * response =  
         reinterpret_cast<CIMEnableModuleResponseMessage *>(  
              (static_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());  
     if (response->cimException.getCode() != CIM_ERR_SUCCESS)  
     {  
         CIMException e = response->cimException;  
         delete asyncRequest;  
         delete asyncReply;  
         delete response;  
         delete cb_data;  
         throw (e);  
     }  
   
     Array<Uint16> operationalStatus = response->operationalStatus;  
   
     delete asyncRequest;  
     delete asyncReply;  
     delete response;  
     delete cb_data;  
 */  
  
 // ATTN-YZ-P2-05032002: Temporarily use ClientSendWait, until asyn_callback fixed      AsyncReply * asyncReply =
           _controller->ClientSendWait(_queueId, asyncRequest);
     AsyncReply * asyncReply = _controller->ClientSendWait(*_client_handle,  
                                                           _queueId,  
                                                           asyncRequest);  
     CIMEnableModuleResponseMessage * response =     CIMEnableModuleResponseMessage * response =
         reinterpret_cast<CIMEnableModuleResponseMessage *>(         reinterpret_cast<CIMEnableModuleResponseMessage *>(
              (static_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());               (dynamic_cast<AsyncLegacyOperationResult
                     *>(asyncReply))->get_result());
     if (response->cimException.getCode() != CIM_ERR_SUCCESS)     if (response->cimException.getCode() != CIM_ERR_SUCCESS)
     {     {
         CIMException e = response->cimException;         CIMException e = response->cimException;
Line 971 
Line 1329 
  
 // send termination message to subscription service // send termination message to subscription service
 void ProviderRegistrationProvider::_sendTerminationMessageToSubscription( void ProviderRegistrationProvider::_sendTerminationMessageToSubscription(
     const CIMReference & ref, const String & moduleName)      const CIMObjectPath & ref, const String & moduleName,
       const Boolean disableProviderOnly,
       const AcceptLanguageList & al)
 { {
     CIMInstance instance;     CIMInstance instance;
     String _moduleName;     String _moduleName;
     Array<CIMInstance> instances;     Array<CIMInstance> instances;
  
     CIMReference reference("", PEGASUS_NAMESPACENAME_INTEROP,      if (!disableProviderOnly)
       {
           CIMObjectPath reference("", PEGASUS_NAMESPACENAME_INTEROP,
         PEGASUS_CLASSNAME_PROVIDER, ref.getKeyBindings());         PEGASUS_CLASSNAME_PROVIDER, ref.getKeyBindings());
  
     // get all registered providers          Array<CIMObjectPath> instanceNames =
     Array<CIMNamedInstance> enumInstances =              _providerRegistrationManager->enumerateInstanceNamesForClass(
         _providerRegistrationManager->enumerateInstances(reference);                  reference);
  
     // find all the instances which have same module name as moduleName     // find all the instances which have same module name as moduleName
     for (Uint32 i = 0, n=enumInstances.size(); i < n; i++)          for (Uint32 i = 0, n=instanceNames.size(); i < n; i++)
     {     {
         instance = enumInstances[i].getInstance();  
   
         //         //
         // get provider module name              // get provider module name from reference
         //         //
         instance.getProperty(instance.findProperty  
         (_PROPERTY_PROVIDERMODULENAME)).getValue().get(_moduleName);              Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
   
               for(Uint32 j=0; j < keys.size(); j++)
               {
                   if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
                   {
                       _moduleName = keys[j].getValue();
                   }
               }
  
         if (String::equalNoCase(moduleName, _moduleName))         if (String::equalNoCase(moduleName, _moduleName))
         {         {
                   reference.setKeyBindings(keys);
                   instance = _providerRegistrationManager->getInstance(reference);
                   //
                   // if the provider is indication provider
                   //
                   if (_isIndicationProvider(moduleName, instance))
                   {
                       instances.append(instance);
                   }
               }
           }
       }
       else
       {
           instance = _providerRegistrationManager->getInstance(ref);
   
           //
           // if the provider is indication provider
           //
           if (_isIndicationProvider(moduleName, instance))
           {
             instances.append(instance);             instances.append(instance);
         }         }
     }     }
Line 1005 
Line 1394 
     // get indication server queueId     // get indication server queueId
     //     //
     MessageQueueService * _service = _getIndicationService();     MessageQueueService * _service = _getIndicationService();
   
       if (_service != NULL)
       {
     Uint32 _queueId = _service->getQueueId();     Uint32 _queueId = _service->getQueueId();
  
     CIMNotifyProviderTerminationRequestMessage * termination_req =     CIMNotifyProviderTerminationRequestMessage * termination_req =
Line 1013 
Line 1405 
             instances,             instances,
             QueueIdStack(_service->getQueueId()));             QueueIdStack(_service->getQueueId()));
  
           // l10n
           termination_req->operationContext.set(AcceptLanguageListContainer(al));
   
     // create request envelope     // create request envelope
     AsyncLegacyOperationStart * asyncRequest =          AsyncLegacyOperationStart asyncRequest(
         new AsyncLegacyOperationStart (  
                 _service->get_next_xid(),  
                 NULL,                 NULL,
                 _queueId,                 _queueId,
                 termination_req,              termination_req);
                 _queueId);  
  
     if( false  == _controller->ClientSendForget(          AutoPtr <AsyncReply> asyncReply(
                            *_client_handle,              _controller->ClientSendWait(_queueId, &asyncRequest));
                            _queueId,  
                            asyncRequest))          AutoPtr <CIMNotifyProviderTerminationResponseMessage> response
               (reinterpret_cast <CIMNotifyProviderTerminationResponseMessage *>
               ((dynamic_cast <AsyncLegacyOperationResult *>
               (asyncReply.get ()))->get_result ()));
   
           if (response->cimException.getCode () != CIM_ERR_SUCCESS)
     {     {
         delete asyncRequest;              CIMException e = response->cimException;
         throw CIMException(CIM_ERR_NOT_FOUND);              throw e;
           }
     }     }
 } }
  
Line 1043 
Line 1441 
     return(_service);     return(_service);
 } }
  
   // disable provider module, return 0 if module is disabled successfully,
   // return 1 if module is already disabled, return -2 if module can not be
   // disabled since there are pending requests, otherwise, return -1
   Sint16 ProviderRegistrationProvider::_disableModule(
       const CIMObjectPath & objectReference,
       const String & moduleName,
       Boolean disableProviderOnly,
       const AcceptLanguageList & al)
   {
           //
           // get module status
           //
           Array<Uint16> _OperationalStatus =
               _providerRegistrationManager->getProviderModuleStatus( moduleName);
   
           for (Uint32 i = 0; i<_OperationalStatus.size(); i++)
           {
               // retValue equals 1 if module is already disabled
               if (_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED ||
                   _OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING)
               {
                   return (1);
               }
           }
   
           CIMInstance instance;
           Array<CIMInstance> instances;
           CIMInstance mInstance;
           String _moduleName;
           CIMObjectPath providerRef;
           Boolean indProvider = false;
           Array<Boolean> indicationProviders;
   
           // disable a provider module or delete a provider module
           if (!disableProviderOnly)
           {
               providerRef = CIMObjectPath(objectReference.getHost(),
                                    objectReference.getNameSpace(),
                                    PEGASUS_CLASSNAME_PROVIDER,
                                    objectReference.getKeyBindings());
   
               // get module instance
               mInstance =
                   _providerRegistrationManager->getInstance(objectReference);
   
           }
           else // disable a provider
           {
               // get module instance
               Array <CIMKeyBinding> moduleKeyBindings;
               moduleKeyBindings.append (CIMKeyBinding
                   (_PROPERTY_PROVIDERMODULE_NAME, moduleName,
                    CIMKeyBinding::STRING));
   
               CIMObjectPath moduleRef(objectReference.getHost(),
                                       objectReference.getNameSpace(),
                                       PEGASUS_CLASSNAME_PROVIDERMODULE,
                                       moduleKeyBindings);
   
               mInstance =
                   _providerRegistrationManager->getInstance(moduleRef);
           }
   
           if (!disableProviderOnly)
           {
               // get all provider instances which have same module name as
               // moduleName
               Array<CIMObjectPath> instanceNames =
                   _providerRegistrationManager->enumerateInstanceNamesForClass(
                       providerRef);
   
               for(Uint32 i = 0, n=instanceNames.size(); i < n; i++)
               {
                   //
                   // get provider module name from reference
                   //
   
                   Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
   
                   for(Uint32 j=0; j < keys.size(); j++)
                   {
                       if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
                       {
                           _moduleName = keys[j].getValue();
                       }
                   }
   
                   if (String::equalNoCase(_moduleName, moduleName))
                   {
                       providerRef.setKeyBindings(keys);
                       instance = _providerRegistrationManager->getInstance
                           (providerRef);
                       if (_isIndicationProvider(moduleName, instance))
                       {
                           indProvider = true;
                           indicationProviders.append(true);
                       }
                       else
                       {
                           indicationProviders.append(false);
                       }
                       instances.append(instance);
                   }
   
               }
           }
           else
           {
               instance =
                   _providerRegistrationManager->getInstance(objectReference);
               if (_isIndicationProvider(moduleName, instance))
               {
                   indProvider = true;
                   indicationProviders.append(true);
               }
               else
               {
                   indicationProviders.append(false);
               }
   
               instances.append(instance);
           }
   
           //
           // get provider manager service
           //
           MessageQueueService * _service = _getProviderManagerService();
   
           if (_service != NULL)
           {
               // create CIMDisableModuleRequestMessage
               CIMDisableModuleRequestMessage * disable_req =
                   new CIMDisableModuleRequestMessage(
                       XmlWriter::getNextMessageId (),
                       mInstance,
                       instances,
                       disableProviderOnly,
                       indicationProviders,
                       QueueIdStack(_service->getQueueId()));
                   // l10n
                   disable_req->operationContext.set
                       (AcceptLanguageListContainer(al));;
   
               Array<Uint16> _opStatus =
                   _sendDisableMessageToProviderManager(disable_req);
   
               if (!disableProviderOnly) // disable provider module
               {
                   for (Uint32 i = 0; i<_opStatus.size(); i++)
                   {
                       // module was disabled successfully
                       if (_opStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED)
                       {
                           if (indProvider)
                           {
                               // send termination message to subscription service
                               _sendTerminationMessageToSubscription(
                                   objectReference, moduleName, false, al);
                           }
                           return (0);
                       }
   
                       // module is not disabled since there are pending
                       // requests for the providers in the module
                       if (_opStatus[i] == CIM_MSE_OPSTATUS_VALUE_OK)
                       {
                           return (-2);
                       }
                   }
               }
               else // disable provider
               {
                   if (indProvider)
                   {
                       _sendTerminationMessageToSubscription(objectReference,
                           moduleName, true, al);
                   }
                   return (0);
               }
           }
   
           // disable failed
           return (-1);
   }
   
   // enable provider module
   // return 0 if module is enabled successfully,
   // return 1 if module is already enabled,
   // return 2 if module can not be enabled since module is stopping,
   // otherwise, return -1
   Sint16 ProviderRegistrationProvider::_enableModule(
       const CIMObjectPath & moduleRef,
       const String & moduleName,
       const AcceptLanguageList & al)
   {
           //
           // get module status
           //
           Array<Uint16> _OperationalStatus =
               _providerRegistrationManager->getProviderModuleStatus( moduleName);
   
           for (Uint32 i = 0; i<_OperationalStatus.size(); i++)
           {
               // retValue equals 1 if module is already enabled
               if (_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_OK)
               {
                   return (1);
               }
   
               // retValue equals 2 if module is stopping
               // at this stage, module can not be started
               if (_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING)
               {
                   return (2);
               }
           }
   
           // get module instance
           CIMInstance mInstance =
               _providerRegistrationManager->getInstance(moduleRef);
   
           //
           // get provider manager service
           //
           MessageQueueService * _service = _getProviderManagerService();
           Boolean enabled = false;
   
           if (_service != NULL)
           {
               // create CIMEnableModuleRequestMessage
               CIMEnableModuleRequestMessage * enable_req =
                   new CIMEnableModuleRequestMessage(
                       XmlWriter::getNextMessageId (),
                       mInstance,
                       QueueIdStack(_service->getQueueId()));
   
               enable_req->operationContext.set(AcceptLanguageListContainer(al));
   
               Array<Uint16> _opStatus;
               _opStatus = _sendEnableMessageToProviderManager(enable_req);
   
               for (Uint32 i = 0; i<_opStatus.size(); i++)
               {
                   // module is enabled successfully
                   if (_opStatus[i] == CIM_MSE_OPSTATUS_VALUE_OK)
                   {
                       enabled = true;
                   }
               }
           }
   
           if (enabled)
           {
               //
               // Since module is enabled, need get updated module instance
               //
               CIMInstance updatedModuleInstance =
                   _providerRegistrationManager->getInstance(moduleRef);
   
               //
               // The module is enabled, need to send enable message to
               // subscription service if the provider is an indication provider
               //
   
               CIMObjectPath providerRef = CIMObjectPath(String::EMPTY,
                                       moduleRef.getNameSpace(),
                                       PEGASUS_CLASSNAME_PROVIDER,
                                       Array<CIMKeyBinding>());
   
               //
               // get all provider instances which have same module name as
               // moduleName
               //
               Array<CIMObjectPath> instanceNames =
                   _providerRegistrationManager->enumerateInstanceNamesForClass(
                       providerRef);
               CIMInstance pInstance;
               String _moduleName;
               String _providerName;
               Array<CIMInstance> capInstances;
   
               for(Uint32 i = 0, n=instanceNames.size(); i < n; i++)
               {
   
                   Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
   
                   for(Uint32 j=0; j < keys.size(); j++)
                   {
                       //
                       // get provider module name from reference
                       //
                       if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
                       {
                           _moduleName = keys[j].getValue();
                       }
   
                       //
                       // get provider name from reference
                       //
                       if(keys[j].getName().equal (PEGASUS_PROPERTYNAME_NAME))
                       {
                           _providerName = keys[j].getValue();
                       }
                   }
   
                   if (String::equalNoCase(_moduleName, moduleName))
                   {
                       providerRef.setKeyBindings(keys);
                       pInstance = _providerRegistrationManager->getInstance
                           (providerRef);
                       //
                       // get all the indication capability instances which
                       // belongs to this provider
                       //
                       capInstances = _getIndicationCapInstances(
                                      moduleName, pInstance, providerRef);
   
                       //
                       // if there are indication capability instances
                       //
                       if (capInstances.size() != 0)
                       {
                           _sendEnableMessageToSubscription(updatedModuleInstance,
                                                            pInstance,
                                                            capInstances,
                                                            al);
                       }
                   }
               }
               return (0);
           }
   
   
           // enable failed
           return (-1);
   }
   
   // send enable message to indication service
   void ProviderRegistrationProvider::_sendEnableMessageToSubscription(
       const CIMInstance & mInstance,
       const CIMInstance & pInstance,
       const Array<CIMInstance> & capInstances,
       const AcceptLanguageList & al)
   {
       //
       // get indication server queueId
       //
       MessageQueueService * _service = _getIndicationService();
   
       if (_service != NULL)
       {
           Uint32 _queueId = _service->getQueueId();
   
           CIMNotifyProviderEnableRequestMessage * enable_req =
                   new CIMNotifyProviderEnableRequestMessage (
                       XmlWriter::getNextMessageId (),
                       capInstances,
                       QueueIdStack(_service->getQueueId()));
   
           enable_req->operationContext.set(AcceptLanguageListContainer(al));
       enable_req->operationContext.insert(ProviderIdContainer
                                           (mInstance,pInstance));
   
           // create request envelope
           AsyncLegacyOperationStart * asyncRequest =
               new AsyncLegacyOperationStart (
                   NULL,
                   _queueId,
                   enable_req);
   
           AsyncReply * asyncReply =
               _controller->ClientSendWait(_queueId, asyncRequest);
   
           CIMNotifyProviderEnableResponseMessage * response =
               reinterpret_cast<CIMNotifyProviderEnableResponseMessage *>(
                   (dynamic_cast<AsyncLegacyOperationResult *>
                       (asyncReply))->get_result());
   
           if (response->cimException.getCode() != CIM_ERR_SUCCESS)
           {
               CIMException e = response->cimException;
               delete asyncRequest;
               delete asyncReply;
               delete response;
               throw e;
           }
   
           delete asyncRequest;
           delete asyncReply;
           delete response;
       }
   }
   
   // If provider is an indication provider, return true,
   // otherwise, return false
   Boolean ProviderRegistrationProvider::_isIndicationProvider(
       const String & moduleName,
       const CIMInstance & instance)
   {
       // get provider name
       String providerName;
       Uint32 pos = instance.findProperty(PEGASUS_PROPERTYNAME_NAME);
       if (pos != PEG_NOT_FOUND)
       {
           instance.getProperty(pos).getValue().get(providerName);
       }
   
       return (_providerRegistrationManager->isIndicationProvider(
               moduleName, providerName));
   }
   
   //
   // get all the capability instances whose provider type is indication
   //
   Array<CIMInstance> ProviderRegistrationProvider::_getIndicationCapInstances(
       const String & moduleName,
       const CIMInstance & instance,
       const CIMObjectPath & providerRef)
   {
       // get provider name
       String providerName;
       Uint32 pos = instance.findProperty(PEGASUS_PROPERTYNAME_NAME);
       if (pos != PEG_NOT_FOUND)
       {
           instance.getProperty(pos).getValue().get(providerName);
       }
   
       CIMObjectPath capabilityRef;
   
       capabilityRef = CIMObjectPath(providerRef.getHost(),
                                     providerRef.getNameSpace(),
                                     PEGASUS_CLASSNAME_PROVIDERCAPABILITIES,
                                     providerRef.getKeyBindings());
   
       // get all Capabilities instances
       Array<CIMObjectPath> instanceNames =
           _providerRegistrationManager->enumerateInstanceNamesForClass(
               capabilityRef);
   
       String _moduleName, _providerName;
       CIMInstance capInstance;
       Array<Uint16> providerTypes;
       Array<CIMInstance> indCapInstances = 0;
       for(Uint32 i = 0, n=instanceNames.size(); i < n; i++)
       {
           Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
   
           for(Uint32 j=0; j < keys.size(); j++)
           {
                if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
                {
                     _moduleName = keys[j].getValue();
                }
   
                if(keys[j].getName().equal (_PROPERTY_PROVIDERNAME))
                {
                     _providerName = keys[j].getValue();
                }
           }
   
          //
          // if capability instance has same module name as moduleName
          // and same provider name as providerName, get provider type
          //
          if(String::equal(_moduleName, moduleName) &&
             String::equal(_providerName, providerName))
          {
               capInstance = _providerRegistrationManager->getInstance
                                   (instanceNames[i]);
   
               Uint32 providerTypePos = capInstance.findProperty(
                   CIMName (_PROPERTY_PROVIDERTYPE));
               if (providerTypePos != PEG_NOT_FOUND)
               {
                   capInstance.getProperty(providerTypePos).getValue().get(
                       providerTypes);
   
                   for (Uint32 k=0; k < providerTypes.size(); k++)
                   {
                       //
                       // if provider type of the instance is indication,
                       // append the instance
                       //
                       if (providerTypes[k] == _INDICATION_PROVIDER)
                       {
                           indCapInstances.append(capInstance);
                       }
                   }
               }
           }
       }
   
       return (indCapInstances);
   }
   
   #ifdef PEGASUS_ENABLE_INTEROP_PROVIDER
   void ProviderRegistrationProvider::_sendUpdateCacheMessagetoInteropProvider(
       const OperationContext & context)
   {
       String referenceStr("//", 2);
       referenceStr.append(System::getHostName());
       referenceStr.append("/");
       referenceStr.append(PEGASUS_NAMESPACENAME_INTEROP.getString());
       referenceStr.append(":");
       referenceStr.append(
           PEGASUS_CLASSNAME_PG_PROVIDERPROFILECAPABILITIES.getString());
       CIMObjectPath reference(referenceStr);
   
       Array<CIMParamValue> inParams;
   
       try
       {
           CIMInvokeMethodRequestMessage* request =
               new CIMInvokeMethodRequestMessage(
                   XmlWriter::getNextMessageId(),
                   PEGASUS_NAMESPACENAME_INTEROP,
                   referenceStr,
                   "updateCache",
                   inParams,
                   QueueIdStack(_controller->getQueueId()));
   
           request->operationContext = context;
   
           AsyncModuleOperationStart* moduleControllerRequest =
               new AsyncModuleOperationStart(
                   0,
                   _controller->getQueueId(),
                   PEGASUS_MODULENAME_INTEROPPROVIDER,
                   request);
   
           _controller->SendForget(moduleControllerRequest);
       }
       catch(const Exception &e)
       {
           PEG_TRACE((TRC_CONTROLPROVIDER,Tracer::LEVEL1,
               "Exception caught while invoking InteropProvider 'updateCache'"
                   " method: %s",(const char*)e.getMessage().getCString()));
       }
       catch(...)
       {
           PEG_TRACE_CSTRING(
               TRC_CONTROLPROVIDER,
               Tracer::LEVEL1,
               "Unknown error occurred while"
                   " invoking InteropProvider 'updateCache' method.");
       }
   }
   #endif
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.12  
changed lines
  Added in v.1.117

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2