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

   1 karl  1.84 //%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 karl  1.84 // 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 mark.hamzy    1.84.2.1 #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 mark.hamzy    1.84.2.1 #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                                    ifcVersionString != "2.5.0"))
 504 kumpf         1.41     	{
 505 humberto      1.53     		//l10n 485
 506 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
 507                        		//"Unsupported InterfaceVersion value: \"" + ifcVersionString +
 508                                           // "\"");
 509                                String unsupported = "InterfaceVersion";
 510                                throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
 511 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.UNSUPPORTED_INTERFACEVERSION_VALUE",
 512                        		"Unsupported InterfaceVersion value: \"$0\"",ifcVersionString));
 513 kumpf         1.1      	}
 514                        
 515 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_LOCATION) == PEG_NOT_FOUND)
 516 kumpf         1.1      	{
 517 humberto      1.53     		//l10n 485
 518 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 519                        		//"Missing Location which is required property in PG_ProviderModule class.");
 520                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 521 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_LOCATION_IN_PG_PROVIDERMODULE",
 522                        		"Missing Location which is required property in PG_ProviderModule class."));
 523 kumpf         1.1      	}
 524                        
 525 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_OPERATIONALSTATUS) == 
 526                                    PEG_NOT_FOUND)
 527 kumpf         1.1      	{
 528                        	    Array<Uint16> _operationalStatus;
 529 kumpf         1.68     	    _operationalStatus.append(CIM_MSE_OPSTATUS_VALUE_OK);
 530 kumpf         1.1      	    instance.addProperty (CIMProperty
 531                        		(_PROPERTY_OPERATIONALSTATUS, _operationalStatus));
 532                        	}
 533 kumpf         1.74     
 534                                //
 535                                // Validate the UserContext property
 536                                //
 537 kumpf         1.76             CIMValue userContextValue;
 538 kumpf         1.74             Uint32 userContextIndex = instanceObject.findProperty(
 539                                    PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT);
 540 kumpf         1.76     
 541 kumpf         1.74             if (userContextIndex != PEG_NOT_FOUND)
 542                                {
 543 kumpf         1.76                 userContextValue =
 544                                        instanceObject.getProperty(userContextIndex).getValue();
 545                                }
 546                        
 547                                if (!userContextValue.isNull())
 548                                {
 549 kumpf         1.74     #ifdef PEGASUS_DISABLE_PROV_USERCTXT
 550                                    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
 551                                        "ControlProviders.ProviderRegistrationProvider."
 552                                            "ProviderRegistrationProvider.USERCONTEXT_UNSUPPORTED",
 553                                        "The UserContext property in the PG_ProviderModule class is "
 554                                            "not supported."));
 555                        #else
 556 kumpf         1.76                 Uint16 userContext;
 557                                    userContextValue.get(userContext);
 558 kumpf         1.74     
 559                                    if (!(
 560                        # ifndef PEGASUS_DISABLE_PROV_USERCTXT_REQUESTOR
 561 kumpf         1.76                       (userContext == PG_PROVMODULE_USERCTXT_REQUESTOR) ||
 562 kumpf         1.74     # endif
 563                        # ifndef PEGASUS_DISABLE_PROV_USERCTXT_DESIGNATED
 564 kumpf         1.76                       (userContext == PG_PROVMODULE_USERCTXT_DESIGNATED) ||
 565 kumpf         1.74     # endif
 566                        # ifndef PEGASUS_DISABLE_PROV_USERCTXT_PRIVILEGED
 567 kumpf         1.76                       (userContext == PG_PROVMODULE_USERCTXT_PRIVILEGED) ||
 568 kumpf         1.74     # endif
 569                        # ifndef PEGASUS_DISABLE_PROV_USERCTXT_CIMSERVER
 570 kumpf         1.76                       (userContext == PG_PROVMODULE_USERCTXT_CIMSERVER) ||
 571 kumpf         1.74     # endif
 572                                          0))
 573                                    {
 574                                        throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
 575                                            MessageLoaderParms(
 576                                                "ControlProviders.ProviderRegistrationProvider."
 577                                                    "ProviderRegistrationProvider."
 578                                                    "UNSUPPORTED_USERCONTEXT_VALUE",
 579                                                "Unsupported UserContext value: \"$0\".",
 580 kumpf         1.76                             userContext));
 581 kumpf         1.74                 }
 582                        
 583                                    // DesignatedUserContext property is required when UserContext == 3
 584 kumpf         1.76                 if (userContext == PG_PROVMODULE_USERCTXT_DESIGNATED)
 585 kumpf         1.74                 {
 586                                        Uint32 designatedUserIndex = instanceObject.findProperty(
 587                                            PEGASUS_PROPERTYNAME_MODULE_DESIGNATEDUSER);
 588                                        if ((designatedUserIndex == PEG_NOT_FOUND) ||
 589                                            instanceObject.getProperty(designatedUserIndex).getValue()
 590                                                .isNull())
 591                                        {
 592                                            throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
 593                                                MessageLoaderParms(
 594                                                    "ControlProviders.ProviderRegistrationProvider."
 595                                                        "ProviderRegistrationProvider."
 596                                                        "MISSING_DESIGNATEDUSER_IN_PG_PROVIDERMODULE",
 597                                                    "Missing DesignatedUserContext property in "
 598                                                        "PG_ProviderModule instance."));
 599                                        }
 600                                        else
 601                                        {
 602                                            // Validate that DesignatedUserContext is of String type
 603                                            String designatedUser;
 604                                            instanceObject.getProperty(designatedUserIndex).getValue()
 605                                                .get(designatedUser);
 606 kumpf         1.74                     }
 607                                    }
 608                        #endif
 609                                }
 610 kumpf         1.1          }
 611 kumpf         1.36         else if (className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES))
 612 kumpf         1.1          {
 613                        	//
 614                        	// ProviderModuleName, ProviderName, InstanceID, ClassName,
 615                         	// Namespaces, and ProviderType properties must be set
 616                        	//
 617                        
 618 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
 619                                    PEG_NOT_FOUND)
 620 kumpf         1.1      	{
 621 humberto      1.53     		//l10n 485
 622 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 623                        		//"Missing ProviderModuleName which is required property in PG_ProviderCapabilities class.");
 624                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 625 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDERMODULENAME_IN_PG_PROVIDERCAPABILITIES",
 626                        		"Missing ProviderModuleName which is required property in PG_ProviderCapabilities class."));
 627 kumpf         1.1      	}
 628                        
 629 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_PROVIDERNAME) == 
 630                                    PEG_NOT_FOUND)
 631 kumpf         1.1      	{
 632 humberto      1.53     		//l10n 485
 633 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 634                        		//"Missing ProviderName which is required property in PG_ProviderCapabilities class.");
 635                        		String missing = "ProviderName";
 636                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 637                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_REQUIRED_PROPERTY",
 638 humberto      1.53     		"Missing ProviderName which is required property in PG_ProviderCapabilities class."));
 639 kumpf         1.1      	}
 640                        
 641 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_CAPABILITYID) == 
 642                                    PEG_NOT_FOUND)
 643 kumpf         1.1      	{
 644 humberto      1.53     		//l10n 485
 645 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 646                        		//"Missing CapabilityID which is required property in PG_ProviderCapabilities class.");
 647                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 648 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSINGCAPABILITYID_IN_PG_PROVIDERCAPABILITIES",
 649                        		"Missing CapabilityID which is required property in PG_ProviderCapabilities class."));
 650 kumpf         1.1      	}
 651                        
 652 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_CLASSNAME) == PEG_NOT_FOUND)
 653 kumpf         1.1      	{
 654 humberto      1.53     		//l10n 485
 655 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 656                        		//"Missing ClassName which is required property in PG_ProviderCapabilities class.");
 657                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 658 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_CLASSNAME_IN_PG_PROVIDERCAPABILITIES",
 659                        		"Missing ClassName which is required property in PG_ProviderCapabilities class."));
 660 kumpf         1.1      	}
 661                        
 662 kumpf         1.80             // Validate the Namespaces property
 663                        
 664                                Uint32 namespacesIndex =
 665                                    instanceObject.findProperty(_PROPERTY_NAMESPACES);
 666                                Array<String> namespacesArray;
 667                                if (namespacesIndex != PEG_NOT_FOUND)
 668                                {
 669                                    CIMValue namespacesValue =
 670                                        instanceObject.getProperty(namespacesIndex).getValue();
 671                                    if (!namespacesValue.isNull())
 672                                    {
 673                                        namespacesValue.get(namespacesArray);
 674                                    }
 675                                }
 676                        
 677                                if (namespacesArray.size() == 0)
 678 kumpf         1.1      	{
 679 kumpf         1.80                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
 680                                        "ControlProviders.ProviderRegistrationProvider."
 681                                            "ProviderRegistrationProvider."
 682                                            "MISSING_NAMESPACES_IN_PG_PROVIDERCAPABILITIES",
 683                                        "Missing Namespaces which is required property in "
 684                                            "PG_ProviderCapabilities class."));
 685 kumpf         1.1      	}
 686                        
 687 kumpf         1.77             // Validate the ProviderType property
 688                        
 689                                Uint32 providerTypeIndex =
 690                                    instanceObject.findProperty(_PROPERTY_PROVIDERTYPE);
 691                                Array<Uint16> providerTypeArray;
 692                                if (providerTypeIndex != PEG_NOT_FOUND)
 693                                {
 694 kumpf         1.80                 CIMValue providerTypeValue =
 695                                        instanceObject.getProperty(providerTypeIndex).getValue();
 696                                    if (!providerTypeValue.isNull())
 697                                    {
 698                                        providerTypeValue.get(providerTypeArray);
 699                                    }
 700 kumpf         1.77             }
 701                        
 702 kumpf         1.80             if (providerTypeArray.size() == 0)
 703 kumpf         1.77             {
 704                                    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
 705                                        MessageLoaderParms(
 706                                            "ControlProviders.ProviderRegistrationProvider."
 707                                                "ProviderRegistrationProvider."
 708                                                "MISSING_PROVIDERTYPE_IN_PG_PROVIDERCAPABILITIES",
 709                                            "Missing ProviderType which is required property in "
 710                                                "PG_ProviderCapabilities class."));
 711                                }
 712                        
 713                                for (Uint32 i = 0; i < providerTypeArray.size(); i++)
 714                                {
 715                                    if ((providerTypeArray[i] < 2) ||
 716                        #ifdef PEGASUS_DISABLE_EXECQUERY
 717                                        (providerTypeArray[i] > 6)
 718                        #else
 719                                        (providerTypeArray[i] > 7)
 720                        #endif
 721                                                                  )
 722                                    {
 723                                        throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
 724 kumpf         1.77                         MessageLoaderParms(
 725                                                "ControlProviders.ProviderRegistrationProvider."
 726                                                    "ProviderRegistrationProvider.UNSUPPORTED_"
 727                                                    "PROVIDERTYPE_IN_PG_PROVIDERCAPABILITIES",
 728                                                "Unsupported ProviderType value \"$0\" in "
 729                                                    "PG_ProviderCapabilities instance.",
 730                                                providerTypeArray[i]));
 731                                    }
 732                                }
 733 kumpf         1.1          }
 734 kumpf         1.46         else if (className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES))
 735                            {
 736                        	//
 737                        	// ProviderModuleName, ProviderName, CapabilityID, ProviderType,
 738                         	// and Destinations properties must be set
 739                        	//
 740                        
 741                        	if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) ==
 742                                    PEG_NOT_FOUND)
 743                        	{
 744 humberto      1.49     //L10N_ TODO DONE
 745                        	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 746                        		//"Missing ProviderModuleName which is required property in PG_ConsumerCapabilities class.");
 747                        	    MessageLoaderParms parms(
 748                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDER_MODULE_NAME_WHICH_IS_REQUIRED",
 749 kumpf         1.46     		"Missing ProviderModuleName which is required property in PG_ConsumerCapabilities class.");
 750 humberto      1.49     
 751                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
 752 kumpf         1.46     	}
 753                        
 754                        	if (instanceObject.findProperty(_PROPERTY_PROVIDERNAME) == 
 755                                    PEG_NOT_FOUND)
 756                        	{
 757 humberto      1.49     //L10N_ TODO DONE
 758                        	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 759                        		//"Missing ProviderName which is required property in PG_ConsumerCapabilities class.");
 760                        
 761                        	    MessageLoaderParms parms(
 762                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDER_NAME_WHICH_IS_REQUIRED",
 763 kumpf         1.46     		"Missing ProviderName which is required property in PG_ConsumerCapabilities class.");
 764 humberto      1.49     
 765                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
 766 kumpf         1.46     	}
 767                        
 768                        	if (instanceObject.findProperty(_PROPERTY_CAPABILITYID) == 
 769                                    PEG_NOT_FOUND)
 770                        	{
 771 humberto      1.49     //L10N_ TODO DONE
 772                        	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 773                        		//"Missing CapabilityID which is required property in PG_ConsumerCapabilities class.");
 774                        
 775                        	    MessageLoaderParms parms(
 776                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_CAPABILITY_ID_WHICH_IS_REQUIRED",
 777 kumpf         1.46     		"Missing CapabilityID which is required property in PG_ConsumerCapabilities class.");
 778 humberto      1.49     
 779                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
 780 kumpf         1.46     	}
 781                        
 782                        	if (instanceObject.findProperty(_PROPERTY_PROVIDERTYPE) == PEG_NOT_FOUND)
 783                        	{
 784 humberto      1.49     //L10N_ TODO DONE
 785                        	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 786                        		//"Missing ProviderType which is required property in PG_ConsumerCapabilities class.");
 787                        
 788                        	    MessageLoaderParms parms(
 789                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDER_TYPE_WHICH_IS_REQUIRED",
 790 kumpf         1.46     		"Missing ProviderType which is required property in PG_ConsumerCapabilities class.");
 791 humberto      1.49     
 792                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
 793 kumpf         1.46     	}
 794                        
 795                        	if (instanceObject.findProperty(_PROPERTY_INDICATIONDESTINATIONS) == 
 796                        	    PEG_NOT_FOUND)
 797                        	{
 798 humberto      1.49     //L10N_ TODO DONE
 799                        	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 800                        		//"Missing Destinations which is required property in PG_ConsumerCapabilities class.");
 801                        
 802                        	    MessageLoaderParms parms(
 803                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_DESTINATIONS_TYPE_WHICH_IS_REQUIRED",
 804 kumpf         1.46     		"Missing Destinations which is required property in PG_ConsumerCapabilities class.");
 805 humberto      1.49     
 806                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
 807 kumpf         1.46     	}
 808                            }
 809 kumpf         1.10         else // PEGASUS_CLASSNAME_PROVIDER
 810 kumpf         1.1          {
 811                        	//
 812                        	// Name and ProviderModuleName properties must be set
 813                        	//
 814 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_PROVIDER_NAME) == PEG_NOT_FOUND)
 815 kumpf         1.1      	{
 816 humberto      1.53     		//l10n 485
 817 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 818                        		//"Missing Name which is required property in PG_Provider class.");
 819                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 820                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_REQUIRED_PROPERTY",
 821 humberto      1.53     		"Missing Name which is required property in PG_Provider class."));
 822 kumpf         1.1      	}
 823                        	
 824 kumpf         1.27     	if (instanceObject.findProperty(_PROPERTY_PROVIDERMODULENAME) == 
 825                                    PEG_NOT_FOUND)
 826 kumpf         1.1      	{
 827 humberto      1.53     		//l10n 485
 828 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 829                        		//"Missing ProviderModuleName which is required property in PG_Provider class.");
 830                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 831 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.MISSING_PROVIDERMODULENAME_IN_PG_PROVIDER",
 832                        		"Missing ProviderModuleName which is required property in PG_Provider class."));
 833 kumpf         1.1      	}
 834                            }
 835                        
 836                            // begin processing the request
 837                            handler.processing();
 838                        	
 839                            try
 840                            {
 841 david.dillard 1.78             returnReference =
 842                                    _providerRegistrationManager->createInstance(instanceReference, instance);
 843 kumpf         1.1          }
 844 david.dillard 1.78         catch(const CIMException&)
 845 kumpf         1.1          {
 846 david.dillard 1.78             throw;
 847 kumpf         1.1          }
 848                        
 849                            handler.deliver(returnReference);
 850                        
 851                            // complete processing request
 852                            handler.complete();
 853                        }
 854                        
 855                        // Unregister a provider
 856                        void ProviderRegistrationProvider::deleteInstance(
 857                            const OperationContext & context,
 858 kumpf         1.13         const CIMObjectPath & instanceReference,
 859 kumpf         1.33         ResponseHandler & handler)
 860 kumpf         1.1      {
 861 kumpf         1.15         // get userName and only privileged user can execute this operation
 862 kumpf         1.19         String userName;
 863                            try
 864                            {
 865 kumpf         1.37             IdentityContainer container = context.get(IdentityContainer::NAME);
 866 kumpf         1.19             userName = container.getUserName();
 867                            }
 868                            catch (...)
 869                            {
 870                                userName = String::EMPTY;
 871                            }
 872 kumpf         1.15     
 873 chip          1.24         if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
 874 kumpf         1.15         {
 875 humberto      1.48         	//l10n
 876                        	//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
 877                        	    //"You must have superuser privilege to unregister providers.");
 878                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,MessageLoaderParms(
 879                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_UNREGISTER_PROVIDERS",
 880                        	    "You must have superuser privilege to unregister providers.")); 	
 881 kumpf         1.15         }
 882                        
 883 kumpf         1.36         if(!instanceReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
 884 kumpf         1.10         {
 885 kumpf         1.36     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
 886                                    instanceReference.getNameSpace().getString());
 887 kumpf         1.10         }
 888                        
 889 chuck         1.47     
 890                        // l10n
 891                            // Get the client's list of preferred languages for the response
 892 kumpf         1.83         AcceptLanguageList al;
 893 chuck         1.47         try 
 894                            {
 895                                AcceptLanguageListContainer al_container = 
 896                        		(AcceptLanguageListContainer)context.get(AcceptLanguageListContainer::NAME);
 897                                al = al_container.getLanguages();
 898                            }
 899                            catch (...)
 900                            {
 901 kumpf         1.83             ;   // Leave AcceptLanguageList empty
 902 chuck         1.47         }
 903                        
 904 kumpf         1.36         CIMName className = instanceReference.getClassName();
 905 kumpf         1.1      
 906                            // ensure the class existing in the specified namespace
 907 kumpf         1.36         if(!className.equal (PEGASUS_CLASSNAME_PROVIDER) &&
 908                               !className.equal (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES) &&
 909 kumpf         1.46            !className.equal (PEGASUS_CLASSNAME_CONSUMERCAPABILITIES) &&
 910 kumpf         1.36            !className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
 911 kumpf         1.1          {
 912 kumpf         1.36     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
 913                                    className.getString());
 914 kumpf         1.1          }
 915                        
 916                            // begin processing the request
 917                            handler.processing();
 918                        
 919 kumpf         1.43         String moduleName;
 920                            Boolean moduleFound = false;
 921                            Array<CIMKeyBinding> keys = instanceReference.getKeyBindings();
 922                        
 923                            //
 924                            // disable provider before delete provider 
 925                            // registration if the class is PG_Provider
 926                            //
 927                            if (className.equal (PEGASUS_CLASSNAME_PROVIDER))
 928                            {
 929                            	// get module name from reference
 930                        
 931                            	for(Uint32 i=0; i<keys.size() ; i++)
 932                            	{
 933                        	    if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULENAME))
 934                        	    {
 935                        	        moduleName = keys[i].getValue();
 936                        	        moduleFound = true;
 937                        	    }
 938                        	}
 939                        
 940 kumpf         1.43         	// if _PROPERTY_PROVIDERMODULENAME key not found
 941                            	if( !moduleFound)
 942                            	{
 943 humberto      1.53         		//l10n 485
 944 humberto      1.48     	    //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
 945                        		//"key ProviderModuleName was not found");
 946                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
 947 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.PROVIDERMODULENAME_KEY_NOT_FOUND",
 948                        		"key ProviderModuleName was not found"));
 949 kumpf         1.43         	}
 950                        
 951                        	// 
 952                        	// disable the provider 
 953                        	//
 954                        	try
 955                        	{
 956 kumpf         1.51     	     Sint16 ret_value = _disableModule(instanceReference, moduleName, true, al);
 957                        
 958 kumpf         1.43                  //
 959                                     // if the provider disable failed
 960                                     //
 961 chuck         1.47     // l10n
 962 kumpf         1.51                  if (ret_value == -1)
 963 kumpf         1.43                  {
 964 humberto      1.48                  	//l10n
 965                                         //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 966                                             //"disable the provider failed.");
 967                                         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 968                        					"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_FAILED",
 969                                            "disable the provider failed."));
 970 kumpf         1.43                  }
 971 kumpf         1.51     	     //
 972                                     // The provider disable failed since there are pending requests
 973                                     //
 974                                     if (ret_value == -2)
 975                                     {
 976                        //L10N TODO
 977 humberto      1.52                     // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 978                                             //"disable the provider failed: Provider is busy.");
 979                                         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
 980                        					"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_FAILED_PROVIDER_BUSY",
 981                                            "disable the provider failed: Provider is busy."));
 982 kumpf         1.51                  }
 983 kumpf         1.43     	}
 984                            	catch(CIMException&)
 985                            	{
 986                        	    throw;
 987                            	}
 988                            }
 989                        
 990                            //
 991                            // disable provider module before remove provider registration
 992                            // if the class is PG_ProviderModule 
 993                            //
 994                        
 995                            if (className.equal (PEGASUS_CLASSNAME_PROVIDERMODULE))
 996                            {
 997                            	// get module name from reference
 998                        
 999                            	for(Uint32 i=0; i<keys.size() ; i++)
1000                            	{
1001                        	    if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULE_NAME))
1002                        	    {
1003                        	        moduleName = keys[i].getValue();
1004 kumpf         1.43     	        moduleFound = true;
1005                        	    }
1006                        	}
1007                        
1008                            	// if _PROPERTY_PROVIDERMODULE_NAME key not found
1009                            	if( !moduleFound)
1010                            	{
1011 humberto      1.53         		//l10n 485
1012 humberto      1.48     	//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
1013                        		//"key Name was not found");
1014                        		throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
1015 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.NAME_KEY_NOT_FOUND",
1016                        		"key Name was not found"));
1017 kumpf         1.43         	}
1018                        
1019                        	// 
1020                        	// disable the provider module
1021                        	//
1022                        	try
1023                        	{
1024 kumpf         1.51     	    Sint16 ret_value = _disableModule(instanceReference, moduleName, false, al);
1025                        
1026 kumpf         1.43                 //
1027                                    // if the provider module disable failed
1028                                    //
1029 chuck         1.47     // l10n
1030 kumpf         1.51                 if (ret_value == -1)
1031 kumpf         1.43                 {
1032 humberto      1.48                 	//l10n
1033                                         //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1034                                             //"disable the provider module failed.");
1035                                             throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
1036                        						"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_MODULE_FAILED",
1037                                             	"disable the provider module failed."));
1038 kumpf         1.43                 }
1039 kumpf         1.51     	    
1040                        	    //
1041                                    // The provider module disable failed since there are pending requests
1042                                    //
1043                                    if (ret_value == -2)
1044                                    {
1045                        //L10N TODO
1046 humberto      1.52                      //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1047                                            // "disable the provider module failed: Provider is busy.");
1048                                         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,MessageLoaderParms(
1049                        						"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.DISABLE_PROVIDER_MODULE_FAILED_PROVIDER_BUSY",
1050                                             	"disable the provider module failed: Provider is busy."));
1051 kumpf         1.51                 }
1052 david.dillard 1.78             }
1053                                catch(const CIMException&)
1054                                {
1055                                    throw;
1056                                }
1057 kumpf         1.43         }
1058                        
1059 kumpf         1.1          try
1060                            {
1061 david.dillard 1.78             _providerRegistrationManager->deleteInstance(instanceReference);
1062 kumpf         1.1          }
1063 david.dillard 1.78         catch(const CIMException&)
1064 kumpf         1.1          {
1065 david.dillard 1.78             throw;
1066 kumpf         1.1          }
1067                        
1068                            // complete processing the request
1069                            handler.complete();
1070                        }
1071                        
1072                        // Block a provider, unblock a provider, and stop a provider
1073                        void ProviderRegistrationProvider::invokeMethod(
1074                            const OperationContext & context,
1075 kumpf         1.13         const CIMObjectPath & objectReference,
1076 kumpf         1.28         const CIMName & methodName,
1077 kumpf         1.1          const Array<CIMParamValue> & inParameters,
1078 kumpf         1.33         MethodResultResponseHandler & handler)
1079 kumpf         1.1      {
1080 kumpf         1.15         // get userName and only privileged user can execute this operation
1081 kumpf         1.19         String userName;
1082                            try
1083                            {
1084 kumpf         1.37             IdentityContainer container = context.get(IdentityContainer::NAME);
1085 kumpf         1.19             userName = container.getUserName();
1086                            }
1087                            catch (...)
1088                            {
1089                                userName = String::EMPTY;
1090                            }
1091 kumpf         1.15     
1092 chip          1.24         if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
1093 mday          1.17         {
1094 humberto      1.48         	//l10n
1095                        	//throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ACCESS_DENIED,
1096                        	    //"You must have superuser privilege to disable or enable providers."); 
1097                        	    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED,MessageLoaderParms(
1098                        		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.SUPERUSER_PRIVILEGE_REQUIRED_DISABLE_ENABLE_PROVIDERS",
1099                        	    "You must have superuser privilege to disable or enable providers.")); 	
1100 mday          1.17         }
1101 kumpf         1.15     
1102 kumpf         1.36         if(!objectReference.getNameSpace().equal (PEGASUS_NAMESPACENAME_INTEROP))
1103 kumpf         1.10         {
1104 kumpf         1.36     	throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, 
1105                                    objectReference.getNameSpace().getString());
1106 kumpf         1.10         }
1107                        
1108 chuck         1.47     
1109                        // l10n
1110                            // Get the client's list of preferred languages for the response
1111 kumpf         1.83         AcceptLanguageList al;
1112 chuck         1.47         try 
1113                            {
1114                                AcceptLanguageListContainer al_container = 
1115                        		(AcceptLanguageListContainer)context.get(AcceptLanguageListContainer::NAME);
1116                                al = al_container.getLanguages();
1117                            }
1118                            catch (...)
1119                            {
1120 kumpf         1.83             ;   // Leave AcceptLanguageList empty
1121 chuck         1.47         }
1122                        
1123 kumpf         1.5          String moduleName;
1124                            Boolean moduleFound = false;
1125 kumpf         1.3      
1126 kumpf         1.5          // get module name from reference
1127 kumpf         1.35         Array<CIMKeyBinding> keys = objectReference.getKeyBindings();
1128 kumpf         1.1      
1129 kumpf         1.5          for(Uint32 i=0; i<keys.size() ; i++)
1130 kumpf         1.1          {
1131 kumpf         1.36     	if(keys[i].getName().equal (_PROPERTY_PROVIDERMODULE_NAME))
1132 kumpf         1.1      	{
1133 kumpf         1.5      	    moduleName = keys[i].getValue();
1134                        	    moduleFound = true;
1135 kumpf         1.1      	}
1136                            }
1137                        
1138 kumpf         1.5          // if _PROPERTY_PROVIDERMODULE_NAME key not found
1139                            if( !moduleFound)
1140 kumpf         1.1          {
1141 humberto      1.53         	//l10n 485
1142 humberto      1.48     	throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,MessageLoaderParms(
1143 humberto      1.53     		"ControlProviders.ProviderRegistrationProvider.ProviderRegistrationProvider.NAME_KEY_NOT_FOUND",
1144                        		"key Name was not found"));
1145 kumpf         1.1          }
1146                        
1147 kumpf         1.5          handler.processing();
1148                        
1149                            Sint16 ret_value;
1150 kumpf         1.1      
1151 kumpf         1.56         try
1152 kumpf         1.1          {
1153 kumpf         1.56             if(methodName.equal(_STOP_PROVIDER))
1154                            	{
1155                        	    // disable module
1156 chuck         1.47         	     ret_value =  _disableModule(objectReference, moduleName, false, al);
1157 kumpf         1.8      	}
1158 kumpf         1.56         	else if(methodName.equal(_START_PROVIDER))
1159 kumpf         1.43         	{
1160 kumpf         1.56     	    // enable module
1161                            	     ret_value =  _enableModule(objectReference, moduleName, al);
1162 kumpf         1.1      	}
1163 kumpf         1.56             else
1164 david.dillard 1.78             {
1165                                    throw PEGASUS_CIM_EXCEPTION(CIM_ERR_METHOD_NOT_AVAILABLE, String::EMPTY);
1166                                }
1167 kumpf         1.1          }
1168 david.dillard 1.78         catch(const CIMException&)
1169 kumpf         1.1          {
1170 david.dillard 1.78             throw;
1171 kumpf         1.1          }
1172 kumpf         1.56     
1173                            CIMValue retValue(ret_value);
1174                            handler.deliver(retValue);
1175                            handler.complete();
1176 kumpf         1.5      }
1177                        
1178                        // get provider manager service
1179                        MessageQueueService * ProviderRegistrationProvider::_getProviderManagerService()
1180                        {
1181                            MessageQueue * queue = MessageQueue::lookup(PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP);
1182                            MessageQueueService * _service = dynamic_cast<MessageQueueService *>(queue);
1183                        
1184 chip          1.24         return(_service);
1185 kumpf         1.5      }
1186                        
1187                        ProviderRegistrationProvider & ProviderRegistrationProvider::operator=(const ProviderRegistrationProvider & handle)
1188                        {
1189                            if(this == &handle)
1190                            {
1191                                return(*this);
1192                            }
1193                        
1194                            return(*this);
1195                        }
1196 kumpf         1.1      
1197 kumpf         1.5      Array<Uint16> ProviderRegistrationProvider::_sendDisableMessageToProviderManager(
1198                                CIMDisableModuleRequestMessage * disable_req)
1199                        {
1200                            MessageQueueService * _service = _getProviderManagerService();
1201                            Uint32 _queueId = _service->getQueueId();
1202                        
1203                            // create request envelope
1204                            AsyncLegacyOperationStart * asyncRequest =
1205                                new AsyncLegacyOperationStart (
1206                                    _service->get_next_xid(),
1207                                    NULL,
1208                                    _queueId,
1209                                    disable_req,
1210                                    _queueId);
1211                        
1212 kumpf         1.8          AsyncReply * asyncReply = _controller->ClientSendWait(*_client_handle,
1213                        							  _queueId,
1214                        							  asyncRequest);
1215 kumpf         1.10         CIMDisableModuleResponseMessage * response =
1216                        	reinterpret_cast<CIMDisableModuleResponseMessage *>(
1217 kumpf         1.70                  (dynamic_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
1218 kumpf         1.8          if (response->cimException.getCode() != CIM_ERR_SUCCESS)
1219                            {
1220 david.dillard 1.78             CIMException e = response->cimException;
1221 kumpf         1.8              delete asyncRequest;
1222                                delete asyncReply;
1223                                delete response;
1224 david.dillard 1.78             throw e;
1225 kumpf         1.8          }
1226 kumpf         1.5      
1227 chip          1.24         Array<Uint16> operationalStatus = response->operationalStatus;
1228 kumpf         1.8      
1229                            delete asyncRequest;
1230                            delete asyncReply;
1231                            delete response;
1232 mday          1.16     
1233 kumpf         1.5          return(operationalStatus);
1234                        }
1235                        
1236                        Array<Uint16> ProviderRegistrationProvider::_sendEnableMessageToProviderManager(
1237                                CIMEnableModuleRequestMessage * enable_req)
1238                        {
1239                            MessageQueueService * _service = _getProviderManagerService();
1240                            Uint32 _queueId = _service->getQueueId();
1241                        
1242                            // create request envelope
1243                            AsyncLegacyOperationStart * asyncRequest =
1244                                new AsyncLegacyOperationStart (
1245                                    _service->get_next_xid(),
1246                                    NULL,
1247                                    _queueId,
1248                                    enable_req,
1249                                    _queueId);
1250                        
1251 kumpf         1.8          AsyncReply * asyncReply = _controller->ClientSendWait(*_client_handle,
1252                        							  _queueId,
1253                        							  asyncRequest);
1254                            CIMEnableModuleResponseMessage * response =
1255                        	reinterpret_cast<CIMEnableModuleResponseMessage *>(
1256 kumpf         1.70                  (dynamic_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
1257 kumpf         1.8          if (response->cimException.getCode() != CIM_ERR_SUCCESS)
1258                            {
1259                        	CIMException e = response->cimException;
1260                                delete asyncRequest;
1261                                delete asyncReply;
1262                                delete response;
1263                        	throw (e);
1264                            }
1265                        
1266 chip          1.24         Array<Uint16> operationalStatus = response->operationalStatus;
1267 kumpf         1.8      
1268                            delete asyncRequest;
1269                            delete asyncReply;
1270                            delete response;
1271 mday          1.16     
1272 kumpf         1.5          return(operationalStatus);
1273 kumpf         1.6      }
1274                        
1275                        // send termination message to subscription service
1276                        void ProviderRegistrationProvider::_sendTerminationMessageToSubscription(
1277 kumpf         1.43         const CIMObjectPath & ref, const String & moduleName,
1278 chuck         1.47         const Boolean disableProviderOnly,
1279 kumpf         1.83         const AcceptLanguageList & al)
1280 kumpf         1.6      {
1281                            CIMInstance instance;
1282                            String _moduleName;
1283                            Array<CIMInstance> instances;
1284                        
1285 kumpf         1.43         if (!disableProviderOnly)
1286                            {
1287                                CIMObjectPath reference("", PEGASUS_NAMESPACENAME_INTEROP,
1288                        	    PEGASUS_CLASSNAME_PROVIDER, ref.getKeyBindings());
1289 chip          1.24     
1290 kumpf         1.43             Array<CIMObjectPath> instanceNames =
1291                        	    _providerRegistrationManager->enumerateInstanceNames(reference);
1292 kumpf         1.6      
1293 kumpf         1.43             // find all the instances which have same module name as moduleName
1294                                for (Uint32 i = 0, n=instanceNames.size(); i < n; i++)
1295                                {
1296 kumpf         1.42     	    //
1297                                    // get provider module name from reference
1298                                    //
1299                        
1300                                    Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
1301                        
1302                                    for(Uint32 j=0; j < keys.size(); j++)
1303                                    {
1304                                        if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
1305                                        {
1306                                            _moduleName = keys[j].getValue();
1307                                        }
1308                                    }
1309 kumpf         1.6      
1310 kumpf         1.43     	    if (String::equalNoCase(moduleName, _moduleName))
1311                        	    {
1312                        	        reference.setKeyBindings(keys);
1313                        	        instance = _providerRegistrationManager->getInstance(reference);
1314 kumpf         1.55     		//
1315                        		// if the provider is indication provider
1316                        		//
1317 kumpf         1.70     		if (_isIndicationProvider(moduleName, instance))
1318 kumpf         1.55     		{
1319                        	            instances.append(instance);
1320                        		}
1321 kumpf         1.43     	    }
1322                                }
1323                            }
1324                            else
1325                            {
1326 kumpf         1.55     	instance = _providerRegistrationManager->getInstance(ref);
1327                        
1328                        	//
1329                        	// if the provider is indication provider
1330                        	//
1331 kumpf         1.70     	if (_isIndicationProvider(moduleName, instance))
1332 kumpf         1.55     	{
1333 kumpf         1.6      	    instances.append(instance);
1334 kumpf         1.55     	}
1335 kumpf         1.6          }
1336                        
1337                            //
1338                            // get indication server queueId
1339                            //
1340                            MessageQueueService * _service = _getIndicationService();
1341                        
1342 kumpf         1.15         if (_service != NULL)
1343                            {
1344                                Uint32 _queueId = _service->getQueueId();
1345 kumpf         1.6      
1346 kumpf         1.15             CIMNotifyProviderTerminationRequestMessage * termination_req =
1347                        	    new CIMNotifyProviderTerminationRequestMessage(
1348                        	        XmlWriter::getNextMessageId (),
1349                        	        instances,
1350                        	        QueueIdStack(_service->getQueueId()));
1351                        
1352 chuck         1.47     // l10n
1353 se.gupta      1.69             termination_req->operationContext.set(AcceptLanguageListContainer(al));
1354 chuck         1.47     
1355 kumpf         1.15             // create request envelope
1356 kumpf         1.71             AsyncLegacyOperationStart asyncRequest
1357                                    (_service->get_next_xid(),
1358                                    NULL,
1359                                    _queueId,
1360                                    termination_req,
1361                                    _queueId);
1362 kumpf         1.6      
1363 kumpf         1.71             AutoPtr <AsyncReply> asyncReply
1364                                    (_controller->ClientSendWait (* _client_handle, _queueId,
1365                                    &asyncRequest));
1366                                
1367                                AutoPtr <CIMNotifyProviderTerminationResponseMessage> response
1368                                    (reinterpret_cast <CIMNotifyProviderTerminationResponseMessage *>
1369                                    ((dynamic_cast <AsyncLegacyOperationResult *>
1370                                    (asyncReply.get ()))->get_result ()));
1371                                
1372                                if (response->cimException.getCode () != CIM_ERR_SUCCESS)
1373 kumpf         1.15             {
1374 kumpf         1.71                 CIMException e = response->cimException;
1375 david.dillard 1.78                 throw e;
1376 kumpf         1.15             }
1377 kumpf         1.6          }
1378                        }
1379                        
1380                        // get indication service
1381                        MessageQueueService * ProviderRegistrationProvider::_getIndicationService()
1382                        {
1383                            MessageQueue * queue = MessageQueue::lookup(
1384                        	PEGASUS_QUEUENAME_INDICATIONSERVICE);
1385                        
1386                            MessageQueueService * _service =
1387                        	dynamic_cast<MessageQueueService *>(queue);
1388                            return(_service);
1389 kumpf         1.43     }
1390                        
1391                        // disable provider module, return 0 if module is disabled successfully,
1392 kumpf         1.51     // return 1 if module is already disabled, return -2 if module can not be
1393                        // disabled since there are pending requests, otherwise, return -1
1394 kumpf         1.43     Sint16 ProviderRegistrationProvider::_disableModule(
1395                            const CIMObjectPath & objectReference, 
1396                            const String & moduleName,
1397 chuck         1.47         Boolean disableProviderOnly,
1398 kumpf         1.83         const AcceptLanguageList & al)
1399 kumpf         1.43     {
1400                            	//
1401                            	// get module status
1402                            	//
1403                            	Array<Uint16> _OperationalStatus =
1404                        	    _providerRegistrationManager->getProviderModuleStatus( moduleName);
1405                        
1406                        	for (Uint32 i = 0; i<_OperationalStatus.size(); i++)
1407                        	{
1408                        	    // retValue equals 1 if module is already disabled
1409 kumpf         1.68     	    if (_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED ||
1410                        		_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING)
1411 kumpf         1.43     	    {
1412                        		return (1);
1413                        	    }
1414                        	}
1415                        
1416                        	CIMInstance instance;
1417                        	Array<CIMInstance> instances;
1418                                CIMInstance mInstance;
1419                        	String _moduleName;
1420                        	Uint16 providers;
1421                        	CIMObjectPath providerRef;
1422 kumpf         1.55     	Boolean indProvider = false;
1423                                Array<Boolean> indicationProviders;
1424 kumpf         1.43     
1425                        	// disable a provider module or delete a provider module
1426                        	if (!disableProviderOnly)
1427                        	{
1428                        	    providerRef = CIMObjectPath(objectReference.getHost(),
1429                        				 objectReference.getNameSpace(),
1430                        				 PEGASUS_CLASSNAME_PROVIDER,
1431                        				 objectReference.getKeyBindings());
1432                        
1433                                    // get module instance
1434                                    mInstance = 
1435                        	        _providerRegistrationManager->getInstance(objectReference);
1436                        
1437                        	}
1438                        	else // disable a provider
1439                        	{
1440                                    // get module instance
1441                        	    Array <CIMKeyBinding> moduleKeyBindings;
1442                        	    moduleKeyBindings.append (CIMKeyBinding
1443                        		(_PROPERTY_PROVIDERMODULE_NAME, moduleName, 
1444                        		 CIMKeyBinding::STRING)); 
1445 kumpf         1.43     
1446                        	    CIMObjectPath moduleRef(objectReference.getHost(),
1447                        				    objectReference.getNameSpace(),
1448                        				    PEGASUS_CLASSNAME_PROVIDERMODULE,
1449                        				    moduleKeyBindings);
1450                        				    
1451                                    mInstance = 
1452                        	        _providerRegistrationManager->getInstance(moduleRef);
1453                        	}
1454                        
1455                                if (!disableProviderOnly)
1456                                {
1457                        	    // get all provider instances which have same module name as 
1458                        	    // moduleName
1459                         	    Array<CIMObjectPath> instanceNames = 
1460                        	        _providerRegistrationManager->enumerateInstanceNames(providerRef);
1461                        
1462                        	    for(Uint32 i = 0, n=instanceNames.size(); i < n; i++)
1463                        	    {
1464                        	        //
1465                                        // get provider module name from reference
1466 kumpf         1.43                     //
1467                        
1468                                        Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
1469                        
1470                                        for(Uint32 j=0; j < keys.size(); j++)
1471                                        {
1472                                            if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
1473                                            {
1474                                                _moduleName = keys[j].getValue();
1475                                            }
1476                                        }
1477                        
1478                        	        if (String::equalNoCase(_moduleName, moduleName))
1479                        	        {
1480                        		    providerRef.setKeyBindings(keys);
1481                        		    instance = _providerRegistrationManager->getInstance
1482                        			(providerRef);
1483 kumpf         1.70     		    if (_isIndicationProvider(moduleName, instance))
1484 kumpf         1.55                         {
1485                                                indProvider = true;
1486                                                indicationProviders.append(true);
1487                                            }
1488                                            else
1489                                            {
1490                                                indicationProviders.append(false);
1491                                            }
1492 kumpf         1.43     		    instances.append(instance);
1493                        	        }
1494                        
1495                        	    }
1496                                }
1497                                else
1498                                {
1499 kumpf         1.55     	    instance = _providerRegistrationManager->getInstance(objectReference);
1500 kumpf         1.70                 if (_isIndicationProvider(moduleName, instance))
1501 kumpf         1.55                 {
1502                                        indProvider = true;
1503                                        indicationProviders.append(true);
1504                                    }
1505                                    else
1506                                    {
1507                                        indicationProviders.append(false);
1508                                    }
1509                        
1510                                    instances.append(instance);
1511 kumpf         1.43             }
1512                        
1513                                //
1514                                // get provider manager service
1515                                //
1516                                MessageQueueService * _service = _getProviderManagerService();
1517                        
1518                        	if (_service != NULL)
1519                        	{
1520                        	    // create CIMDisableModuleRequestMessage
1521                        	    CIMDisableModuleRequestMessage * disable_req =
1522                        	        new CIMDisableModuleRequestMessage(
1523                        		    XmlWriter::getNextMessageId (),
1524                        		    mInstance,
1525                        		    instances,
1526                        		    disableProviderOnly,
1527 kumpf         1.55     		    indicationProviders,
1528 kumpf         1.43     		    QueueIdStack(_service->getQueueId()));
1529 chuck         1.47     // l10n
1530 se.gupta      1.66     		disable_req->operationContext.set(AcceptLanguageListContainer(al));;
1531 kumpf         1.43     
1532                          	    Array<Uint16> _opStatus =
1533                        	        _sendDisableMessageToProviderManager(disable_req);
1534                        
1535                        	    if (!disableProviderOnly) // disable provider module
1536                        	    {
1537                        	        for (Uint32 i = 0; i<_opStatus.size(); i++)
1538                        	        {
1539                        		    // module was disabled successfully
1540 kumpf         1.68     	            if (_opStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPED)
1541 kumpf         1.43     	            {
1542 kumpf         1.55     			if (indProvider)
1543                        			{
1544                        	 	            // send termination message to subscription service
1545                        		            _sendTerminationMessageToSubscription(objectReference,
1546                        				  moduleName, false, al);
1547                        			}
1548 kumpf         1.43     		        return (0);
1549                        	            }
1550 kumpf         1.51     
1551                        		    // module is not disabled since there are pending
1552                                            // requests for the providers in the module
1553 kumpf         1.68                         if (_opStatus[i] == CIM_MSE_OPSTATUS_VALUE_OK)
1554 kumpf         1.51                         {
1555                                                return (-2);
1556                                            }
1557 kumpf         1.43     	        }
1558                        	    }
1559                        	    else // disable provider
1560                        	    {
1561 kumpf         1.55     		if (indProvider)
1562                        		{
1563                        	            _sendTerminationMessageToSubscription(objectReference,
1564 chuck         1.47     			moduleName, true, al);
1565 kumpf         1.55     		}
1566 kumpf         1.43     	        return (0);
1567                        	    }
1568                          	}
1569                        
1570                                // disable failed
1571                        	return (-1);
1572 kumpf         1.55     }
1573                        
1574 kumpf         1.56     // enable provider module 
1575                        // return 0 if module is enabled successfully,
1576                        // return 1 if module is already enabled,
1577                        // return 2 if module can not be enabled since module is stopping,
1578                        // otherwise, return -1 
1579                        Sint16 ProviderRegistrationProvider::_enableModule(
1580                            const CIMObjectPath & moduleRef, 
1581                            const String & moduleName,
1582 kumpf         1.83         const AcceptLanguageList & al)
1583 kumpf         1.56     {
1584                            	//
1585                            	// get module status
1586                            	//
1587                            	Array<Uint16> _OperationalStatus =
1588                        	    _providerRegistrationManager->getProviderModuleStatus( moduleName);
1589                        
1590                        	for (Uint32 i = 0; i<_OperationalStatus.size(); i++)
1591                        	{
1592                        	    // retValue equals 1 if module is already enabled
1593 kumpf         1.68     	    if (_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_OK)
1594 kumpf         1.56     	    {
1595                        		return (1);
1596                        	    }
1597                        
1598                        	    // retValue equals 2 if module is stopping
1599                        	    // at this stage, module can not be started
1600 kumpf         1.68     	    if (_OperationalStatus[i] == CIM_MSE_OPSTATUS_VALUE_STOPPING)
1601 kumpf         1.56     	    {
1602                                        return (2);
1603                        	    }
1604                        	}
1605                        
1606                                // get module instance
1607                                CIMInstance mInstance = 
1608                        	    _providerRegistrationManager->getInstance(moduleRef);
1609                        
1610                        	//
1611                                // get provider manager service
1612                                //
1613                                MessageQueueService * _service = _getProviderManagerService();
1614                        	Boolean enabled = false;
1615                        
1616 kumpf         1.65             if (_service != NULL)
1617 kumpf         1.56     	{
1618                        	    // create CIMEnableModuleRequestMessage
1619                        	    CIMEnableModuleRequestMessage * enable_req =
1620                        	        new CIMEnableModuleRequestMessage(
1621                        		    XmlWriter::getNextMessageId (),
1622                        		    mInstance,
1623                        		    QueueIdStack(_service->getQueueId()));
1624                        // l10n
1625 se.gupta      1.66             enable_req->operationContext.set(AcceptLanguageListContainer(al));;    
1626                        		
1627 kumpf         1.56       	    Array<Uint16> _opStatus;
1628                                    _opStatus = _sendEnableMessageToProviderManager(enable_req);
1629                        
1630                        	    for (Uint32 i = 0; i<_opStatus.size(); i++)
1631                        	    {
1632                        		// module is enabled successfully
1633 kumpf         1.68     	        if (_opStatus[i] == CIM_MSE_OPSTATUS_VALUE_OK)
1634 kumpf         1.56     	        {
1635                        		    enabled = true;
1636                        	        }
1637                        	    }
1638                        	}
1639                        
1640                        	if (enabled)
1641                        	{
1642                        	    //
1643 kumpf         1.59     	    // Since module is enabled, need get updated module instance
1644                        	    //
1645 kumpf         1.65                 CIMInstance updatedModuleInstance = 
1646 kumpf         1.59     	        _providerRegistrationManager->getInstance(moduleRef);
1647                        
1648 kumpf         1.65     	    // module is enabled, initialize providers as necessary
1649                        	    _providerRegistrationManager->initializeProviders(
1650                        		updatedModuleInstance);
1651                        
1652 kumpf         1.59     	    //
1653                        	    // The module is enabled, need to send enable message to 
1654 kumpf         1.56     	    // subscription service if the provider is an indication provider
1655                        	    //
1656                        
1657                        	    CIMObjectPath providerRef = CIMObjectPath(String::EMPTY,
1658                        				    moduleRef.getNameSpace(),
1659                        				    PEGASUS_CLASSNAME_PROVIDER,
1660                        				    Array<CIMKeyBinding>());
1661                        
1662                        	    //
1663                        	    // get all provider instances which have same module name as
1664                        	    // moduleName
1665                                    //
1666                        	    Array<CIMObjectPath> instanceNames =
1667                        	        _providerRegistrationManager->enumerateInstanceNames(providerRef);
1668                        	    CIMInstance pInstance;
1669                        	    String _moduleName;
1670                        	    String _providerName;
1671                        	    Array<CIMInstance> capInstances;
1672                        
1673                        	    for(Uint32 i = 0, n=instanceNames.size(); i < n; i++)
1674                        	    {
1675 kumpf         1.56     
1676                                        Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
1677                        
1678                                        for(Uint32 j=0; j < keys.size(); j++)
1679                                        {
1680                        	            //
1681                                            // get provider module name from reference
1682                                            //
1683                                            if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
1684                                            {
1685                                                _moduleName = keys[j].getValue();
1686                                            }
1687                        
1688                        	            //
1689                                            // get provider name from reference
1690                                            //
1691                                            if(keys[j].getName().equal (_PROPERTY_PROVIDER_NAME))
1692                                            {
1693                                                _providerName = keys[j].getValue();
1694                                            }
1695                                        }
1696 kumpf         1.56     
1697                        	        if (String::equalNoCase(_moduleName, moduleName))
1698                        	        {
1699                        	 	    providerRef.setKeyBindings(keys);
1700                        	            pInstance = _providerRegistrationManager->getInstance
1701                        			(providerRef);
1702                        		    // 
1703                        		    // get all the indication capability instances which belongs 
1704                        		    // to this provider
1705                        		    //
1706                        		    capInstances = _getIndicationCapInstances(
1707                        				   moduleName, pInstance, providerRef);
1708                        
1709                        		    //
1710                        		    // if there are indication capability instances
1711                        		    //
1712 kumpf         1.71                         if (capInstances.size() != 0)
1713 kumpf         1.56     		    {
1714 kumpf         1.65     		        _sendEnableMessageToSubscription(updatedModuleInstance,
1715 kumpf         1.56     		  					 pInstance,
1716                        						     	 capInstances,
1717                        							 al);
1718                        		    }
1719                        	        }    
1720                        	    }
1721                        	    return (0);
1722                        	}
1723                        
1724                        
1725                                // enable failed
1726                        	return (-1);
1727                        }
1728                        
1729                        // send enable message to indication service
1730                        void ProviderRegistrationProvider::_sendEnableMessageToSubscription(
1731                            const CIMInstance & mInstance,
1732                            const CIMInstance & pInstance,
1733                            const Array<CIMInstance> & capInstances,
1734 kumpf         1.83         const AcceptLanguageList & al)
1735 kumpf         1.56     {
1736                            //
1737                            // get indication server queueId
1738                            //
1739                            MessageQueueService * _service = _getIndicationService();
1740                        
1741                            if (_service != NULL)
1742                            {
1743                            	Uint32 _queueId = _service->getQueueId();
1744                        	    
1745                            	CIMNotifyProviderEnableRequestMessage * enable_req = 
1746                        		new CIMNotifyProviderEnableRequestMessage (
1747                        		    XmlWriter::getNextMessageId (),
1748                        		    capInstances,
1749                        		    QueueIdStack(_service->getQueueId()));
1750                        
1751 se.gupta      1.66     	enable_req->operationContext.set(AcceptLanguageListContainer(al));
1752 se.gupta      1.67         enable_req->operationContext.insert(ProviderIdContainer(mInstance,pInstance));
1753 se.gupta      1.66     	
1754 kumpf         1.56     	// create request envelope
1755                                AsyncLegacyOperationStart * asyncRequest =
1756                                    new AsyncLegacyOperationStart (
1757                                        _service->get_next_xid(),
1758                                        NULL,
1759                                        _queueId,
1760                                        enable_req,
1761                                        _queueId);
1762                        	    
1763 kumpf         1.64     	AsyncReply * asyncReply = 
1764                        	    _controller->ClientSendWait(*_client_handle,
1765                                              			_queueId,
1766                                              			asyncRequest);
1767 kumpf         1.56     
1768 kumpf         1.64             CIMNotifyProviderEnableResponseMessage * response =
1769                        	    reinterpret_cast<CIMNotifyProviderEnableResponseMessage *>(
1770 kumpf         1.70     		(dynamic_cast<AsyncLegacyOperationResult *>(asyncReply))->get_result());
1771 kumpf         1.64     
1772                                if (response->cimException.getCode() != CIM_ERR_SUCCESS)
1773 david.dillard 1.78             {
1774                                    CIMException e = response->cimException;
1775                                    delete asyncRequest;
1776                                    delete asyncReply;
1777                                    delete response;
1778                                    throw e;
1779                                }
1780 kumpf         1.64     
1781                                delete asyncRequest;
1782                                delete asyncReply;
1783                                delete response;
1784 kumpf         1.56         }
1785                        }
1786                        
1787 kumpf         1.70     // If provider is an indication provider, return true,
1788 kumpf         1.55     // otherwise, return false
1789                        Boolean ProviderRegistrationProvider::_isIndicationProvider(
1790                            const String & moduleName,
1791 kumpf         1.70         const CIMInstance & instance)
1792 kumpf         1.55     {
1793                            // get provider name
1794                            String providerName;
1795 kumpf         1.70         Uint32 pos = instance.findProperty(_PROPERTY_PROVIDER_NAME);
1796 kumpf         1.55         if (pos != PEG_NOT_FOUND)
1797                            {
1798                        	instance.getProperty(pos).getValue().get(providerName);	
1799                            }
1800                        
1801 kumpf         1.70         return (_providerRegistrationManager->isIndicationProvider(
1802                        	    moduleName, providerName));
1803 kumpf         1.56     }
1804                        
1805                        //
1806                        // get all the capability instances whose provider type is indication 
1807                        // 
1808                        Array<CIMInstance> ProviderRegistrationProvider::_getIndicationCapInstances(
1809                            const String & moduleName,
1810                            const CIMInstance & instance,
1811                            const CIMObjectPath & providerRef)
1812                        {
1813                            // get provider name
1814                            String providerName;
1815                            Uint32 pos = instance.findProperty(CIMName (_PROPERTY_PROVIDER_NAME));
1816                            if (pos != PEG_NOT_FOUND)
1817                            {
1818                        	instance.getProperty(pos).getValue().get(providerName);	
1819                            }
1820                        
1821                            CIMObjectPath capabilityRef;
1822                        
1823                            capabilityRef = CIMObjectPath(providerRef.getHost(),
1824 kumpf         1.56     				  providerRef.getNameSpace(),
1825                        		       		  PEGASUS_CLASSNAME_CAPABILITIESREGISTRATION,
1826                        		       		  providerRef.getKeyBindings());
1827                        
1828                            // get all Capabilities instances
1829                            Array<CIMObjectPath> instanceNames =
1830                        	_providerRegistrationManager->enumerateInstanceNames(capabilityRef);
1831                        			
1832                            String _moduleName, _providerName;
1833                            CIMInstance capInstance;
1834                            Array<Uint16> providerTypes;
1835                            Array<CIMInstance> indCapInstances = 0;
1836                            for(Uint32 i = 0, n=instanceNames.size(); i < n; i++)
1837                            {
1838                        	Array<CIMKeyBinding> keys = instanceNames[i].getKeyBindings();
1839                        
1840                        	for(Uint32 j=0; j < keys.size(); j++)
1841                                {
1842                                     if(keys[j].getName().equal (_PROPERTY_PROVIDERMODULENAME))
1843                                     {
1844                                          _moduleName = keys[j].getValue();
1845 kumpf         1.56                  }
1846                        
1847                                     if(keys[j].getName().equal (_PROPERTY_PROVIDERNAME))
1848                                     {
1849                                          _providerName = keys[j].getValue();
1850                                     }
1851 kumpf         1.58     	}
1852 kumpf         1.56     
1853 kumpf         1.58            //
1854                               // if capability instance has same module name as moduleName
1855                               // and same provider name as providerName, get provider type
1856                               //
1857                               if(String::equal(_moduleName, moduleName) &&
1858                                  String::equal(_providerName, providerName))
1859                               {
1860                        	    capInstance = _providerRegistrationManager->getInstance
1861 kumpf         1.56     				(instanceNames[i]);
1862                        
1863 kumpf         1.58     	    Uint32 pos = capInstance.findProperty(CIMName (_PROPERTY_PROVIDERTYPE));
1864                            	    if (pos != PEG_NOT_FOUND)
1865                        	    {
1866                        	        capInstance.getProperty(pos).getValue().get(providerTypes); 
1867 kumpf         1.56     
1868 kumpf         1.58         		for (Uint32 k=0; k < providerTypes.size(); k++)
1869                            		{
1870                        		    // 
1871                        		    // if provider type of the instance is indication,
1872                        		    // append the instance 
1873                        		    //
1874                                	    if (providerTypes[k] == _INDICATION_PROVIDER)
1875                                	    {
1876                                    	        indCapInstances.append(capInstance);
1877                                	    }
1878                            		}
1879                        	    }
1880                        	}
1881 kumpf         1.56         }
1882                        
1883                            return (indCapInstances);
1884 kumpf         1.1      }
1885                        
1886                        PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2