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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2