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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2