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

   1 a.dunfey 1.82.2.1 //%2006////////////////////////////////////////////////////////////////////////
   2 kumpf    1.1      //
   3 karl     1.73     // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
   4                   // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   5                   // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   6 karl     1.57     // IBM Corp.; EMC Corporation, The Open Group.
   7 karl     1.73     // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   8                   // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   9 karl     1.75     // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  10                   // EMC Corporation; VERITAS Software Corporation; The Open Group.
  11 a.dunfey 1.82.2.1 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
  12                   // EMC Corporation; Symantec Corporation; The Open Group.
  13 kumpf    1.1      //
  14                   // Permission is hereby granted, free of charge, to any person obtaining a copy
  15                   // of this software and associated documentation files (the "Software"), to
  16                   // deal in the Software without restriction, including without limitation the
  17                   // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  18                   // sell copies of the Software, and to permit persons to whom the Software is
  19                   // furnished to do so, subject to the following conditions:
  20 karl     1.57     // 
  21 kumpf    1.1      // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
  22                   // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
  23                   // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  24                   // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  25                   // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  26                   // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  27                   // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28                   // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29                   //
  30                   //==============================================================================
  31                   //
  32                   // Author: Yi Zhou (yi_zhou@hp.com)
  33                   //
  34                   // Modified By: Chip Vincent (cvincent@us.ibm.com)
  35                   //              Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
  36                   //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
  37 kumpf    1.20     //              Carol Ann Krug Graves, Hewlett-Packard Company
  38                   //                  (carolann_graves@hp.com)
  39 kumpf    1.71     //              Seema Gupta (gseema@in.ibm.com) for PEP135
  40 kumpf    1.1      //
  41                   //%/////////////////////////////////////////////////////////////////////////////
  42                   
  43 kumpf    1.5      #include "ProviderRegistrationProvider.h"
  44                   
  45 kumpf    1.4      #include <Pegasus/Common/PegasusVersion.h>
  46 kumpf    1.5      #include <Pegasus/Common/XmlWriter.h>
  47 kumpf    1.6      #include <Pegasus/Common/Constants.h>
  48                   #include <Pegasus/Common/CIMMessage.h>
  49 se.gupta 1.67     #include <Pegasus/Common/OperationContextInternal.h>
  50 kumpf    1.15     #include <Pegasus/Common/System.h>
  51 humberto 1.48     #include <Pegasus/Common/MessageLoader.h> //l10n
  52 kumpf    1.68     #include <Pegasus/Common/Constants.h>
  53 kumpf    1.1      
  54                   PEGASUS_NAMESPACE_BEGIN
  55                   
  56                   /**
  57                      The name of the CapabilityID property for provider capabilities class
  58                   */
  59 kumpf    1.36     static const CIMName _PROPERTY_CAPABILITYID  = CIMName ("CapabilityID");
  60 kumpf    1.1      
  61                   /**
  62                      stopping provider method
  63                   */
  64 kumpf    1.36     static const CIMName _STOP_PROVIDER     = CIMName ("Stop");
  65 kumpf    1.1      
  66                   /**
  67                      starting provider method
  68                   */
  69 kumpf    1.36     static const CIMName _START_PROVIDER   = CIMName ("Start");
  70 kumpf    1.1      
  71                   ProviderRegistrationProvider::ProviderRegistrationProvider(
  72                       ProviderRegistrationManager * providerRegistrationManager)	
  73 kumpf    1.6          :_id(peg_credential_types::PROVIDER)
  74 kumpf    1.1      {
  75                       _providerRegistrationManager = providerRegistrationManager;
  76 kumpf    1.6      
  77                       _controller = &(ModuleController::get_client_handle(_id, &_client_handle));
  78                       if(_client_handle == NULL)
  79 kumpf    1.32             throw UninitializedObjectException();
  80 kumpf    1.1      }
  81                   
  82                   ProviderRegistrationProvider::~ProviderRegistrationProvider(void)	
  83                   {
  84 kumpf    1.6          if (_client_handle)
  85                       {
  86                   	delete _client_handle;
  87                       }
  88                   
  89 kumpf    1.1      }
  90                   
  91                   void ProviderRegistrationProvider::initialize(CIMOMHandle & cimom)
  92                   {
  93                       // This method should not be called because this is a control provider
  94                       // and is not dynamically loaded through the provider manager
  95                   }
  96                   
  97                   void ProviderRegistrationProvider::terminate(void)
  98                   {
  99 konrad.r 1.79       // delete self. this is necessary because the entry point for this object allocated it, and
 100                     // the module is responsible for its memory management.
 101                     delete this;
 102 kumpf    1.1      }
 103                   
 104                   // get registered provider
 105                   void ProviderRegistrationProvider::getInstance(
 106                       const OperationContext & context,
 107 kumpf    1.13         const CIMObjectPath & instanceReference,
 108 kumpf    1.34         const Boolean includeQualifiers,
 109                       const Boolean includeClassOrigin,
 110 kumpf    1.2          const CIMPropertyList & propertyList,
 111 kumpf    1.33         InstanceResponseHandler & handler)
 112 kumpf    1.1      {
 113                   
 114 kumpf    1.36         if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
 115 kumpf    1.10         {
 116 kumpf    1.30     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
 117 kumpf    1.36                 instanceReference.getNameSpace().getString());
 118 kumpf    1.10         }
 119                   
 120 kumpf    1.1          // ensure the class existing in the specified namespace
 121 kumpf    1.36         CIMName className = instanceReference.getClassName();
 122 kumpf    1.1      
 123 kumpf    1.36         if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
 124                          !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
 125 kumpf    1.46            !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
 126 kumpf    1.36            !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
 127 kumpf    1.1          {
 128 kumpf    1.36     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
 129                               className.getString());
 130 kumpf    1.1          }
 131                   
 132                       // begin processing the request
 133                       handler.processing();
 134                   
 135                       CIMInstance instance;
 136                   
 137                       try
 138                       {
 139 kumpf    1.60     	instance = _providerRegistrationManager->getInstance(instanceReference,
 140                   							     includeQualifiers,
 141                   							     includeClassOrigin,
 142                   							     propertyList);
 143 kumpf    1.1          }
 144 david.dillard 1.78         catch(const CIMException&)
 145 kumpf         1.1          {
 146 david.dillard 1.78             throw;
 147 kumpf         1.1          }
 148                        
 149                            handler.deliver(instance);
 150                        
 151                            // complete processing the request
 152                            handler.complete();
 153                        }
 154                        
 155                        // get all registered providers
 156                        void ProviderRegistrationProvider::enumerateInstances(
 157                            const OperationContext & context,
 158 kumpf         1.13         const CIMObjectPath & classReference,
 159 kumpf         1.34         const Boolean includeQualifiers,
 160                            const Boolean includeClassOrigin,
 161 kumpf         1.2          const CIMPropertyList & propertyList,
 162 kumpf         1.33         InstanceResponseHandler & handler)
 163 kumpf         1.1      {
 164 kumpf         1.36         if(!classReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
 165 kumpf         1.10         {
 166 kumpf         1.36     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
 167                                    classReference.getNameSpace().getString());
 168 kumpf         1.10         }
 169                        
 170 kumpf         1.1          // ensure the class existing in the specified namespace
 171 kumpf         1.36         CIMName className = classReference.getClassName();
 172 kumpf         1.1      
 173 kumpf         1.36         if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
 174                               !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
 175 kumpf         1.46            !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
 176 kumpf         1.36            !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
 177 kumpf         1.1          {
 178 kumpf         1.36     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
 179                                    className.getString());
 180 kumpf         1.1          }
 181                        
 182                            // begin processing the request
 183                            handler.processing();
 184                        
 185 kumpf         1.20         Array<CIMInstance> enumInstances;
 186 kumpf         1.1      
 187                            try
 188                            {
 189 kumpf         1.60             enumInstances = 
 190                        	    _providerRegistrationManager->enumerateInstances(classReference, 
 191                        							     includeQualifiers,
 192                        			 				     includeClassOrigin, 
 193                        							     propertyList);
 194 kumpf         1.1          }
 195 david.dillard 1.78         catch(const CIMException&)
 196 kumpf         1.1          {
 197 david.dillard 1.78             throw;
 198 kumpf         1.1          }
 199                        
 200 kumpf         1.21         handler.deliver(enumInstances);
 201 kumpf         1.1      
 202                            // complete processing the request
 203                            handler.complete();
 204                        }
 205                        
 206                        // get all registered provider names
 207                        void ProviderRegistrationProvider::enumerateInstanceNames(
 208                            const OperationContext & context,
 209 kumpf         1.13         const CIMObjectPath & classReference,
 210 kumpf         1.33         ObjectPathResponseHandler & handler)
 211 kumpf         1.1      {
 212 kumpf         1.36         if(!classReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
 213 kumpf         1.10         {
 214 kumpf         1.36     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
 215                                    classReference.getNameSpace().getString());
 216 kumpf         1.10         }
 217                        
 218 kumpf         1.1          // ensure the class existing in the specified namespace
 219 kumpf         1.36         CIMName className = classReference.getClassName();
 220 kumpf         1.1      
 221 kumpf         1.36         if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
 222                               !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
 223 kumpf         1.46            !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
 224 kumpf         1.36            !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
 225 kumpf         1.1          {
 226 kumpf         1.36     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
 227                                    className.getString());
 228 kumpf         1.1          }
 229                        
 230                            // begin processing the request
 231                            handler.processing();
 232                        
 233 kumpf         1.13         Array<CIMObjectPath> enumInstanceNames;
 234 kumpf         1.1      
 235                            // get all instance names from repository
 236                            try
 237                            {
 238 david.dillard 1.78             enumInstanceNames =
 239                                    _providerRegistrationManager->enumerateInstanceNames(classReference);
 240 kumpf         1.1          }
 241 david.dillard 1.78         catch(const CIMException&)
 242 kumpf         1.1          {
 243 david.dillard 1.78             throw;
 244 kumpf         1.1          }
 245                        
 246                            handler.deliver(enumInstanceNames);
 247                        
 248                            // complete processing the request
 249                            handler.complete();
 250                        }
 251                        
 252                        // change properties for the registered provider
 253 chip          1.24     // only support to change property of Namespaces, property of
 254 kumpf         1.1      // SupportedProperties, and property of SupportedMethods
 255                        void ProviderRegistrationProvider::modifyInstance(
 256 kumpf         1.15             const OperationContext & context,
 257 kumpf         1.13             const CIMObjectPath & instanceReference,
 258 kumpf         1.1              const CIMInstance & instanceObject,
 259 kumpf         1.34             const Boolean includeQualifiers,
 260 kumpf         1.2              const CIMPropertyList & propertyList,
 261 kumpf         1.33             ResponseHandler & handler)
 262 kumpf         1.1      {
 263 kumpf         1.15         // get userName and only privileged user can execute this operation
 264 kumpf         1.19         String userName;
 265                            try
 266                            {
 267 kumpf         1.37             IdentityContainer container = context.get(IdentityContainer::NAME);
 268 kumpf         1.19             userName = container.getUserName();
 269                            }
 270                            catch (...)
 271                            {
 272                                userName = String::EMPTY;
 273                            }
 274 kumpf         1.15     
 275 chip          1.24         if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
 276 kumpf         1.15         {
 277 humberto      1.48         	//l10n
 278                        	//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
 279                        	    //"You must have superuser privilege to modify the registration."); 
 280                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,MessageLoaderParms(
 281                        	    		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_MODIFY_REGISTRATION",
 282                        	    		"You must have superuser privilege to modify the registration.")); 	
 283 kumpf         1.15         }
 284                        
 285 kumpf         1.36         if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
 286 kumpf         1.10         {
 287 kumpf         1.36     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
 288                                    instanceReference.getNameSpace().getString());
 289 kumpf         1.10         }
 290                        
 291 kumpf         1.1          //
 292                            // only support to modify the instance of PG_ProviderCapabilities
 293                            //
 294 kumpf         1.36         if (!instanceReference.getClassName().equal 
 295                                (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))
 296 kumpf         1.1          {
 297 kumpf         1.36     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
 298                                    instanceReference.getClassName().getString());
 299 kumpf         1.1          }
 300                        
 301                            //
 302 kumpf         1.2          // only can modify the property of Namespaces, property of
 303 kumpf         1.1          // SupportedProperties, and property of SupportedMethods
 304                            //
 305 kumpf         1.2          if (propertyList.isNull())
 306 kumpf         1.1          {
 307 humberto      1.48         	//l10n
 308                        	//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
 309                        	    //"Only can modify Namespaces, SupportedProperties, and SupportedMethods.");
 310                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED, MessageLoaderParms(
 311                        	    		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.CAN_ONLY_MODIFY_ERR",
 312 humberto      1.50     	    		"Only can modify Namespaces, SupportedProperties, and SupportedMethods."));
 313 kumpf         1.2          }
 314                        
 315 kumpf         1.28         Array<CIMName> propertyArray = propertyList.getPropertyNameArray();
 316 kumpf         1.2          for (Uint32 i=0; i<propertyArray.size(); i++)
 317                            {
 318 kumpf         1.36     	if (!propertyArray[i].equal (_PROPERTY_NAMESPACES) &&
 319                        	    !propertyArray[i].equal (_PROPERTY_SUPPORTEDPROPERTIES) &&
 320                        	    !propertyArray[i].equal (_PROPERTY_SUPPORTEDMETHODS))
 321 kumpf         1.1      	{
 322 kumpf         1.36     	    throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
 323                                        propertyArray[i].getString());
 324 kumpf         1.2      	}
 325 kumpf         1.1          }
 326                        
 327                            // begin processing the request
 328                            handler.processing();
 329                        
 330                            try
 331                            {
 332 kumpf         1.60             _providerRegistrationManager->modifyInstance(instanceReference, 
 333                        						     instanceObject, 
 334                        						     includeQualifiers, 
 335                        	    					     propertyArray);
 336 kumpf         1.1          }
 337 david.dillard 1.78         catch(const CIMException& e)
 338 kumpf         1.1          {
 339 david.dillard 1.78             throw;
 340 kumpf         1.1          }
 341                        
 342                            // complete processing the request
 343                            handler.complete();
 344                        }
 345                        
 346                        // register a provider
 347                        void ProviderRegistrationProvider::createInstance(
 348                            const OperationContext & context,
 349 kumpf         1.13         const CIMObjectPath & instanceReference,
 350 kumpf         1.1          const CIMInstance & instanceObject,
 351 kumpf         1.33         ObjectPathResponseHandler & handler)
 352 kumpf         1.1      {
 353 kumpf         1.15         // get userName and only privileged user can execute this operation
 354 kumpf         1.19         String userName;
 355                            try
 356                            {
 357 kumpf         1.37             IdentityContainer container = context.get(IdentityContainer::NAME);
 358 kumpf         1.19             userName = container.getUserName();
 359                            }
 360                            catch (...)
 361                            {
 362                                userName = String::EMPTY;
 363                            }
 364 kumpf         1.15     
 365 chip          1.24         if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
 366 kumpf         1.15         {
 367 humberto      1.48         	//l10n
 368                        	//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
 369                        	    //"You must have superuser privilege to register providers."); 
 370                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, MessageLoaderParms(
 371                        	    			"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_REGISTER_PROVIDERS",
 372                        	    			"You must have superuser privilege to register providers.")); 	
 373 kumpf         1.15         }
 374                        
 375 kumpf         1.36         CIMName className = instanceReference.getClassName();
 376                            CIMNamespaceName nameSpace = instanceReference.getNameSpace();
 377 kumpf         1.1      
 378 kumpf         1.13         CIMObjectPath returnReference;
 379 kumpf         1.1      
 380                            CIMInstance instance = instanceObject;
 381                        
 382 kumpf         1.36         if(!nameSpace.equal (PEGASUS_NAMESPACENAME_INTEROP))
 383 kumpf         1.10         {
 384 kumpf         1.36     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
 385                                    nameSpace.getString());
 386 kumpf         1.10         }
 387                        
 388 kumpf         1.1          // ensure the class existing in the specified namespace
 389 kumpf         1.36         if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
 390                               !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
 391 kumpf         1.46            !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
 392 kumpf         1.36            !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
 393 kumpf         1.1          {
 394 kumpf         1.36     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
 395                                    className.getString());
 396 kumpf         1.1          }
 397                        
 398                            //
 399                            // Check all required properties are set
 400                            //
 401 kumpf         1.36         if (className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
 402 kumpf         1.1          {
 403                        	//
 404                        	// Name, Version, InterfaceType, InterfaceVersion, and Location
 405                        	// properties must be set
 406                        	// OperationalStatus property needs to be set. If not, set to default
 407                        	//
 408 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULE_NAME) ==
 409                                    PEG_NOT_FOUND)
 410 kumpf         1.1      	{
 411 humberto      1.53     		//l10n 485
 412 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 413                        		//"Missing Name which is required property in PG_ProviderModule class.");
 414                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 415 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_NAME_IN_PG_PROVIDERMODULE",
 416                        		"Missing Name which is required property in PG_ProviderModule class."));
 417 kumpf         1.12     	}
 418                        
 419 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_VENDOR) == PEG_NOT_FOUND)
 420 kumpf         1.12     	{
 421 humberto      1.53     		//l10n 485
 422 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 423                        		//"Missing Vendor which is required property in PG_ProviderModule class.");
 424                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 425 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_VENDOR_IN_PG_PROVIDERMODULE",
 426                        		"Missing Vendor which is required property in PG_ProviderModule class."));
 427 kumpf         1.1      	}
 428                        
 429 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_VERSION) == PEG_NOT_FOUND)
 430 kumpf         1.1      	{
 431 humberto      1.53     		//l10n 485
 432 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 433                        		//"Missing Version which is required property in PG_ProviderModule class.");
 434                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 435 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_VERSION_IN_PG_PROVIDERMODULE",
 436                        		"Missing Version which is required property in PG_ProviderModule class."));
 437 kumpf         1.1      	}
 438                        
 439 kumpf         1.41             Uint32 ifcTypeIndex =
 440                                    instanceObject.findProperty(_PROPERTY_INTERFACETYPE);
 441                        	if (ifcTypeIndex == PEG_NOT_FOUND)
 442 kumpf         1.1      	{
 443 humberto      1.53     		//l10n 485
 444 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 445                        		//"Missing InterfaceType which is required property in PG_ProviderModule class.");
 446                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 447 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_INTERFACETYPE_IN_PG_PROVIDERMODULE",
 448 humberto      1.54     		"Missing InterfaceType which is required property in PG_ProviderModule class."));
 449 kumpf         1.1      	}
 450 kumpf         1.41             String ifcTypeString;
 451                                instanceObject.getProperty(ifcTypeIndex).getValue().
 452                                    get(ifcTypeString);
 453 mday          1.45     
 454 schuur        1.63             if (ifcTypeString != "C++Default"
 455 se.gupta      1.72     #ifdef PEGASUS_ENABLE_CMPI_PROVIDER_MANAGER
 456 schuur        1.63                 && ifcTypeString != "CMPI"
 457                        #endif
 458 a.dunfey      1.82.2.2 #ifdef PEGASUS_ENABLE_JMPI_PROVIDER_MANAGER
 459                                    && (ifcTypeString != "JMPI")
 460                                    && (ifcTypeString != "JMPIExperimental")
 461                        #endif
 462 schuur        1.63     	        )
 463 kumpf         1.41     	{
 464 humberto      1.53     		//l10n 485
 465 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
 466                        		//"Unsupported InterfaceType value: \"" + ifcTypeString + "\"");
 467                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
 468 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.UNSUPPORTED_INTERFACETYPE_VALUE",
 469                        		"Unsupported InterfaceType value: \"$0\"",ifcTypeString));
 470 kumpf         1.41     	}
 471 kumpf         1.1      
 472 kumpf         1.41             Uint32 ifcVersionIndex =
 473                                    instanceObject.findProperty(_PROPERTY_INTERFACEVERSION);
 474                        	if (ifcVersionIndex == PEG_NOT_FOUND)
 475 kumpf         1.1      	{
 476 humberto      1.53     		//l10n 485
 477 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 478                        		//"Missing InterfaceVersion which is required property in PG_ProviderModule class.");
 479                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 480 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_INTERFACEVERSION_IN_PG_PROVIDERMODULE",
 481                        		"Missing InterfaceVersion which is required property in PG_ProviderModule class."));
 482 kumpf         1.41     	}
 483                                String ifcVersionString;
 484                                instanceObject.getProperty(ifcVersionIndex).getValue().
 485                                    get(ifcVersionString);
 486 schuur        1.63             if (
 487 se.gupta      1.72     #ifdef PEGASUS_ENABLE_CMPI_PROVIDER_MANAGER
 488 schuur        1.63                (ifcTypeString == "CMPI" &&
 489                                    ifcVersionString != "2.0.0") ||
 490                        #endif
 491 a.dunfey      1.82.2.2 #ifdef PEGASUS_ENABLE_JMPI_PROVIDER_MANAGER
 492                                   (ifcTypeString == "JMPI" &&
 493                                    ifcVersionString != "1.0.0" &&
 494                                    ifcVersionString != "2.0.0" &&
 495                                    ifcVersionString != "2.2.0") ||
 496                                   (ifcTypeString == "JMPIExperimental" &&
 497                                    ifcVersionString != "0.0.1") ||
 498                        #endif
 499 schuur        1.63                (ifcTypeString == "C++Default" &&
 500                                    ifcVersionString != "2.1.0" &&
 501                                    ifcVersionString != "2.2.0" &&
 502 kumpf         1.74                 ifcVersionString != "2.3.0" &&
 503 a.dunfey      1.82.2.3             ifcVersionString != "2.5.0" &&
 504                                    ifcVersionString != "2.6.0"))
 505 kumpf         1.41     	{
 506 humberto      1.53     		//l10n 485
 507 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
 508                        		//"Unsupported InterfaceVersion value: \"" + ifcVersionString +
 509                                           // "\"");
 510                                String unsupported = "InterfaceVersion";
 511                                throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
 512 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.UNSUPPORTED_INTERFACEVERSION_VALUE",
 513                        		"Unsupported InterfaceVersion value: \"$0\"",ifcVersionString));
 514 kumpf         1.1      	}
 515                        
 516 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_LOCATION) == PEG_NOT_FOUND)
 517 kumpf         1.1      	{
 518 humberto      1.53     		//l10n 485
 519 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 520                        		//"Missing Location which is required property in PG_ProviderModule class.");
 521                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 522 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_LOCATION_IN_PG_PROVIDERMODULE",
 523                        		"Missing Location which is required property in PG_ProviderModule class."));
 524 kumpf         1.1      	}
 525                        
 526 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_OPERATIONALSTATUS) == 
 527                                    PEG_NOT_FOUND)
 528 kumpf         1.1      	{
 529                        	    Array<Uint16> _operationalStatus;
 530 kumpf         1.68     	    _operationalStatus.append(CIM_MSE_OPSTATUS_VALUE_OK);
 531 kumpf         1.1      	    instance.addProperty (CIMProperty
 532                        		(_PROPERTY_OPERATIONALSTATUS, _operationalStatus));
 533                        	}
 534 kumpf         1.74     
 535                                //
 536                                // Validate the UserContext property
 537                                //
 538 kumpf         1.76             CIMValue userContextValue;
 539 kumpf         1.74             Uint32 userContextIndex = instanceObject.findProperty(
 540                                    PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT);
 541 kumpf         1.76     
 542 kumpf         1.74             if (userContextIndex != PEG_NOT_FOUND)
 543                                {
 544 kumpf         1.76                 userContextValue =
 545                                        instanceObject.getProperty(userContextIndex).getValue();
 546                                }
 547                        
 548                                if (!userContextValue.isNull())
 549                                {
 550 kumpf         1.74     #ifdef PEGASUS_DISABLE_PROV_USERCTXT
 551                                    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
 552                                        "ControlProviders.ProviderRegistrationProvider."
 553                                            "ProviderRegistrationProvider.USERCONTEXT_UNSUPPORTED",
 554                                        "The UserContext property in the PG_ProviderModule class is "
 555                                            "not supported."));
 556                        #else
 557 kumpf         1.76                 Uint16 userContext;
 558                                    userContextValue.get(userContext);
 559 kumpf         1.74     
 560                                    if (!(
 561                        # ifndef PEGASUS_DISABLE_PROV_USERCTXT_REQUESTOR
 562 kumpf         1.76                       (userContext == PG_PROVMODULE_USERCTXT_REQUESTOR) ||
 563 kumpf         1.74     # endif
 564                        # ifndef PEGASUS_DISABLE_PROV_USERCTXT_DESIGNATED
 565 kumpf         1.76                       (userContext == PG_PROVMODULE_USERCTXT_DESIGNATED) ||
 566 kumpf         1.74     # endif
 567                        # ifndef PEGASUS_DISABLE_PROV_USERCTXT_PRIVILEGED
 568 kumpf         1.76                       (userContext == PG_PROVMODULE_USERCTXT_PRIVILEGED) ||
 569 kumpf         1.74     # endif
 570                        # ifndef PEGASUS_DISABLE_PROV_USERCTXT_CIMSERVER
 571 kumpf         1.76                       (userContext == PG_PROVMODULE_USERCTXT_CIMSERVER) ||
 572 kumpf         1.74     # endif
 573                                          0))
 574                                    {
 575                                        throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
 576                                            MessageLoaderParms(
 577                                                "ControlProviders.ProviderRegistrationProvider."
 578                                                    "ProviderRegistrationProvider."
 579                                                    "UNSUPPORTED_USERCONTEXT_VALUE",
 580                                                "Unsupported UserContext value: \"$0\".",
 581 kumpf         1.76                             userContext));
 582 kumpf         1.74                 }
 583                        
 584                                    // DesignatedUserContext property is required when UserContext == 3
 585 kumpf         1.76                 if (userContext == PG_PROVMODULE_USERCTXT_DESIGNATED)
 586 kumpf         1.74                 {
 587                                        Uint32 designatedUserIndex = instanceObject.findProperty(
 588                                            PEGASUS_PROPERTYNAME_MODULE_DESIGNATEDUSER);
 589                                        if ((designatedUserIndex == PEG_NOT_FOUND) ||
 590                                            instanceObject.getProperty(designatedUserIndex).getValue()
 591                                                .isNull())
 592                                        {
 593                                            throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
 594                                                MessageLoaderParms(
 595                                                    "ControlProviders.ProviderRegistrationProvider."
 596                                                        "ProviderRegistrationProvider."
 597                                                        "MISSING_DESIGNATEDUSER_IN_PG_PROVIDERMODULE",
 598                                                    "Missing DesignatedUserContext property in "
 599                                                        "PG_ProviderModule instance."));
 600                                        }
 601                                        else
 602                                        {
 603                                            // Validate that DesignatedUserContext is of String type
 604                                            String designatedUser;
 605                                            instanceObject.getProperty(designatedUserIndex).getValue()
 606                                                .get(designatedUser);
 607 kumpf         1.74                     }
 608                                    }
 609                        #endif
 610                                }
 611 kumpf         1.1          }
 612 kumpf         1.36         else if (className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))
 613 kumpf         1.1          {
 614                        	//
 615                        	// ProviderModuleName, ProviderName, InstanceID, ClassName,
 616                         	// Namespaces, and ProviderType properties must be set
 617                        	//
 618                        
 619 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
 620                                    PEG_NOT_FOUND)
 621 kumpf         1.1      	{
 622 humberto      1.53     		//l10n 485
 623 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 624                        		//"Missing ProviderModuleName which is required property in PG_ProviderCapabilities class.");
 625                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 626 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDERMODULENAME_IN_PG_PROVIDERCAPABILITIES",
 627                        		"Missing ProviderModuleName which is required property in PG_ProviderCapabilities class."));
 628 kumpf         1.1      	}
 629                        
 630 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_PROVIDERNAME) == 
 631                                    PEG_NOT_FOUND)
 632 kumpf         1.1      	{
 633 humberto      1.53     		//l10n 485
 634 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 635                        		//"Missing ProviderName which is required property in PG_ProviderCapabilities class.");
 636                        		String missing = "ProviderName";
 637                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 638                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_REQUIRED_PROPERTY",
 639 humberto      1.53     		"Missing ProviderName which is required property in PG_ProviderCapabilities class."));
 640 kumpf         1.1      	}
 641                        
 642 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_CAPABILITYID) == 
 643                                    PEG_NOT_FOUND)
 644 kumpf         1.1      	{
 645 humberto      1.53     		//l10n 485
 646 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 647                        		//"Missing CapabilityID which is required property in PG_ProviderCapabilities class.");
 648                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 649 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSINGCAPABILITYID_IN_PG_PROVIDERCAPABILITIES",
 650                        		"Missing CapabilityID which is required property in PG_ProviderCapabilities class."));
 651 kumpf         1.1      	}
 652                        
 653 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_CLASSNAME) == PEG_NOT_FOUND)
 654 kumpf         1.1      	{
 655 humberto      1.53     		//l10n 485
 656 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 657                        		//"Missing ClassName which is required property in PG_ProviderCapabilities class.");
 658                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 659 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_CLASSNAME_IN_PG_PROVIDERCAPABILITIES",
 660                        		"Missing ClassName which is required property in PG_ProviderCapabilities class."));
 661 kumpf         1.1      	}
 662                        
 663 kumpf         1.80             // Validate the Namespaces property
 664                        
 665                                Uint32 namespacesIndex =
 666                                    instanceObject.findProperty(_PROPERTY_NAMESPACES);
 667                                Array<String> namespacesArray;
 668                                if (namespacesIndex != PEG_NOT_FOUND)
 669                                {
 670                                    CIMValue namespacesValue =
 671                                        instanceObject.getProperty(namespacesIndex).getValue();
 672                                    if (!namespacesValue.isNull())
 673                                    {
 674                                        namespacesValue.get(namespacesArray);
 675                                    }
 676                                }
 677                        
 678                                if (namespacesArray.size() == 0)
 679 kumpf         1.1      	{
 680 kumpf         1.80                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
 681                                        "ControlProviders.ProviderRegistrationProvider."
 682                                            "ProviderRegistrationProvider."
 683                                            "MISSING_NAMESPACES_IN_PG_PROVIDERCAPABILITIES",
 684                                        "Missing Namespaces which is required property in "
 685                                            "PG_ProviderCapabilities class."));
 686 kumpf         1.1      	}
 687                        
 688 kumpf         1.77             // Validate the ProviderType property
 689                        
 690                                Uint32 providerTypeIndex =
 691                                    instanceObject.findProperty(_PROPERTY_PROVIDERTYPE);
 692                                Array<Uint16> providerTypeArray;
 693                                if (providerTypeIndex != PEG_NOT_FOUND)
 694                                {
 695 kumpf         1.80                 CIMValue providerTypeValue =
 696                                        instanceObject.getProperty(providerTypeIndex).getValue();
 697                                    if (!providerTypeValue.isNull())
 698                                    {
 699                                        providerTypeValue.get(providerTypeArray);
 700                                    }
 701 kumpf         1.77             }
 702                        
 703 kumpf         1.80             if (providerTypeArray.size() == 0)
 704 kumpf         1.77             {
 705                                    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
 706                                        MessageLoaderParms(
 707                                            "ControlProviders.ProviderRegistrationProvider."
 708                                                "ProviderRegistrationProvider."
 709                                                "MISSING_PROVIDERTYPE_IN_PG_PROVIDERCAPABILITIES",
 710                                            "Missing ProviderType which is required property in "
 711                                                "PG_ProviderCapabilities class."));
 712                                }
 713                        
 714                                for (Uint32 i = 0; i < providerTypeArray.size(); i++)
 715                                {
 716                                    if ((providerTypeArray[i] < 2) ||
 717                        #ifdef PEGASUS_DISABLE_EXECQUERY
 718                                        (providerTypeArray[i] > 6)
 719                        #else
 720                                        (providerTypeArray[i] > 7)
 721                        #endif
 722                                                                  )
 723                                    {
 724                                        throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
 725 kumpf         1.77                         MessageLoaderParms(
 726                                                "ControlProviders.ProviderRegistrationProvider."
 727                                                    "ProviderRegistrationProvider.UNSUPPORTED_"
 728                                                    "PROVIDERTYPE_IN_PG_PROVIDERCAPABILITIES",
 729                                                "Unsupported ProviderType value \"$0\" in "
 730                                                    "PG_ProviderCapabilities instance.",
 731                                                providerTypeArray[i]));
 732                                    }
 733                                }
 734 kumpf         1.1          }
 735 kumpf         1.46         else if (className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES))
 736                            {
 737                        	//
 738                        	// ProviderModuleName, ProviderName, CapabilityID, ProviderType,
 739                         	// and Destinations properties must be set
 740                        	//
 741                        
 742                        	if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
 743                                    PEG_NOT_FOUND)
 744                        	{
 745 humberto      1.49     //L10N_ TODO DONE
 746                        	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 747                        		//"Missing ProviderModuleName which is required property in PG_ConsumerCapabilities class.");
 748                        	    MessageLoaderParms parms(
 749                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDER_MODULE_NAME_WHICH_IS_REQUIRED",
 750 kumpf         1.46     		"Missing ProviderModuleName which is required property in PG_ConsumerCapabilities class.");
 751 humberto      1.49     
 752                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
 753 kumpf         1.46     	}
 754                        
 755                        	if (instanceObject.findProperty(_PROPERTY_PROVIDERNAME) == 
 756                                    PEG_NOT_FOUND)
 757                        	{
 758 humberto      1.49     //L10N_ TODO DONE
 759                        	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 760                        		//"Missing ProviderName which is required property in PG_ConsumerCapabilities class.");
 761                        
 762                        	    MessageLoaderParms parms(
 763                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDER_NAME_WHICH_IS_REQUIRED",
 764 kumpf         1.46     		"Missing ProviderName which is required property in PG_ConsumerCapabilities class.");
 765 humberto      1.49     
 766                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
 767 kumpf         1.46     	}
 768                        
 769                        	if (instanceObject.findProperty(_PROPERTY_CAPABILITYID) == 
 770                                    PEG_NOT_FOUND)
 771                        	{
 772 humberto      1.49     //L10N_ TODO DONE
 773                        	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 774                        		//"Missing CapabilityID which is required property in PG_ConsumerCapabilities class.");
 775                        
 776                        	    MessageLoaderParms parms(
 777                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_CAPABILITY_ID_WHICH_IS_REQUIRED",
 778 kumpf         1.46     		"Missing CapabilityID which is required property in PG_ConsumerCapabilities class.");
 779 humberto      1.49     
 780                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
 781 kumpf         1.46     	}
 782                        
 783                        	if (instanceObject.findProperty(_PROPERTY_PROVIDERTYPE) == PEG_NOT_FOUND)
 784                        	{
 785 humberto      1.49     //L10N_ TODO DONE
 786                        	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 787                        		//"Missing ProviderType which is required property in PG_ConsumerCapabilities class.");
 788                        
 789                        	    MessageLoaderParms parms(
 790                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDER_TYPE_WHICH_IS_REQUIRED",
 791 kumpf         1.46     		"Missing ProviderType which is required property in PG_ConsumerCapabilities class.");
 792 humberto      1.49     
 793                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
 794 kumpf         1.46     	}
 795                        
 796                        	if (instanceObject.findProperty(_PROPERTY_INDICATIONDESTINATIONS) == 
 797                        	    PEG_NOT_FOUND)
 798                        	{
 799 humberto      1.49     //L10N_ TODO DONE
 800                        	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 801                        		//"Missing Destinations which is required property in PG_ConsumerCapabilities class.");
 802                        
 803                        	    MessageLoaderParms parms(
 804                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_DESTINATIONS_TYPE_WHICH_IS_REQUIRED",
 805 kumpf         1.46     		"Missing Destinations which is required property in PG_ConsumerCapabilities class.");
 806 humberto      1.49     
 807                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
 808 kumpf         1.46     	}
 809                            }
 810 kumpf         1.10         else // PEGASUS_CLASSNAME_PROVIDER
 811 kumpf         1.1          {
 812                        	//
 813                        	// Name and ProviderModuleName properties must be set
 814                        	//
 815 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_PROVIDER_NAME) == PEG_NOT_FOUND)
 816 kumpf         1.1      	{
 817 humberto      1.53     		//l10n 485
 818 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 819                        		//"Missing Name which is required property in PG_Provider class.");
 820                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 821                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_REQUIRED_PROPERTY",
 822 humberto      1.53     		"Missing Name which is required property in PG_Provider class."));
 823 kumpf         1.1      	}
 824                        	
 825 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) == 
 826                                    PEG_NOT_FOUND)
 827 kumpf         1.1      	{
 828 humberto      1.53     		//l10n 485
 829 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 830                        		//"Missing ProviderModuleName which is required property in PG_Provider class.");
 831                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 832 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDERMODULENAME_IN_PG_PROVIDER",
 833                        		"Missing ProviderModuleName which is required property in PG_Provider class."));
 834 kumpf         1.1      	}
 835                            }
 836                        
 837                            // begin processing the request
 838                            handler.processing();
 839                        	
 840                            try
 841                            {
 842 david.dillard 1.78             returnReference =
 843                                    _providerRegistrationManager->createInstance(instanceReference, instance);
 844 kumpf         1.1          }
 845 david.dillard 1.78         catch(const CIMException&)
 846 kumpf         1.1          {
 847 david.dillard 1.78             throw;
 848 kumpf         1.1          }
 849                        
 850                            handler.deliver(returnReference);
 851                        
 852                            // complete processing request
 853                            handler.complete();
 854                        }
 855                        
 856                        // Unregister a provider
 857                        void ProviderRegistrationProvider::deleteInstance(
 858                            const OperationContext & context,
 859 kumpf         1.13         const CIMObjectPath & instanceReference,
 860 kumpf         1.33         ResponseHandler & handler)
 861 kumpf         1.1      {
 862 kumpf         1.15         // get userName and only privileged user can execute this operation
 863 kumpf         1.19         String userName;
 864                            try
 865                            {
 866 kumpf         1.37             IdentityContainer container = context.get(IdentityContainer::NAME);
 867 kumpf         1.19             userName = container.getUserName();
 868                            }
 869                            catch (...)
 870                            {
 871                                userName = String::EMPTY;
 872                            }
 873 kumpf         1.15     
 874 chip          1.24         if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
 875 kumpf         1.15         {
 876 humberto      1.48         	//l10n
 877                        	//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
 878                        	    //"You must have superuser privilege to unregister providers.");
 879                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,MessageLoaderParms(
 880                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_UNREGISTER_PROVIDERS",
 881                        	    "You must have superuser privilege to unregister providers.")); 	
 882 kumpf         1.15         }
 883                        
 884 kumpf         1.36         if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
 885 kumpf         1.10         {
 886 kumpf         1.36     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
 887                                    instanceReference.getNameSpace().getString());
 888 kumpf         1.10         }
 889                        
 890 chuck         1.47     
 891                        // l10n
 892                            // Get the client's list of preferred languages for the response
 893 a.dunfey      1.82.2.1     AcceptLanguageList al;
 894 chuck         1.47         try 
 895                            {
 896                                AcceptLanguageListContainer al_container = 
 897                        		(AcceptLanguageListContainer)context.get(AcceptLanguageListContainer::NAME);
 898                                al = al_container.getLanguages();
 899                            }
 900                            catch (...)
 901                            {
 902 a.dunfey      1.82.2.1         ;   // Leave AcceptLanguageList empty
 903 chuck         1.47         }
 904                        
 905 kumpf         1.36         CIMName className = instanceReference.getClassName();
 906 kumpf         1.1      
 907                            // ensure the class existing in the specified namespace
 908 kumpf         1.36         if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
 909                               !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
 910 kumpf         1.46            !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
 911 kumpf         1.36            !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
 912 kumpf         1.1          {
 913 kumpf         1.36     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
 914                                    className.getString());
 915 kumpf         1.1          }
 916                        
 917                            // begin processing the request
 918                            handler.processing();
 919                        
 920 kumpf         1.43         String moduleName;
 921                            Boolean moduleFound = false;
 922                            Array<CIMKeyBinding> keys = instanceReference.getKeyBindings();
 923                        
 924                            //
 925                            // disable provider before delete provider 
 926                            // registration if the class is PG_Provider
 927                            //
 928                            if (className.equal (PEGASUS_CLASSNAME_PROVIDER))
 929                            {
 930                            	// get module name from reference
 931                        
 932                            	for(Uint32 i=0; i<keys.size() ; i++)
 933                            	{
 934                        	    if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULENAME))
 935                        	    {
 936                        	        moduleName = keys[i].getValue();
 937                        	        moduleFound = true;
 938                        	    }
 939                        	}
 940                        
 941 kumpf         1.43         	// if _PROPERTY_PROVIDERMODULENAME key not found
 942                            	if( !moduleFound)
 943                            	{
 944 humberto      1.53         		//l10n 485
 945 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
 946                        		//"key ProviderModuleName was not found");
 947                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
 948 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.PROVIDERMODULENAME_KEY_NOT_FOUND",
 949                        		"key ProviderModuleName was not found"));
 950 kumpf         1.43         	}
 951                        
 952                        	// 
 953                        	// disable the provider 
 954                        	//
 955                        	try
 956                        	{
 957 kumpf         1.51     	     Sint16 ret_value = _disableModule(instanceReference, moduleName, true, al);
 958                        
 959 kumpf         1.43                  //
 960                                     // if the provider disable failed
 961                                     //
 962 chuck         1.47     // l10n
 963 kumpf         1.51                  if (ret_value == -1)
 964 kumpf         1.43                  {
 965 humberto      1.48                  	//l10n
 966                                         //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 967                                             //"disable the provider failed.");
 968                                         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 969                        					"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_FAILED",
 970                                            "disable the provider failed."));
 971 kumpf         1.43                  }
 972 kumpf         1.51     	     //
 973                                     // The provider disable failed since there are pending requests
 974                                     //
 975                                     if (ret_value == -2)
 976                                     {
 977                        //L10N TODO
 978 humberto      1.52                     // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 979                                             //"disable the provider failed: Provider is busy.");
 980                                         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 981                        					"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_FAILED_PROVIDER_BUSY",
 982                                            "disable the provider failed: Provider is busy."));
 983 kumpf         1.51                  }
 984 kumpf         1.43     	}
 985                            	catch(CIMException&)
 986                            	{
 987                        	    throw;
 988                            	}
 989                            }
 990                        
 991                            //
 992                            // disable provider module before remove provider registration
 993                            // if the class is PG_ProviderModule 
 994                            //
 995                        
 996                            if (className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
 997                            {
 998                            	// get module name from reference
 999                        
1000                            	for(Uint32 i=0; i<keys.size() ; i++)
1001                            	{
1002                        	    if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULE_NAME))
1003                        	    {
1004                        	        moduleName = keys[i].getValue();
1005 kumpf         1.43     	        moduleFound = true;
1006                        	    }
1007                        	}
1008                        
1009                            	// if _PROPERTY_PROVIDERMODULE_NAME key not found
1010                            	if( !moduleFound)
1011                            	{
1012 humberto      1.53         		//l10n 485
1013 humberto      1.48     	//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
1014                        		//"key Name was not found");
1015                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
1016 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.NAME_KEY_NOT_FOUND",
1017                        		"key Name was not found"));
1018 kumpf         1.43         	}
1019                        
1020                        	// 
1021                        	// disable the provider module
1022                        	//
1023                        	try
1024                        	{
1025 kumpf         1.51     	    Sint16 ret_value = _disableModule(instanceReference, moduleName, false, al);
1026                        
1027 kumpf         1.43                 //
1028                                    // if the provider module disable failed
1029                                    //
1030 chuck         1.47     // l10n
1031 kumpf         1.51                 if (ret_value == -1)
1032 kumpf         1.43                 {
1033 humberto      1.48                 	//l10n
1034                                         //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1035                                             //"disable the provider module failed.");
1036                                             throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
1037                        						"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_MODULE_FAILED",
1038                                             	"disable the provider module failed."));
1039 kumpf         1.43                 }
1040 kumpf         1.51     	    
1041                        	    //
1042                                    // The provider module disable failed since there are pending requests
1043                                    //
1044                                    if (ret_value == -2)
1045                                    {
1046                        //L10N TODO
1047 humberto      1.52                      //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1048                                            // "disable the provider module failed: Provider is busy.");
1049                                         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
1050                        						"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_MODULE_FAILED_PROVIDER_BUSY",
1051                                             	"disable the provider module failed: Provider is busy."));
1052 kumpf         1.51                 }
1053 david.dillard 1.78             }
1054                                catch(const CIMException&)
1055                                {
1056                                    throw;
1057                                }
1058 kumpf         1.43         }
1059                        
1060 kumpf         1.1          try
1061                            {
1062 david.dillard 1.78             _providerRegistrationManager->deleteInstance(instanceReference);
1063 kumpf         1.1          }
1064 david.dillard 1.78         catch(const CIMException&)
1065 kumpf         1.1          {
1066 david.dillard 1.78             throw;
1067 kumpf         1.1          }
1068                        
1069                            // complete processing the request
1070                            handler.complete();
1071                        }
1072                        
1073                        // Block a provider, unblock a provider, and stop a provider
1074                        void ProviderRegistrationProvider::invokeMethod(
1075                            const OperationContext & context,
1076 kumpf         1.13         const CIMObjectPath & objectReference,
1077 kumpf         1.28         const CIMName & methodName,
1078 kumpf         1.1          const Array<CIMParamValue> & inParameters,
1079 kumpf         1.33         MethodResultResponseHandler & handler)
1080 kumpf         1.1      {
1081 kumpf         1.15         // get userName and only privileged user can execute this operation
1082 kumpf         1.19         String userName;
1083                            try
1084                            {
1085 kumpf         1.37             IdentityContainer container = context.get(IdentityContainer::NAME);
1086 kumpf         1.19             userName = container.getUserName();
1087                            }
1088                            catch (...)
1089                            {
1090                                userName = String::EMPTY;
1091                            }
1092 kumpf         1.15     
1093 chip          1.24         if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
1094 mday          1.17         {
1095 humberto      1.48         	//l10n
1096                        	//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
1097                        	    //"You must have superuser privilege to disable or enable providers."); 
1098                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,MessageLoaderParms(
1099                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_DISABLE_ENABLE_PROVIDERS",
1100                        	    "You must have superuser privilege to disable or enable providers.")); 	
1101 mday          1.17         }
1102 kumpf         1.15     
1103 kumpf         1.36         if(!objectReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
1104 kumpf         1.10         {
1105 kumpf         1.36     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
1106                                    objectReference.getNameSpace().getString());
1107 kumpf         1.10         }
1108                        
1109 chuck         1.47     
1110                        // l10n
1111                            // Get the client's list of preferred languages for the response
1112 a.dunfey      1.82.2.1     AcceptLanguageList al;
1113 chuck         1.47         try 
1114                            {
1115                                AcceptLanguageListContainer al_container = 
1116                        		(AcceptLanguageListContainer)context.get(AcceptLanguageListContainer::NAME);
1117                                al = al_container.getLanguages();
1118                            }
1119                            catch (...)
1120                            {
1121 a.dunfey      1.82.2.1         ;   // Leave AcceptLanguageList empty
1122 chuck         1.47         }
1123                        
1124 kumpf         1.5          String moduleName;
1125                            Boolean moduleFound = false;
1126 kumpf         1.3      
1127 kumpf         1.5          // get module name from reference
1128 kumpf         1.35         Array<CIMKeyBinding> keys = objectReference.getKeyBindings();
1129 kumpf         1.1      
1130 kumpf         1.5          for(Uint32 i=0; i<keys.size() ; i++)
1131 kumpf         1.1          {
1132 kumpf         1.36     	if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULE_NAME))
1133 kumpf         1.1      	{
1134 kumpf         1.5      	    moduleName = keys[i].getValue();
1135                        	    moduleFound = true;
1136 kumpf         1.1      	}
1137                            }
1138                        
1139 kumpf         1.5          // if _PROPERTY_PROVIDERMODULE_NAME key not found
1140                            if( !moduleFound)
1141 kumpf         1.1          {
1142 humberto      1.53         	//l10n 485
1143 humberto      1.48     	throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
1144 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.NAME_KEY_NOT_FOUND",
1145                        		"key Name was not found"));
1146 kumpf         1.1          }
1147                        
1148 kumpf         1.5          handler.processing();
1149                        
1150                            Sint16 ret_value;
1151 kumpf         1.1      
1152 kumpf         1.56         try
1153 kumpf         1.1          {
1154 kumpf         1.56             if(methodName.equal(_STOP_PROVIDER))
1155                            	{
1156                        	    // disable module
1157 chuck         1.47         	     ret_value =  _disableModule(objectReference, moduleName, false, al);
1158 kumpf         1.8      	}
1159 kumpf         1.56         	else if(methodName.equal(_START_PROVIDER))
1160 kumpf         1.43         	{
1161 kumpf         1.56     	    // enable module
1162                            	     ret_value =  _enableModule(objectReference, moduleName, al);
1163 kumpf         1.1      	}
1164 kumpf         1.56             else
1165 david.dillard 1.78             {
1166                                    throw PEGASUS_CIM_EXCEPTION(CIM_ERR_METHOD_NOT_AVAILABLE, String::EMPTY);
1167                                }
1168 kumpf         1.1          }
1169 david.dillard 1.78         catch(const CIMException&)
1170 kumpf         1.1          {
1171 david.dillard 1.78             throw;
1172 kumpf         1.1          }
1173 kumpf         1.56     
1174                            CIMValue retValue(ret_value);
1175                            handler.deliver(retValue);
1176                            handler.complete();
1177 kumpf         1.5      }
1178                        
1179                        // get provider manager service
1180                        MessageQueueService * ProviderRegistrationProvider::_getProviderManagerService()
1181                        {
1182                            MessageQueue * queue = MessageQueue::lookup(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP);
1183                            MessageQueueService * _service = dynamic_cast<MessageQueueService *>(queue);
1184                        
1185 chip          1.24         return(_service);
1186 kumpf         1.5      }
1187                        
1188                        ProviderRegistrationProvider & ProviderRegistrationProvider::operator=(const ProviderRegistrationProvider & handle)
1189                        {
1190                            if(this == &handle)
1191                            {
1192                                return(*this);
1193                            }
1194                        
1195                            return(*this);
1196                        }
1197 kumpf         1.1      
1198 kumpf         1.5      Array<Uint16> ProviderRegistrationProvider::_sendDisableMessageToProviderManager(
1199                                CIMDisableModuleRequestMessage * disable_req)
1200                        {
1201                            MessageQueueService * _service = _getProviderManagerService();
1202                            Uint32 _queueId = _service->getQueueId();
1203                        
1204                            // create request envelope
1205                            AsyncLegacyOperationStart * asyncRequest =
1206                                new AsyncLegacyOperationStart (
1207                                    _service->get_next_xid(),
1208                                    NULL,
1209                                    _queueId,
1210                                    disable_req,
1211                                    _queueId);
1212                        
1213 kumpf         1.8          AsyncReply * asyncReply = _controller->ClientSendWait(*_client_handle,
1214                        							  _queueId,
1215                        							  asyncRequest);
1216 kumpf         1.10         CIMDisableModuleResponseMessage * response =
1217                        	reinterpret_cast<CIMDisableModuleResponseMessage *>(
1218 kumpf         1.70                  (dynamic_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
1219 kumpf         1.8          if (response->cimException.getCode() != CIM_ERR_SUCCESS)
1220                            {
1221 david.dillard 1.78             CIMException e = response->cimException;
1222 kumpf         1.8              delete asyncRequest;
1223                                delete asyncReply;
1224                                delete response;
1225 david.dillard 1.78             throw e;
1226 kumpf         1.8          }
1227 kumpf         1.5      
1228 chip          1.24         Array<Uint16> operationalStatus = response->operationalStatus;
1229 kumpf         1.8      
1230                            delete asyncRequest;
1231                            delete asyncReply;
1232                            delete response;
1233 mday          1.16     
1234 kumpf         1.5          return(operationalStatus);
1235                        }
1236                        
1237                        Array<Uint16> ProviderRegistrationProvider::_sendEnableMessageToProviderManager(
1238                                CIMEnableModuleRequestMessage * enable_req)
1239                        {
1240                            MessageQueueService * _service = _getProviderManagerService();
1241                            Uint32 _queueId = _service->getQueueId();
1242                        
1243                            // create request envelope
1244                            AsyncLegacyOperationStart * asyncRequest =
1245                                new AsyncLegacyOperationStart (
1246                                    _service->get_next_xid(),
1247                                    NULL,
1248                                    _queueId,
1249                                    enable_req,
1250                                    _queueId);
1251                        
1252 kumpf         1.8          AsyncReply * asyncReply = _controller->ClientSendWait(*_client_handle,
1253                        							  _queueId,
1254                        							  asyncRequest);
1255                            CIMEnableModuleResponseMessage * response =
1256                        	reinterpret_cast<CIMEnableModuleResponseMessage *>(
1257 kumpf         1.70                  (dynamic_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
1258 kumpf         1.8          if (response->cimException.getCode() != CIM_ERR_SUCCESS)
1259                            {
1260                        	CIMException e = response->cimException;
1261                                delete asyncRequest;
1262                                delete asyncReply;
1263                                delete response;
1264                        	throw (e);
1265                            }
1266                        
1267 chip          1.24         Array<Uint16> operationalStatus = response->operationalStatus;
1268 kumpf         1.8      
1269                            delete asyncRequest;
1270                            delete asyncReply;
1271                            delete response;
1272 mday          1.16     
1273 kumpf         1.5          return(operationalStatus);
1274 kumpf         1.6      }
1275                        
1276                        // send termination message to subscription service
1277                        void ProviderRegistrationProvider::_sendTerminationMessageToSubscription(
1278 kumpf         1.43         const CIMObjectPath & ref, const String & moduleName,
1279 chuck         1.47         const Boolean disableProviderOnly,
1280 a.dunfey      1.82.2.1     const AcceptLanguageList & al)
1281 kumpf         1.6      {
1282                            CIMInstance instance;
1283                            String _moduleName;
1284                            Array<CIMInstance> instances;
1285                        
1286 kumpf         1.43         if (!disableProviderOnly)
1287                            {
1288                                CIMObjectPath reference("", PEGASUS_NAMESPACENAME_INTEROP,
1289                        	    PEGASUS_CLASSNAME_PROVIDER, ref.getKeyBindings());
1290 chip          1.24     
1291 kumpf         1.43             Array<CIMObjectPath> instanceNames =
1292                        	    _providerRegistrationManager->enumerateInstanceNames(reference);
1293 kumpf         1.6      
1294 kumpf         1.43             // find all the instances which have same module name as moduleName
1295                                for (Uint32 i = 0, n=instanceNames.size(); i < n; i++)
1296                                {
1297 kumpf         1.42     	    //
1298                                    // get provider module name from reference
1299                                    //
1300                        
1301                                    Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
1302                        
1303                                    for(Uint32 j=0; j < keys.size(); j++)
1304                                    {
1305                                        if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
1306                                        {
1307                                            _moduleName = keys[j].getValue();
1308                                        }
1309                                    }
1310 kumpf         1.6      
1311 kumpf         1.43     	    if (String::equalNoCase(moduleName, _moduleName))
1312                        	    {
1313                        	        reference.setKeyBindings(keys);
1314                        	        instance = _providerRegistrationManager->getInstance(reference);
1315 kumpf         1.55     		//
1316                        		// if the provider is indication provider
1317                        		//
1318 kumpf         1.70     		if (_isIndicationProvider(moduleName, instance))
1319 kumpf         1.55     		{
1320                        	            instances.append(instance);
1321                        		}
1322 kumpf         1.43     	    }
1323                                }
1324                            }
1325                            else
1326                            {
1327 kumpf         1.55     	instance = _providerRegistrationManager->getInstance(ref);
1328                        
1329                        	//
1330                        	// if the provider is indication provider
1331                        	//
1332 kumpf         1.70     	if (_isIndicationProvider(moduleName, instance))
1333 kumpf         1.55     	{
1334 kumpf         1.6      	    instances.append(instance);
1335 kumpf         1.55     	}
1336 kumpf         1.6          }
1337                        
1338                            //
1339                            // get indication server queueId
1340                            //
1341                            MessageQueueService * _service = _getIndicationService();
1342                        
1343 kumpf         1.15         if (_service != NULL)
1344                            {
1345                                Uint32 _queueId = _service->getQueueId();
1346 kumpf         1.6      
1347 kumpf         1.15             CIMNotifyProviderTerminationRequestMessage * termination_req =
1348                        	    new CIMNotifyProviderTerminationRequestMessage(
1349                        	        XmlWriter::getNextMessageId (),
1350                        	        instances,
1351                        	        QueueIdStack(_service->getQueueId()));
1352                        
1353 chuck         1.47     // l10n
1354 se.gupta      1.69             termination_req->operationContext.set(AcceptLanguageListContainer(al));
1355 chuck         1.47     
1356 kumpf         1.15             // create request envelope
1357 kumpf         1.71             AsyncLegacyOperationStart asyncRequest
1358                                    (_service->get_next_xid(),
1359                                    NULL,
1360                                    _queueId,
1361                                    termination_req,
1362                                    _queueId);
1363 kumpf         1.6      
1364 kumpf         1.71             AutoPtr <AsyncReply> asyncReply
1365                                    (_controller->ClientSendWait (* _client_handle, _queueId,
1366                                    &asyncRequest));
1367                                
1368                                AutoPtr <CIMNotifyProviderTerminationResponseMessage> response
1369                                    (reinterpret_cast <CIMNotifyProviderTerminationResponseMessage *>
1370                                    ((dynamic_cast <AsyncLegacyOperationResult *>
1371                                    (asyncReply.get ()))->get_result ()));
1372                                
1373                                if (response->cimException.getCode () != CIM_ERR_SUCCESS)
1374 kumpf         1.15             {
1375 kumpf         1.71                 CIMException e = response->cimException;
1376 david.dillard 1.78                 throw e;
1377 kumpf         1.15             }
1378 kumpf         1.6          }
1379                        }
1380                        
1381                        // get indication service
1382                        MessageQueueService * ProviderRegistrationProvider::_getIndicationService()
1383                        {
1384                            MessageQueue * queue = MessageQueue::lookup(
1385                        	PEGASUS_QUEUENAME_INDICATIONSERVICE);
1386                        
1387                            MessageQueueService * _service =
1388                        	dynamic_cast<MessageQueueService *>(queue);
1389                            return(_service);
1390 kumpf         1.43     }
1391                        
1392                        // disable provider module, return 0 if module is disabled successfully,
1393 kumpf         1.51     // return 1 if module is already disabled, return -2 if module can not be
1394                        // disabled since there are pending requests, otherwise, return -1
1395 kumpf         1.43     Sint16 ProviderRegistrationProvider::_disableModule(
1396                            const CIMObjectPath & objectReference, 
1397                            const String & moduleName,
1398 chuck         1.47         Boolean disableProviderOnly,
1399 a.dunfey      1.82.2.1     const AcceptLanguageList & al)
1400 kumpf         1.43     {
1401                            	//
1402                            	// get module status
1403                            	//
1404                            	Array<Uint16> _OperationalStatus =
1405                        	    _providerRegistrationManager->getProviderModuleStatus( moduleName);
1406                        
1407                        	for (Uint32 i = 0; i<_OperationalStatus.size(); i++)
1408                        	{
1409                        	    // retValue equals 1 if module is already disabled
1410 kumpf         1.68     	    if (_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED ||
1411                        		_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING)
1412 kumpf         1.43     	    {
1413                        		return (1);
1414                        	    }
1415                        	}
1416                        
1417                        	CIMInstance instance;
1418                        	Array<CIMInstance> instances;
1419                                CIMInstance mInstance;
1420                        	String _moduleName;
1421                        	Uint16 providers;
1422                        	CIMObjectPath providerRef;
1423 kumpf         1.55     	Boolean indProvider = false;
1424                                Array<Boolean> indicationProviders;
1425 kumpf         1.43     
1426                        	// disable a provider module or delete a provider module
1427                        	if (!disableProviderOnly)
1428                        	{
1429                        	    providerRef = CIMObjectPath(objectReference.getHost(),
1430                        				 objectReference.getNameSpace(),
1431                        				 PEGASUS_CLASSNAME_PROVIDER,
1432                        				 objectReference.getKeyBindings());
1433                        
1434                                    // get module instance
1435                                    mInstance = 
1436                        	        _providerRegistrationManager->getInstance(objectReference);
1437                        
1438                        	}
1439                        	else // disable a provider
1440                        	{
1441                                    // get module instance
1442                        	    Array <CIMKeyBinding> moduleKeyBindings;
1443                        	    moduleKeyBindings.append (CIMKeyBinding
1444                        		(_PROPERTY_PROVIDERMODULE_NAME, moduleName, 
1445                        		 CIMKeyBinding::STRING)); 
1446 kumpf         1.43     
1447                        	    CIMObjectPath moduleRef(objectReference.getHost(),
1448                        				    objectReference.getNameSpace(),
1449                        				    PEGASUS_CLASSNAME_PROVIDERMODULE,
1450                        				    moduleKeyBindings);
1451                        				    
1452                                    mInstance = 
1453                        	        _providerRegistrationManager->getInstance(moduleRef);
1454                        	}
1455                        
1456                                if (!disableProviderOnly)
1457                                {
1458                        	    // get all provider instances which have same module name as 
1459                        	    // moduleName
1460                         	    Array<CIMObjectPath> instanceNames = 
1461                        	        _providerRegistrationManager->enumerateInstanceNames(providerRef);
1462                        
1463                        	    for(Uint32 i = 0, n=instanceNames.size(); i < n; i++)
1464                        	    {
1465                        	        //
1466                                        // get provider module name from reference
1467 kumpf         1.43                     //
1468                        
1469                                        Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
1470                        
1471                                        for(Uint32 j=0; j < keys.size(); j++)
1472                                        {
1473                                            if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
1474                                            {
1475                                                _moduleName = keys[j].getValue();
1476                                            }
1477                                        }
1478                        
1479                        	        if (String::equalNoCase(_moduleName, moduleName))
1480                        	        {
1481                        		    providerRef.setKeyBindings(keys);
1482                        		    instance = _providerRegistrationManager->getInstance
1483                        			(providerRef);
1484 kumpf         1.70     		    if (_isIndicationProvider(moduleName, instance))
1485 kumpf         1.55                         {
1486                                                indProvider = true;
1487                                                indicationProviders.append(true);
1488                                            }
1489                                            else
1490                                            {
1491                                                indicationProviders.append(false);
1492                                            }
1493 kumpf         1.43     		    instances.append(instance);
1494                        	        }
1495                        
1496                        	    }
1497                                }
1498                                else
1499                                {
1500 kumpf         1.55     	    instance = _providerRegistrationManager->getInstance(objectReference);
1501 kumpf         1.70                 if (_isIndicationProvider(moduleName, instance))
1502 kumpf         1.55                 {
1503                                        indProvider = true;
1504                                        indicationProviders.append(true);
1505                                    }
1506                                    else
1507                                    {
1508                                        indicationProviders.append(false);
1509                                    }
1510                        
1511                                    instances.append(instance);
1512 kumpf         1.43             }
1513                        
1514                                //
1515                                // get provider manager service
1516                                //
1517                                MessageQueueService * _service = _getProviderManagerService();
1518                        
1519                        	if (_service != NULL)
1520                        	{
1521                        	    // create CIMDisableModuleRequestMessage
1522                        	    CIMDisableModuleRequestMessage * disable_req =
1523                        	        new CIMDisableModuleRequestMessage(
1524                        		    XmlWriter::getNextMessageId (),
1525                        		    mInstance,
1526                        		    instances,
1527                        		    disableProviderOnly,
1528 kumpf         1.55     		    indicationProviders,
1529 kumpf         1.43     		    QueueIdStack(_service->getQueueId()));
1530 chuck         1.47     // l10n
1531 se.gupta      1.66     		disable_req->operationContext.set(AcceptLanguageListContainer(al));;
1532 kumpf         1.43     
1533                          	    Array<Uint16> _opStatus =
1534                        	        _sendDisableMessageToProviderManager(disable_req);
1535                        
1536                        	    if (!disableProviderOnly) // disable provider module
1537                        	    {
1538                        	        for (Uint32 i = 0; i<_opStatus.size(); i++)
1539                        	        {
1540                        		    // module was disabled successfully
1541 kumpf         1.68     	            if (_opStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED)
1542 kumpf         1.43     	            {
1543 kumpf         1.55     			if (indProvider)
1544                        			{
1545                        	 	            // send termination message to subscription service
1546                        		            _sendTerminationMessageToSubscription(objectReference,
1547                        				  moduleName, false, al);
1548                        			}
1549 kumpf         1.43     		        return (0);
1550                        	            }
1551 kumpf         1.51     
1552                        		    // module is not disabled since there are pending
1553                                            // requests for the providers in the module
1554 kumpf         1.68                         if (_opStatus[i] == CIM_MSE_OPSTATUS_VALUE_OK)
1555 kumpf         1.51                         {
1556                                                return (-2);
1557                                            }
1558 kumpf         1.43     	        }
1559                        	    }
1560                        	    else // disable provider
1561                        	    {
1562 kumpf         1.55     		if (indProvider)
1563                        		{
1564                        	            _sendTerminationMessageToSubscription(objectReference,
1565 chuck         1.47     			moduleName, true, al);
1566 kumpf         1.55     		}
1567 kumpf         1.43     	        return (0);
1568                        	    }
1569                          	}
1570                        
1571                                // disable failed
1572                        	return (-1);
1573 kumpf         1.55     }
1574                        
1575 kumpf         1.56     // enable provider module 
1576                        // return 0 if module is enabled successfully,
1577                        // return 1 if module is already enabled,
1578                        // return 2 if module can not be enabled since module is stopping,
1579                        // otherwise, return -1 
1580                        Sint16 ProviderRegistrationProvider::_enableModule(
1581                            const CIMObjectPath & moduleRef, 
1582                            const String & moduleName,
1583 a.dunfey      1.82.2.1     const AcceptLanguageList & al)
1584 kumpf         1.56     {
1585                            	//
1586                            	// get module status
1587                            	//
1588                            	Array<Uint16> _OperationalStatus =
1589                        	    _providerRegistrationManager->getProviderModuleStatus( moduleName);
1590                        
1591                        	for (Uint32 i = 0; i<_OperationalStatus.size(); i++)
1592                        	{
1593                        	    // retValue equals 1 if module is already enabled
1594 kumpf         1.68     	    if (_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_OK)
1595 kumpf         1.56     	    {
1596                        		return (1);
1597                        	    }
1598                        
1599                        	    // retValue equals 2 if module is stopping
1600                        	    // at this stage, module can not be started
1601 kumpf         1.68     	    if (_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING)
1602 kumpf         1.56     	    {
1603                                        return (2);
1604                        	    }
1605                        	}
1606                        
1607                                // get module instance
1608                                CIMInstance mInstance = 
1609                        	    _providerRegistrationManager->getInstance(moduleRef);
1610                        
1611                        	//
1612                                // get provider manager service
1613                                //
1614                                MessageQueueService * _service = _getProviderManagerService();
1615                        	Boolean enabled = false;
1616                        
1617 kumpf         1.65             if (_service != NULL)
1618 kumpf         1.56     	{
1619                        	    // create CIMEnableModuleRequestMessage
1620                        	    CIMEnableModuleRequestMessage * enable_req =
1621                        	        new CIMEnableModuleRequestMessage(
1622                        		    XmlWriter::getNextMessageId (),
1623                        		    mInstance,
1624                        		    QueueIdStack(_service->getQueueId()));
1625                        // l10n
1626 se.gupta      1.66             enable_req->operationContext.set(AcceptLanguageListContainer(al));;    
1627                        		
1628 kumpf         1.56       	    Array<Uint16> _opStatus;
1629                                    _opStatus = _sendEnableMessageToProviderManager(enable_req);
1630                        
1631                        	    for (Uint32 i = 0; i<_opStatus.size(); i++)
1632                        	    {
1633                        		// module is enabled successfully
1634 kumpf         1.68     	        if (_opStatus[i] == CIM_MSE_OPSTATUS_VALUE_OK)
1635 kumpf         1.56     	        {
1636                        		    enabled = true;
1637                        	        }
1638                        	    }
1639                        	}
1640                        
1641                        	if (enabled)
1642                        	{
1643                        	    //
1644 kumpf         1.59     	    // Since module is enabled, need get updated module instance
1645                        	    //
1646 kumpf         1.65                 CIMInstance updatedModuleInstance = 
1647 kumpf         1.59     	        _providerRegistrationManager->getInstance(moduleRef);
1648                        
1649 kumpf         1.65     	    // module is enabled, initialize providers as necessary
1650                        	    _providerRegistrationManager->initializeProviders(
1651                        		updatedModuleInstance);
1652                        
1653 kumpf         1.59     	    //
1654                        	    // The module is enabled, need to send enable message to 
1655 kumpf         1.56     	    // subscription service if the provider is an indication provider
1656                        	    //
1657                        
1658                        	    CIMObjectPath providerRef = CIMObjectPath(String::EMPTY,
1659                        				    moduleRef.getNameSpace(),
1660                        				    PEGASUS_CLASSNAME_PROVIDER,
1661                        				    Array<CIMKeyBinding>());
1662                        
1663                        	    //
1664                        	    // get all provider instances which have same module name as
1665                        	    // moduleName
1666                                    //
1667                        	    Array<CIMObjectPath> instanceNames =
1668                        	        _providerRegistrationManager->enumerateInstanceNames(providerRef);
1669                        	    CIMInstance pInstance;
1670                        	    String _moduleName;
1671                        	    String _providerName;
1672                        	    Array<CIMInstance> capInstances;
1673                        
1674                        	    for(Uint32 i = 0, n=instanceNames.size(); i < n; i++)
1675                        	    {
1676 kumpf         1.56     
1677                                        Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
1678                        
1679                                        for(Uint32 j=0; j < keys.size(); j++)
1680                                        {
1681                        	            //
1682                                            // get provider module name from reference
1683                                            //
1684                                            if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
1685                                            {
1686                                                _moduleName = keys[j].getValue();
1687                                            }
1688                        
1689                        	            //
1690                                            // get provider name from reference
1691                                            //
1692                                            if(keys[j].getName().equal (_PROPERTY_PROVIDER_NAME))
1693                                            {
1694                                                _providerName = keys[j].getValue();
1695                                            }
1696                                        }
1697 kumpf         1.56     
1698                        	        if (String::equalNoCase(_moduleName, moduleName))
1699                        	        {
1700                        	 	    providerRef.setKeyBindings(keys);
1701                        	            pInstance = _providerRegistrationManager->getInstance
1702                        			(providerRef);
1703                        		    // 
1704                        		    // get all the indication capability instances which belongs 
1705                        		    // to this provider
1706                        		    //
1707                        		    capInstances = _getIndicationCapInstances(
1708                        				   moduleName, pInstance, providerRef);
1709                        
1710                        		    //
1711                        		    // if there are indication capability instances
1712                        		    //
1713 kumpf         1.71                         if (capInstances.size() != 0)
1714 kumpf         1.56     		    {
1715 kumpf         1.65     		        _sendEnableMessageToSubscription(updatedModuleInstance,
1716 kumpf         1.56     		  					 pInstance,
1717                        						     	 capInstances,
1718                        							 al);
1719                        		    }
1720                        	        }    
1721                        	    }
1722                        	    return (0);
1723                        	}
1724                        
1725                        
1726                                // enable failed
1727                        	return (-1);
1728                        }
1729                        
1730                        // send enable message to indication service
1731                        void ProviderRegistrationProvider::_sendEnableMessageToSubscription(
1732                            const CIMInstance & mInstance,
1733                            const CIMInstance & pInstance,
1734                            const Array<CIMInstance> & capInstances,
1735 a.dunfey      1.82.2.1     const AcceptLanguageList & al)
1736 kumpf         1.56     {
1737                            //
1738                            // get indication server queueId
1739                            //
1740                            MessageQueueService * _service = _getIndicationService();
1741                        
1742                            if (_service != NULL)
1743                            {
1744                            	Uint32 _queueId = _service->getQueueId();
1745                        	    
1746                            	CIMNotifyProviderEnableRequestMessage * enable_req = 
1747                        		new CIMNotifyProviderEnableRequestMessage (
1748                        		    XmlWriter::getNextMessageId (),
1749                        		    capInstances,
1750                        		    QueueIdStack(_service->getQueueId()));
1751                        
1752 se.gupta      1.66     	enable_req->operationContext.set(AcceptLanguageListContainer(al));
1753 se.gupta      1.67         enable_req->operationContext.insert(ProviderIdContainer(mInstance,pInstance));
1754 se.gupta      1.66     	
1755 kumpf         1.56     	// create request envelope
1756                                AsyncLegacyOperationStart * asyncRequest =
1757                                    new AsyncLegacyOperationStart (
1758                                        _service->get_next_xid(),
1759                                        NULL,
1760                                        _queueId,
1761                                        enable_req,
1762                                        _queueId);
1763                        	    
1764 kumpf         1.64     	AsyncReply * asyncReply = 
1765                        	    _controller->ClientSendWait(*_client_handle,
1766                                              			_queueId,
1767                                              			asyncRequest);
1768 kumpf         1.56     
1769 kumpf         1.64             CIMNotifyProviderEnableResponseMessage * response =
1770                        	    reinterpret_cast<CIMNotifyProviderEnableResponseMessage *>(
1771 kumpf         1.70     		(dynamic_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
1772 kumpf         1.64     
1773                                if (response->cimException.getCode() != CIM_ERR_SUCCESS)
1774 david.dillard 1.78             {
1775                                    CIMException e = response->cimException;
1776                                    delete asyncRequest;
1777                                    delete asyncReply;
1778                                    delete response;
1779                                    throw e;
1780                                }
1781 kumpf         1.64     
1782                                delete asyncRequest;
1783                                delete asyncReply;
1784                                delete response;
1785 kumpf         1.56         }
1786                        }
1787                        
1788 kumpf         1.70     // If provider is an indication provider, return true,
1789 kumpf         1.55     // otherwise, return false
1790                        Boolean ProviderRegistrationProvider::_isIndicationProvider(
1791                            const String & moduleName,
1792 kumpf         1.70         const CIMInstance & instance)
1793 kumpf         1.55     {
1794                            // get provider name
1795                            String providerName;
1796 kumpf         1.70         Uint32 pos = instance.findProperty(_PROPERTY_PROVIDER_NAME);
1797 kumpf         1.55         if (pos != PEG_NOT_FOUND)
1798                            {
1799                        	instance.getProperty(pos).getValue().get(providerName);	
1800                            }
1801                        
1802 kumpf         1.70         return (_providerRegistrationManager->isIndicationProvider(
1803                        	    moduleName, providerName));
1804 kumpf         1.56     }
1805                        
1806                        //
1807                        // get all the capability instances whose provider type is indication 
1808                        // 
1809                        Array<CIMInstance> ProviderRegistrationProvider::_getIndicationCapInstances(
1810                            const String & moduleName,
1811                            const CIMInstance & instance,
1812                            const CIMObjectPath & providerRef)
1813                        {
1814                            // get provider name
1815                            String providerName;
1816                            Uint32 pos = instance.findProperty(CIMName (_PROPERTY_PROVIDER_NAME));
1817                            if (pos != PEG_NOT_FOUND)
1818                            {
1819                        	instance.getProperty(pos).getValue().get(providerName);	
1820                            }
1821                        
1822                            CIMObjectPath capabilityRef;
1823                        
1824                            capabilityRef = CIMObjectPath(providerRef.getHost(),
1825 kumpf         1.56     				  providerRef.getNameSpace(),
1826                        		       		  PEGASUS_CLASSNAME_CAPABILITIESREGISTRATION,
1827                        		       		  providerRef.getKeyBindings());
1828                        
1829                            // get all Capabilities instances
1830                            Array<CIMObjectPath> instanceNames =
1831                        	_providerRegistrationManager->enumerateInstanceNames(capabilityRef);
1832                        			
1833                            String _moduleName, _providerName;
1834                            CIMInstance capInstance;
1835                            Array<Uint16> providerTypes;
1836                            Array<CIMInstance> indCapInstances = 0;
1837                            for(Uint32 i = 0, n=instanceNames.size(); i < n; i++)
1838                            {
1839                        	Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
1840                        
1841                        	for(Uint32 j=0; j < keys.size(); j++)
1842                                {
1843                                     if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
1844                                     {
1845                                          _moduleName = keys[j].getValue();
1846 kumpf         1.56                  }
1847                        
1848                                     if(keys[j].getName().equal (_PROPERTY_PROVIDERNAME))
1849                                     {
1850                                          _providerName = keys[j].getValue();
1851                                     }
1852 kumpf         1.58     	}
1853 kumpf         1.56     
1854 kumpf         1.58            //
1855                               // if capability instance has same module name as moduleName
1856                               // and same provider name as providerName, get provider type
1857                               //
1858                               if(String::equal(_moduleName, moduleName) &&
1859                                  String::equal(_providerName, providerName))
1860                               {
1861                        	    capInstance = _providerRegistrationManager->getInstance
1862 kumpf         1.56     				(instanceNames[i]);
1863                        
1864 kumpf         1.58     	    Uint32 pos = capInstance.findProperty(CIMName (_PROPERTY_PROVIDERTYPE));
1865                            	    if (pos != PEG_NOT_FOUND)
1866                        	    {
1867                        	        capInstance.getProperty(pos).getValue().get(providerTypes); 
1868 kumpf         1.56     
1869 kumpf         1.58         		for (Uint32 k=0; k < providerTypes.size(); k++)
1870                            		{
1871                        		    // 
1872                        		    // if provider type of the instance is indication,
1873                        		    // append the instance 
1874                        		    //
1875                                	    if (providerTypes[k] == _INDICATION_PROVIDER)
1876                                	    {
1877                                    	        indCapInstances.append(capInstance);
1878                                	    }
1879                            		}
1880                        	    }
1881                        	}
1882 kumpf         1.56         }
1883                        
1884                            return (indCapInstances);
1885 kumpf         1.1      }
1886                        
1887                        PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2