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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2