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

   1 karl  1.12 //%2004////////////////////////////////////////////////////////////////////////
   2 karl  1.1  //
   3 karl  1.12 // 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.3  // IBM Corp.; EMC Corporation, The Open Group.
   7 karl  1.12 // 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.1  //
  10            // Permission is hereby granted, free of charge, to any person obtaining a copy
  11            // of this software and associated documentation files (the "Software"), to
  12            // deal in the Software without restriction, including without limitation the
  13            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  14            // sell copies of the Software, and to permit persons to whom the Software is
  15            // furnished to do so, subject to the following conditions:
  16 karl  1.3  // 
  17 karl  1.1  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
  18            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
  19            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  20            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  21            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  22            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  23            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  24            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25            //
  26            //==============================================================================
  27            //
  28            // Author: Karl Schopmeyer (k.schopmeyer@opengroup.org)
  29            //
  30            // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
  31            //                (carolann_graves@hp.com)
  32 karl  1.8  //              Karl Schopmeyer - Created Cim_Namespace capabilities.
  33            //              Karl Schopmeyer - added objectmanager and communication classes
  34 karl  1.1  //
  35            //%////////////////////////////////////////////////////////////////////////////
  36            
  37            
  38            ///////////////////////////////////////////////////////////////////////////////
  39 karl  1.5  //  Interop Provider - This provider services those classes from the
  40            //  DMTF Interop schema association with the CIMOM itself
  41 karl  1.1  //
  42 karl  1.5  //  This provider services the following classes:
  43            //      CIMObjectManager
  44            //      CIM_ObjectManagerCommunicationMechanism
  45            //      CIM_CIMXMLCommunicationMechanism
  46            //      CIM_ProtocolAdapter
  47 karl  1.8  //      CIM_Namespace (Effective Pegasus 2.4 we use PG_Namespace which
  48            //      is a subclass of CIM_Namespace with additional properties for
  49            //      shared namespaces.
  50 karl  1.5  //      
  51            //      It also services the Interop associations tied to these classes
  52            //      including:
  53            //      CIM_NamespaceInManager
  54            //      ...
  55 karl  1.11 //      This is a control provider and as such uses the Tracer functions
  56            //      for data and function traces.  Since we do not expect high volume
  57            //      use we added a number of traces to help diagnostics.  
  58 karl  1.1  ///////////////////////////////////////////////////////////////////////////////
  59 karl  1.11 /* TODO LIST:
  60                1. Finish the association functions
  61                
  62                2. UUID generation should become a system function since it will be used
  63                   by many providers, etc. as part of id generation.
  64                   
  65                3. Review the key parameters on create, etc. to be sort out which are
  66                   required from user and which we can supply.  I think we are asking too
  67                   much of the user right now.
  68 tony  1.6  */
  69 karl  1.1  
  70            #include <Pegasus/Common/Config.h>
  71            #include <Pegasus/Common/PegasusVersion.h>
  72            
  73            #include <cctype>
  74            #include <iostream>
  75            
  76            #include "InteropProvider.h"
  77 tony  1.6  #include "Guid.h"
  78 karl  1.1  #include <Pegasus/Common/String.h>
  79            #include <Pegasus/Common/System.h>
  80            #include <Pegasus/Common/ArrayInternal.h>
  81            #include <Pegasus/Common/CIMName.h>
  82            #include <Pegasus/Common/CIMType.h>
  83            #include <Pegasus/Common/CIMInstance.h>
  84            #include <Pegasus/Common/CIMObjectPath.h>
  85            #include <Pegasus/Common/InternalException.h>
  86            #include <Pegasus/Common/CIMStatusCode.h>
  87            #include <Pegasus/Common/Tracer.h>
  88            #include <Pegasus/Common/OperationContext.h>
  89            #include <Pegasus/Config/ConfigManager.h>
  90 tony  1.6  #include <Pegasus/Common/XmlWriter.h>
  91            #include <Pegasus/Config/ConfigManager.h>
  92 karl  1.8  #include <Pegasus/Common/StatisticalData.h>
  93            #include <Pegasus/Common/HashTable.h>
  94 karl  1.1  
  95            
  96 tony  1.6  #include <stdlib.h>
  97 karl  1.1  
  98 tony  1.6  //The following include is needed for gethostbyname
  99            #if defined(PEGASUS_OS_TYPE_WINDOWS)
 100            #include <objbase.h>
 101            #else
 102            #include <netdb.h>
 103            #include <arpa/inet.h>
 104            #endif
 105 karl  1.1  
 106            PEGASUS_USING_STD;
 107            
 108            PEGASUS_NAMESPACE_BEGIN
 109            
 110 tony  1.6  #define CDEBUG(X)
 111 karl  1.11 #define LDEBUG()
 112 tony  1.6  //#define CDEBUG(X) PEGASUS_STD(cout) << "InteropProvider " << X << PEGASUS_STD(endl)
 113 karl  1.11 //#define LDEBUG(X) Logger::put (Logger::DEBUG_LOG, "InteropProvider", Logger::INFORMATION, "$0", X)
 114            // The following is attempt to use the tracer for CDEBUG.  Not working. 1 sept 2004
 115            //#include <cstring>
 116            //#include <stdcxx/stream/strstream>
 117            // This one sucks because not applicable to separate executables.
 118            // looks like we use trace for the externals.
 119            // requires using PEGASUS_USING_PEGASUS
 120            //#define CDEBUG(X) {ostrstream os; os << X; char* tmp = os.str(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, String(tmp));delete tmp;} 
 121            //#define CDEBUG(X) {stringstream os; os << X;string os_str = os.str(); const char* tmp = os_str.c_str(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, String(tmp); }
 122 tony  1.6  
 123            //**************************************************************************
 124            //
 125            //    Constants representing the class names processed
 126            //
 127            //**************************************************************************
 128            
 129 karl  1.10 const char * thisProvider = "InteropProvider";
 130 tony  1.6  // The following should be moved to somewhere like constants.
 131 karl  1.5  static const String PegasusInstanceIDGlobalPrefix = "PEG";
 132 karl  1.1  
 133            /**
 134                The constants representing the class names we process
 135            */
 136 karl  1.8  // ATTN DELETE: static const CIMName __NAMESPACE_CLASSNAME  = CIMName ("__Namespace");
 137 karl  1.1  static const CIMName CIM_NAMESPACE_CLASSNAME  = CIMName ("CIM_Namespace");
 138 karl  1.8  static const CIMName PG_NAMESPACE_CLASSNAME  = CIMName ("PG_Namespace");
 139            
 140 karl  1.1  static const CIMName CIM_OBJECTMANAGER_CLASSNAME  = CIMName ("CIM_ObjectManager");
 141            static const CIMName CIM_OBJECTMANAGERCOMMUNICATIONMECHANISM_CLASSNAME  = 
 142                    CIMName ("CIM_ObjectManagerCommunicationMechanism");
 143 tony  1.6  static const CIMName PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME  = 
 144                    CIMName ("PG_CIMXMLCommunicationMechanism");
 145            static const CIMName CIM_COMMMECHANISMFORMANAGER_CLASSNAME  = 
 146                    CIMName ("CIM_CommMechanismForManager");
 147            static const CIMName CIM_NAMESPACEINMANAGER_CLASSNAME  = 
 148                    CIMName ("CIM_NamespaceInManager");
 149 karl  1.1  
 150            // Property Names for __Namespace Class
 151            static const CIMName NAMESPACE_PROPERTYNAME  = CIMName ("Name");
 152            static const CIMNamespaceName ROOTNS  = CIMNamespaceName ("root");
 153            
 154            
 155            // Property names for CIM_ObjectManager Class
 156            static const CIMName OM_GATHERSTATISTICALDATA  =
 157             CIMName ("GatherStatisticalData");
 158 tony  1.6  // Property for the slp template.
 159            static const CIMName OM_DESCRIPTIONPROPERTY =
 160                CIMName("Description");
 161 karl  1.1  
 162            // Property Names for ObjectManagerCommunicationMechanism Class
 163            static const CIMName OM_COMMUNICATIONMECHANISM  = 
 164                    CIMName ("CommunicationMechanism");
 165            static const CIMName OM_FUNCTIONALPROFILESSUPPORTED  =
 166             CIMName ("FunctionalProfilesSupported");
 167            static const CIMName OM_FUNCTIONALPROFILEDESCRIPTIONS  =
 168             CIMName ("FunctionalProfileDescriptions");
 169            static const CIMName OM_AUTHENTICATIONMECHANISMSSUPPORTED  =
 170             CIMName ("AuthenticationMechanismsSupported");
 171            static const CIMName OM_AUTHENTICATIONMECHANISMDESCRIPTIONS  =
 172             CIMName ("AuthenticationMechanismDescriptions");
 173            static const CIMName OM_MULTIPLEOPERATIONSSUPPORTED  =
 174             CIMName ("MultipleOperationsSupported");
 175            static const CIMName OM_VERSION  =
 176             CIMName ("Version");
 177            
 178            // Property Names for CIMXML CommunicationMechanism
 179            
 180            static const CIMName CIMVALIDATED  =
 181             CIMName ("CIMValidated");
 182 karl  1.1  
 183            static const String CIMXMLProtocolVersion = "1.0";
 184            
 185 karl  1.5  // Property names for CIM_Namespace Class
 186 karl  1.1  
 187            static const CIMName CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME = 
 188                    CIMName ("SystemCreationClassName");
 189            static const CIMName CIM_NAMESPACE_PROPERTY_SYSTEMNAME = 
 190                    CIMName ("SystemName");
 191            static const CIMName CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME = 
 192                    CIMName ("ObjectManagerCreationClassName");
 193            static const CIMName CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME = 
 194                    CIMName ("ObjectManagerName");
 195            static const CIMName CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME = 
 196                    CIMName ("CreationClassName");
 197            static const CIMName CIM_NAMESPACE_PROPERTY_NAME  = CIMName ("Name");
 198            static const CIMName CIM_NAMESPACE_PROPERTY_CLASSINFO = 
 199                    CIMName ("ClassInfo");
 200            static const CIMName CIM_NAMESPACE_PROPERTY_DESCRIPTIONOFCLASSINFO = 
 201                    CIMName ("DescriptionOfClassInfo");
 202            
 203 karl  1.8  // Additional Property names for PG_Namespace Class
 204            
 205            static const CIMName PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED = 
 206                    CIMName ("SchemaUpdatesAllowed");
 207            static const CIMName PG_NAMESPACE_PROPERTY_ISSHAREABLE = 
 208                    CIMName ("IsShareable");
 209            static const CIMName PG_NAMESPACE_PROPERTY_PARENTNAMESPACE = 
 210                    CIMName ("ParentNamespace");
 211 karl  1.11 static const CIMName PG_NAMESPACE_PROPERTY_NAME = 
 212                    CIMName ("Name");
 213 karl  1.8  
 214 karl  1.5  // Defines to serve as the ENUM for class selection for instance
 215            // operations.
 216            
 217            enum targetClass{
 218 karl  1.11         //__NAMESPACE = 1,
 219                    PG_NAMESPACE = 1,
 220                    CIM_OBJECTMANAGER = 2,
 221                    PG_CIMXMLCOMMUNICATIONMECHANISM = 3,
 222                    CIM_NAMESPACEINMANAGERINST =4,
 223                    CIM_COMMMECHANISMFORMANAGERINST=5
 224                };
 225                
 226 tony  1.6   enum targetAssocClass{
 227                 CIM_NAMESPACEINMANAGER =1,
 228                 CIM_COMMMECHANISMFORMANAGER=2
 229             };
 230 karl  1.5  
 231 karl  1.1  //***************************************************************
 232 karl  1.5  // Provider Utility Functions
 233 karl  1.1  //***************************************************************
 234 tony  1.6  
 235 karl  1.8  /** get one string property from an instance. Note that these functions simply
 236                return the default value if the property cannot be found or is of the wrong
 237                type thus, in reality being a maintenance problem since there is no 
 238                error indication.
 239 tony  1.6      @param instance CIMInstance from which we get property value
 240                @param propertyName String name of the property containing the value
 241                @param default String optional parameter that is substituted if the property does
 242                not exist, is Null, or is not a string type. The substitute is String::EMPTY
 243                @return String value found or defaultValue.
 244            */
 245 karl  1.10 String _getPropertyValue(const CIMInstance& instance, const CIMName& propertyName, const String& defaultValue)
 246 tony  1.6  {
 247 karl  1.8      String output = defaultValue;
 248 tony  1.6      Uint32 pos;
 249                if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
 250                {
 251                    CIMConstProperty p1 = instance.getProperty(pos);
 252                    if (p1.getType() == CIMTYPE_STRING)
 253                    {
 254                        CIMValue v1  = p1.getValue();
 255            
 256                        if (!v1.isNull())
 257                            v1.get(output);
 258                    }
 259                }
 260 karl  1.8      return(output);
 261            }
 262            
 263            // Overload of _getPropertyValue for boolean type
 264 karl  1.10 Boolean _getPropertyValue(const CIMInstance& instance, const CIMName& propertyName, const Boolean defaultValue)
 265 karl  1.8  {
 266                Boolean output = defaultValue;
 267                Uint32 pos;
 268                if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
 269                {
 270                    CIMConstProperty p1 = instance.getProperty(pos);
 271                    if (p1.getType() == CIMTYPE_BOOLEAN)
 272                    {
 273                        CIMValue v1  = p1.getValue();
 274            
 275                        if (!v1.isNull())
 276                            v1.get(output);
 277                    }
 278                }
 279 tony  1.6      return(output);
 280            }
 281 karl  1.11 
 282 tony  1.6  /** get Host IP address from host name. If the
 283                host name is not provided, uses internal function.
 284                If everything fails, gets the definition normally
 285                used for localhost (127.0.0.1).
 286                
 287                @param hostName String with the name of the host
 288                @return String with the IP address to be used
 289                NOTE: This code should not be in slpprovider. This
 290                should be in the Interop classes but for the moment
 291                it is not.
 292            */
 293            String _getHostAddress(String hostName)
 294 marek 1.12.2.1 {  
 295                  String ipAddress;
 296 tony  1.6        
 297                  if (hostName == String::EMPTY)
 298                    	hostName = System::getHostName();
 299                
 300 marek 1.12.2.1   if ((ipAddress = System::getHostIP(hostName)) == String::EMPTY)
 301                  {
 302                      // set default address if everything else failed
 303                      ipAddress = String("127.0.0.1");
 304                  }
 305 tony  1.6        return ipAddress;
 306                }
 307                
 308                 Array<String> _getFunctionalProfiles(Array<Uint16> profiles)
 309                 {
 310                     Array<String> profileDescriptions;
 311                     profiles.append(2); profileDescriptions.append("Basic Read");
 312                     profiles.append(3); profileDescriptions.append("Basic Write");
 313                     profiles.append(4); profileDescriptions.append("Schema Manipulation");
 314                     profiles.append(5); profileDescriptions.append("Instance Manipulation");
 315                     profiles.append(6); profileDescriptions.append("Association Traversal");
 316                     profiles.append(8); profileDescriptions.append("Qualifier Declaration");
 317                     profiles.append(9); profileDescriptions.append("Indications");
 318                     return(profileDescriptions);
 319                 }
 320                
 321                /*  get the prefix that will be part of the cimom identification
 322                    This can be either the default PEG or if the environment
 323                    variable PEGASUS_TRADEMARK_PREFIX is defined this is used.
 324                    NOTE: getting from the environment variable is a hack until
 325                    we can come up with a better source.
 326 tony  1.6          @return String containing the unique name for the CIMOM ID
 327                */
 328                
 329                String getTrademarkCIMOMIDPrefix()
 330                {
 331                
 332                    char * trademark;
 333                    trademark = getenv("PEGASUS_TRADEMARK_PREFIX");
 334                    return((trademark)? trademark : PegasusInstanceIDGlobalPrefix);
 335                }
 336                /** Builds the UUID string for this CIMOM.
 337                **/
 338                String getUUIDString()
 339                {
 340                    return(Guid::getGuid());
 341                }
 342 karl  1.1      
 343                /* Test the keys in the CIM_Namespace for valid values
 344                   This includes all of the keys above the name key.
 345                   THis is a dummy for now.
 346                   ATTN: KS Extend and finish this function.
 347                */
 348 karl  1.5      Boolean _validateProperties(const CIMObjectPath& path)
 349 karl  1.1      {
 350                    return true;
 351                }
 352 karl  1.5      Boolean _validateProperties(const CIMInstance& instance)
 353 karl  1.1      {
 354                    return true;
 355                }
 356                
 357 tony  1.6      /* Validate that the property exists, is string type and
 358 karl  1.5         optionally the value itself. Note processes only String
 359 tony  1.6         properties.
 360                   @param Instance to search for property.
 361                   @param CIMName containing property Name
 362                   @value String containing value. If not String::EMPTY, compare to 
 363 karl  1.5         value in the property
 364 tony  1.6         @return True if passes all tests
 365 karl  1.5      */
 366                Boolean _validateRequiredProperty(const CIMInstance& instance, 
 367                                          const CIMName& propertyName,
 368                                          const String& value)
 369                {
 370 tony  1.6          PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 371                            "InteropProvider::_validateRequiredProperty()");
 372 karl  1.5          Uint32 pos;
 373 tony  1.6      
 374 karl  1.5          if ((pos = instance.findProperty (propertyName)) == PEG_NOT_FOUND)
 375 tony  1.6          {
 376                        PEG_METHOD_EXIT();
 377 karl  1.5              return(false);
 378 tony  1.6          }
 379 karl  1.5          //
 380                    //  Get the property
 381                    //
 382                    CIMConstProperty theProperty = instance.getProperty(pos);
 383                    const CIMValue theValue = theProperty.getValue ();
 384                    //
 385 tony  1.6          //  ATTN: Required property must have a non-null value
 386 karl  1.5          //
 387 tony  1.6          if ((theValue.getType() != CIMTYPE_STRING) || (theValue.isNull()))
 388                    {
 389                        PEG_METHOD_EXIT();
 390 karl  1.5              return(false);
 391 tony  1.6          }
 392                
 393                    String valueField;
 394                    theValue.get(valueField);
 395                    if ((value == String::EMPTY) || (valueField == value))
 396 karl  1.5          {
 397 tony  1.6              PEG_METHOD_EXIT();
 398                        return(true);
 399 karl  1.5          }
 400 tony  1.6          PEG_METHOD_EXIT();
 401                    return(false);
 402 karl  1.5      }
 403                
 404                Boolean _validateRequiredProperty(const CIMInstance& instance,
 405                                          const CIMName& propertyName,
 406                                          const Uint16& value)
 407                {
 408 tony  1.6          PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 409                        "InteropProvider::_validateRequiredProperty()");
 410                    
 411                    PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "Validate "
 412                        + propertyName.getString());
 413                
 414 karl  1.5          Uint32 pos;
 415                    if ((pos = instance.findProperty (propertyName)) == PEG_NOT_FOUND)
 416 tony  1.6          {
 417                        PEG_METHOD_EXIT();
 418 karl  1.5              return(false);
 419 tony  1.6          }
 420 karl  1.5          //
 421                    //  Get the property
 422                    //
 423                    CIMConstProperty theProperty = instance.getProperty(pos);
 424                    CIMValue theValue = theProperty.getValue ();
 425                    //
 426 tony  1.6          //  ATTN:Required property must have a non-null value
 427 karl  1.5          //
 428 tony  1.6          if ((theValue.getType() != CIMTYPE_UINT16) 
 429                        || (theValue.isNull()) ) 
 430                    {
 431                        PEG_METHOD_EXIT();
 432 karl  1.5              return(false);
 433 tony  1.6          }
 434                    PEG_METHOD_EXIT();
 435 karl  1.5          return(true);
 436                }
 437                Boolean _validateRequiredProperty(const CIMObjectPath& objectPath,
 438                                          const CIMName& propertyName,
 439                                          const String value)
 440                {
 441 tony  1.6          PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 442                            "InteropProvider::_validateRequiedProperty()");
 443 karl  1.5          Array<CIMKeyBinding> kbArray = objectPath.getKeyBindings();
 444                
 445                    // find the correct key binding
 446                    for (Uint32 i = 0; i < kbArray.size(); i++)
 447                    {
 448                        if (kbArray[i].getName() == propertyName)
 449                        {
 450                            if (value != String::EMPTY)
 451                            {
 452                                if (value !=kbArray[i].getValue())
 453                                {
 454 tony  1.6                          PEG_METHOD_EXIT();
 455 karl  1.5                          return(true);
 456                                }
 457                            }
 458                        }
 459                    }
 460 tony  1.6          PEG_METHOD_EXIT();
 461 karl  1.5          return(true);
 462                }
 463 karl  1.1      
 464                /* Query the repository for array of all namespacenames
 465 tony  1.6         @return Array<CIMNamespaceName> with all namespaces
 466                   @exception Passes all exception that repository may generate.
 467 karl  1.1      */        
 468                Array<CIMNamespaceName> InteropProvider::_enumerateNameSpaces()
 469                {
 470                    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 471                            "InteropProvider::_enumerateNameSpaces()");
 472 tony  1.6      
 473 karl  1.1          Array<CIMNamespaceName> namespaceNames;
 474                    
 475 tony  1.6          namespaceNames = _repository->enumerateNameSpaces();
 476 karl  1.1      
 477                    PEG_METHOD_EXIT();
 478                    return(namespaceNames);
 479                }
 480                
 481 tony  1.6      /* get a class defintion. Gets the class defined by
 482                    the parameters. Generates exception of class not defined.
 483 karl  1.1         @param namespace in which to look for the class.
 484                   @param name of class to get.
 485                   @return the CIMClass object
 486                   @Exceptions any repository exceptions if class not found.
 487                */ 
 488                CIMClass InteropProvider::_getClass(const CIMNamespaceName& nameSpace,
 489 tony  1.6                                          const CIMName& className)
 490 karl  1.1      {
 491                    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 492 tony  1.6                  "InteropProvider::_getClass");
 493                
 494                    CIMClass myClass = _repository->getClass(nameSpace, className,
 495                                            false,true,true);
 496 karl  1.1          PEG_METHOD_EXIT();
 497                    return myClass;
 498                }
 499                
 500                /* Verify that this is one of the legal classnames and
 501                   return indicator which.
 502                   @param - Classname
 503                   @return - Uint32 indicating type
 504                   @Exceptions - throws CIMNotSupportedException if invalid class.
 505                */
 506 karl  1.5      targetClass _verifyValidClassInput(const CIMName& className)
 507 karl  1.1      {
 508 karl  1.10         PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 509                            "InteropProvider::_verifyValidClassInput");
 510 karl  1.1          if (className.equal(CIM_OBJECTMANAGER_CLASSNAME))
 511                        return CIM_OBJECTMANAGER;
 512                
 513 tony  1.6          if (className.equal(PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME))
 514                        return PG_CIMXMLCOMMUNICATIONMECHANISM;
 515 karl  1.1      
 516 karl  1.10         // Last entry, reverse test and return OK if PG_Namespace
 517 karl  1.8          // Note: Changed to PG_Namespace for CIM 2.4
 518                    if (!className.equal(PG_NAMESPACE_CLASSNAME))
 519 karl  1.1              throw CIMNotSupportedException
 520                            (className.getString() + " not supported by Interop Provider");
 521                
 522 karl  1.10         PEG_METHOD_EXIT();
 523 karl  1.8          return PG_NAMESPACE;
 524 karl  1.1      }
 525                
 526 tony  1.6      targetAssocClass _verifyValidAssocClassInput(const CIMName& className)
 527                {
 528 karl  1.10         PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 529                            "InteropProvider::_verifyValidAssocClassInput");
 530 tony  1.6          if (className.equal(CIM_NAMESPACEINMANAGER_CLASSNAME))
 531                        return CIM_NAMESPACEINMANAGER;
 532 karl  1.8          // Last entry, reverse test and return OK if CIM_CommMech....
 533 tony  1.6          if (!className.equal(CIM_COMMMECHANISMFORMANAGER_CLASSNAME))
 534                        throw CIMNotSupportedException
 535                            (className.getString() + " not supported by Interop Provider");
 536                
 537 karl  1.10         PEG_METHOD_EXIT();
 538 tony  1.6          return CIM_COMMMECHANISMFORMANAGER;
 539                }
 540                
 541 karl  1.1      /* validate the authorization of the user name against the namespace.
 542                */
 543                String _validateUserID(const OperationContext & context)
 544                {
 545 karl  1.10         PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 546                            "InteropProvider::_validateUserID");
 547 karl  1.1          //ATTN-DME-P3-20020522: ADD AUTHORIZATION CHECK TO __NAMESPACE PROVIDER
 548                    String userName;
 549                    try
 550                    {
 551                        IdentityContainer container = context.get(IdentityContainer::NAME);
 552                        userName = container.getUserName();
 553                    }
 554 karl  1.10     
 555 karl  1.1          catch (...)
 556                    {
 557                       userName = String::EMPTY;
 558                    }
 559 karl  1.10     
 560                    PEG_METHOD_EXIT();
 561 karl  1.1          return userName;
 562                }
 563                
 564 karl  1.11     /** Set the value of a property defined by property name in the instance provided.
 565 tony  1.6          Sets a String into the value field unless the property name cannot be found.
 566                    If the property cannot be found, it simply returns.
 567                    ATTN: This function does not pass an error back if property not found.
 568                    @param instance CIMInstance in which to set property value
 569                    @param propertyName CIMName of property in which value will be set.
 570                    @param value String value to set into property
 571                    
 572                */
 573                void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const String& value)
 574                {
 575                    Uint32 pos;
 576                    if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
 577                        instance.getProperty(pos).setValue(CIMValue(value));
 578                }
 579                
 580                void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Boolean& value)
 581                {
 582                    Uint32 pos;
 583                    if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
 584                        instance.getProperty(pos).setValue(CIMValue(value));
 585                }
 586 karl  1.1      
 587 tony  1.6      void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Uint16& value)
 588                {
 589                    Uint32 pos;
 590                    if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
 591                        instance.getProperty(pos).setValue(CIMValue(value));
 592                }
 593                
 594                void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Array<String>& value)
 595                {
 596                    Uint32 pos;
 597                    if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
 598                        instance.getProperty(pos).setValue(CIMValue(value));
 599                }
 600                
 601                void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const Array<Uint16>& value)
 602                {
 603                    Uint32 pos;
 604                    if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
 605                        instance.getProperty(pos).setValue(CIMValue(value));
 606                }
 607                
 608 tony  1.6      void _setPropertyValue(CIMInstance& instance, const CIMName propertyName, const CIMObjectPath& value)
 609                {
 610                    Uint32 pos;
 611                    if ((pos = instance.findProperty(propertyName)) != PEG_NOT_FOUND)
 612                        instance.getProperty(pos).setValue(CIMValue(value));
 613                }
 614                
 615                /** add the correct values to the common keys defined for all of the classes. This is
 616                    systemcreationclassname and systemname
 617                    Note that if the properties do not exist, we simply ignore them.
 618                */
 619                void _fixInstanceCommonKeys(CIMInstance& instance)
 620 karl  1.1      {
 621                    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 622 tony  1.6                  "InteropProvider::_fixInstanceCommonKeys()");
 623 karl  1.1          String SystemCreationClassName = System::getSystemCreationClassName ();
 624                    if (SystemCreationClassName == String::EMPTY)
 625                    {
 626 tony  1.6              //Attn: Get this globally. For now This in place because global is often Empty
 627 karl  1.1              SystemCreationClassName = "CIM_ComputerSystem";
 628                    }
 629                
 630 tony  1.6          _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,SystemCreationClassName);
 631 karl  1.1      
 632 karl  1.5          // Add property SystemName
 633 tony  1.6      
 634                    _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_SYSTEMNAME,System::getHostName());
 635 karl  1.1          PEG_METHOD_EXIT();
 636                }
 637                
 638 tony  1.6      /** builds one instance of the class named className. Gets Class defintion and f
 639                    fills in the correct properties from the class.  This requires a repository
 640                    getclass request for each instance built. The skeleton is built by
 641                    creating the instance and copying qualifiers and properties from
 642                    the class. Finally the instance is cloned to separate it from the
 643                    original objects.
 644                    NOTE: This is very inefficient for anything larger than a few instances.
 645                    We should separate the get from the createSkeleton.
 646                    @param className CIMName of the class for which the instance is to be built
 647                    @return CIMInstance of this class with properties complete.
 648                    @exception passes on any exceptions received from the repository request.
 649                */
 650                CIMInstance InteropProvider::_buildInstanceSkeleton(const CIMName& className)
 651 karl  1.1      {
 652                    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 653 tony  1.6                  "InteropProvider::_buildInstanceSkeleton()");
 654 karl  1.10         CIMClass myClass;
 655 karl  1.1      
 656 tony  1.6          CIMInstance skeleton(className);
 657                        myClass = _repository->getClass(_operationNamespace, className, false, true, true);
 658 karl  1.1          
 659 tony  1.6          // copy the qualifiers
 660                    for (Uint32 i = 0 ; i < myClass.getQualifierCount() ; i++)
 661                        skeleton.addQualifier(myClass.getQualifier(i));
 662                
 663                    // copy the properties
 664                    for (Uint32 i = 0 ; i < myClass.getPropertyCount() ; i++)
 665                        skeleton.addProperty(myClass.getProperty(i));
 666 karl  1.1      
 667                    PEG_METHOD_EXIT();
 668 tony  1.6          return(skeleton.clone());
 669 karl  1.1      }
 670                
 671 tony  1.6      /* build a single instance of the cimxmlcommunicationmechanism class
 672                   using the parameter provided as the name property
 673                   @parm name String representing the name to be used for this object.
 674                   @return CIMInstance of the class
 675 karl  1.5      */
 676 tony  1.6      CIMInstance InteropProvider::_buildInstancePGCIMXMLCommunicationMechanism(
 677                                                            const String& namespaceType,
 678                                                            const String& IPAddress,
 679                                                            const Boolean& includeQualifiers,
 680                                                            const Boolean& includeClassOrigin,
 681                                                            const CIMPropertyList& propertyList)
 682 karl  1.1      {
 683                    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 684 tony  1.6                  "InteropProvider::_buildInstancePGCIMXMLCommunicationMechanism()");
 685 karl  1.1          
 686 tony  1.6          CIMInstance instance = _buildInstanceSkeleton(PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME);
 687 karl  1.1      
 688 tony  1.6          _fixInstanceCommonKeys(instance);
 689 karl  1.1      
 690 tony  1.6          //CreationClassName
 691                    _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME.getString());
 692 karl  1.1      
 693 tony  1.6          //Name, this CommunicationMechanism.
 694                    _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME, PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME.getString());
 695 karl  1.1      
 696 tony  1.6          // CommunicationMechanism Property
 697                    _setPropertyValue(instance, OM_COMMUNICATIONMECHANISM, Uint16(2));
 698 karl  1.1      
 699                    //Functional Profiles Supported Property.
 700                    Array<Uint16> profiles;
 701 tony  1.6          Array<String> profileDescriptions = _getFunctionalProfiles(profiles);
 702 karl  1.1      
 703 tony  1.6          // Set functional profiles in instance
 704                    _setPropertyValue(instance, OM_FUNCTIONALPROFILESSUPPORTED, profiles);
 705                
 706                    _setPropertyValue(instance, OM_FUNCTIONALPROFILEDESCRIPTIONS, profileDescriptions);
 707 karl  1.1      
 708                    // Multiple OperationsSupported Property
 709 tony  1.6          _setPropertyValue(instance, OM_MULTIPLEOPERATIONSSUPPORTED, false);
 710 karl  1.5      
 711                    // AuthenticationMechanismsSupported Property
 712 karl  1.1          Array<Uint16> authentications;
 713                    Array<String> authenticationDescriptions;
 714 karl  1.5      
 715 tony  1.7          authentications.append(3); authenticationDescriptions.append("Basic");
 716 karl  1.5      
 717 tony  1.6          _setPropertyValue(instance, OM_AUTHENTICATIONMECHANISMSSUPPORTED, authentications);
 718                
 719                    _setPropertyValue(instance, OM_AUTHENTICATIONMECHANISMDESCRIPTIONS, authenticationDescriptions);
 720 karl  1.1          
 721 tony  1.6          _setPropertyValue(instance, OM_VERSION, CIMXMLProtocolVersion);
 722                
 723                    _setPropertyValue(instance, "namespaceType", namespaceType);
 724                
 725                    _setPropertyValue(instance, "IPAddress", IPAddress);
 726 karl  1.1      
 727                    PEG_METHOD_EXIT();
 728                    return(instance);
 729                }
 730 tony  1.6      
 731                Array<CIMInstance> InteropProvider::_buildInstancesPGCIMXMLCommunicationMechanism(
 732                                                            const Boolean includeQualifiers,
 733                                                            const Boolean includeClassOrigin,
 734                                                            const CIMPropertyList& propertyList)
 735                {
 736 karl  1.10         PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 737                            "InteropProvider::_buildInstancesPGCIMXMLCommunicationMechanism");
 738                    
 739 tony  1.6          // This is a temporary hack to get the multiple connections.
 740                    ConfigManager* configManager = ConfigManager::getInstance();
 741                    Boolean enableHttpConnection = String::equal(
 742                        configManager->getCurrentValue("enableHttpConnection"), "true");
 743                    Boolean enableHttpsConnection = String::equal(
 744                        configManager->getCurrentValue("enableHttpsConnection"), "true");
 745                
 746                    String IPAddress = _getHostAddress(System::getHostName());
 747                    Array<CIMInstance> instances;
 748                
 749                    if (enableHttpConnection)
 750                    {
 751                        CDEBUG("building pgcimxmlinstances 1");
 752                        CIMInstance instance = _buildInstancePGCIMXMLCommunicationMechanism(
 753                                            "http", IPAddress,
 754                                            includeQualifiers,
 755                                            includeClassOrigin,
 756                                            propertyList);
 757                        instances.append(instance);
 758                    }
 759                
 760 tony  1.6          if (enableHttpsConnection)
 761                    {
 762                        CDEBUG("building pgcimxmlinstances 2");
 763                        CIMInstance instance = _buildInstancePGCIMXMLCommunicationMechanism(
 764                                                                "https", IPAddress,
 765                                                                includeQualifiers,
 766                                                                includeClassOrigin,
 767                                                                propertyList);
 768                        instances.append(instance);
 769                    }
 770 karl  1.10         PEG_METHOD_EXIT();
 771 tony  1.6          return(instances);
 772                }
 773                /*  Gets the value for the CIMObjectManager name.  This is a key
 774                    property with the following characteristics.
 775                    1. It is persistent. This must be persistent through CIMOM
 776                    restarts.  We will save it in the instance database to achieve this. 
 777                    2. It must be unique. We cannot create duplicate CIMOM names
 778                    3. It is based on the DMTF description of how unique InstanceIds
 779                    are defined (Trademark/etc followed by unique identification.
 780                    Use the Global constant PegasusInstanceIDGlobalPrefix as the
 781                    prefix allowing this to be changed.
 782                */
 783                String buildObjectManagerName()
 784                {
 785                    return(getTrademarkCIMOMIDPrefix() + ":" + getUUIDString());
 786 karl  1.1      }
 787                
 788 karl  1.10     /** get either the local or disk CIMObjectmanager instance.
 789                    @return Boolean true if already exists. False if 
 790                    not initialized. Also returns with the current version set
 791                    into local parameter.
 792                    ATTN: Probably should get rid of the local parameter since
 793                    this is used so infrequently, waste of space.
 794                */
 795                Boolean InteropProvider::_getInstanceCIMObjectManager(
 796                                        const Boolean includeQualifiers,
 797                                        const Boolean includeClassOrigin,
 798                                        const CIMPropertyList& propertyList)
 799                {
 800                
 801                    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 802                            "InteropProvider::_getInstanceCIMObjectManager");
 803                    // If there is already an instance of this class local use it.
 804                    if (!instanceOfCIMObjectManager.isUninitialized())
 805                    {
 806                        PEG_METHOD_EXIT();
 807                        return(true);
 808                    }
 809 karl  1.10         // Try to get persistent instance from repository
 810                    Array<CIMInstance> instances;
 811                    try
 812                    {
 813                        instances = _repository->enumerateInstances(_operationNamespace,
 814                                      CIM_OBJECTMANAGER_CLASSNAME, true, false, includeQualifiers,
 815                                        includeClassOrigin, propertyList);
 816                    
 817                        CDEBUG("_buildInstanceCIMOBJMGR Found Instance in repository " << instances.size() );
 818                    
 819                        if (instances.size() >= 1)
 820                        {
 821                            // set this instance into global variable.
 822                            instanceOfCIMObjectManager = instances[0];
 823                    
 824                            // log entry if there is more than one instance.
 825                            // Some day we may support multiple entries to see other CIMOMs but
 826                            // for now this should be illegal and represent an internal error.
 827                            // but we will still continue to use the first entry.
 828                            if (instances.size() > 1)
 829                            {
 830 karl  1.10                     Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
 831                                    "Error. Multiple definitons of : $0", CIM_OBJECTMANAGER_CLASSNAME.getString());
 832                            }
 833                            return(true);
 834                        }
 835                        else
 836                            return(false);
 837                    }
 838                    catch(CIMException& e)
 839                    {
 840                        Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
 841                            "Error. Cannot access $0 in repository", CIM_OBJECTMANAGER_CLASSNAME.getString());
 842                        PEG_METHOD_EXIT();
 843                        throw e;
 844                    }
 845                    catch(Exception& e)
 846                    {
 847                        Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION,
 848                            "Error. Cannot access $0 in repository", CIM_OBJECTMANAGER_CLASSNAME.getString());
 849                        PEG_METHOD_EXIT();
 850                        throw e;
 851 karl  1.10         }
 852                }
 853                
 854                
 855 tony  1.6      /** build an instance of the CIM_ObjectManager class filling out
 856                    the required properties
 857                    @param includeQualifiers Boolean
 858                    @param includeClassOrigin Boolean
 859                    @param propertylist CIMPropertyList 
 860                    @return CIMInstance with a single built instance of the class
 861                    @exception repository instances if exception to enumerateInstances
 862                        for this class.
 863                */
 864                CIMInstance InteropProvider::_buildInstanceCIMObjectManager(
 865                                        const Boolean includeQualifiers,
 866                                        const Boolean includeClassOrigin,
 867                                        const CIMPropertyList& propertyList)
 868 karl  1.1      {
 869                    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 870 karl  1.10                 "InteropProvider::_buildInstanceCIMObjectManager");
 871 karl  1.1      
 872 karl  1.10         // Try to get the current object.  If true then it is already created.
 873                    if (_getInstanceCIMObjectManager(includeQualifiers,includeClassOrigin,propertyList))
 874 karl  1.5          {
 875                        PEG_METHOD_EXIT();
 876                        return(instanceOfCIMObjectManager);
 877                    }
 878                    //
 879 karl  1.8          // No instance in the repository. Build new instance and save it.
 880 karl  1.5          //
 881 tony  1.6          CIMInstance instance = _buildInstanceSkeleton(CIM_OBJECTMANAGER_CLASSNAME);
 882                
 883                    _fixInstanceCommonKeys(instance);
 884 karl  1.1      
 885 tony  1.6          _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,CIM_OBJECTMANAGER_CLASSNAME.getString());
 886 karl  1.1      
 887 tony  1.6          _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME,buildObjectManagerName());
 888                
 889                    _setPropertyValue(instance, CIMName("ElementName"), String("Pegasus"));
 890                
 891 karl  1.8          //
 892 tony  1.6          //Description property this object manager instance
 893 karl  1.10         // default is Pegasus CIM_Server Version.
 894                    // Provided undocumented option to get this from the environment.
 895                    // This should probably be removed or documented.
 896 karl  1.8          //
 897 tony  1.6          String description;
 898                    char * envDescription;
 899                    envDescription = getenv("PEGASUS_CIMOM_DESCRIPTION");
 900                
 901 karl  1.10         description = (envDescription) ?
 902                        envDescription :
 903                        "Pegasus " + String(PEGASUS_NAME) + "Version " + String(PEGASUS_VERSION);
 904 tony  1.6      
 905                    _setPropertyValue(instance, CIMName("Description"), description);
 906 karl  1.1      
 907 karl  1.8          //Property GatherStatisticalData. Initially this is set to false
 908                    // and can then be modified by a modify instance on the instance.
 909                    
 910 karl  1.10         Boolean gatherStatDataFlag = false;
 911                
 912                    _setPropertyValue(instance, OM_GATHERSTATISTICALDATA, Boolean(gatherStatDataFlag));
 913                
 914                    // ATTN: This one is a problem KS rethink this.
 915                    // the following is a temporary hack to set the value of the statistics
 916                    // gathering function dynamically.  We simply get the correct value
 917                    // and call the internal method to set it each time this object is
 918                    // built.
 919                #ifdef PEGASUS_HAS_PERFINST
 920                    StatisticalData* sd = StatisticalData::current();
 921                    sd->setCopyGSD(gatherStatDataFlag);
 922                #endif
 923 tony  1.6      
 924 karl  1.5          // write the instance to the repository
 925 karl  1.10         CIMObjectPath instancePath;
 926                    // Add the instance path to this if necessary ATTN ATTN:
 927 karl  1.5          try
 928                    {
 929 karl  1.10             instancePath = _repository->createInstance(_operationNamespace,
 930                                       instance );
 931 karl  1.5          }
 932                    catch(CIMException& e)
 933                    {
 934 tony  1.6              // ATTN: KS generate log error if this not possible
 935 karl  1.5              PEG_METHOD_EXIT();
 936                        throw e;
 937                    }
 938                    catch(Exception& e)
 939                    {
 940 karl  1.10             // ATTN: Generate log error.
 941                        PEG_METHOD_EXIT();
 942 karl  1.5              throw e;
 943                    }
 944 karl  1.10         instance.setPath(instancePath);
 945                    CDEBUG("CIMObjectMgr path = " << instancePath.toString());
 946                    // Save this instance for other requests
 947                    instanceOfCIMObjectManager = instance;
 948 karl  1.5          PEG_METHOD_EXIT();
 949                    return(instanceOfCIMObjectManager);
 950 karl  1.1      }
 951                
 952 karl  1.8      /** Get the instances of CIM_Namespace. Gets all instances of the namespace from
 953                    the repository namespace management functions
 954                    Pegasus 2.4 - This now gets CIM_Namespace and its subclass PG_Namespace
 955 tony  1.6      */
 956                Array<CIMInstance> InteropProvider::_getInstancesCIMNamespace(const Boolean& includeQualifiers,
 957                                            const Boolean& includeClassOrigin,
 958                                            const CIMPropertyList& propertyList)
 959                {
 960                    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 961                            "InteropProvider::_getInstancesCIMNamespace()");
 962 karl  1.8      
 963                    CDEBUG("_getinstancesPGNamespace");
 964 tony  1.6          Array<CIMNamespaceName> namespaceNames = _enumerateNameSpaces();
 965 karl  1.10         CDEBUG("_getInstancesCIMNamespace. count = " << namespaceNames.size());
 966 tony  1.6          Array<CIMInstance> instanceArray;
 967                
 968 karl  1.8          // We build instances of PG namespace since that is the leaf class
 969 tony  1.6          for (Uint32 i = 0; i < namespaceNames.size(); i++)
 970                    {
 971 karl  1.8             instanceArray.append( _buildInstancePGNamespace(namespaceNames[i]));
 972 tony  1.6          }
 973 karl  1.10         CDEBUG("Build this many PG_Namespace Instances. count= " << instanceArray.size());
 974 tony  1.6          PEG_METHOD_EXIT();
 975                    return(instanceArray);
 976                }
 977                
 978                /** get the instance of namespace defined by the input parameter which is the object path
 979                    for the instance required.
 980                    ATTN: Note that this is incorrect. We are supplying the namespace name and need to supply
 981                    the objectpath
 982                    @param TBD
 983                    @return CIMInstance with the found instance or CIMInstance() if nothing found.
 984                */
 985                CIMInstance InteropProvider::_getInstanceCIMNamespace(const CIMNamespaceName & nameSpace)
 986                {
 987                    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
 988                            "InteropProvider::_getInstancesCIMNamespace()");
 989                
 990                    CDEBUG("_getinstanceCIMNamespace Gets ONE only from Namespace=" << nameSpace.getString());
 991                    Array<CIMInstance> instances = _getInstancesCIMNamespace(true, true, CIMPropertyList());
 992                
 993 karl  1.8          // search the instances for one with the name property value = input parameter.
 994 tony  1.6          for (Uint32 i = 0 ; i < instances.size() ; i++)
 995                    {
 996 karl  1.8              if (_getPropertyValue(instances[i], CIMName("name"), String::EMPTY) == nameSpace.getString())
 997 tony  1.6              {
 998                            PEG_METHOD_EXIT();
 999                            return(instances[i]);
1000                        }
1001                    }
1002                    PEG_METHOD_EXIT();
1003                    CIMInstance nullInstance;
1004                    return(nullInstance);
1005                }
1006                
1007                CIMObjectPath InteropProvider::_buildReference(const CIMInstance& instance, const CIMName& className)
1008                {
1009                    return(_buildObjectPath(_operationNamespace,className, instance));
1010                }
1011                
1012                Array<CIMInstance> InteropProvider::_buildInstancesNamespaceInManager()
1013                {
1014 karl  1.10         PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1015                            "InteropProvider::_buildInstancesNamespaceInManager");
1016 tony  1.6      
1017                    Array<CIMInstance> namespaceInstances = _getInstancesCIMNamespace(false,
1018                                            false, CIMPropertyList());
1019                
1020                    CIMInstance instanceObjMgr = _buildInstanceCIMObjectManager( true, true, CIMPropertyList());
1021                
1022                    CIMObjectPath refObjMgr = _buildReference(instanceObjMgr, CIM_OBJECTMANAGER_CLASSNAME);
1023                
1024                    Array<CIMInstance> assocInstances;
1025                
1026                    for (Uint32 i = 0 ; i < namespaceInstances.size() ; i++)
1027                    {
1028                        CIMInstance instance = _buildInstanceSkeleton(CIM_NAMESPACEINMANAGER_CLASSNAME);
1029                
1030                        _setPropertyValue(instance, CIMName("Antecdent"), refObjMgr);
1031                        //ATTNATTN: this is weak qualifier.
1032                        _setPropertyValue(instance, CIMName("Dependent"), _buildReference(namespaceInstances[i],
1033                                                                            CIM_NAMESPACEINMANAGER_CLASSNAME));
1034                        assocInstances.append(instance);
1035                    }
1036 karl  1.10     
1037                    PEG_METHOD_EXIT();
1038 tony  1.6          return(assocInstances);
1039                }
1040                
1041                Array<CIMInstance> InteropProvider::_buildInstancesCommMechanismForManager()
1042                {
1043 karl  1.10         PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1044                            "InteropProvider::_buildInstancesCommMechanismForManager");
1045 tony  1.6      
1046                    Array<CIMInstance> commInstances = _buildInstancesPGCIMXMLCommunicationMechanism(true,
1047                         true, CIMPropertyList());
1048                
1049                    CIMInstance instanceObjMgr = _buildInstanceCIMObjectManager( true, true, CIMPropertyList());
1050                
1051                    CIMObjectPath refObjMgr = _buildReference(instanceObjMgr, CIM_OBJECTMANAGER_CLASSNAME);
1052                    Array<CIMInstance> assocInstances;
1053                
1054                    for (Uint32 i = 0 ; i < commInstances.size() ; i++)
1055                    {
1056                        
1057                        CIMInstance instance = _buildInstanceSkeleton(CIM_COMMMECHANISMFORMANAGER_CLASSNAME);
1058                
1059                        _setPropertyValue(instance,CIMName("Antecdent"), refObjMgr);
1060                        //ATTNATTN: this is weak qualifier.
1061                        _setPropertyValue(instance,CIMName("Dependent"), _buildReference(commInstances[i],CIM_COMMMECHANISMFORMANAGER_CLASSNAME));
1062                        assocInstances.append(instance);
1063                    }
1064 karl  1.10     
1065                    PEG_METHOD_EXIT();
1066 tony  1.6          return(assocInstances);
1067                }
1068                
1069 karl  1.1      /* generate one instance of the CIM_Namespace class with the
1070                   properties
1071 karl  1.8         NOTE: CIM 2.4 - Changed to build PG namespace
1072 karl  1.1         @param namespace name to put into the class
1073                   @exceptions - exceptions carried forward from create instance
1074                   and addProperty.
1075                */
1076 karl  1.8      CIMInstance InteropProvider::_buildInstancePGNamespace(const CIMNamespaceName & nameSpace)
1077 karl  1.1      {
1078                    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1079 karl  1.10                 "InteropProvider::_buildInstancePGNamespace");
1080 tony  1.6          
1081                    // ATTN: KS need to get the real objectManager name from elsewhere.  the only place
1082                    // this exists is through the objectmanager object.  
1083                    // ATTN: Should we be saving the objectmanager name somewhere internally either in
1084                    // interop or more generally somewhere within the system for common access.
1085 karl  1.1          String ObjectManagerName = "ObjectManagerNameValue";
1086                    
1087 karl  1.8          CIMInstance instance = _buildInstanceSkeleton(PG_NAMESPACE_CLASSNAME);
1088 karl  1.1      
1089 tony  1.6          _fixInstanceCommonKeys(instance);
1090 karl  1.1      
1091                    //ObjectManagerCreationClassName
1092 tony  1.6          _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME, CIM_OBJECTMANAGER_CLASSNAME.getString());
1093                
1094 karl  1.1          //ObjectManagerName
1095 tony  1.6          _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME, ObjectManagerName);
1096                
1097 karl  1.1          //CreationClassName
1098 tony  1.6          // Class in which this was created, 
1099                    _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME, CIM_NAMESPACE_CLASSNAME.getString());
1100 karl  1.1          //Name
1101 tony  1.6          // This is the namespace name itself
1102                    _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_NAME, nameSpace.getString());
1103 karl  1.1      
1104                    //ClassInfo
1105 tony  1.6          // Set the classinfo to unknown and the description to namespace.
1106                    _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_CLASSINFO, Uint16(0));
1107                    _setPropertyValue(instance, CIM_NAMESPACE_PROPERTY_DESCRIPTIONOFCLASSINFO, String("namespace"));
1108                
1109 karl  1.8          //
1110                    //  Everything above was commmon to CIM Namespace.  The following is PG_Namespace Properties
1111                    //
1112                    // ATTN: KS Get the correct values for these entities from repository interface.
1113 karl  1.10         CDEBUG("_buildPGNS Instance get namespace attributes for namespace= " << nameSpace.getString()); 
1114 karl  1.8      	CIMRepository::NameSpaceAttributes attributes;
1115                    _repository->getNameSpaceAttributes(nameSpace.getString(), attributes);
1116                    String parent="";
1117 karl  1.11     	String name = "";
1118 karl  1.8          Boolean shareable=false;
1119                    Boolean updatesAllowed=true;
1120                    for (CIMRepository::NameSpaceAttributes::Iterator i = attributes.start(); i; i++) 
1121                    {
1122                       String key=i.key();
1123 karl  1.10            String value = i.value();
1124                       CDEBUG("Show Attributes. key= " << key << " value= " << value);
1125 karl  1.8             if (String::equalNoCase(key,"shareable"))
1126 karl  1.11     	   {
1127 karl  1.10               if (String::equalNoCase(value,"true"))
1128                              shareable=true;
1129 karl  1.11     	   }
1130 karl  1.8             else if (String::equalNoCase(key,"updatesAllowed")) 
1131 karl  1.11     	   {
1132 karl  1.10               if (String::equalNoCase(value,"false"))
1133                              updatesAllowed=false;
1134 karl  1.11     	   }
1135 karl  1.10            // Test to be sure we are returning proper namespace name
1136                       else if (String::equalNoCase(key,"name"))
1137 karl  1.8             {
1138 karl  1.10               if (!String::equalNoCase(value, nameSpace.getString()))
1139                          {
1140                              PEG_METHOD_EXIT();
1141                              // This is poor exception since it reflects internal error. Do error log
1142                              throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, 
1143                                  "Namespace attribute rtnd error for key " + key + "expected " +
1144                                   nameSpace.getString()+ value + " in " + String(thisProvider));
1145                          }
1146 karl  1.11     
1147                		  name = value;
1148 karl  1.8             }
1149                       else if (String::equalNoCase(key,"parent"))
1150 karl  1.11     	   {
1151 karl  1.10               parent=value;
1152 karl  1.11     	   }
1153 karl  1.8             else 
1154                       {
1155                          PEG_METHOD_EXIT();
1156 karl  1.10               // Poor error definition since it reflects internal error. do error log
1157 karl  1.8                throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, nameSpace.getString()+
1158 karl  1.10                   " namespace attribute " + key + " option not supported in"+ String(thisProvider));
1159 karl  1.8             }
1160                    }
1161                    _setPropertyValue(instance, PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED, updatesAllowed);
1162                    _setPropertyValue(instance, PG_NAMESPACE_PROPERTY_ISSHAREABLE, shareable);
1163                    _setPropertyValue(instance, PG_NAMESPACE_PROPERTY_PARENTNAMESPACE, parent);
1164 karl  1.11     	_setPropertyValue(instance, PG_NAMESPACE_PROPERTY_NAME, name);
1165 karl  1.8      
1166 karl  1.1          PEG_METHOD_EXIT();
1167                    return(instance);
1168                }
1169 karl  1.5      void _validateCIMNamespaceKeys(const CIMObjectPath& objectPath)
1170                {
1171 tony  1.6          PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1172                            "InteropProvider::_validateCIMNamespaceKeys");
1173                
1174 karl  1.5          Boolean valid = true;
1175                    CIMName propertyName;
1176                    if (!_validateRequiredProperty(objectPath,
1177                                CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,
1178                                System::getSystemCreationClassName ()))
1179                    {
1180                        propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME;
1181                        valid = false;
1182                    }
1183                    if (!_validateRequiredProperty(objectPath,
1184                                CIM_NAMESPACE_PROPERTY_SYSTEMNAME,
1185                                System::getHostName()))
1186                    {
1187                        propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME;
1188                        valid = false;
1189                    }
1190                    if (!_validateRequiredProperty(objectPath,
1191                                CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME,
1192                                CIM_OBJECTMANAGER_CLASSNAME.getString()))
1193                    {
1194                        propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME;
1195 karl  1.5              valid = false;
1196                    }
1197                
1198                    // ATTN: This one still a problem.  We have to get the name first
1199                    if (!_validateRequiredProperty(objectPath,
1200                                CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME,
1201                                String::EMPTY))
1202                    {
1203                        propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME;
1204                        valid = false;
1205                    }
1206                    if (!_validateRequiredProperty(objectPath,
1207                                CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,
1208                                System::getHostName()))
1209                    {
1210                        propertyName = CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME;
1211                        valid = false;
1212                    }
1213                
1214                    if (!_validateRequiredProperty(objectPath,
1215                                CIM_NAMESPACE_PROPERTY_NAME,
1216 karl  1.5                      String::EMPTY))
1217                    {
1218                        propertyName = CIM_NAMESPACE_PROPERTY_NAME;
1219                        valid = false;
1220                    }
1221                
1222                    if (false)
1223                    {
1224 tony  1.6              PEG_METHOD_EXIT();
1225 karl  1.5              throw CIMInvalidParameterException(
1226                            "Invalid key property: " + propertyName.getString());
1227                    }
1228 tony  1.6          PEG_METHOD_EXIT();
1229                }
1230 karl  1.5      
1231 karl  1.11     /** completes a property in the defined instance either
1232                    by adding the complete property if it does not exist
1233                    or by adding the value if the property does exist.
1234                    Used to make sure that key properties for things
1235                    like systemcreationclass are included in the 
1236                    creation of new instances and that the
1237                    values are logical for the CIMOM.
1238                */
1239                Boolean _completeProperty(CIMInstance& instance,
1240                    const CIMName& propertyName,
1241                    const String& value)
1242                {
1243                
1244                    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1245                            "InteropProvider::_completeProperty()");
1246                
1247                    Uint32 pos;
1248                
1249                    if (!_validateRequiredProperty(instance,
1250                                propertyName,
1251                                value))
1252 karl  1.11         {
1253                        if ((pos = instance.findProperty (propertyName)) == PEG_NOT_FOUND)
1254                        {
1255                            // Add the property.  Should be from the class.
1256                            PEG_METHOD_EXIT();
1257                            return(false);
1258                        }
1259                        else
1260                        {
1261                            //
1262                            _setPropertyValue(instance, propertyName, value);
1263                        }
1264                    }
1265                
1266                    PEG_METHOD_EXIT();
1267                    return(true);
1268                }
1269                Boolean _completeCIMNamespaceKeys(CIMInstance& instance)
1270                {
1271                
1272                    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1273 karl  1.11                 "InteropProvider::_completeCIMNamespaceKeys");
1274                
1275                    Boolean valid = true;
1276                    CIMName propertyName;
1277                
1278                    if (!_completeProperty(instance,
1279                                CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,
1280                                System::getSystemCreationClassName ()))
1281                    {
1282                
1283                        propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME;
1284                        valid = false;
1285                    }
1286                
1287                    if (!_completeProperty(instance,
1288                                CIM_NAMESPACE_PROPERTY_SYSTEMNAME,
1289                                System::getHostName()))
1290                    {
1291                        propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME;
1292                        valid = false;
1293                    }
1294 karl  1.11     
1295                    if (!_completeProperty(instance,
1296                                CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME,
1297                                CIM_OBJECTMANAGER_CLASSNAME.getString()))
1298                    {
1299                        propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME;
1300                        valid = false;
1301                    }
1302                
1303                    if (!_completeProperty(instance,
1304                                CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME,
1305                                String::EMPTY))
1306                    {
1307                        propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME;
1308                        valid = false;
1309                    }
1310                    if (!_completeProperty(instance,
1311                                CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,
1312                                System::getHostName()))
1313                    {
1314                        propertyName = CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME;
1315 karl  1.11             valid = false;
1316                    }
1317                
1318                    if (!_completeProperty(instance,
1319                                CIM_NAMESPACE_PROPERTY_NAME,
1320                                String::EMPTY))
1321                    {
1322                        propertyName = CIM_NAMESPACE_PROPERTY_NAME;
1323                        valid = false;
1324                    }
1325                
1326                    if (!valid)
1327                    {
1328                        PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1329                            "Invalid CIM_Namespace Key Property " +  propertyName.getString());
1330                        PEG_METHOD_EXIT();
1331                        throw CIMInvalidParameterException(
1332                            "Invalid CIM_Namespace key property: " + propertyName.getString());
1333                    }
1334                    PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "CIM_Namespace Keys Valid");
1335                    PEG_METHOD_EXIT();
1336 karl  1.11         return(valid);
1337                }
1338                
1339                
1340 karl  1.5      void _validateCIMNamespaceKeys(const CIMInstance& instance)
1341                {
1342 tony  1.6          PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1343                            "InteropProvider::_validateCIMNamespaceKeys");
1344 karl  1.5          Boolean valid = true;
1345                    CIMName propertyName;
1346                    if (!_validateRequiredProperty(instance,
1347                                CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME,
1348                                System::getSystemCreationClassName ()))
1349                    {
1350                        propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMCREATIONCLASSNAME;
1351                        valid = false;
1352                    }
1353                
1354                    if (!_validateRequiredProperty(instance,
1355                                CIM_NAMESPACE_PROPERTY_SYSTEMNAME,
1356                                System::getHostName()))
1357                    {
1358                        propertyName = CIM_NAMESPACE_PROPERTY_SYSTEMNAME;
1359                        valid = false;
1360                    }
1361                
1362                    if (!_validateRequiredProperty(instance,
1363                                CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME,
1364                                CIM_OBJECTMANAGER_CLASSNAME.getString()))
1365 karl  1.5          {
1366                        propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERCREATIONCLASSNAME;
1367                        valid = false;
1368                    }
1369                
1370                    // ATTN: This one still a problem.  We have to get the name first
1371                    if (!_validateRequiredProperty(instance,
1372                                CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME,
1373                                String::EMPTY))
1374                    {
1375                        propertyName = CIM_NAMESPACE_PROPERTY_OBJECTMANAGERNAME;
1376                        valid = false;
1377                    }
1378                    if (!_validateRequiredProperty(instance,
1379                                CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME,
1380                                System::getHostName()))
1381                    {
1382                        propertyName = CIM_NAMESPACE_PROPERTY_CREATIONCLASSNAME;
1383                        valid = false;
1384                    }
1385                
1386 karl  1.5          if (!_validateRequiredProperty(instance,
1387                                CIM_NAMESPACE_PROPERTY_NAME,
1388                                String::EMPTY))
1389                    {
1390                        propertyName = CIM_NAMESPACE_PROPERTY_NAME;
1391                        valid = false;
1392                    }
1393                
1394                    if (false)
1395                    {
1396 tony  1.6              PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1397                            "Invalid CIM_Namespace Key Property " +  propertyName.getString());
1398                        PEG_METHOD_EXIT();
1399 karl  1.5              throw CIMInvalidParameterException(
1400 tony  1.6                  "Invalid CIM_Namespace key property: " + propertyName.getString());
1401 karl  1.5          }
1402 tony  1.6          PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "CIM_Namespace Keys Valid");
1403                    PEG_METHOD_EXIT();
1404                }
1405                
1406                /** builds complete object path from instance and classinfo by building the full path
1407                    with host and namespace names included.
1408                */
1409                CIMObjectPath InteropProvider::_buildObjectPath(const CIMNamespaceName& name,
1410                                                                const CIMName& className,
1411                                                                const CIMInstance& instance)
1412                {
1413 karl  1.10         PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1414                            "InteropProvider::_buildObjectPath");
1415                
1416 tony  1.6          CIMObjectPath objectPath;
1417                    objectPath = _buildInstancePath(name,className,instance);
1418                
1419                    objectPath.setHost(System::getHostName());
1420                
1421                    objectPath.setNameSpace(name);
1422 karl  1.10     
1423                    PEG_METHOD_EXIT();
1424 tony  1.6          return(objectPath);
1425 karl  1.5      }
1426                
1427 tony  1.6      /* Given a class and instance build the instance path for a
1428 karl  1.1         the object.  This builds all components of the path
1429                   @param namespace name to build
1430                   @return CIMObjectPath containing namespace, class and keybinding 
1431                   components of path
1432 tony  1.6         @exceptions - Passes repository exceptions.
1433 karl  1.1      */
1434                
1435                CIMObjectPath InteropProvider::_buildInstancePath(const CIMNamespaceName& name,
1436 tony  1.6                                                 const CIMName& className, 
1437 karl  1.1                                                 const CIMInstance& instance)
1438                {
1439                    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1440 tony  1.6                  "InteropProvider::_buildInstancePath");
1441 karl  1.1      
1442                    // get the class CIM_Namespace class to use in building path
1443 tony  1.6          // Exception out if Class does not exist in this namespace
1444                    CIMClass thisClass = _getClass(name, className);
1445 karl  1.1      
1446                    CIMObjectPath ref = instance.buildPath(thisClass);
1447                    
1448                    PEG_METHOD_EXIT();
1449                    return(ref);
1450                }
1451                
1452                /* _isNamespace determines if the namespace in the second
1453                   parameter is in the array in the first parameter.
1454                    @param array of possible namespaces
1455                    @param canidate namespace
1456                    @return - true if found
1457                */
1458                Boolean _isNamespace(
1459 tony  1.6                  Array<CIMNamespaceName>& namespaceNames,
1460                	        CIMNamespaceName& namespaceName)
1461 karl  1.1      {
1462 karl  1.10         PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1463                            "InteropProvider::_isNamespace");
1464                
1465 karl  1.1           Boolean found = false;
1466                     for(Uint32 i = 0; i < namespaceNames.size(); i++)
1467                     {
1468 tony  1.6              if(namespaceNames[i].equal ( namespaceName ))
1469 karl  1.1                  return true;
1470                     }
1471 karl  1.10     
1472                     PEG_METHOD_EXIT();
1473 karl  1.1           return false;
1474                }
1475                
1476                //**************************************************************
1477                // Overloaded functions to get key value with different params
1478                //**************************************************************
1479                
1480 tony  1.6      /*  find the name key in the keybindings and return the value.
1481 karl  1.1          Executes exception if the key not found
1482                    @param object path we will search
1483                    @param keyName - Name of the key to find.
1484                    @return value of name property
1485                    @exceptions CIMInvalidParameterException
1486                */
1487                String _getKeyValue(const CIMObjectPath& instanceName, const CIMName& keyName)
1488                {
1489                    Array<CIMKeyBinding> kbArray = instanceName.getKeyBindings();
1490                
1491                    // find the correct key binding
1492                    for (Uint32 i = 0; i < kbArray.size(); i++)
1493                    {
1494                        if (kbArray[i].getName() == keyName)
1495                            return (kbArray[i].getValue());
1496                    }
1497 tony  1.6      
1498 karl  1.1          throw CIMInvalidParameterException("Invalid key property: " + keyName.getString());
1499                }
1500                
1501                String _getKeyValue(const CIMInstance& instance, const CIMName& keyName)
1502                {
1503                    Uint32 pos;
1504                    CIMValue propertyValue;
1505                
1506                    pos = instance.findProperty(keyName);
1507                    if (pos == PEG_NOT_FOUND)
1508                       throw CIMPropertyNotFoundException
1509                           (NAMESPACE_PROPERTYNAME.getString());
1510                    
1511                    propertyValue = instance.getProperty(pos).getValue();
1512                    if (propertyValue.getType() != CIMTYPE_STRING)
1513                       throw CIMInvalidParameterException("Invalid type for property: "
1514                                             + NAMESPACE_PROPERTYNAME.getString());
1515                    String name;
1516                    propertyValue.get(name);
1517                    return(name);
1518                    //ATTN: KS Returns String whereas below returns CIMNamespaceName.
1519 karl  1.1      }
1520                
1521                //***************************************************************************
1522                //  The following section is the Instance Operation processors
1523                //***************************************************************************
1524                //                createInstance
1525                //***************************************************************************
1526                void InteropProvider::createInstance(
1527                	const OperationContext & context,
1528                	const CIMObjectPath & instanceReference,
1529                    const CIMInstance& myInstance,
1530                	ObjectPathResponseHandler & handler)
1531                    {
1532                        PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::createInstance()");
1533                        
1534 karl  1.11             handler.processing();
1535 karl  1.1              CIMNamespaceName newNamespaceName;
1536                        CDEBUG("CreateInstance " << instanceReference.toString());
1537                        // operation namespace needed internally to get class.
1538                        _operationNamespace = instanceReference.getNameSpace();
1539                        
1540                        // Verify that ClassName is correct and get value
1541 karl  1.11             targetClass classEnum  = _verifyValidClassInput(instanceReference.getClassName());
1542                
1543 karl  1.1              String userName = _validateUserID(context);
1544                        CIMObjectPath newInstanceReference;
1545 karl  1.11     
1546 karl  1.5              if ((classEnum == CIM_OBJECTMANAGER) || 
1547 tony  1.6                  (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM))
1548 karl  1.5                  throw CIMNotSupportedException("InteropProvider, Create Not allowed");
1549 karl  1.1      
1550 karl  1.8              if (classEnum == PG_NAMESPACE)
1551 karl  1.1              {
1552 karl  1.11                 // Create local instance to complete any keys.
1553                            CIMInstance localInstance = myInstance.clone();
1554                
1555                            _completeCIMNamespaceKeys(localInstance);
1556 tony  1.6                  // Validate that keys are as required. Does its own exception.
1557 karl  1.11                 newNamespaceName = _getKeyValue(myInstance, CIM_NAMESPACE_PROPERTY_NAME);
1558                
1559                            newInstanceReference = _buildInstancePath(_operationNamespace,
1560                                                        PG_NAMESPACE_CLASSNAME, localInstance);
1561 karl  1.1              }
1562 tony  1.6      
1563 karl  1.11             else   // Invalid class for the create functions.
1564 karl  1.1              {
1565 karl  1.10                 PEGASUS_ASSERT(false);
1566 karl  1.1              }
1567 karl  1.10     
1568 karl  1.1              // Create the new namespace
1569                        try
1570                        {
1571 tony  1.6                  PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1572                                "Namespace = " + newNamespaceName.getString() + 
1573                                    " to be created.");
1574 karl  1.10                 Boolean updatesAllowed = false;
1575                            Boolean shareable = false;
1576                            String parent = String::EMPTY;
1577 karl  1.11     
1578 karl  1.8                  CIMRepository::NameSpaceAttributes attributes;
1579 karl  1.10                 // optional property.  Set false if not found.
1580                            // ATTN: Should set to class default.
1581 karl  1.8                  if (myInstance.findProperty(PG_NAMESPACE_PROPERTY_ISSHAREABLE) != PEG_NOT_FOUND)
1582                            {
1583                                if (_getPropertyValue(myInstance, PG_NAMESPACE_PROPERTY_ISSHAREABLE, false))
1584 karl  1.10                     {
1585 karl  1.8                          attributes.insert("shareable","true");
1586 karl  1.10                         shareable = true;
1587                                }
1588 karl  1.8                      else
1589 karl  1.10                         attributes.insert("shareable", "false");
1590 karl  1.8                  }
1591                            else
1592 karl  1.10                     attributes.insert("shareable", "false");
1593 karl  1.8      
1594 karl  1.10                 // Optional property.  Set false if not found.
1595 karl  1.8                  if (myInstance.findProperty(PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED) != PEG_NOT_FOUND)
1596                            {
1597                                if (_getPropertyValue(myInstance, PG_NAMESPACE_PROPERTY_SCHEMAUPDATESALLOWED, false))
1598 karl  1.10                     {
1599 karl  1.8                          attributes.insert("updatesAllowed","true");
1600 karl  1.10                         updatesAllowed = true;
1601                                }
1602 karl  1.8                      else
1603                                    attributes.insert("updatesAllowed", "false");
1604                            }
1605                            else
1606                                attributes.insert("updatesAllowed", "false");
1607                
1608 karl  1.10                 // ATTN: Need to reflect and dependencies between these properties. Right now
1609                            // this lets anything happen.
1610 karl  1.8                  if (myInstance.findProperty(PG_NAMESPACE_PROPERTY_PARENTNAMESPACE) != PEG_NOT_FOUND)
1611                            {
1612                                String parent = _getPropertyValue(myInstance, PG_NAMESPACE_PROPERTY_PARENTNAMESPACE, String::EMPTY);
1613                                if (parent != String::EMPTY)
1614 karl  1.10                         attributes.insert("parent",parent);
1615 karl  1.8                  }
1616                            _repository->createNameSpace(newNamespaceName, attributes);
1617 karl  1.1              
1618                            PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1619                                "Namespace = " + newNamespaceName.getString() + 
1620                                    " successfully created.");
1621 karl  1.10                 Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1622                                "Create Namespace: Shareable = $0, Updates allows: $1,  Parent: $2",
1623                                newNamespaceName.getString(), shareable? "true" : "false", shareable? "true" : "false", parent );
1624 karl  1.11     
1625 karl  1.1              }
1626                        catch(CIMException& e)
1627                        {
1628                           PEG_METHOD_EXIT();
1629                           throw e;
1630                        }
1631                        catch(Exception& e)
1632                        {
1633                           PEG_METHOD_EXIT();
1634                           throw e;
1635                        }
1636                        
1637                        // begin processing the request
1638                
1639                       handler.deliver(newInstanceReference);
1640                
1641                       // complete processing the request
1642                       handler.complete();
1643                
1644                       PEG_METHOD_EXIT();
1645                       return;
1646 karl  1.1         }
1647                
1648                //***************************************************************************
1649                //                deleteInstance
1650                //***************************************************************************
1651                void InteropProvider::deleteInstance(
1652                	const OperationContext & context,
1653                	const CIMObjectPath & instanceName,
1654                	ResponseHandler & handler)
1655                    {
1656                        PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::deleteInstance");
1657 tony  1.6      
1658 karl  1.1              CIMNamespaceName childNamespaceName;
1659                        CIMNamespaceName deleteNamespaceName;
1660                        
1661 tony  1.6              _operationNamespace = instanceName.getNameSpace();
1662                        handler.processing();
1663 karl  1.1              // Verify that ClassName is correct and get value
1664 karl  1.5              targetClass classEnum  = _verifyValidClassInput(instanceName.getClassName());    
1665 karl  1.1              
1666                        String userName = _validateUserID(context);
1667 tony  1.6              
1668                        
1669                        if ((classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM))
1670                            throw CIMNotSupportedException("Delete Not allowed");
1671                        
1672                        // Delete the instance since it may be in persistent storage
1673                        if ((classEnum == CIM_OBJECTMANAGER))
1674                        {
1675                            CIMInstance instance;
1676                            try
1677                            {
1678                            instance = _repository->getInstance(_operationNamespace, instanceName);
1679                
1680                            // If instance found, then delete it.
1681                            _repository->deleteInstance(_operationNamespace,instanceName);
1682                
1683                            PEG_METHOD_EXIT();
1684                            handler.complete();
1685                            return;
1686                            }
1687                            catch(CIMException& e)
1688 tony  1.6                  {
1689                                PEG_METHOD_EXIT();
1690                                throw e;
1691                            }
1692                        }
1693 karl  1.1      
1694                        Array<CIMNamespaceName> namespaceNames;
1695                        namespaceNames = _enumerateNameSpaces();
1696 karl  1.8              if (classEnum == PG_NAMESPACE)
1697 karl  1.1              {
1698 karl  1.5                  // validate requred keys.  Exception out if not valid
1699                            _validateCIMNamespaceKeys(instanceName);
1700                            
1701 karl  1.1                  deleteNamespaceName = _getKeyValue(instanceName, CIM_NAMESPACE_PROPERTY_NAME);
1702                            CDEBUG("Delete namespace = " << deleteNamespaceName );
1703                        }
1704                
1705                	    // ATTN: KS Why THis??? 
1706                        if (deleteNamespaceName.equal (ROOTNS))
1707                       {
1708                           throw CIMNotSupportedException("root namespace cannot be deleted.");
1709                       }
1710                
1711                	   _repository->deleteNameSpace(deleteNamespaceName);
1712                
1713                	   PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1714                	       "Namespace = " + deleteNamespaceName.getString() + 
1715                               " successfully deleted.");
1716 karl  1.5      
1717                       Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1718                           "Interop Provider Delete Namespace: $0",
1719                           deleteNamespaceName.getString());
1720                
1721 karl  1.1             handler.processing();
1722                
1723                       // complete processing the request
1724                       handler.complete();
1725                
1726                       PEG_METHOD_EXIT();
1727                       return ;
1728                    }
1729                
1730                //***************************************************************************
1731                //                getInstance
1732                //***************************************************************************
1733                void InteropProvider::getInstance(
1734                    const OperationContext & context,
1735                    const CIMObjectPath & instanceName,
1736                    const Boolean includeQualifiers,
1737                    const Boolean includeClassOrigin,
1738 tony  1.6          const CIMPropertyList & propertyList,
1739 karl  1.1          InstanceResponseHandler & handler)
1740                    {
1741                        PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::getInstance");
1742                        
1743                        // Verify that ClassName is correct and get value
1744 karl  1.5              targetClass classEnum  = _verifyValidClassInput(instanceName.getClassName());    
1745 karl  1.1              
1746                        String userName = _validateUserID(context);
1747                        
1748                        // begin processing the request
1749                        handler.processing();
1750                        if (classEnum == CIM_OBJECTMANAGER)
1751                        {
1752 tony  1.6                  CIMInstance instance = _buildInstanceCIMObjectManager(includeQualifiers,
1753                                                        includeClassOrigin, propertyList);
1754 karl  1.1                  handler.deliver(instance);
1755                            handler.complete();
1756                            PEG_METHOD_EXIT();
1757                            return;
1758                        }
1759                        
1760 tony  1.6              if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)
1761 karl  1.1              {
1762 tony  1.6                  // ATTN: test for correct instance KS: Priority 1    
1763                            Array <CIMInstance> instances = _buildInstancesPGCIMXMLCommunicationMechanism(
1764                                                    includeQualifiers,
1765                                                    includeClassOrigin, propertyList);
1766                            handler.deliver(instances[0]);
1767 karl  1.1                  handler.complete();
1768                            PEG_METHOD_EXIT();
1769                            return;
1770                        }
1771                        
1772                        // Get List of namespaces
1773                        Array<CIMNamespaceName> namespaceNames;
1774                        namespaceNames = _enumerateNameSpaces();
1775                        CIMInstance instance;
1776                        
1777 karl  1.8              if (classEnum == PG_NAMESPACE)
1778 karl  1.1              {
1779                            // Not clear what we have to take into account here.
1780                            // get the namespace from the name value.
1781                            // should check the other keys to see if valid.
1782                            CIMNamespaceName namespaceName;
1783                            namespaceName = _getKeyValue(instanceName, CIM_NAMESPACE_PROPERTY_NAME);
1784 tony  1.6      
1785 karl  1.1                  // ATTN: Why this CIMNamespaceName parentNamespaceName = instanceName.getNameSpace();
1786                            if (!_isNamespace(namespaceNames, namespaceName))
1787                            {
1788                                throw CIMObjectNotFoundException("Namespace does not exist: "
1789                                                     + namespaceName.getString());
1790                            }
1791                            PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4,
1792                               "Namespace = " + namespaceName.getString() + " successfully found.");
1793 tony  1.6      
1794                            instance = _getInstanceCIMNamespace(namespaceName);
1795 karl  1.1              }
1796                        else  // processing for __Namespace
1797                        {
1798 karl  1.10                 PEGASUS_ASSERT(false);
1799 karl  1.8              }
1800 karl  1.1      
1801                       handler.deliver(instance);
1802                
1803                       // complete processing the request
1804                       handler.complete();
1805                
1806                       PEG_METHOD_EXIT();
1807                       return ;
1808                    }
1809                
1810                //***************************************************************************
1811                //                enumerateInstances
1812                //***************************************************************************
1813                void InteropProvider::enumerateInstances(
1814                    const OperationContext & context,
1815                    const CIMObjectPath & ref,
1816                    const Boolean includeQualifiers,
1817                    const Boolean includeClassOrigin,
1818                    const CIMPropertyList& propertyList,
1819                    InstanceResponseHandler & handler)
1820                    {
1821 karl  1.1              PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "InteropProvider::enumerateInstances()");
1822                        // Verify that ClassName is correct and get value
1823 tony  1.6      
1824 karl  1.5              targetClass classEnum  = _verifyValidClassInput(ref.getClassName());    
1825 karl  1.1              
1826 tony  1.6              // operation namespace needed internally to get class.
1827                        _operationNamespace = ref.getNameSpace();
1828                        //String userName = _validateUserID(context);
1829 karl  1.1              
1830                        // The following 3 classes deliver a single instance because
1831                        // that is all there is today.
1832                        if (classEnum == CIM_OBJECTMANAGER)
1833                        {
1834 tony  1.6                  CIMInstance instance = _buildInstanceCIMObjectManager(includeQualifiers,
1835                                                    includeClassOrigin,
1836                                                    propertyList);
1837 karl  1.10     
1838                            //Array<Sint8> tmp;
1839                            ///XmlWriter::appendInstanceElement(tmp, instance);
1840                            //tmp.append('\0');
1841                            //Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
1842                            //        "Instance - XML content: $0", tmp.getData());
1843                            ///XmlWriter::printInstanceElement(instance);
1844 karl  1.1                  handler.deliver(instance);
1845                            handler.complete();
1846                            PEG_METHOD_EXIT();
1847                            return;
1848                        }
1849                        
1850 tony  1.6              if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)
1851 karl  1.1              {
1852 tony  1.6                  Array<CIMInstance> instances = _buildInstancesPGCIMXMLCommunicationMechanism(includeQualifiers,
1853                                                    includeClassOrigin, propertyList);
1854                            CDEBUG("Build instances of PGCIMXML. count= " << instances.size());
1855                            handler.deliver(instances);
1856 karl  1.1                  handler.complete();
1857                            PEG_METHOD_EXIT();
1858                            return;
1859                        }
1860                
1861                
1862 karl  1.8              if (classEnum == PG_NAMESPACE)
1863 karl  1.1              {
1864 tony  1.6                  Array<CIMInstance> instances = _getInstancesCIMNamespace(includeQualifiers,
1865                                                    includeClassOrigin, propertyList);
1866                
1867                            handler.deliver(instances);
1868 karl  1.1                  handler.complete();
1869                            PEG_METHOD_EXIT();
1870                            return;
1871                        }
1872                
1873                        handler.complete();
1874                        
1875                        PEG_METHOD_EXIT();
1876                    }
1877                
1878 karl  1.10     void InteropProvider::modifyObjectManagerInstance(const OperationContext & context,
1879                    const CIMObjectPath & instanceReference,
1880                    const CIMInstance& modifiedIns,
1881                    const Boolean includeQualifiers,
1882                    const CIMPropertyList& propertyList,
1883                    ResponseHandler & handler)
1884                {
1885                    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1886                            "InteropProvider::modifyInstanceManagerInstance");
1887                    // the only allowed modification is this one property, statistical data
1888                    if (modifiedIns.findProperty(OM_GATHERSTATISTICALDATA) != PEG_NOT_FOUND)
1889                    {
1890 karl  1.11             // ATTN: This function is a design problem.
1891                        // ATTN: Should the ifdef include everything????
1892 karl  1.10             // the following is a temporary hack to set the value of the statistics
1893                        // gathering function dynamically.  We simply get the  value from input
1894                        // and call the internal method to set it each time this object is
1895                        // built.
1896                #ifdef PEGASUS_HAS_PERFINST
1897                        StatisticalData* sd = StatisticalData::current();
1898                        Boolean statisticsFlag = _getPropertyValue(modifiedIns, OM_GATHERSTATISTICALDATA, false);  
1899                        sd->setCopyGSD(statisticsFlag);
1900                        if ( ! _getInstanceCIMObjectManager(false, false, CIMPropertyList()))
1901                        {
1902                            _buildInstanceCIMObjectManager(true, true, CIMPropertyList());
1903                        }
1904                
1905                        // ATTN: Think we need to clone here to avoid any issues of overwriting.
1906                        _setPropertyValue(instanceOfCIMObjectManager, OM_GATHERSTATISTICALDATA, statisticsFlag);  
1907                        CIMObjectPath instancePath;
1908 karl  1.11     
1909                        // Modify the object on disk
1910 karl  1.10             try
1911                        {
1912                            _repository->modifyInstance(_operationNamespace,
1913                                           instanceOfCIMObjectManager );
1914                        }
1915                        catch(CIMException& e)
1916                        {
1917                            // ATTN: KS generate log error if this not possible
1918                            PEG_METHOD_EXIT();
1919                            throw e;
1920                        }
1921                        catch(Exception& e)
1922                        {
1923                            // ATTN: Generate log error.
1924                            PEG_METHOD_EXIT();
1925                            throw e;
1926                        }
1927                        Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
1928                            "Interop Provider Set Statistics gathering in CIM_ObjectManager: $0",
1929                            (statisticsFlag? "true" : "false"));
1930 karl  1.11             // modify returns nothing normally.
1931 karl  1.10             return;
1932                #endif
1933 karl  1.8      
1934 karl  1.10         }
1935                    PEG_METHOD_EXIT();
1936 karl  1.11         // ATTN Expand this defintion to be more precise since it allows only mod of
1937                    // one property and that property MUST be in the instance to be modifiable.
1938 karl  1.10         throw CIMNotSupportedException
1939                        (OM_GATHERSTATISTICALDATA.getString() + " modify operation not supported by Interop Provider");
1940                }
1941 karl  1.1      //***************************************************************************
1942 karl  1.10     //                modifyInstance
1943 karl  1.1      //***************************************************************************
1944 karl  1.8      void InteropProvider::modifyInstance(const OperationContext & context,
1945                    const CIMObjectPath & instanceReference,
1946                    const CIMInstance& modifiedIns,
1947                    const Boolean includeQualifiers,
1948                    const CIMPropertyList& propertyList,
1949                    ResponseHandler & handler)
1950                {
1951                
1952                    PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
1953 karl  1.10                 "InteropProvider::modifyInstance");
1954 karl  1.8      
1955                    // operation namespace needed internally to get class.
1956 karl  1.10     
1957                    // ATTN: KS 31 August 2004. This must test for privileged user.
1958 karl  1.8          _operationNamespace = instanceReference.getNameSpace();
1959                    CIMName className =  instanceReference.getClassName();
1960                    targetClass classEnum  = _verifyValidClassInput(instanceReference.getClassName());    
1961                
1962                    String userName = _validateUserID(context);
1963                    // begin processing the request
1964                    handler.processing();
1965                
1966                    if (classEnum == CIM_OBJECTMANAGER)
1967                    {
1968 karl  1.10             modifyObjectManagerInstance(context, instanceReference,modifiedIns,
1969                            includeQualifiers, propertyList, handler);
1970 karl  1.8              // for the moment allow modification of the statistics property only
1971                    }
1972                
1973 karl  1.10         else if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)
1974 karl  1.8          {
1975                
1976                        PEG_METHOD_EXIT();
1977                        throw CIMNotSupportedException
1978                            (className.getString() + " not supported by Interop Provider");
1979                    }
1980 karl  1.10         else if (classEnum == PG_NAMESPACE)
1981 karl  1.8          {
1982 karl  1.10             // for the moment allow modification of the statistics property only
1983 karl  1.8              PEG_METHOD_EXIT();
1984                        throw CIMNotSupportedException
1985                            (className.getString() + " not supported by Interop Provider");
1986                    }
1987 karl  1.10         else
1988                    {
1989                        PEGASUS_ASSERT(false);  // should never get here.
1990                    }
1991 karl  1.8      
1992 karl  1.10         handler.complete();
1993 karl  1.8          PEG_METHOD_EXIT();
1994                    return;
1995                }
1996                
1997 karl  1.10     //***************************************************************************
1998                //                enumerateInstanceNames
1999                //***************************************************************************
2000 karl  1.1      void InteropProvider::enumerateInstanceNames(
2001                	const OperationContext & context,
2002                	const CIMObjectPath & classReference,
2003                        ObjectPathResponseHandler & handler)
2004                    {
2005                    	PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
2006                                "InteropProvider::enumerateInstanceNames()");
2007                
2008                        // operation namespace needed internally to get class.
2009                        _operationNamespace = classReference.getNameSpace();
2010                
2011 karl  1.5              targetClass classEnum  = _verifyValidClassInput(classReference.getClassName());    
2012 karl  1.1          
2013 tony  1.6              String userName = _validateUserID(context);
2014 karl  1.11     
2015 karl  1.1              // begin processing the request
2016                        handler.processing();
2017                        
2018 karl  1.11             // Deliver a single instance because there should only be one instance.
2019 karl  1.1              if (classEnum == CIM_OBJECTMANAGER)
2020                        {
2021 tony  1.6                  CIMInstance instance = _buildInstanceCIMObjectManager( true, true, CIMPropertyList());
2022                            CIMObjectPath ref = _buildInstancePath(_operationNamespace,
2023 karl  1.1                      CIM_OBJECTMANAGER_CLASSNAME, instance);
2024                            handler.deliver(ref);
2025                            handler.complete();
2026                            PEG_METHOD_EXIT();
2027                            return;
2028                        }
2029 karl  1.11     
2030                        // Deliver all possible instances of this class
2031 tony  1.6              if (classEnum == PG_CIMXMLCOMMUNICATIONMECHANISM)
2032 karl  1.1              {
2033 tony  1.6                  Array<CIMInstance> instances = _buildInstancesPGCIMXMLCommunicationMechanism(true,
2034                                 true, CIMPropertyList());
2035                
2036                            for (Uint32 i = 0 ; i < instances.size() ; i++)
2037                            {
2038                                CIMObjectPath ref = _buildInstancePath(_operationNamespace,
2039                                    PG_CIMXMLCOMMUNICATIONMECHANISM_CLASSNAME, instances[i]);
2040                                handler.deliver(ref);
2041                            }
2042 karl  1.1                  handler.complete();
2043                            PEG_METHOD_EXIT();
2044                            return;
2045                        }
2046                
2047 karl  1.8              if (classEnum == PG_NAMESPACE)
2048 tony  1.6              {
2049                            Array<CIMInstance> instances = _getInstancesCIMNamespace(false,
2050                                                    false, CIMPropertyList());
2051                            CDEBUG("EvalNames. Found instances. Count= " << instances.size());
2052                            for (Uint32 i = 0 ; i < instances.size() ; i++)
2053                            {
2054                                CIMObjectPath ref = _buildInstancePath(_operationNamespace,
2055                                                            CIM_NAMESPACE_CLASSNAME, instances[i]);
2056                                handler.deliver(ref);
2057                            }
2058 karl  1.1      
2059                            handler.complete();
2060                            PEG_METHOD_EXIT();
2061                            return;
2062                        }
2063                
2064 karl  1.11             if (classEnum == CIM_COMMMECHANISMFORMANAGERINST)
2065                        {
2066                            Array<CIMInstance> instances = _buildInstancesCommMechanismForManager();
2067                            for (Uint32 i = 0 ; i < instances.size() ; i++ )
2068                            {
2069                                CIMObjectPath ref = _buildObjectPath(_operationNamespace,
2070                                        CIM_COMMMECHANISMFORMANAGER_CLASSNAME, instances[i]);
2071                                handler.deliver(ref);
2072                            }
2073                        }
2074                
2075                        if (classEnum == CIM_NAMESPACEINMANAGERINST)
2076                        {
2077                            Array<CIMInstance> instances = _buildInstancesNamespaceInManager();
2078                            for (Uint32 i = 0 ; i < instances.size() ; i++ )
2079                            {
2080                                CIMObjectPath ref = _buildObjectPath(_operationNamespace,
2081                                        CIM_NAMESPACEINMANAGER_CLASSNAME, instances[i]);
2082                                handler.deliver(ref);
2083                            }
2084                        }
2085 karl  1.11     
2086                
2087 karl  1.8              // ATTN: Exception response because of error
2088 karl  1.1              PEG_METHOD_EXIT();
2089                    }
2090                
2091                //**************************************************************
2092                //**************************************************************
2093                // Association Functions
2094                //**************************************************************
2095                //**************************************************************
2096                
2097                void InteropProvider::associators(
2098                	const OperationContext & context,
2099                	const CIMObjectPath & objectName,
2100                	const CIMName & associationClass,
2101                	const CIMName & resultClass,
2102                	const String & role,
2103                	const String & resultRole,
2104                	const Boolean includeQualifiers,
2105                	const Boolean includeClassOrigin,
2106                	const CIMPropertyList & propertyList,
2107                	ObjectResponseHandler & handler)
2108                {
2109 tony  1.6          PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
2110                            "InteropProvider::associatorNames()");
2111 karl  1.1      	throw CIMNotSupportedException("AssociationProvider::associators");
2112                }
2113                
2114                void InteropProvider::associatorNames(
2115                	const OperationContext & context,
2116                	const CIMObjectPath & objectName,
2117                	const CIMName & associationClass,
2118                	const CIMName & resultClass,
2119                	const String & role,
2120                	const String & resultRole,
2121                	ObjectPathResponseHandler & handler)
2122                {
2123 tony  1.6          PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
2124                            "InteropProvider::associatorNames()");
2125 karl  1.1      	throw CIMNotSupportedException("AssociationProvider::associatorNames");
2126                }
2127                
2128                void InteropProvider::references(
2129                	const OperationContext & context,
2130                	const CIMObjectPath & objectName,
2131                	const CIMName & resultClass,
2132                	const String & role,
2133                	const Boolean includeQualifiers,
2134                	const Boolean includeClassOrigin,
2135                	const CIMPropertyList & propertyList,
2136                	ObjectResponseHandler & handler)
2137                {
2138 tony  1.6          PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
2139                            "InteropProvider::references()");
2140 karl  1.1      	throw CIMNotSupportedException("AssociationProvider::references");
2141                }
2142                
2143 tony  1.6      void _filterAssocInstances(Array<CIMInstance>& instances,
2144                                      CIMName assocClassName,
2145                                      String assocRole,
2146                                      CIMName resultClassName = CIMName(),
2147                                      String resultRole = String::EMPTY)
2148                {
2149                    return;
2150                }
2151 karl  1.11     
2152 karl  1.1      void InteropProvider::referenceNames(
2153                	const OperationContext & context,
2154                	const CIMObjectPath & objectName,
2155                	const CIMName & resultClass,
2156                	const String & role,
2157                	ObjectPathResponseHandler & handler)
2158                {
2159 tony  1.6          PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
2160                            "InteropProvider::referenceNames()");
2161                    CDEBUG("::referenceNames(): object= " << objectName.toString() << " result Class= " << resultClass.getString());
2162                                    
2163                    // operation namespace needed internally to get class.
2164                    _operationNamespace = objectName.getNameSpace();
2165                    String userName = _validateUserID(context);
2166                    // begin processing the request
2167                    handler.processing();
2168                
2169                    // determine if valid class result class
2170                
2171                    CIMName targetAssocClassName = resultClass;
2172                    
2173                    CIMName targetClassName = objectName.getClassName();
2174                
2175                    targetAssocClass classEnum  = _verifyValidAssocClassInput(targetAssocClassName);
2176                
2177                    Array<CIMInstance> assocInstances;
2178                
2179                    if (classEnum == CIM_COMMMECHANISMFORMANAGER)
2180 tony  1.6              assocInstances = _buildInstancesCommMechanismForManager();
2181                
2182                    if (classEnum == CIM_NAMESPACEINMANAGER)
2183                        assocInstances = _buildInstancesNamespaceInManager();
2184                
2185                    _filterAssocInstances(assocInstances, resultClass, role);
2186                
2187                    for (Uint32 i = 0 ; i < assocInstances.size() ; i++ )
2188                    {
2189                        CIMObjectPath ref = _buildObjectPath(_operationNamespace,
2190                                targetAssocClassName, assocInstances[i]);
2191                        CDEBUG("referenceNames returns: " << ref.toString());
2192                        handler.deliver(ref);
2193 karl  1.11         }
2194 tony  1.6      
2195                    handler.complete();
2196                
2197                    PEG_METHOD_EXIT();
2198                    // Convert the instances to referenceNames response
2199 karl  1.1      }
2200                
2201                PEGASUS_NAMESPACE_END
2202                // END_OF_FILE

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2