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

   1 karl  1.129 //%2004////////////////////////////////////////////////////////////////////////
   2 mike  1.48  //
   3 karl  1.129 // 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.100 // IBM Corp.; EMC Corporation, The Open Group.
   7 karl  1.129 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   8             // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   9 mike  1.48  //
  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.129 // 
  17 mike  1.48  // 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: Mike Brasher (mbrasher@bmc.com)
  29             //
  30 mike  1.51  // Modified By: Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com)
  31             //              Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
  32             //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
  33 kumpf 1.70  //              Carol Ann Krug Graves, Hewlett-Packard Company
  34             //                  (carolann_graves@hp.com)
  35 karl  1.86  //              Karl Schopmeyer(k.schopmeyer@opengroup.org) - extend ref function.
  36 r.kieninger 1.126 //              Robert Kieninger, IBM (kieningr@de.ibm.com) - Bugzilla 383,1508,1813,667
  37 a.arora     1.106 //              Seema Gupta (gseema@in.ibm.com) - Bugzilla 281, Bugzilla 1313
  38 schuur      1.114 //              Adrian Schuur (schuur@de.ibm.com) - PEP 129 & 164
  39 a.arora     1.113 //              Amit K Arora, IBM (amita@in.ibm.com) for PEP#101
  40 dave.sudlik 1.117 //              Dave Sudlik, IBM (dsudlik@us.ibm.com)
  41 mike        1.48  //
  42                   //%/////////////////////////////////////////////////////////////////////////////
  43                   
  44 mike        1.51  #include <Pegasus/Common/Config.h>
  45 mike        1.48  #include <cctype>
  46                   #include <cstdio>
  47                   #include <fstream>
  48                   #include <Pegasus/Common/Pair.h>
  49                   #include <Pegasus/Common/FileSystem.h>
  50 kumpf       1.82  #include <Pegasus/Common/InternalException.h>
  51 schuur      1.114 
  52 mike        1.48  #include <Pegasus/Common/DeclContext.h>
  53 kumpf       1.76  #include <Pegasus/Common/Resolver.h>
  54 mike        1.48  #include <Pegasus/Common/System.h>
  55 kumpf       1.52  #include <Pegasus/Common/Tracer.h>
  56 kumpf       1.63  #include <Pegasus/Common/PegasusVersion.h>
  57 humberto    1.88  #include <Pegasus/Common/MessageLoader.h> //l10n
  58 chuck       1.109 #include <Pegasus/Common/CommonUTF.h>
  59 kumpf       1.63  
  60 schuur      1.114 #include <Pegasus/Common/XmlStreamer.h>
  61                   #include <Pegasus/Common/BinaryStreamer.h>
  62                   #include <Pegasus/Common/AutoStreamer.h>
  63                   
  64 mike        1.48  #include "CIMRepository.h"
  65                   #include "RepositoryDeclContext.h"
  66                   #include "InstanceIndexFile.h"
  67 mike        1.53  #include "InstanceDataFile.h"
  68 mike        1.48  #include "AssocInstTable.h"
  69                   #include "AssocClassTable.h"
  70                   
  71 david       1.92  #if  defined(PEGASUS_OS_OS400)
  72                   #include "OS400ConvertChar.h"
  73                   #endif
  74                   
  75 schuur      1.112 #if 0
  76                   #undef PEG_METHOD_ENTER
  77                   #undef PEG_METHOD_EXIT
  78                   #define PEG_METHOD_ENTER(x,y)  cout<<"--- Enter: "<<y<<endl;
  79                   #define PEG_METHOD_EXIT()
  80                   #endif
  81                   
  82 karl        1.102 /* See bug report 1046
  83                   The following fix  turns off the filtering of enumerate
  84                   instances for localOnly, includeQualifiers, IncludClassOrigin
  85                   deepInheritance, PropertyList. It is included for the moment
  86                   13 November 2003 to keep the code installed but not change
  87                   current client behavior pending architecture team decison.
  88 kumpf       1.104 KS, 13 Sept 2003  Note that there is also a flag in
  89 karl        1.103 tests/cimrepository2.cpp. Note that this was extended to
  90                   include get instance (at least the property filtering pending
  91                   conclusion of the questions around bug. Set this flag
  92                   PEGASUS_ENABLE_INSTANCE_FILTER to stop the filtering
  93                   NOTE: We did not make these env variable params because
  94                   the test suite must be changed also.*/
  95                   
  96                   // comment this to disable filters #define PEGASUS_ENABLE_INSTANCE_FILTER
  97                   
  98 mike        1.48  PEGASUS_USING_STD;
  99                   
 100                   PEGASUS_NAMESPACE_BEGIN
 101                   
 102 mike        1.53  static const Uint32 _MAX_FREE_COUNT = 16;
 103 dave.sudlik 1.117 static int binaryMode = -1; // PEP 164
 104 mike        1.53  
 105 karl        1.101 //
 106                   //  The following _xx functions are local to the repository implementation
 107                   //
 108 mike        1.48  ////////////////////////////////////////////////////////////////////////////////
 109                   //
 110 kumpf       1.104 //   _containsProperty
 111 karl        1.97  //
 112                   ////////////////////////////////////////////////////////////////////////////////
 113 karl        1.101 
 114                   /** Check to see if the specified property is in the property list
 115 kumpf       1.104     @param property the specified property
 116 karl        1.101     @param propertyList the property list
 117 kumpf       1.104     @return true if the property is in the list otherwise false.
 118 karl        1.101 */
 119                   Boolean _containsProperty(CIMProperty& property, const CIMPropertyList& propertyList)
 120 karl        1.97  {
 121 kumpf       1.104     //  For each property in the propertly list
 122                       for (Uint32 p=0; p<propertyList.size(); p++)
 123                       {
 124                           if (propertyList[p].equal(property.getName()))
 125                               return true;
 126                       }
 127                       return false;
 128 karl        1.97  }
 129                   
 130 karl        1.98  ////////////////////////////////////////////////////////////////////////////////
 131                   //
 132                   // removeAllQualifiers - Remove all of the qualifiers from a class
 133                   //
 134                   ////////////////////////////////////////////////////////////////////////////////
 135 karl        1.101 
 136                   /* removes all Qualifiers from a CIMClass.  This function removes all
 137                      of the qualifiers from the class, from all of the properties,
 138                      from the methods, and from the parameters attached to the methods.
 139                      @param cimClass reference to the class from which qualifiers are to
 140                      be removed.
 141                      NOTE: This would be logical to be moved to CIMClass since it may be more general
 142                      than this usage.
 143                   */
 144 chip        1.118 void _removeAllQualifiers(CIMClass & cimClass)
 145 karl        1.98  {
 146 kumpf       1.104     // remove qualifiers of the class
 147                       Uint32 count = 0;
 148                       while((count = cimClass.getQualifierCount()) > 0)
 149                           cimClass.removeQualifier(count - 1);
 150                   
 151                       // remove qualifiers from the properties
 152                       for (Uint32 i = 0; i < cimClass.getPropertyCount(); i++)
 153                       {
 154                           CIMProperty p = cimClass.getProperty(i);
 155                           count=0;
 156                           while((count = p.getQualifierCount()) > 0)
 157                               p.removeQualifier(count - 1);
 158                       }
 159                       // remove qualifiers from the methods
 160                       for (Uint32 i = 0; i < cimClass.getMethodCount(); i++)
 161                       {
 162                           CIMMethod m = cimClass.getMethod(i);
 163                           for (Uint32 j = 0 ; j < m.getParameterCount(); j++)
 164                           {
 165                               CIMParameter p = m.getParameter(j);
 166                               count = 0;
 167 kumpf       1.104             while ((count = p.getQualifierCount()) > 0)
 168                                   p.removeQualifier(count - 1);
 169                           }
 170                           count=0;
 171                           while((count = m.getQualifierCount()) > 0)
 172                               m.removeQualifier(count - 1);
 173                       }
 174 karl        1.98  }
 175                   
 176                   /////////////////////////////////////////////////////////////////////////
 177                   //
 178 karl        1.101 // _removePropagatedQualifiers - Removes all qualifiers from the class
 179 kumpf       1.104 // that are marked propagated
 180 karl        1.98  //
 181                   /////////////////////////////////////////////////////////////////////////
 182 karl        1.101 
 183 kumpf       1.104 /* removes propagatedQualifiers from the defined CIMClass.
 184 karl        1.101    This function removes the qualifiers from the class,
 185                      from each of the properties, from the methods and
 186                      the parameters if the qualifiers are marked propagated.
 187                      NOTE: This could be logical to be moved to CIMClass since it may be more general
 188                      than the usage here.
 189                   */
 190 chip        1.118 void _removePropagatedQualifiers(CIMClass & cimClass)
 191 karl        1.98  {
 192 kumpf       1.104     Uint32 count = cimClass.getQualifierCount();
 193                       // Remove nonlocal qualifiers from Class
 194                       for (Sint32 i = (count - 1); i >= 0; i--)
 195                       {
 196                           CIMQualifier q = cimClass.getQualifier(i);
 197                           if (q.getPropagated())
 198                           {
 199                               cimClass.removeQualifier(i);
 200                           }
 201                       }
 202                   
 203                       // remove  non localOnly qualifiers from the properties
 204                       for (Uint32 i = 0; i < cimClass.getPropertyCount(); i++)
 205                       {
 206                           CIMProperty p = cimClass.getProperty(i);
 207                           // loop to search qualifiers for nonlocal parameters
 208                           count = p.getQualifierCount();
 209                           for (Sint32 j = (count - 1); j > 0; j--)
 210                           {
 211                               CIMQualifier q = p.getQualifier(j);
 212                               if (q.getPropagated())
 213 kumpf       1.104             {
 214                                   p.removeQualifier(j);
 215                               }
 216                           }
 217                       }
 218                       // remove non LocalOnly qualifiers from the methods and parameters
 219                       for (Uint32 i = 0; i < cimClass.getMethodCount(); i++)
 220                       {
 221                           CIMMethod m = cimClass.getMethod(i);
 222                           // Remove  nonlocal qualifiers from all parameters
 223                           for (Uint32 j = 0 ; j < m.getParameterCount(); j++)
 224                           {
 225                               CIMParameter p = m.getParameter(j);
 226                               count = p.getQualifierCount();
 227                               for (Sint32 k = (count - 1); k > 0; k--)
 228                               {
 229                                   CIMQualifier q = p.getQualifier(k);
 230                                   if (q.getPropagated())
 231                                   {
 232                                       p.removeQualifier(k);
 233                                   }
 234 kumpf       1.104             }
 235                           }
 236                   
 237                           // remove nonlocal qualifiers from the method
 238                           count = m.getQualifierCount();
 239                           for (Sint32 j = (count - 1); j > 0; j--)
 240                           {
 241                               CIMQualifier q = m.getQualifier(j);
 242                               if (q.getPropagated())
 243                               {
 244                                   m.removeQualifier(j);
 245                               }
 246                           }
 247                       }
 248 karl        1.98  }
 249 karl        1.97  
 250 karl        1.103 /* remove the properties from an instance based on attributes.
 251 karl        1.101     @param Instance from which properties will be removed.
 252                       @param propertyList PropertyList is used in the removal algorithm
 253                       @param localOnly - Boolean used in the removal.
 254                       NOTE: This could be logical to move to CIMInstance since the
 255                       usage is more general than just in the repository
 256                   */
 257                   void _removeProperties(CIMInstance& cimInstance,
 258                       const CIMPropertyList& propertyList, Boolean localOnly)
 259                   {
 260                       Boolean propertyListNull = propertyList.isNull();
 261                       if ((!propertyListNull) || localOnly)
 262                       {
 263                           // Loop through properties to remove those that do not filter through
 264                           // local only attribute and are not in the property list.
 265                           Uint32 count = cimInstance.getPropertyCount();
 266                           // Work backwards because removal may be cheaper. Sint32 covers count=0
 267                           for (Sint32 i = (count - 1); i >= 0; i--)
 268                           {
 269                               CIMProperty p = cimInstance.getProperty(i);
 270                   
 271                               // if localOnly==true, ignore properties defined in super class
 272 karl        1.101             if (localOnly && (p.getPropagated()))
 273                               {
 274                                   cimInstance.removeProperty(i);
 275                                   continue;
 276                               }
 277                   
 278                               // propertyList NULL means deliver properties.  PropertyList empty, none.
 279                               // Test for removal if propertyList not NULL. The empty list option
 280                               // is covered by fact that property is not in the list.
 281                               if (!propertyListNull)
 282                                   if(!_containsProperty(p, propertyList))
 283                                       cimInstance.removeProperty(i);
 284                           }
 285                       }
 286                   }
 287                   
 288                   /* remove all Qualifiers from a single CIMInstance. Removes
 289                       all of the qualifiers from the instance and from properties
 290                       within the instance.
 291                       @param instance from which parameters are removed.
 292                       NOTE: This could be logical to be moved to CIMInstance since
 293 karl        1.101     the usage may be more general than just in the repository.
 294                   */
 295                   void _removeAllQualifiers(CIMInstance& cimInstance)
 296                   {
 297                           // remove qualifiers from the instance
 298                           Uint32 count = 0;
 299                           while((count = cimInstance.getQualifierCount()) > 0)
 300                               cimInstance.removeQualifier(count - 1);
 301                   
 302                           // remove qualifiers from the properties
 303                           for (Uint32 i = 0; i < cimInstance.getPropertyCount(); i++)
 304                           {
 305                               CIMProperty p = cimInstance.getProperty(i);
 306                               count=0;
 307                               while((count = p.getQualifierCount()) > 0)
 308                                   p.removeQualifier(count - 1);
 309 kumpf       1.104         }
 310 karl        1.101 }
 311                   /* removes all ClassOrigin attributes from a single CIMInstance. Removes
 312                       the classOrigin attribute from each property in the Instance.
 313                      @param Instance from which the ClassOrigin Properties will be removed.
 314                      NOTE: Logical to be moved to CIMInstance since it may be more general
 315                      than just the repositoryl
 316                   */
 317                   void _removeClassOrigins(CIMInstance& cimInstance)
 318                   {
 319 kumpf       1.104         PEG_TRACE_STRING(TRC_REPOSITORY, Tracer::LEVEL4, "Remove Class Origins");
 320                   
 321 karl        1.101         Uint32 propertyCount = cimInstance.getPropertyCount();
 322                           for (Uint32 i = 0; i < propertyCount ; i++)
 323                               cimInstance.getProperty(i).setClassOrigin(CIMName());
 324                   }
 325                   
 326 karl        1.103 /* Filters the properties, qualifiers, and classorigin out of a single instance.
 327 karl        1.101     Based on the parameters provided for localOnly, includeQualifiers,
 328                       and includeClassOrigin, this function simply filters the properties
 329                       qualifiers, and classOrigins out of a single instance.  This function
 330                       was created to have a single piece of code that processes getinstance
 331                       and enumerateInstances returns.
 332                       @param cimInstance reference to instance to be processed.
 333                       @param localOnly defines if request is for localOnly parameters.
 334                       @param includeQualifiers Boolean defining if qualifiers to be returned.
 335                       @param includeClassOrigin Boolean defining if ClassOrigin attribute to
 336                       be removed from properties.
 337                   */
 338                   void _filterInstance(CIMInstance& cimInstance,
 339                                   const CIMPropertyList& propertyList,
 340                                   Boolean localOnly,
 341                                   Boolean includeQualifiers,
 342                                   Boolean includeClassOrigin)
 343                   {
 344 karl        1.103     // Remove properties based on propertylist and localOnly flag
 345                   #ifdef PEGASUS_ENABLE_INSTANCE_FILTER
 346 karl        1.101     _removeProperties(cimInstance, propertyList, localOnly);
 347 karl        1.103 #endif
 348 karl        1.101     // If includequalifiers false, remove all qualifiers from
 349                       // properties.
 350                   
 351                       if(!includeQualifiers)
 352                       {
 353                           _removeAllQualifiers(cimInstance);
 354                       }
 355 karl        1.103     // if ClassOrigin Flag false, remove classOrigin info from Instance object
 356                       // by setting the classOrigin to Null.
 357 karl        1.101     if (!includeClassOrigin)
 358                       {
 359                           _removeClassOrigins(cimInstance);
 360                       }
 361                   }
 362 karl        1.97  ////////////////////////////////////////////////////////////////////////////////
 363                   //
 364 mike        1.48  // _LoadObject()
 365                   //
 366 mike        1.51  //      Loads objects (classes and qualifiers) from disk to
 367                   //      memory objects.
 368 mike        1.48  //
 369                   ////////////////////////////////////////////////////////////////////////////////
 370                   
 371                   template<class Object>
 372                   void _LoadObject(
 373                       const String& path,
 374 schuur      1.114     Object& object,
 375                       ObjectStreamer *streamer)
 376 mike        1.48  {
 377 kumpf       1.58      PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_LoadObject");
 378                   
 379 mike        1.48      // Get the real path of the file:
 380                   
 381                       String realPath;
 382                   
 383                       if (!FileSystem::existsNoCase(path, realPath))
 384 kumpf       1.104     {
 385 kumpf       1.75          String traceString = path + " does not exist.";
 386 kumpf       1.61          PEG_TRACE_STRING(TRC_REPOSITORY, Tracer::LEVEL4, traceString);
 387 kumpf       1.58          PEG_METHOD_EXIT();
 388 mike        1.51          throw CannotOpenFile(path);
 389 kumpf       1.58      }
 390 mike        1.48  
 391 kumpf       1.61      PEG_TRACE_STRING(TRC_REPOSITORY, Tracer::LEVEL4, "realpath = " + realPath);
 392                   
 393 mike        1.48      // Load file into memory:
 394                   
 395                       Array<Sint8> data;
 396                       FileSystem::loadFileToMemory(data, realPath);
 397                       data.append('\0');
 398                   
 399 schuur      1.114     streamer->decode(data, 0, object);
 400                   
 401                       //XmlParser parser((char*)data.getData());
 402 mike        1.48  
 403 schuur      1.114     //XmlReader::getObject(parser, object);
 404 kumpf       1.58  
 405                       PEG_METHOD_EXIT();
 406 mike        1.48  }
 407                   
 408                   ////////////////////////////////////////////////////////////////////////////////
 409                   //
 410                   // _SaveObject()
 411                   //
 412 mike        1.51  //      Saves objects (classes and qualifiers) from memory to
 413                   //      disk files.
 414 mike        1.48  //
 415                   ////////////////////////////////////////////////////////////////////////////////
 416                   
 417 schuur      1.114 void _SaveObject(const String& path, Array<Sint8>& objectXml,
 418                       ObjectStreamer *streamer)
 419 mike        1.48  {
 420 kumpf       1.58      PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_SaveObject");
 421 david       1.96  
 422 david       1.108     PEGASUS_STD(ofstream) os(path.getCString() PEGASUS_IOS_BINARY);
 423 david       1.96  
 424 mike        1.48      if (!os)
 425 kumpf       1.58      {
 426                           PEG_METHOD_EXIT();
 427 mike        1.51          throw CannotOpenFile(path);
 428 kumpf       1.58      }
 429 mike        1.48  
 430 kumpf       1.123     streamer->write(os, objectXml);
 431 kumpf       1.58  
 432                       PEG_METHOD_EXIT();
 433 mike        1.48  }
 434                   
 435                   ////////////////////////////////////////////////////////////////////////////////
 436                   //
 437                   // CIMRepository
 438                   //
 439                   //     The following are not implemented:
 440                   //
 441                   //         CIMRepository::execQuery()
 442                   //         CIMRepository::invokeMethod()
 443                   //
 444                   //     Note that invokeMethod() will not never implemented since it is not
 445                   //     meaningful for a repository.
 446                   //
 447                   ////////////////////////////////////////////////////////////////////////////////
 448                   
 449                   CIMRepository::CIMRepository(const String& repositoryRoot)
 450 mike        1.51     : _repositoryRoot(repositoryRoot), _nameSpaceManager(repositoryRoot),
 451 kumpf       1.56       _lock(), _resolveInstance(true)
 452 mike        1.48  {
 453 kumpf       1.58      PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::CIMRepository");
 454                   
 455 dave.sudlik 1.117     if (binaryMode==-1) { // PEP 164
 456                          binaryMode = (ConfigManager::getInstance()->getCurrentValue(
 457                           "enableBinaryRepository") == "true");
 458 schuur      1.114     }
 459                   
 460 dave.sudlik 1.117     if (binaryMode>0) { // PEP 164
 461 schuur      1.114        streamer=new AutoStreamer(new BinaryStreamer(),BINREP_MARKER);
 462                          ((AutoStreamer*)streamer)->addReader(new XmlStreamer(),0);
 463                       }
 464 schuur      1.116     else { // streamer=new XmlStreamer();
 465                          streamer=new AutoStreamer(new XmlStreamer(),0xff);
 466                          ((AutoStreamer*)streamer)->addReader(new BinaryStreamer(),BINREP_MARKER);
 467                          ((AutoStreamer*)streamer)->addReader(new XmlStreamer(),0);
 468                       }
 469 schuur      1.114 
 470 mike        1.48      _context = new RepositoryDeclContext(this);
 471 mike        1.51      _isDefaultInstanceProvider = (ConfigManager::getInstance()->getCurrentValue(
 472                           "repositoryIsDefaultInstanceProvider") == "true");
 473 kumpf       1.58  
 474                       PEG_METHOD_EXIT();
 475 mike        1.48  }
 476                   
 477                   CIMRepository::~CIMRepository()
 478                   {
 479 kumpf       1.58      PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::~CIMRepository");
 480                   
 481 mike        1.48      delete _context;
 482 kumpf       1.58  
 483                       PEG_METHOD_EXIT();
 484 mike        1.48  }
 485                   
 486 kumpf       1.104 String _toString(Boolean x)
 487 mike        1.51  {
 488 kumpf       1.104     return(x ? "true" : "false");
 489 mike        1.51  }
 490                   
 491 kumpf       1.104 CIMClass CIMRepository::getClass(
 492                       const CIMNamespaceName& nameSpace,
 493                       const CIMName& className,
 494                       Boolean localOnly,
 495                       Boolean includeQualifiers,
 496                       Boolean includeClassOrigin,
 497                       const CIMPropertyList& propertyList)
 498 mike        1.51  {
 499 kumpf       1.104     PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::getClass");
 500 kumpf       1.58  
 501 kumpf       1.104     ReadLock lock(_lock);
 502                       CIMClass cimClass = _getClass(nameSpace,
 503                                                     className,
 504                                                     localOnly,
 505                                                     includeQualifiers,
 506                                                     includeClassOrigin,
 507                                                     propertyList);
 508 kumpf       1.58  
 509                       PEG_METHOD_EXIT();
 510 kumpf       1.104     return cimClass;
 511 mike        1.51  }
 512                   
 513 kumpf       1.104 CIMClass CIMRepository::_getClass(
 514 kumpf       1.85      const CIMNamespaceName& nameSpace,
 515                       const CIMName& className,
 516 mike        1.48      Boolean localOnly,
 517                       Boolean includeQualifiers,
 518                       Boolean includeClassOrigin,
 519 mike        1.51      const CIMPropertyList& propertyList)
 520 mike        1.48  {
 521 kumpf       1.104     PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_getClass");
 522 kumpf       1.58  
 523 kumpf       1.104     PEG_TRACE_STRING(TRC_REPOSITORY, Tracer::LEVEL4, "nameSpace= " +
 524                                        nameSpace.getString() + ", className= " +
 525 karl        1.97                       className.getString() +
 526 kumpf       1.104                      ", localOnly= " + _toString(localOnly) +
 527                                        ", includeQualifiers= " + _toString(includeQualifiers) +
 528                                        ", includeClassOrigin= " + _toString(includeClassOrigin));
 529 mike        1.48      String classFilePath;
 530 schuur      1.112     classFilePath = _nameSpaceManager.getClassFilePath(nameSpace, className, NameSpaceRead);
 531 kumpf       1.104 
 532                       CIMClass cimClass;
 533 mike        1.51  
 534                       try
 535                       {
 536 schuur      1.114         _LoadObject(classFilePath, cimClass, streamer);
 537 mike        1.51      }
 538 kumpf       1.79      catch (Exception& e)
 539 mike        1.51      {
 540 kumpf       1.58          PEG_METHOD_EXIT();
 541 kumpf       1.85          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND, className.getString());
 542 mike        1.51      }
 543 mike        1.48  
 544 kumpf       1.104     // Remove properties based on propertylist and localOnly flag (Bug 565)
 545                       Boolean propertyListNull = propertyList.isNull();
 546                   
 547                       // if localOnly OR there is a property list, process properties
 548 karl        1.97      if ((!propertyListNull) || localOnly)
 549                       {
 550 kumpf       1.104         // Loop through properties to remove those that do not filter through
 551                           // local only attribute and are not in the property list.
 552                           Uint32 count = cimClass.getPropertyCount();
 553                           // Work backwards because removal may be cheaper. Sint32 covers count=0
 554                           for (Sint32 i = (count - 1); i >= 0; i--)
 555                           {
 556                               CIMProperty p = cimClass.getProperty(i);
 557                               // if localOnly==true, ignore properties defined in super class
 558                               if (localOnly && (p.getPropagated()))
 559                               {
 560                                   cimClass.removeProperty(i);
 561                                   continue;
 562                               }
 563                   
 564                               // propertyList NULL means all properties.  PropertyList empty, none.
 565                               // Test for removal if propertyList not NULL. The empty list option
 566                               // is covered by fact that property is not in the list.
 567                               if (!propertyListNull)
 568                                   if(!_containsProperty(p, propertyList))
 569                                       cimClass.removeProperty(i);
 570                           }
 571 kumpf       1.104     }
 572                   
 573                       // remove methods based on localOnly flag
 574                       if (localOnly)
 575                       {
 576                           Uint32 count = cimClass.getMethodCount();
 577                           // Work backwards because removal may be cheaper.
 578                           for (Sint32 i = (count - 1); i > 0; i--)
 579                           {
 580                               CIMMethod m = cimClass.getMethod(i);
 581                   
 582                               // if localOnly==true, ignore properties defined in super class
 583                               if (localOnly && (m.getPropagated()))
 584                                   cimClass.removeMethod(i);
 585                           }
 586                   
 587                       }
 588                       // If includequalifiers false, remove all qualifiers from
 589                       // properties, methods and parameters.
 590                       if(!includeQualifiers)
 591                       {
 592 kumpf       1.104         _removeAllQualifiers(cimClass);
 593                       }
 594                       else
 595                       {
 596                           // if includequalifiers and localOnly, remove nonLocal qualifiers
 597                           if (localOnly)
 598                           {
 599                               _removePropagatedQualifiers(cimClass);
 600                           }
 601                   
 602                       }
 603                       // if ClassOrigin Flag false, remove classOrigin info from class object
 604                       // by setting the property to Null.
 605                       if (!includeClassOrigin)
 606                       {
 607                           PEG_TRACE_STRING(TRC_REPOSITORY, Tracer::LEVEL4, "Remove Class Origins");
 608                   
 609                           Uint32 propertyCount = cimClass.getPropertyCount();
 610                           for (Uint32 i = 0; i < propertyCount ; i++)
 611                               cimClass.getProperty(i).setClassOrigin(CIMName());
 612                   
 613 kumpf       1.104         Uint32 methodCount =  cimClass.getMethodCount();
 614                           for (Uint32 i=0; i < methodCount ; i++)
 615                               cimClass.getMethod(i).setClassOrigin(CIMName());
 616                       }
 617 karl        1.97  
 618 kumpf       1.58      PEG_METHOD_EXIT();
 619 mike        1.48      return cimClass;
 620                   }
 621                   
 622                   Boolean CIMRepository::_getInstanceIndex(
 623 kumpf       1.85      const CIMNamespaceName& nameSpace,
 624 kumpf       1.68      const CIMObjectPath& instanceName,
 625 kumpf       1.85      CIMName& className,
 626 mike        1.53      Uint32& index,
 627 mike        1.51      Uint32& size,
 628 mike        1.48      Boolean searchSuperClasses) const
 629                   {
 630 kumpf       1.58      PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_getInstanceIndex");
 631                   
 632 mike        1.53      //
 633                       // Get all descendent classes of this class:
 634                       //
 635 mike        1.51  
 636 mike        1.48      className = instanceName.getClassName();
 637                   
 638 kumpf       1.85      Array<CIMName> classNames;
 639 kumpf       1.94      classNames.append(className);
 640 mike        1.48      _nameSpaceManager.getSubClassNames(nameSpace, className, true, classNames);
 641                   
 642 mike        1.53      //
 643                       // Get all superclasses of this one:
 644                       //
 645 mike        1.48  
 646                       if (searchSuperClasses)
 647 mike        1.51          _nameSpaceManager.getSuperClassNames(nameSpace, className, classNames);
 648 mike        1.48  
 649 mike        1.53      //
 650                       // Get instance names from each qualifying instance file for the class:
 651                       //
 652 mike        1.48  
 653                       for (Uint32 i = 0; i < classNames.size(); i++)
 654                       {
 655 kumpf       1.68          CIMObjectPath tmpInstanceName = instanceName;
 656 mike        1.51          tmpInstanceName.setClassName(classNames[i]);
 657 mike        1.48  
 658 kumpf       1.104     //
 659 karl        1.98      // Lookup index of instance:
 660 kumpf       1.104     //
 661 mike        1.48  
 662 mike        1.53          String path = _getInstanceIndexFilePath(nameSpace, classNames[i]);
 663 mike        1.48  
 664 mike        1.53          if (InstanceIndexFile::lookupEntry(path, tmpInstanceName, index, size))
 665 mike        1.51          {
 666                               className = classNames[i];
 667 kumpf       1.58              PEG_METHOD_EXIT();
 668 mike        1.51              return true;
 669                           }
 670 mike        1.48      }
 671                   
 672 kumpf       1.58      PEG_METHOD_EXIT();
 673 mike        1.48      return false;
 674                   }
 675                   
 676                   CIMInstance CIMRepository::getInstance(
 677 kumpf       1.85      const CIMNamespaceName& nameSpace,
 678 kumpf       1.68      const CIMObjectPath& instanceName,
 679 mike        1.48      Boolean localOnly,
 680                       Boolean includeQualifiers,
 681                       Boolean includeClassOrigin,
 682 mike        1.55      const CIMPropertyList& propertyList)
 683 mike        1.48  {
 684 kumpf       1.58      PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::getInstance");
 685                   
 686 kumpf       1.104     ReadLock lock(_lock);
 687                       CIMInstance cimInstance = _getInstance(nameSpace,
 688                                                              instanceName,
 689                                                              localOnly,
 690                                                              includeQualifiers,
 691                                                              includeClassOrigin,
 692                                                              propertyList);
 693                   
 694                       PEG_METHOD_EXIT();
 695                       return cimInstance;
 696                   }
 697                   
 698                   CIMInstance CIMRepository::_getInstance(
 699                       const CIMNamespaceName& nameSpace,
 700                       const CIMObjectPath& instanceName,
 701                       Boolean localOnly,
 702                       Boolean includeQualifiers,
 703                       Boolean includeClassOrigin,
 704                       const CIMPropertyList& propertyList)
 705                   {
 706                       PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_getInstance");
 707 kumpf       1.104 
 708 mike        1.53      //
 709 r.kieninger 1.125     // Validate namespace
 710                       //
 711                       if ((!instanceName.getNameSpace().isNull()) &&
 712                           (!instanceName.getNameSpace().equal(nameSpace)))
 713                       {
 714                           PEG_METHOD_EXIT();
 715                           throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND,
 716                                                          instanceName.toString());
 717                       }
 718                   
 719                       //
 720 mike        1.53      // Get the index for this instance:
 721                       //
 722 mike        1.48  
 723 kumpf       1.85      CIMName className;
 724 mike        1.48      Uint32 index;
 725 mike        1.51      Uint32 size;
 726                   
 727 mike        1.53      if (!_getInstanceIndex(nameSpace, instanceName, className, index, size))
 728 mike        1.48      {
 729 kumpf       1.104         PEG_METHOD_EXIT();
 730 mike        1.51          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND, instanceName.toString());
 731 mike        1.48      }
 732                   
 733 mike        1.53      //
 734                       // Load the instance from file:
 735                       //
 736 mike        1.48  
 737 mike        1.53      String path = _getInstanceDataFilePath(nameSpace, className);
 738 mike        1.48      CIMInstance cimInstance;
 739 mike        1.53  
 740 mike        1.51      if (!_loadInstance(path, cimInstance, index, size))
 741                       {
 742 kumpf       1.104         PEG_METHOD_EXIT();
 743 mike        1.51          throw CannotOpenFile(path);
 744                       }
 745                   
 746 mike        1.54      //
 747                       // Resolve the instance (if requested):
 748                       //
 749                   
 750                       if (_resolveInstance)
 751                       {
 752 kumpf       1.104         CIMConstClass cimClass;
 753                           Resolver::resolveInstance (cimInstance, _context, nameSpace, cimClass,
 754 kumpf       1.76              true);
 755 mike        1.54      }
 756 kumpf       1.99  
 757 karl        1.101     _filterInstance(cimInstance, propertyList, localOnly, includeQualifiers, includeClassOrigin);
 758 kumpf       1.104 
 759 kumpf       1.52      PEG_METHOD_EXIT();
 760 mike        1.48      return cimInstance;
 761                   }
 762                   
 763                   void CIMRepository::deleteClass(
 764 kumpf       1.85      const CIMNamespaceName& nameSpace,
 765                       const CIMName& className)
 766 mike        1.48  {
 767 kumpf       1.61      PEG_METHOD_ENTER(TRC_REPOSITORY,"CIMRepository::deleteClass");
 768 kumpf       1.58  
 769 kumpf       1.104     WriteLock lock(_lock);
 770                   
 771 mike        1.53      //
 772                       // Get the class and check to see if it is an association class:
 773                       //
 774 mike        1.51  
 775 kumpf       1.104     CIMClass cimClass = _getClass(
 776                           nameSpace, className, false, true, false, CIMPropertyList());
 777 mike        1.48      Boolean isAssociation = cimClass.isAssociation();
 778                   
 779 mike        1.53      //
 780                       // Delete the class. The NameSpaceManager::deleteClass() method throws
 781 karl        1.97      // an exception if the class has subclasses.
 782 mike        1.53      //
 783 kumpf       1.58      try
 784                       {
 785                           _nameSpaceManager.deleteClass(nameSpace, className);
 786                       }
 787                       catch (CIMException& e)
 788                       {
 789                           PEG_METHOD_EXIT();
 790                           throw e;
 791                       }
 792 mike        1.48  
 793 mike        1.53      //
 794 karl        1.97      // Remove associations:
 795 mike        1.53      //
 796 mike        1.48  
 797                       if (isAssociation)
 798                       {
 799 schuur      1.112         Array<String> assocFileName = _nameSpaceManager.getAssocClassPath(nameSpace,NameSpaceDelete);
 800 mike        1.48  
 801 schuur      1.112         if (FileSystem::exists(assocFileName[0]))
 802                               AssocClassTable::deleteAssociation(assocFileName[0], className);
 803 mike        1.48      }
 804 kumpf       1.104 
 805 kumpf       1.58      PEG_METHOD_EXIT();
 806 mike        1.48  }
 807                   
 808 mike        1.53  void _CompactInstanceRepository(
 809 kumpf       1.104     const String& indexFilePath,
 810 mike        1.53      const String& dataFilePath)
 811                   {
 812 kumpf       1.58      PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_CompactInstanceRepository");
 813                   
 814 mike        1.53      //
 815                       // Compact the data file first:
 816                       //
 817                   
 818                       Array<Uint32> freeFlags;
 819                       Array<Uint32> indices;
 820                       Array<Uint32> sizes;
 821 kumpf       1.68      Array<CIMObjectPath> instanceNames;
 822 mike        1.53  
 823 kumpf       1.104     if (!InstanceIndexFile::enumerateEntries(
 824                               indexFilePath, freeFlags, indices, sizes, instanceNames, true))
 825 mike        1.53      {
 826 kumpf       1.58          PEG_METHOD_EXIT();
 827 kumpf       1.104         //l10n
 828 humberto    1.88          //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "compact failed");
 829                           throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
 830 kumpf       1.99              MessageLoaderParms("Repository.CIMRepository.COMPACT_FAILED",
 831                                   "compact failed"));
 832 humberto    1.88          //l10n end
 833 mike        1.53      }
 834                   
 835                       if (!InstanceDataFile::compact(dataFilePath, freeFlags, indices, sizes))
 836 kumpf       1.58      {
 837                           PEG_METHOD_EXIT();
 838 humberto    1.88          //l10n
 839                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "compact failed");
 840 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
 841                               MessageLoaderParms("Repository.CIMRepository.COMPACT_FAILED",
 842                                   "compact failed"));
 843 humberto    1.88          //l10n end
 844 kumpf       1.58      }
 845 mike        1.53  
 846                       //
 847                       // Now compact the index file:
 848                       //
 849                   
 850                       if (!InstanceIndexFile::compact(indexFilePath))
 851 kumpf       1.58      {
 852                           PEG_METHOD_EXIT();
 853 humberto    1.88          //l10n
 854                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "compact failed");
 855 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
 856                               MessageLoaderParms("Repository.CIMRepository.COMPACT_FAILED",
 857                                   "compact failed"));
 858 humberto    1.88          //l10n end
 859 kumpf       1.58      }
 860                   
 861                       PEG_METHOD_EXIT();
 862 mike        1.53  }
 863                   
 864 mike        1.48  void CIMRepository::deleteInstance(
 865 kumpf       1.85      const CIMNamespaceName& nameSpace,
 866 kumpf       1.68      const CIMObjectPath& instanceName)
 867 mike        1.48  {
 868 mike        1.53      PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::deleteInstance");
 869 mike        1.51  
 870 r.kieninger 1.125     //
 871                       // Validate namespace
 872                       //
 873                       if ((!instanceName.getNameSpace().isNull()) &&
 874                           (!instanceName.getNameSpace().equal(nameSpace)))
 875                       {
 876                           PEG_METHOD_EXIT();
 877                           throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND,
 878                                                       instanceName.toString());
 879                       }
 880                   
 881 kumpf       1.104     WriteLock lock(_lock);
 882                   
 883 mike        1.51      String errMessage;
 884                   
 885 mike        1.53      //
 886                       // Get paths of index and data files:
 887                       //
 888                   
 889                       String indexFilePath = _getInstanceIndexFilePath(
 890                           nameSpace, instanceName.getClassName());
 891 mike        1.48  
 892 mike        1.53      String dataFilePath = _getInstanceDataFilePath(
 893 mike        1.51          nameSpace, instanceName.getClassName());
 894 mike        1.48  
 895 mike        1.53      //
 896 kumpf       1.104     // Attempt rollback (if there are no rollback files, this will have no
 897                       // effect). This code is here to rollback uncommitted changes left over
 898 mike        1.53      // from last time an instance-oriented function was called.
 899                       //
 900                   
 901                       if (!InstanceIndexFile::rollbackTransaction(indexFilePath))
 902                       {
 903                           PEG_METHOD_EXIT();
 904 humberto    1.88          //l10n
 905                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "rollback failed");
 906 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
 907                               MessageLoaderParms("Repository.CIMRepository.ROLLBACK_FAILED",
 908                                   "rollback failed"));
 909 humberto    1.88          //l10n end
 910 mike        1.53      }
 911                   
 912                       if (!InstanceDataFile::rollbackTransaction(dataFilePath))
 913                       {
 914                           PEG_METHOD_EXIT();
 915 humberto    1.88          //l10n
 916                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "rollback failed");
 917 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
 918                               MessageLoaderParms("Repository.CIMRepository.ROLLBACK_FAILED",
 919                                   "rollback failed"));
 920 humberto    1.88          //l10n end
 921 mike        1.53      }
 922                   
 923                       //
 924                       // Lookup instance from the index file (raise error if not found).
 925                       //
 926                   
 927 mike        1.48      Uint32 index;
 928 mike        1.51      Uint32 size;
 929 mike        1.48  
 930 mike        1.53      if (!InstanceIndexFile::lookupEntry(
 931 kumpf       1.104             indexFilePath, instanceName, index, size))
 932 kumpf       1.52      {
 933                           PEG_METHOD_EXIT();
 934 mike        1.51          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND, instanceName.toString());
 935 kumpf       1.52      }
 936 mike        1.48  
 937 mike        1.53      //
 938                       // Begin the transaction (any return prior to commit will cause
 939                       // a rollback next time an instance-oriented routine is invoked).
 940                       //
 941                   
 942                       if (!InstanceIndexFile::beginTransaction(indexFilePath))
 943                       {
 944                           PEG_METHOD_EXIT();
 945 humberto    1.88          //l10n
 946                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "begin failed");
 947 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
 948                               MessageLoaderParms("Repository.CIMRepository.BEGIN_FAILED",
 949                                   "begin failed"));
 950 humberto    1.88          //l10n end
 951 mike        1.53      }
 952 mike        1.48  
 953 mike        1.53      if (!InstanceDataFile::beginTransaction(dataFilePath))
 954 mike        1.48      {
 955 kumpf       1.52          PEG_METHOD_EXIT();
 956 humberto    1.88          //l10n
 957                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "begin failed");
 958 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
 959                               MessageLoaderParms("Repository.CIMRepository.BEGIN_FAILED",
 960                                   "begin failed"));
 961 humberto    1.88          //l10n end
 962 mike        1.48      }
 963                   
 964 mike        1.53      //
 965                       // Remove entry from index file.
 966                       //
 967 mike        1.48  
 968 mike        1.53      Uint32 freeCount;
 969 mike        1.48  
 970 mike        1.53      if (!InstanceIndexFile::deleteEntry(indexFilePath, instanceName, freeCount))
 971 mike        1.48      {
 972 kumpf       1.104         //l10n
 973 humberto    1.88          //errMessage.append("Failed to delete instance: ");
 974                           //errMessage.append(instanceName.toString());
 975                           PEG_METHOD_EXIT();
 976                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, errMessage);
 977 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
 978                               MessageLoaderParms(
 979                                   "Repository.CIMRepository.FAILED_TO_DELETE_INSTANCE",
 980 kumpf       1.104                 "Failed to delete instance: $0",
 981 kumpf       1.99                  instanceName.toString()));
 982 humberto    1.88          //l10n end
 983 mike        1.48      }
 984                   
 985 mike        1.53      //
 986                       // Commit the transaction:
 987                       //
 988 mike        1.51  
 989 mike        1.53      if (!InstanceIndexFile::commitTransaction(indexFilePath))
 990                       {
 991                           PEG_METHOD_EXIT();
 992 humberto    1.88          //l10n
 993                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "commit failed");
 994 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
 995                               MessageLoaderParms("Repository.CIMRepository.COMMIT_FAILED",
 996                                   "commit failed"));
 997 humberto    1.88          //l10n end
 998 mike        1.53      }
 999                   
1000                       if (!InstanceDataFile::commitTransaction(dataFilePath))
1001 mike        1.48      {
1002 kumpf       1.52          PEG_METHOD_EXIT();
1003 humberto    1.88          //l10n
1004                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "commit failed");
1005 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1006                               MessageLoaderParms("Repository.CIMRepository.COMMIT_FAILED",
1007                                   "commit failed"));
1008 humberto    1.88          //l10n end
1009 mike        1.48      }
1010                   
1011 mike        1.53      //
1012                       // Compact the index and data files if the free count max was
1013                       // reached.
1014                       //
1015                   
1016                       if (freeCount == _MAX_FREE_COUNT)
1017 kumpf       1.104         _CompactInstanceRepository(indexFilePath, dataFilePath);
1018 mike        1.53  
1019                       //
1020                       // Delete from assocation table (if an assocation).
1021                       //
1022 mike        1.48  
1023 kumpf       1.91      String assocFileName = _nameSpaceManager.getAssocInstPath(nameSpace);
1024 mike        1.48  
1025                       if (FileSystem::exists(assocFileName))
1026 mike        1.51          AssocInstTable::deleteAssociation(assocFileName, instanceName);
1027 kumpf       1.52  
1028                       PEG_METHOD_EXIT();
1029 mike        1.48  }
1030                   
1031                   void CIMRepository::_createAssocClassEntries(
1032 kumpf       1.85      const CIMNamespaceName& nameSpace,
1033 mike        1.48      const CIMConstClass& assocClass)
1034                   {
1035 kumpf       1.58      PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_createAssocClassEntries");
1036                   
1037 mike        1.48      // Open input file:
1038                   
1039 mike        1.51  
1040 schuur      1.112     Array<String> assocFileName = _nameSpaceManager.getAssocClassPath(nameSpace,NameSpaceWrite);
1041 mike        1.48      ofstream os;
1042                   
1043 schuur      1.112     if (!OpenAppend(os, assocFileName[0]))
1044 kumpf       1.58      {
1045                           PEG_METHOD_EXIT();
1046 schuur      1.112         throw CannotOpenFile(assocFileName[0]);
1047 kumpf       1.58      }
1048 mike        1.48  
1049                       // Get the association's class name:
1050                   
1051 kumpf       1.85      CIMName assocClassName = assocClass.getClassName();
1052 mike        1.48  
1053                       // For each property:
1054                   
1055                       Uint32 n = assocClass.getPropertyCount();
1056                   
1057                       for (Uint32 i = 0; i < n; i++)
1058                       {
1059 mike        1.51          CIMConstProperty fromProp = assocClass.getProperty(i);
1060 mike        1.48  
1061 kumpf       1.78          if (fromProp.getType() == CIMTYPE_REFERENCE)
1062 mike        1.51          {
1063                               for (Uint32 j = 0; j < n; j++)
1064                               {
1065                                   CIMConstProperty toProp = assocClass.getProperty(j);
1066                   
1067 kumpf       1.78                  if (toProp.getType() == CIMTYPE_REFERENCE &&
1068 kumpf       1.85                      (!fromProp.getName().equal (toProp.getName())))
1069 mike        1.51                  {
1070 kumpf       1.85                      CIMName fromClassName = fromProp.getReferenceClassName();
1071                                       CIMName fromPropertyName = fromProp.getName();
1072                                       CIMName toClassName = toProp.getReferenceClassName();
1073                                       CIMName toPropertyName = toProp.getName();
1074 mike        1.51  
1075                                       AssocClassTable::append(
1076                                           os,
1077                                           assocClassName,
1078                                           fromClassName,
1079                                           fromPropertyName,
1080                                           toClassName,
1081                                           toPropertyName);
1082                                   }
1083                               }
1084                           }
1085 mike        1.48      }
1086 kumpf       1.58  
1087                       PEG_METHOD_EXIT();
1088 mike        1.48  }
1089                   
1090                   void CIMRepository::createClass(
1091 kumpf       1.85      const CIMNamespaceName& nameSpace,
1092 chuck       1.110     const CIMClass& newClass,
1093                       const ContentLanguages& contentLangs)
1094 mike        1.48  {
1095 kumpf       1.58      PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::createClass");
1096                   
1097 chuck       1.110     if (contentLangs.size() > 0)
1098                       {
1099                         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
1100                               MessageLoaderParms("Repository.CIMRepository.UNSUPPORTED_CONTENTLANG",
1101                   			       "The Content-Language header is not supported for this request"));
1102                       }
1103                   
1104 kumpf       1.104     WriteLock lock(_lock);
1105                       _createClass(nameSpace, newClass);
1106                   
1107                       PEG_METHOD_EXIT();
1108                   }
1109                   
1110                   void CIMRepository::_createClass(
1111                       const CIMNamespaceName& nameSpace,
1112                       const CIMClass& newClass)
1113                   {
1114                       PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_createClass");
1115                   
1116 mike        1.48      // -- Resolve the class:
1117 mike        1.51          CIMClass cimClass(newClass);
1118 kumpf       1.104 
1119 kumpf       1.76      Resolver::resolveClass (cimClass, _context, nameSpace);
1120 mike        1.48  
1121                       // -- If an association, populate associations file:
1122                   
1123                       if (cimClass.isAssociation())
1124 mike        1.51          _createAssocClassEntries(nameSpace, cimClass);
1125 mike        1.48  
1126                       // -- Create namespace manager entry:
1127                   
1128                       String classFilePath;
1129                   
1130                       _nameSpaceManager.createClass(nameSpace, cimClass.getClassName(),
1131 mike        1.51          cimClass.getSuperClassName(), classFilePath);
1132 mike        1.48  
1133                       // -- Create the class file:
1134                   
1135 kumpf       1.66      Array<Sint8> classXml;
1136 schuur      1.114     streamer->encode(classXml, cimClass);
1137                       //XmlWriter::appendClassElement(classXml, cimClass);
1138                       _SaveObject(classFilePath, classXml,streamer);
1139 kumpf       1.58  
1140                       PEG_METHOD_EXIT();
1141 mike        1.48  }
1142                   
1143                   /*------------------------------------------------------------------------------
1144                   
1145                       This routine does the following:
1146                   
1147 mike        1.51          1.  Creates two entries in the association file for each relationship
1148                               formed by this new assocation instance. A binary association
1149                               (one with two references) ties two instances together. Suppose
1150                               there are two instances: I1 and I2. Then two entries are created:
1151                   
1152                                   I2 -> I1
1153                                   I1 -> I2
1154                   
1155                               For a ternary relationship, six entries will be created. Suppose
1156                               there are three instances: I1, I2, and I3:
1157                   
1158                                   I1 -> I2
1159                                   I1 -> I3
1160                                   I2 -> I1
1161                                   I2 -> I3
1162                                   I3 -> I1
1163                                   I3 -> I2
1164                   
1165                               So for an N-ary relationship, there will be 2*N entries created.
1166                   
1167                           2.  Verifies that the association instance refers to real objects.
1168 mike        1.51              (note that an association reference may refer to either an instance
1169                               or a class). Throws an exception if one of the references does not
1170                               refer to a valid object.
1171 mike        1.48  
1172                   ------------------------------------------------------------------------------*/
1173                   
1174 r.kieninger 1.126 
1175                   /*------------------------------------------------------------------------------
1176                     Checks whether a hostname points to the local CIMOM
1177                   ------------------------------------------------------------------------------*/
1178 r.kieninger 1.128 static Boolean isLocalCIMOM( const String& hostname )
1179 r.kieninger 1.126 {
1180 r.kieninger 1.128    PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::isLocalCIMOM");
1181 r.kieninger 1.126 
1182                      // First do a brute force check for equality of the strings
1183                      if( String::equalNoCase(hostname,System::getHostName()))
1184                      {
1185                         PEG_METHOD_EXIT();
1186                         return true;
1187                      }
1188                   
1189                      // ------------------------------------------------------------------------
1190 r.kieninger 1.128    // Strip of the port numbers
1191 r.kieninger 1.126    // ------------------------------------------------------------------------
1192 r.kieninger 1.128    String hn = hostname;
1193 r.kieninger 1.126 
1194                      Uint32 index = hostname.find(':');
1195                      if ( index != PEG_NOT_FOUND )
1196                      {
1197                         hn = hostname.subString(0,index);
1198                      }
1199                   
1200                      // ------------------------------------------------------------------------
1201                      // Normalize hostname into a a single host unique integer representation
1202                      // and compare against the equivalent for the local CIMOM, if not localhost.
1203                      // ------------------------------------------------------------------------
1204                      Uint32 hostIP = System::_acquireIP((const char*) hn.getCString());
1205                   
1206                      // Check if localhost or 127.0.0.x
1207                      if (hostIP == 0x7F000001)
1208                      {
1209                         PEG_METHOD_EXIT();
1210                         return true;
1211                      }
1212                   
1213                      Uint32 localHostIP = System::_acquireIP((const char*) System::getHostName().getCString());
1214 r.kieninger 1.126 
1215                      PEG_METHOD_EXIT();
1216                      return hostIP == localHostIP;
1217                   }
1218                   
1219                   
1220 mike        1.48  void CIMRepository::_createAssocInstEntries(
1221 kumpf       1.85      const CIMNamespaceName& nameSpace,
1222 mike        1.48      const CIMConstClass& cimClass,
1223                       const CIMInstance& cimInstance,
1224 kumpf       1.68      const CIMObjectPath& instanceName)
1225 mike        1.48  {
1226 kumpf       1.58      PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_createAssocInstEntries");
1227                   
1228 mike        1.48      // Open input file:
1229                   
1230 kumpf       1.91      String assocFileName = _nameSpaceManager.getAssocInstPath(nameSpace);
1231 mike        1.48      ofstream os;
1232                   
1233                       if (!OpenAppend(os, assocFileName))
1234 kumpf       1.58      {
1235                           PEG_METHOD_EXIT();
1236 mike        1.51          throw CannotOpenFile(assocFileName);
1237 kumpf       1.58      }
1238 mike        1.48  
1239                       // Get the association's instance name and class name:
1240                   
1241                       String assocInstanceName = instanceName.toString();
1242 kumpf       1.85      CIMName assocClassName = instanceName.getClassName();
1243 mike        1.48  
1244                       // For each property:
1245                   
1246                       for (Uint32 i = 0, n = cimInstance.getPropertyCount(); i < n; i++)
1247                       {
1248 mike        1.51          CIMConstProperty fromProp = cimInstance.getProperty(i);
1249 mike        1.48  
1250 mike        1.51          // If a reference property:
1251 mike        1.48  
1252 kumpf       1.78          if (fromProp.getType() == CIMTYPE_REFERENCE)
1253 mike        1.51          {
1254                               // For each property:
1255                   
1256                               for (Uint32 j = 0, n = cimInstance.getPropertyCount(); j < n; j++)
1257                               {
1258                                   CIMConstProperty toProp = cimInstance.getProperty(j);
1259                   
1260                                   // If a reference property and not the same property:
1261                   
1262 kumpf       1.78                  if (toProp.getType() == CIMTYPE_REFERENCE &&
1263 kumpf       1.85                      (!fromProp.getName().equal (toProp.getName())))
1264 mike        1.51                  {
1265 kumpf       1.68                      CIMObjectPath fromRef;
1266 mike        1.51                      fromProp.getValue().get(fromRef);
1267                   
1268 kumpf       1.68                      CIMObjectPath toRef;
1269 mike        1.51                      toProp.getValue().get(toRef);
1270                   
1271 r.kieninger 1.126 
1272                                       // Fix for bugzilla 667:
1273                                       // Strip off the hostname if it is the same as the local host
1274                                       if ((fromRef.getHost() != String::EMPTY) &&
1275 r.kieninger 1.128                         (isLocalCIMOM(fromRef.getHost())))
1276 r.kieninger 1.126                     {
1277                                          PEG_TRACE_STRING(TRC_REPOSITORY, Tracer::LEVEL4, "_createAssocInstEntries() - Stripping of local hostName from fromRef");
1278                                          fromRef.setHost(String::EMPTY);
1279                                       }
1280                   
1281                                       // Strip off the namespace when it is the same as the
1282                                       // one this instance is created in.
1283                                       if ((fromRef.getHost() == String::EMPTY) &&
1284                                           (fromRef.getNameSpace() == nameSpace))
1285                                       {
1286                                          PEG_TRACE_STRING(TRC_REPOSITORY, Tracer::LEVEL4, "_createAssocInstEntries() - Stripping of local nameSpace from fromRef");
1287                                          fromRef.setNameSpace(CIMNamespaceName());
1288                                       }
1289                   
1290                                       // Strip off the hostname if it is the same as the local host
1291                                       if ((toRef.getHost() != String::EMPTY) &&
1292 r.kieninger 1.128                         (isLocalCIMOM(toRef.getHost())))
1293 r.kieninger 1.126                     {
1294                                          PEG_TRACE_STRING(TRC_REPOSITORY, Tracer::LEVEL4, "_createAssocInstEntries() - Stripping of local hostName from toRef");
1295                                          toRef.setHost(String::EMPTY);
1296                                       }
1297                   
1298                                       // Strip off the namespace when it is the same as the
1299                                       // one this instance is created in.
1300                                       if ((toRef.getHost() == String::EMPTY) &&
1301                                           (toRef.getNameSpace() == nameSpace))
1302                                       {
1303                                          PEG_TRACE_STRING(TRC_REPOSITORY, Tracer::LEVEL4, "_createAssocInstEntries() - Stripping of local nameSpace from toRef");
1304                                          toRef.setNameSpace(CIMNamespaceName());
1305                                       }
1306                   
1307                   
1308 mike        1.51                      String fromObjectName = fromRef.toString();
1309 kumpf       1.85                      CIMName fromClassName = fromRef.getClassName();
1310                                       CIMName fromPropertyName = fromProp.getName();
1311 mike        1.51                      String toObjectName = toRef.toString();
1312 kumpf       1.85                      CIMName toClassName = toRef.getClassName();
1313                                       CIMName toPropertyName = toProp.getName();
1314 mike        1.51  
1315                                       AssocInstTable::append(
1316                                           os,
1317                                           assocInstanceName,
1318                                           assocClassName,
1319                                           fromObjectName,
1320                                           fromClassName,
1321                                           fromPropertyName,
1322                                           toObjectName,
1323                                           toClassName,
1324                                           toPropertyName);
1325                                   }
1326                               }
1327                           }
1328 mike        1.48      }
1329 kumpf       1.58  
1330                       PEG_METHOD_EXIT();
1331 mike        1.48  }
1332                   
1333 kumpf       1.68  CIMObjectPath CIMRepository::createInstance(
1334 kumpf       1.85      const CIMNamespaceName& nameSpace,
1335 chuck       1.110     const CIMInstance& newInstance,
1336                       const ContentLanguages& contentLangs)
1337 mike        1.48  {
1338 kumpf       1.61      PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::createInstance");
1339 mike        1.51  
1340 chuck       1.110     if (contentLangs.size() > 0)
1341                       {
1342                         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
1343                               MessageLoaderParms("Repository.CIMRepository.UNSUPPORTED_CONTENTLANG",
1344                   			       "The Content-Language header is not supported for this request"));
1345                       }
1346                   
1347 kumpf       1.104     WriteLock lock(_lock);
1348                       CIMObjectPath instanceName = _createInstance(nameSpace, newInstance);
1349                   
1350                       PEG_METHOD_EXIT();
1351                       return instanceName;
1352                   }
1353                   
1354                   CIMObjectPath CIMRepository::_createInstance(
1355                       const CIMNamespaceName& nameSpace,
1356                       const CIMInstance& newInstance)
1357                   {
1358                       PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_createInstance");
1359                   
1360 mike        1.51      String errMessage;
1361                   
1362 mike        1.53      //
1363                       // Get paths to data and index files:
1364                       //
1365                   
1366                       String dataFilePath = _getInstanceDataFilePath(
1367 kumpf       1.104         nameSpace, newInstance.getClassName());
1368 mike        1.53  
1369                       String indexFilePath = _getInstanceIndexFilePath(
1370                           nameSpace, newInstance.getClassName());
1371                   
1372                       //
1373 kumpf       1.104     // Attempt rollback (if there are no rollback files, this will have no
1374                       // effect). This code is here to rollback uncommitted changes left over
1375 mike        1.53      // from last time an instance-oriented function was called.
1376                       //
1377                   
1378                       if (!InstanceIndexFile::rollbackTransaction(indexFilePath))
1379                       {
1380                           PEG_METHOD_EXIT();
1381 humberto    1.88          //l10n
1382                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "rollback failed");
1383 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1384                               MessageLoaderParms("Repository.CIMRepository.ROLLBACK_FAILED",
1385                                   "rollback failed"));
1386 humberto    1.88          //l10n end
1387 mike        1.53      }
1388                   
1389                       if (!InstanceDataFile::rollbackTransaction(dataFilePath))
1390                       {
1391                           PEG_METHOD_EXIT();
1392 humberto    1.88          //l10n
1393                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "rollback failed");
1394 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1395                               MessageLoaderParms(
1396                                   "Repository.CIMRepository.ROLLBACK_FAILED",
1397                                   "rollback failed"));
1398 humberto    1.88          //l10n end
1399 mike        1.53      }
1400                   
1401                       //
1402 mike        1.54      // Resolve the instance. Looks up class and fills out properties but
1403                       // not the qualifiers.
1404 mike        1.53      //
1405                   
1406 mike        1.51      CIMInstance cimInstance(newInstance);
1407 mike        1.48      CIMConstClass cimClass;
1408 kumpf       1.104     Resolver::resolveInstance (cimInstance, _context, nameSpace, cimClass,
1409 kumpf       1.76          false);
1410 kumpf       1.81      CIMObjectPath instanceName = cimInstance.buildPath(cimClass);
1411 mike        1.48  
1412 mike        1.53      //
1413                       // Make sure the class has keys (otherwise it will be impossible to
1414                       // create the instance).
1415                       //
1416 mike        1.48  
1417                       if (!cimClass.hasKeys())
1418                       {
1419 kumpf       1.104         //l10n
1420                           //errMessage = "class has no keys: " +
1421 humberto    1.88              //cimClass.getClassName().getString();
1422                           PEG_METHOD_EXIT();
1423 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1424                               MessageLoaderParms("Repository.CIMRepository.CLASS_HAS_NO_KEYS",
1425 kumpf       1.104                 "class has no keys: $0",
1426 kumpf       1.99                  cimClass.getClassName().getString()));
1427 humberto    1.88          //l10n end
1428 mike        1.48      }
1429                   
1430 mike        1.53      //
1431                       // Be sure instance does not already exist:
1432                       //
1433 mike        1.48  
1434 kumpf       1.85      CIMName className;
1435 mike        1.48      Uint32 dummyIndex;
1436 mike        1.51      Uint32 dummySize;
1437 mike        1.48  
1438 kumpf       1.104     if (_getInstanceIndex(nameSpace, instanceName, className, dummyIndex,
1439 mike        1.53          dummySize, true))
1440 mike        1.48      {
1441 kumpf       1.52          PEG_METHOD_EXIT();
1442 kumpf       1.104         throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ALREADY_EXISTS,
1443 mike        1.51              instanceName.toString());
1444 mike        1.48      }
1445                   
1446 mike        1.53      //
1447                       // Create association entries if an association instance.
1448                       //
1449 mike        1.48  
1450                       if (cimClass.isAssociation())
1451 mike        1.53          _createAssocInstEntries(nameSpace, cimClass, cimInstance, instanceName);
1452                   
1453                       //
1454                       // Begin the transaction (any return prior to commit will cause
1455                       // a rollback next time an instance-oriented routine is invoked).
1456                       //
1457                   
1458                       if (!InstanceIndexFile::beginTransaction(indexFilePath))
1459 mike        1.48      {
1460 mike        1.53          PEG_METHOD_EXIT();
1461 humberto    1.88          //l10n
1462                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "begin failed");
1463 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1464                               MessageLoaderParms("Repository.CIMRepository.BEGIN_FAILED",
1465                                   "begin failed"));
1466 humberto    1.88          //l10n end
1467 mike        1.48      }
1468                   
1469 mike        1.53      if (!InstanceDataFile::beginTransaction(dataFilePath))
1470                       {
1471                           PEG_METHOD_EXIT();
1472 humberto    1.88          //l10n
1473                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "begin failed");
1474 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1475                               MessageLoaderParms("Repository.CIMRepository.BEGIN_FAILED",
1476                                   "begin failed"));
1477 humberto    1.88          //l10n end
1478 mike        1.53      }
1479 mike        1.48  
1480 mike        1.53      //
1481                       // Save instance to file:
1482                       //
1483 mike        1.51  
1484                       Uint32 index;
1485                       Uint32 size;
1486 mike        1.53  
1487 mike        1.51      {
1488 kumpf       1.104         Array<Sint8> data;
1489 schuur      1.114         streamer->encode(data, cimInstance);
1490                           // XmlWriter::appendInstanceElement(data, cimInstance);
1491 kumpf       1.104         size = data.size();
1492                   
1493                           if (!InstanceDataFile::appendInstance(dataFilePath, data, index))
1494                           {
1495                               //l10n
1496                               //errMessage.append("Failed to create instance: ");
1497                               //errMessage.append(instanceName.toString());
1498                               PEG_METHOD_EXIT();
1499                               //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, errMessage);
1500                               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1501 kumpf       1.99                  MessageLoaderParms(
1502                                       "Repository.CIMRepository.FAILED_TO_CREATE_INSTANCE",
1503 kumpf       1.104                     "Failed to create instance: $0",
1504 kumpf       1.99                      instanceName.toString()));
1505 kumpf       1.104             //l10n end
1506                           }
1507 mike        1.53      }
1508                   
1509                       //
1510                       // Create entry in index file:
1511                       //
1512                   
1513                       if (!InstanceIndexFile::createEntry(
1514 kumpf       1.104             indexFilePath, instanceName, index, size))
1515 mike        1.53      {
1516 kumpf       1.104         //l10n
1517 humberto    1.88          //errMessage.append("Failed to create instance: ");
1518                           //errMessage.append(instanceName.toString());
1519                           PEG_METHOD_EXIT();
1520                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, errMessage);
1521 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1522                               MessageLoaderParms(
1523                                   "Repository.CIMRepository.FAILED_TO_CREATE_INSTANCE",
1524 kumpf       1.104                 "Failed to create instance: $0",
1525 kumpf       1.99                  instanceName.toString()));
1526 kumpf       1.104         //l10n end
1527 mike        1.51      }
1528 mike        1.48  
1529 mike        1.53      //
1530                       // Commit the changes:
1531                       //
1532 mike        1.48  
1533 mike        1.53      if (!InstanceIndexFile::commitTransaction(indexFilePath))
1534 mike        1.51      {
1535 kumpf       1.52          PEG_METHOD_EXIT();
1536 humberto    1.88          //l10n
1537                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "commit failed");
1538 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1539                               MessageLoaderParms("Repository.CIMRepository.COMMIT_FAILED",
1540                                   "commit failed"));
1541 humberto    1.88          //l10n end
1542 mike        1.51      }
1543 mike        1.48  
1544 mike        1.53      if (!InstanceDataFile::commitTransaction(dataFilePath))
1545 mike        1.51      {
1546 kumpf       1.52          PEG_METHOD_EXIT();
1547 humberto    1.88          //l10n
1548                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "commit failed");
1549 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1550                               MessageLoaderParms("Repository.CIMRepository.COMMIT_FAILED",
1551                                   "commit failed"));
1552 humberto    1.88          //l10n end
1553 mike        1.51      }
1554 mike        1.53  
1555 kumpf       1.104     Resolver::resolveInstance (cimInstance, _context, nameSpace, cimClass,
1556 kumpf       1.76          true);
1557 mike        1.54  
1558 kumpf       1.52      PEG_METHOD_EXIT();
1559 mike        1.53      return instanceName;
1560 mike        1.48  }
1561                   
1562                   void CIMRepository::modifyClass(
1563 kumpf       1.85      const CIMNamespaceName& nameSpace,
1564 chuck       1.110     const CIMClass& modifiedClass,
1565                       const ContentLanguages& contentLangs)
1566 mike        1.48  {
1567 kumpf       1.58      PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::modifyClass");
1568                   
1569 chuck       1.110     if (contentLangs.size() > 0)
1570                       {
1571                         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
1572                               MessageLoaderParms("Repository.CIMRepository.UNSUPPORTED_CONTENTLANG",
1573                   			       "The Content-Language header is not supported for this request"));
1574                       }
1575                   
1576 kumpf       1.104     WriteLock lock(_lock);
1577                       _modifyClass(nameSpace, modifiedClass);
1578                   
1579                       PEG_METHOD_EXIT();
1580                   }
1581                   
1582                   void CIMRepository::_modifyClass(
1583                       const CIMNamespaceName& nameSpace,
1584                       const CIMClass& modifiedClass)
1585                   {
1586                       PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_modifyClass");
1587                   
1588 mike        1.53      //
1589                       // Resolve the class:
1590                       //
1591 mike        1.51  
1592 mike        1.53      CIMClass cimClass(modifiedClass);
1593 kumpf       1.76      Resolver::resolveClass (cimClass, _context, nameSpace);
1594 mike        1.48  
1595 mike        1.53      //
1596                       // Check to see if it is okay to modify this class:
1597                       //
1598 mike        1.48  
1599                       String classFilePath;
1600                   
1601                       _nameSpaceManager.checkModify(nameSpace, cimClass.getClassName(),
1602 mike        1.51          cimClass.getSuperClassName(), classFilePath);
1603 mike        1.48  
1604 mike        1.53      //
1605                       // ATTN: KS
1606                       // Disallow modification of classes which have instances (that are
1607                       // in the repository). And we have no idea whether the class has
1608                       // instances in other repositories or in providers. We should do
1609                       // an enumerate instance names at a higher level (above the repository).
1610                       //
1611 chip        1.118 
1612 mike        1.53  
1613                       //
1614                       // Delete the old file containing the class:
1615                       //
1616 mike        1.48  
1617                       if (!FileSystem::removeFileNoCase(classFilePath))
1618                       {
1619 kumpf       1.58          PEG_METHOD_EXIT();
1620 humberto    1.88          //l10n
1621                           String str = "CIMRepository::modifyClass()";
1622                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1623                               //"failed to remove file in CIMRepository::modifyClass()");
1624 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1625                               MessageLoaderParms(
1626                                   "Repository.CIMRepository.FAILED_TO_REMOVE_FILE",
1627                                   "failed to remove file in $0", str));
1628 humberto    1.88          //l10n end
1629 mike        1.48      }
1630                   
1631 mike        1.53      //
1632                       // Create new class file:
1633                       //
1634 mike        1.48  
1635 kumpf       1.66      Array<Sint8> classXml;
1636 schuur      1.114     streamer->encode(classXml, cimClass);
1637                       //XmlWriter::appendClassElement(classXml, cimClass);
1638                       _SaveObject(classFilePath, classXml,streamer);
1639 kumpf       1.58  
1640 konrad.r    1.111     if (cimClass.isAssociation()) {
1641                         // Remove from Association
1642 schuur      1.112       Array<String> assocFileName =
1643                            _nameSpaceManager.getAssocClassPath(nameSpace,NameSpaceDelete);
1644                         if (FileSystem::exists(assocFileName[0])) {
1645                   	AssocClassTable::deleteAssociation(assocFileName[0], cimClass.getClassName());
1646 konrad.r    1.111 	// Create the association again.
1647                   	_createAssocClassEntries(nameSpace, cimClass);
1648 chip        1.118       }
1649 konrad.r    1.111       else
1650                   	{
1651                   	  PEG_METHOD_EXIT();
1652 schuur      1.112 	  throw CannotOpenFile(assocFileName[0]);
1653 konrad.r    1.111 	}
1654                       }
1655                   
1656 kumpf       1.58      PEG_METHOD_EXIT();
1657 mike        1.48  }
1658                   
1659                   void CIMRepository::modifyInstance(
1660 kumpf       1.85      const CIMNamespaceName& nameSpace,
1661 kumpf       1.70      const CIMInstance& modifiedInstance,
1662 mike        1.51      Boolean includeQualifiers,
1663 chuck       1.110     const CIMPropertyList& propertyList,
1664                       const ContentLanguages& contentLangs)
1665 mike        1.48  {
1666 kumpf       1.58      PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::modifyInstance");
1667                   
1668 chuck       1.110     if (contentLangs.size() > 0)
1669                       {
1670                         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
1671                               MessageLoaderParms("Repository.CIMRepository.UNSUPPORTED_CONTENTLANG",
1672                   			       "The Content-Language header is not supported for this request"));
1673                       }
1674                   
1675 kumpf       1.104     WriteLock lock(_lock);
1676                   
1677 mike        1.53      //
1678                       // Get paths of index and data files:
1679                       //
1680 mike        1.51  
1681 kumpf       1.70      const CIMInstance& instance = modifiedInstance;
1682 mike        1.53  
1683                       String indexFilePath = _getInstanceIndexFilePath(
1684                           nameSpace, instance.getClassName());
1685                   
1686                       String dataFilePath = _getInstanceDataFilePath(
1687                           nameSpace, instance.getClassName());
1688                   
1689                       //
1690                       // First attempt rollback:
1691                       //
1692                   
1693                       if (!InstanceIndexFile::rollbackTransaction(indexFilePath))
1694 kumpf       1.58      {
1695                           PEG_METHOD_EXIT();
1696 humberto    1.88          //l10n
1697                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "rollback failed");
1698 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1699                               MessageLoaderParms("Repository.CIMRepository.ROLLBACK_FAILED",
1700                                   "rollback failed"));
1701 humberto    1.88          //l10n end
1702 kumpf       1.58      }
1703 mike        1.53  
1704                       if (!InstanceDataFile::rollbackTransaction(dataFilePath))
1705 kumpf       1.58      {
1706                           PEG_METHOD_EXIT();
1707 humberto    1.88          //l10n
1708                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "rollback failed");
1709 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1710                               MessageLoaderParms("Repository.CIMRepository.ROLLBACK_FAILED",
1711                                   "rollback failed"));
1712 humberto    1.88          //l10n end
1713 kumpf       1.58      }
1714 mike        1.53  
1715                       //
1716                       // Begin the transaction:
1717                       //
1718                   
1719                       if (!InstanceIndexFile::beginTransaction(indexFilePath))
1720 kumpf       1.58      {
1721                           PEG_METHOD_EXIT();
1722 humberto    1.88          //l10n
1723                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "begin failed");
1724 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1725                               MessageLoaderParms("Repository.CIMRepository.BEGIN_FAILED",
1726                                   "begin failed"));
1727 humberto    1.88          //l10n end
1728 kumpf       1.58      }
1729 mike        1.53  
1730                       if (!InstanceDataFile::beginTransaction(dataFilePath))
1731 kumpf       1.104     {
1732 kumpf       1.58          PEG_METHOD_EXIT();
1733 humberto    1.88          //l10n
1734                           //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "begin failed");
1735 kumpf       1.99          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1736                               MessageLoaderParms("Repository.CIMRepository.BEGIN_FAILED",
1737                                   "begin failed"));
1738 humberto    1.88          //l10n end
1739 kumpf       1.58      }
1740 mike        1.53  
1741                       //
1742                       // Do this:
1743                       //
1744 mike        1.51  
1745                       String errMessage;
1746 mike        1.53      CIMInstance cimInstance;   // The instance that replaces the original
1747 mike        1.51  
1748                       if (propertyList.isNull())
1749                       {
1750                           //
1751                           // Replace all the properties in the instance
1752                           //
1753                           if (includeQualifiers)
1754                           {
1755                               //
1756                               // Replace the entire instance with the given instance
1757                               // (this is the default behavior)
1758                               //
1759 kumpf       1.70              cimInstance = modifiedInstance;
1760 mike        1.51          }
1761                           else
1762                           {
1763                               //
1764                               // Replace all the properties in the instance, but keep the
1765                               // original qualifiers on the instance and on the properties
1766                               //
1767                   
1768 kumpf       1.104             _resolveInstance = false;
1769 mike        1.55  
1770 kumpf       1.104             cimInstance = _getInstance(
1771                                   nameSpace,
1772                                   modifiedInstance.getPath (),
1773                                   false,
1774                                   true,
1775                                   true,
1776                                   CIMPropertyList());
1777 mike        1.55  
1778 kumpf       1.104             _resolveInstance = true;
1779 mike        1.54  
1780 mike        1.51              CIMInstance newInstance(
1781 kumpf       1.70                  modifiedInstance.getPath ().getClassName());
1782 mike        1.54  
1783 kumpf       1.70              CIMInstance givenInstance = modifiedInstance;
1784 mike        1.51  
1785                               //
1786                               // Copy over the original instance qualifiers
1787                               //
1788 mike        1.54  
1789                               for (Uint32 i = 0; i < cimInstance.getQualifierCount(); i++)
1790 mike        1.51              {
1791                                   newInstance.addQualifier(cimInstance.getQualifier(i));
1792                               }
1793                   
1794                               //
1795                               // Loop through the properties replacing each property in the
1796                               // original with a new value, but keeping the original qualifiers
1797                               //
1798                               for (Uint32 i=0; i<givenInstance.getPropertyCount(); i++)
1799                               {
1800                                   // Copy the given property value (not qualifiers)
1801                                   CIMProperty givenProperty = givenInstance.getProperty(i);
1802                                   CIMProperty newProperty(
1803                                       givenProperty.getName(),
1804                                       givenProperty.getValue(),
1805                                       givenProperty.getArraySize(),
1806                                       givenProperty.getReferenceClassName(),
1807                                       givenProperty.getClassOrigin(),
1808                                       givenProperty.getPropagated());
1809                   
1810                                   // Copy the original property qualifiers
1811 mike        1.51                  Uint32 origPos =
1812                                       cimInstance.findProperty(newProperty.getName());
1813                                   if (origPos != PEG_NOT_FOUND)
1814                                   {
1815                                       CIMProperty origProperty = cimInstance.getProperty(origPos);
1816                                       for (Uint32 j=0; j<origProperty.getQualifierCount(); j++)
1817                                       {
1818 jim.wunderlich 1.129.2.1                         newProperty.addQualifier(origProperty.getQualifier(j));
1819 mike           1.51                          }
1820                                          }
1821                          
1822                                          // Add the newly constructed property to the new instance
1823                                          newInstance.addProperty(newProperty);
1824                                      }
1825                          
1826                                      // Use the newly merged instance to replace the original instance
1827                                      cimInstance = newInstance;
1828                                  }
1829                              }
1830                              else
1831                              {
1832                                  //
1833                                  // Replace only the properties specified in the given instance
1834                                  //
1835                          
1836 kumpf          1.104             _resolveInstance = false;
1837 mike           1.55      
1838 kumpf          1.104             cimInstance = _getInstance(nameSpace,
1839                                      modifiedInstance.getPath (), false, true, true, CIMPropertyList());
1840 mike           1.55      
1841 kumpf          1.104             _resolveInstance = true;
1842 mike           1.55      
1843 kumpf          1.70              CIMInstance givenInstance = modifiedInstance;
1844 mike           1.51      
1845                                  // NOTE: Instance qualifiers are not changed when a property list
1846                                  // is specified.  Property qualifiers are replaced with the
1847                                  // corresponding property values.
1848                          
1849                                  //
1850                                  // Loop through the propertyList replacing each property in the original
1851                                  //
1852 mike           1.53      
1853 kumpf          1.74              for (Uint32 i=0; i<propertyList.size(); i++)
1854 mike           1.51              {
1855 kumpf          1.74                  Uint32 origPropPos = cimInstance.findProperty(propertyList[i]);
1856 mike           1.51                  if (origPropPos != PEG_NOT_FOUND)
1857                                      {
1858                                          // Case: Property set in original
1859                                          CIMProperty origProperty =
1860                                              cimInstance.getProperty(origPropPos);
1861                          
1862                                          // Get the given property value
1863                                          Uint32 givenPropPos =
1864 kumpf          1.74                          givenInstance.findProperty(propertyList[i]);
1865 mike           1.51                      if (givenPropPos != PEG_NOT_FOUND)
1866                                          {
1867                                              // Case: Property set in original and given
1868                                              CIMProperty givenProperty =
1869                                                  givenInstance.getProperty(givenPropPos);
1870                          
1871                                              // Copy over the property from the given to the original
1872                                              if (includeQualifiers)
1873                                              {
1874                                                  // Case: Total property replacement
1875                                                  cimInstance.removeProperty(origPropPos);
1876                                                  cimInstance.addProperty(givenProperty);
1877                                              }
1878                                              else
1879                                              {
1880                                                  // Case: Replace only the property value (not quals)
1881                                                  origProperty.setValue(givenProperty.getValue());
1882                                                  cimInstance.removeProperty(origPropPos);
1883                                                  cimInstance.addProperty(origProperty);
1884                                              }
1885                                          }
1886 mike           1.51                      else
1887                                          {
1888                                              // Case: Property set in original and not in given
1889                                              // Just remove the property (set to null)
1890                                              cimInstance.removeProperty(origPropPos);
1891                                          }
1892                                      }
1893                                      else
1894                                      {
1895                                          // Case: Property not set in original
1896                          
1897                                          // Get the given property value
1898                                          Uint32 givenPropPos =
1899 kumpf          1.74                          givenInstance.findProperty(propertyList[i]);
1900 mike           1.51                      if (givenPropPos != PEG_NOT_FOUND)
1901                                          {
1902                                              // Case: Property set in given and not in original
1903                                              CIMProperty givenProperty =
1904                                                  givenInstance.getProperty(givenPropPos);
1905                          
1906                                              // Copy over the property from the given to the original
1907                                              if (includeQualifiers)
1908                                              {
1909                                                  // Case: Total property copy
1910                                                  cimInstance.addProperty(givenProperty);
1911                                              }
1912                                              else
1913                                              {
1914                                                  // Case: Copy only the property value (not qualifiers)
1915                                                  CIMProperty newProperty(
1916                                                      givenProperty.getName(),
1917                                                      givenProperty.getValue(),
1918                                                      givenProperty.getArraySize(),
1919                                                      givenProperty.getReferenceClassName(),
1920                                                      givenProperty.getClassOrigin(),
1921 mike           1.51                                  givenProperty.getPropagated());
1922                                                  cimInstance.addProperty(newProperty);
1923                                              }
1924                                          }
1925                                          else
1926                                          {
1927                                              // Case: Property not set in original or in given
1928                          
1929                                              // Nothing to do; just make sure the property name is valid
1930                                              // ATTN: This is not the most efficient solution
1931                                              CIMClass cimClass = getClass(
1932                                                  nameSpace, cimInstance.getClassName(), false);
1933 kumpf          1.74                          if (cimClass.findProperty(propertyList[i]) == PEG_NOT_FOUND)
1934 mike           1.51                          {
1935                                                  // ATTN: This exception may be returned by setProperty
1936 kumpf          1.58                              PEG_METHOD_EXIT();
1937 mike           1.51                              throw PEGASUS_CIM_EXCEPTION(
1938                                                      CIM_ERR_NO_SUCH_PROPERTY, "modifyInstance()");
1939                                              }
1940                                          }
1941                                      }
1942                                  }
1943                              }
1944                          
1945 mike           1.53          //
1946 mike           1.54          // Resolve the instance (do not propagate qualifiers from class since
1947                              // this will bloat the instance).
1948 mike           1.53          //
1949 mike           1.48      
1950                              CIMConstClass cimClass;
1951 kumpf          1.104         Resolver::resolveInstance (cimInstance, _context, nameSpace, cimClass,
1952 kumpf          1.76              false);
1953 mike           1.48      
1954 kumpf          1.81          CIMObjectPath instanceName = cimInstance.buildPath(cimClass);
1955 mike           1.51      
1956 mike           1.53          //
1957                              // Disallow operation if the instance name was changed:
1958                              //
1959 mike           1.51      
1960 r.kieninger    1.122         // For for bugzilla 1508. Hostname and namespace are not included
1961                              // in the comparison here.
1962                              CIMObjectPath modifiedInstancePath = modifiedInstance.getPath();
1963                              modifiedInstancePath.setNameSpace(CIMNamespaceName());
1964                              modifiedInstancePath.setHost(String::EMPTY);
1965                              if (instanceName != modifiedInstancePath)
1966 mike           1.51          {
1967 kumpf          1.58              PEG_METHOD_EXIT();
1968 humberto       1.88              //l10n
1969                                  //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
1970                                      //"Attempted to modify a key property");
1971 kumpf          1.99              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1972                                      MessageLoaderParms(
1973                                          "Repository.CIMRepository.ATTEMPT_TO_MODIFY_KEY_PROPERTY",
1974                                          "Attempted to modify a key property"));
1975 humberto       1.88              //l10n end
1976 mike           1.51          }
1977                          
1978                              Uint32 oldSize;
1979                              Uint32 oldIndex;
1980                              Uint32 newSize;
1981                              Uint32 newIndex;
1982 mike           1.48      
1983 mike           1.53          if (!InstanceIndexFile::lookupEntry(
1984 kumpf          1.104                 indexFilePath, instanceName, oldIndex, oldSize))
1985 mike           1.51          {
1986 kumpf          1.58              PEG_METHOD_EXIT();
1987 mike           1.51              throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND, instanceName.toString());
1988                              }
1989 mike           1.48      
1990 mike           1.53          //
1991                              // Modify the data file:
1992                              //
1993                          
1994                              {
1995 kumpf          1.104             Array<Sint8> out;
1996 schuur         1.114             streamer->encode(out, cimInstance);
1997                                  //XmlWriter::appendInstanceElement(out, cimInstance);
1998 kumpf          1.104     
1999                                  newSize = out.size();
2000                          
2001                                  if (!InstanceDataFile::appendInstance(dataFilePath, out, newIndex))
2002                                  {
2003                                      //l10n
2004                                      //errMessage.append("Failed to modify instance ");
2005                                      //errMessage.append(instanceName.toString());
2006                                      PEG_METHOD_EXIT();
2007                                      //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, errMessage);
2008                                      throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
2009                                          MessageLoaderParms(
2010                                              "Repository.CIMRepository.FAILED_TO_MODIFY_INSTANCE",
2011                                              "Failed to modify instance $0",
2012                                              instanceName.toString()));
2013                                      //l10n end
2014                                  }
2015 mike           1.48          }
2016                          
2017 mike           1.53          //
2018                              // Modify the index file:
2019                              //
2020                          
2021                              Uint32 freeCount;
2022 mike           1.51      
2023 mike           1.53          if (!InstanceIndexFile::modifyEntry(indexFilePath, instanceName, newIndex,
2024                                  newSize, freeCount))
2025 mike           1.51          {
2026 humberto       1.88              //l10n
2027 kumpf          1.104             //errMessage.append("Failed to modify instance ");
2028                                  //errMessage.append(instanceName.toString());
2029                                  PEG_METHOD_EXIT();
2030                                  //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, errMessage);
2031                                  throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
2032                                      MessageLoaderParms(
2033                                          "Repository.CIMRepository.FAILED_TO_MODIFY_INSTANCE",
2034                                          "Failed to modify instance $0",
2035                                          instanceName.toString()));
2036                                  //l10n end
2037 mike           1.51          }
2038                          
2039 mike           1.53          //
2040                              // Commit the transaction:
2041                              //
2042                          
2043                              if (!InstanceIndexFile::commitTransaction(indexFilePath))
2044 kumpf          1.58          {
2045                                  PEG_METHOD_EXIT();
2046 humberto       1.88              //l10n
2047                                  //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "commit failed");
2048 kumpf          1.99              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
2049                                      MessageLoaderParms("Repository.CIMRepository.COMMIT_FAILED",
2050                                          "commit failed"));
2051 humberto       1.88              //l10n end
2052 kumpf          1.58          }
2053 mike           1.53      
2054                              if (!InstanceDataFile::commitTransaction(dataFilePath))
2055 kumpf          1.58          {
2056                                  PEG_METHOD_EXIT();
2057 humberto       1.88              //l10n
2058                                  //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "commit failed");
2059 kumpf          1.99              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
2060                                      MessageLoaderParms("Repository.CIMRepository.COMMIT_FAILED",
2061                                          "commit failed"));
2062 humberto       1.88              //l10n end
2063 kumpf          1.58          }
2064 mike           1.48      
2065 mike           1.53          //
2066                              // Compact the index and data files if the free count max was
2067                              // reached.
2068                              //
2069                          
2070                              if (freeCount == _MAX_FREE_COUNT)
2071 kumpf          1.104             _CompactInstanceRepository(indexFilePath, dataFilePath);
2072 mike           1.54      
2073                              //
2074                              // Resolve the instance:
2075                              //
2076                          
2077 kumpf          1.104         Resolver::resolveInstance (cimInstance, _context, nameSpace, cimClass,
2078 kumpf          1.76              true);
2079 kumpf          1.58      
2080                              PEG_METHOD_EXIT();
2081 mike           1.48      }
2082                          
2083                          Array<CIMClass> CIMRepository::enumerateClasses(
2084 kumpf          1.85          const CIMNamespaceName& nameSpace,
2085                              const CIMName& className,
2086 mike           1.48          Boolean deepInheritance,
2087                              Boolean localOnly,
2088                              Boolean includeQualifiers,
2089                              Boolean includeClassOrigin)
2090                          {
2091 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::enumerateClasses");
2092 mike           1.51      
2093 kumpf          1.104         ReadLock lock(_lock);
2094                          
2095 kumpf          1.85          Array<CIMName> classNames;
2096 mike           1.48      
2097                              _nameSpaceManager.getSubClassNames(
2098 mike           1.51              nameSpace, className, deepInheritance, classNames);
2099 mike           1.48      
2100                              Array<CIMClass> result;
2101                          
2102                              for (Uint32 i = 0; i < classNames.size(); i++)
2103                              {
2104 kumpf          1.104             result.append(_getClass(nameSpace, classNames[i], localOnly,
2105                                      includeQualifiers, includeClassOrigin, CIMPropertyList()));
2106 mike           1.48          }
2107                          
2108 kumpf          1.58          PEG_METHOD_EXIT();
2109 mike           1.48          return result;
2110                          }
2111                          
2112 kumpf          1.85      Array<CIMName> CIMRepository::enumerateClassNames(
2113                              const CIMNamespaceName& nameSpace,
2114                              const CIMName& className,
2115 mike           1.48          Boolean deepInheritance)
2116                          {
2117 kumpf          1.59          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::enumerateClassNames");
2118 kumpf          1.58      
2119 kumpf          1.104         ReadLock lock(_lock);
2120                          
2121 kumpf          1.85          Array<CIMName> classNames;
2122 mike           1.48      
2123                              _nameSpaceManager.getSubClassNames(
2124 schuur         1.112             nameSpace, className, deepInheritance, classNames,true);
2125 mike           1.48      
2126 kumpf          1.58          PEG_METHOD_EXIT();
2127 mike           1.48          return classNames;
2128                          }
2129                          
2130 mike           1.53      Boolean CIMRepository::_loadAllInstances(
2131 kumpf          1.85          const CIMNamespaceName& nameSpace,
2132                              const CIMName& className,
2133 kumpf          1.70          Array<CIMInstance>& namedInstances)
2134 mike           1.53      {
2135 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_loadAllInstances");
2136                          
2137 kumpf          1.68          Array<CIMObjectPath> instanceNames;
2138 mike           1.53          Array<Sint8> data;
2139                              Array<Uint32> indices;
2140                              Array<Uint32> sizes;
2141                          
2142                              //
2143                              // Form the name of the instance index file
2144                              //
2145                          
2146                              String indexFilePath = _getInstanceIndexFilePath(nameSpace, className);
2147                          
2148                              //
2149                              // Form the name of the instance file
2150                              //
2151                          
2152                              String dataFilePath = _getInstanceDataFilePath(nameSpace, className);
2153                          
2154                              //
2155                              // Enumerate the index file:
2156                              //
2157                          
2158                              Array<Uint32> freeFlags;
2159 mike           1.53      
2160                              if (!InstanceIndexFile::enumerateEntries(
2161                                  indexFilePath, freeFlags, indices, sizes, instanceNames, true))
2162                              {
2163 kumpf          1.58              PEG_METHOD_EXIT();
2164 mike           1.53              return false;
2165                              }
2166                          
2167                              //
2168                              // Form the array of instances result:
2169                              //
2170                          
2171                              if (instanceNames.size() > 0)
2172                              {
2173 kumpf          1.104             //
2174                                  // Load all instances from the data file:
2175                                  //
2176 mike           1.53      
2177                                  if (!InstanceDataFile::loadAllInstances(dataFilePath, data))
2178 kumpf          1.58              {
2179                                      PEG_METHOD_EXIT();
2180 mike           1.53                  return false;
2181 kumpf          1.58              }
2182 kumpf          1.104     
2183 mike           1.53              //
2184                                  // for each instance loaded, call XML parser to parse the XML
2185                                  // data and create a CIMInstance object.
2186                                  //
2187                          
2188                                  CIMInstance tmpInstance;
2189                          
2190                                  Uint32 bufferSize = data.size();
2191                                  char* buffer = (char*)data.getData();
2192                          
2193                                  for (Uint32 i = 0; i < instanceNames.size(); i++)
2194                                  {
2195 kumpf          1.104                 if (!freeFlags[i])
2196                                      {
2197 schuur         1.114                     Uint32 pos=(&(buffer[indices[i]]))-buffer;
2198                                          streamer->decode(data, pos, tmpInstance);
2199 kumpf          1.104     
2200 schuur         1.114     //                XmlParser parser(&(buffer[indices[i]]));
2201                          //
2202                          //                XmlReader::getObject(parser, tmpInstance);
2203 kumpf          1.104     
2204                                          Resolver::resolveInstance (tmpInstance, _context, nameSpace,
2205 karl           1.101                             true);
2206 kumpf          1.104                     tmpInstance.setPath (instanceNames[i]);
2207                          
2208                                          namedInstances.append (tmpInstance);
2209                                      }
2210 mike           1.53              }
2211                              }
2212                          
2213 kumpf          1.58          PEG_METHOD_EXIT();
2214 mike           1.53          return true;
2215                          }
2216                          
2217 kumpf          1.70      Array<CIMInstance> CIMRepository::enumerateInstances(
2218 kumpf          1.85          const CIMNamespaceName& nameSpace,
2219                              const CIMName& className,
2220 mike           1.48          Boolean deepInheritance,
2221                              Boolean localOnly,
2222                              Boolean includeQualifiers,
2223                              Boolean includeClassOrigin,
2224 mike           1.51          const CIMPropertyList& propertyList)
2225 mike           1.48      {
2226 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::enumerateInstances");
2227 kumpf          1.104     
2228                              // It is not necessary to control access to the ReadWriteSem _lock here.
2229                              // This method calls enumerateInstancesForClass, which does its own
2230                              // access control.
2231                          
2232 karl           1.69          //
2233                              // Get all descendent classes of this class:
2234                              //
2235                          
2236 kumpf          1.85          Array<CIMName> classNames;
2237 kumpf          1.94          classNames.append(className);
2238 karl           1.69          _nameSpaceManager.getSubClassNames(nameSpace, className, true, classNames);
2239                          
2240                              //
2241                              // Get all instances for this class and all its descendent classes
2242                              //
2243 kumpf          1.58      
2244 kumpf          1.70          Array<CIMInstance> namedInstances;
2245 kumpf          1.104     
2246 karl           1.69          for (Uint32 i = 0; i < classNames.size(); i++)
2247 karl           1.65          {
2248 karl           1.101             Array<CIMInstance> localNamedInstances =
2249 jim.wunderlich 1.129.2.1                 enumerateInstancesForClass(nameSpace, classNames[i],
2250 karl           1.101                     deepInheritance, localOnly,
2251                                          includeQualifiers, includeClassOrigin, false, propertyList);
2252 karl           1.102             /* Code from before we changed to call once per class.
2253 karl           1.101             if (!_loadAllInstances(nameSpace, classNames[i], localNamedInstances))
2254 karl           1.69              {
2255 kumpf          1.104                 //l10n
2256 humberto       1.88                  //String errMessage = "Failed to load instances in class ";
2257                                      //errMessage.append(classNames[i].getString ());
2258 karl           1.69                  PEG_METHOD_EXIT();
2259 humberto       1.88                  //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, errMessage);
2260 kumpf          1.99                  throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
2261                                          MessageLoaderParms(
2262                                              "Repository.CIMRepository.FAILED_TO_LOAD_INSTANCES",
2263                                              "Failed to load instances in class $0",
2264                                              classNames[i].getString()));
2265 humberto       1.88                  //10n end
2266 karl           1.69              }
2267 karl           1.101             */
2268                                  // ATTN: Handles everything but deepInheritance.
2269                                  for (Uint32 i = 0 ; i < localNamedInstances.size(); i++)
2270                                  {
2271                                      _filterInstance(localNamedInstances[i],
2272                                          propertyList,
2273                                          localOnly,
2274                                          includeQualifiers,
2275                                          includeClassOrigin);
2276                                  }
2277                                  namedInstances.appendArray(localNamedInstances);
2278 karl           1.65          }
2279 karl           1.98      
2280 karl           1.65          PEG_METHOD_EXIT();
2281                              return namedInstances;
2282 karl           1.69      }
2283 karl           1.65      
2284 kumpf          1.70      Array<CIMInstance> CIMRepository::enumerateInstancesForClass(
2285 kumpf          1.85          const CIMNamespaceName& nameSpace,
2286                              const CIMName& className,
2287 karl           1.69          Boolean deepInheritance,
2288                              Boolean localOnly,
2289                              Boolean includeQualifiers,
2290                              Boolean includeClassOrigin,
2291                              Boolean includeInheritance,
2292                              const CIMPropertyList& propertyList)
2293                          {
2294 kumpf          1.104         PEG_METHOD_ENTER(TRC_REPOSITORY,
2295                                               "CIMRepository::enumerateInstancesForClass");
2296                          
2297                              ReadLock lock(_lock);
2298                          
2299 mike           1.53          //
2300                              // Get all descendent classes of this class:
2301                              //
2302 mike           1.48      
2303 kumpf          1.85          Array<CIMName> classNames;
2304 kumpf          1.94          classNames.append(className);
2305 karl           1.69          // If includeInheritance is true, get all subclasses.
2306                              // ATTN: P3 KS Look at whether the subclassNames requires an empty array.
2307                              if(includeInheritance)
2308                              {
2309 kumpf          1.104             try
2310                                  {
2311                                      _nameSpaceManager.getSubClassNames(nameSpace, className, true, classNames);
2312                                  }
2313                                  catch(CIMException& e)
2314                                  {
2315                                      PEG_METHOD_EXIT();
2316                                      throw e;
2317                                  }
2318 karl           1.69          }
2319 mike           1.48      
2320 mike           1.53          //
2321                              // Get all instances for this class and all its descendent classes
2322                              //
2323 mike           1.48      
2324 kumpf          1.70          Array<CIMInstance> namedInstances;
2325 kumpf          1.104     
2326 mike           1.48          for (Uint32 i = 0; i < classNames.size(); i++)
2327                              {
2328 mike           1.51              if (!_loadAllInstances(nameSpace, classNames[i], namedInstances))
2329                                  {
2330 kumpf          1.104                 //l10n
2331 humberto       1.88                  //String errMessage = "Failed to load instances in class ";
2332                                      //errMessage.append(classNames[i].getString());
2333 kumpf          1.58                  PEG_METHOD_EXIT();
2334 humberto       1.88                  //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, errMessage);
2335 kumpf          1.99                  throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
2336                                          MessageLoaderParms(
2337                                              "Repository.CIMRepository.FAILED_TO_LOAD_INSTANCES",
2338                                              "Failed to load instances in class $0",
2339                                              classNames[i].getString()));
2340 humberto       1.88                  //l10n end
2341 karl           1.101             }
2342                                  // Do any required filtering of properties, qualifiers, classorigin
2343                                  // on the returned instances.
2344 karl           1.102     // Turn off this function for the moment since it changes client behavior
2345 karl           1.103     #ifdef PEGASUS_ENABLE_INSTANCE_FILTER
2346 karl           1.101             for (Uint32 i = 0 ; i < namedInstances.size(); i++)
2347                                  {
2348                                      _filterInstance(namedInstances[i],
2349                                          propertyList,
2350                                          localOnly,
2351                                          includeQualifiers,
2352                                          includeClassOrigin);
2353 mike           1.51              }
2354 kumpf          1.104     #endif
2355 mike           1.48          }
2356 kumpf          1.58          PEG_METHOD_EXIT();
2357 mike           1.51          return namedInstances;
2358 mike           1.48      }
2359 kumpf          1.104     
2360 kumpf          1.68      Array<CIMObjectPath> CIMRepository::enumerateInstanceNames(
2361 kumpf          1.85          const CIMNamespaceName& nameSpace,
2362                              const CIMName& className)
2363 mike           1.48      {
2364 kumpf          1.61          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::enumerateInstanceNames");
2365 mike           1.51      
2366 kumpf          1.104         ReadLock lock(_lock);
2367                          
2368 karl           1.65          //
2369 karl           1.69          // Get names of descendent classes:
2370 karl           1.65          //
2371 kumpf          1.85          Array<CIMName> classNames;
2372 karl           1.69      
2373 kumpf          1.94          classNames.append(className);
2374                          
2375 karl           1.69          try
2376                              {
2377 kumpf          1.104             _nameSpaceManager.getSubClassNames(nameSpace, className, true, classNames);
2378 karl           1.69          }
2379                              catch(CIMException& e)
2380                              {
2381 kumpf          1.104             PEG_METHOD_EXIT();
2382                                  throw e;
2383 karl           1.69          }
2384 karl           1.65      
2385                              //
2386 karl           1.69          // Get instance names from each qualifying instance file for the class:
2387 karl           1.65          //
2388 karl           1.69          Array<CIMObjectPath> instanceNames;
2389                              Array<Uint32> indices;
2390                              Array<Uint32> sizes;
2391 karl           1.65      
2392 karl           1.69          for (Uint32 i = 0; i < classNames.size(); i++)
2393                              {
2394 kumpf          1.104             //
2395 karl           1.69              // Form the name of the class index file:
2396 kumpf          1.104             //
2397 karl           1.69      
2398                                  String indexFilePath = _getInstanceIndexFilePath(
2399 kumpf          1.104                 nameSpace, classNames[i]);
2400 karl           1.69      
2401 kumpf          1.104             //
2402 karl           1.69              // Get all instances for that class:
2403 kumpf          1.104             //
2404 karl           1.69      
2405 kumpf          1.104             Array<Uint32> freeFlags;
2406 karl           1.65      
2407 kumpf          1.104             if (!InstanceIndexFile::enumerateEntries(
2408                                      indexFilePath, freeFlags, indices, sizes, instanceNames, false))
2409 karl           1.69              {
2410 kumpf          1.104                 //l10n
2411 humberto       1.88                  //String errMessage = "Failed to load instance names in class ";
2412 kumpf          1.104                 //errMessage.append(classNames[i].getString());
2413 karl           1.69                  PEG_METHOD_EXIT();
2414 humberto       1.88                  //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, errMessage);
2415 kumpf          1.99                  throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
2416                                          MessageLoaderParms(
2417                                              "Repository.CIMRepository.FAILED_TO_LOAD_INSTANCE_NAMES",
2418                                              "Failed to load instance names in class $0",
2419                                              classNames[i].getString()));
2420 humberto       1.88                  //l10n end
2421 karl           1.69              }
2422 karl           1.65          }
2423                          
2424 karl           1.69          PEG_METHOD_EXIT();
2425                              return instanceNames;
2426                          }
2427                          
2428                          Array<CIMObjectPath> CIMRepository::enumerateInstanceNamesForClass(
2429 kumpf          1.85          const CIMNamespaceName& nameSpace,
2430                              const CIMName& className,
2431 karl           1.69          Boolean includeInheritance)
2432                          {
2433 kumpf          1.104         PEG_METHOD_ENTER(TRC_REPOSITORY,
2434                                               "CIMRepository::enumerateInstanceNamesForClass");
2435                          
2436                              ReadLock lock(_lock);
2437 karl           1.69      
2438 mike           1.53          //
2439                              // Get names of descendent classes:
2440                              //
2441 kumpf          1.85          Array<CIMName> classNames;
2442 karl           1.69      
2443 kumpf          1.94          classNames.append(className);
2444                          
2445 karl           1.69          // If includeInheritance is true, get all subclasses.
2446                              if(includeInheritance)
2447 mday           1.57          {
2448 kumpf          1.104             try
2449                                  {
2450                                      _nameSpaceManager.getSubClassNames(nameSpace, className, true, classNames);
2451                                  }
2452                                  catch(CIMException& e)
2453                                  {
2454                                      PEG_METHOD_EXIT();
2455                                      throw e;
2456                                  }
2457 mday           1.57          }
2458 mike           1.48      
2459 mike           1.53          //
2460                              // Get instance names from each qualifying instance file for the class:
2461                              //
2462 kumpf          1.68          Array<CIMObjectPath> instanceNames;
2463 mike           1.48          Array<Uint32> indices;
2464 mike           1.51          Array<Uint32> sizes;
2465 mike           1.48      
2466                              for (Uint32 i = 0; i < classNames.size(); i++)
2467                              {
2468 kumpf          1.104             //
2469 mike           1.53              // Form the name of the class index file:
2470 kumpf          1.104             //
2471 mike           1.48      
2472 mike           1.53              String indexFilePath = _getInstanceIndexFilePath(
2473 kumpf          1.104                 nameSpace, classNames[i]);
2474 mike           1.48      
2475 kumpf          1.104             //
2476 mike           1.51              // Get all instances for that class:
2477 kumpf          1.104             //
2478 mike           1.53      
2479 kumpf          1.104             Array<Uint32> freeFlags;
2480 mike           1.48      
2481 kumpf          1.104             if (!InstanceIndexFile::enumerateEntries(
2482                                      indexFilePath, freeFlags, indices, sizes, instanceNames, false))
2483 mike           1.51              {
2484 kumpf          1.104                 //l10n
2485 humberto       1.88                  //String errMessage = "Failed to load instance names in class ";
2486 kumpf          1.104                 //errMessage.append(classNames[i].getString());
2487 kumpf          1.52                  PEG_METHOD_EXIT();
2488 humberto       1.88                  //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, errMessage);
2489 kumpf          1.99                  throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
2490                                          MessageLoaderParms(
2491                                              "Repository.CIMRepository.FAILED_TO_LOAD_INSTANCE_NAMES",
2492                                              "Failed to load instance names in class $0",
2493                                              classNames[i].getString()));
2494 humberto       1.88                  //l10n end
2495 mike           1.51              }
2496 mike           1.48          }
2497 mike           1.53      
2498 kumpf          1.52          PEG_METHOD_EXIT();
2499 mike           1.48          return instanceNames;
2500                          }
2501 karl           1.69      
2502 mike           1.48      
2503                          Array<CIMInstance> CIMRepository::execQuery(
2504                              const String& queryLanguage,
2505                              const String& query)
2506                          {
2507 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::execQuery");
2508                          
2509 kumpf          1.104         ReadLock lock(_lock);
2510                          
2511 kumpf          1.58          PEG_METHOD_EXIT();
2512 mike           1.48          throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, "execQuery()");
2513                          
2514 kumpf          1.58          PEG_METHOD_EXIT();
2515 mike           1.48          return Array<CIMInstance>();
2516                          }
2517                          
2518 kumpf          1.71      Array<CIMObject> CIMRepository::associators(
2519 kumpf          1.85          const CIMNamespaceName& nameSpace,
2520 kumpf          1.68          const CIMObjectPath& objectName,
2521 kumpf          1.85          const CIMName& assocClass,
2522                              const CIMName& resultClass,
2523 mike           1.48          const String& role,
2524                              const String& resultRole,
2525                              Boolean includeQualifiers,
2526                              Boolean includeClassOrigin,
2527 mike           1.51          const CIMPropertyList& propertyList)
2528 mike           1.48      {
2529 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::associators");
2530                          
2531 kumpf          1.104         ReadLock lock(_lock);
2532                          
2533                              Array<CIMObjectPath> names = _associatorNames(
2534 mike           1.51              nameSpace,
2535                                  objectName,
2536                                  assocClass,
2537                                  resultClass,
2538                                  role,
2539                                  resultRole);
2540 mike           1.48      
2541 kumpf          1.71          Array<CIMObject> result;
2542 mike           1.48      
2543                              for (Uint32 i = 0, n = names.size(); i < n; i++)
2544                              {
2545 kumpf          1.85              CIMNamespaceName tmpNameSpace = names[i].getNameSpace();
2546 mike           1.48      
2547 kumpf          1.85              if (tmpNameSpace.isNull())
2548 mike           1.51                  tmpNameSpace = nameSpace;
2549 mike           1.48      
2550 kumpf          1.80              //
2551                                  //  ATTN-CAKG-P2-20020726:  The following condition does not correctly
2552                                  //  distinguish instanceNames from classNames in every case
2553                                  //  The instanceName of a singleton instance of a keyless class also
2554                                  //  has no key bindings
2555                                  //
2556                                  if (names[i].getKeyBindings ().size () == 0)
2557 mike           1.51              {
2558 kumpf          1.68                  CIMObjectPath tmpRef = names[i];
2559 mike           1.51                  tmpRef.setHost(String());
2560 kumpf          1.95                  tmpRef.setNameSpace(CIMNamespaceName());
2561 mike           1.51      
2562 kumpf          1.104                 CIMClass cimClass = _getClass(
2563 mike           1.51                      tmpNameSpace,
2564                                          tmpRef.getClassName(),
2565                                          false,
2566                                          includeQualifiers,
2567                                          includeClassOrigin,
2568                                          propertyList);
2569                          
2570                                      CIMObject cimObject(cimClass);
2571 kumpf          1.71                  cimObject.setPath (names[i]);
2572                                      result.append(cimObject);
2573 mike           1.51              }
2574                                  else
2575                                  {
2576 kumpf          1.68                  CIMObjectPath tmpRef = names[i];
2577 mike           1.51                  tmpRef.setHost(String());
2578 kumpf          1.95                  tmpRef.setNameSpace(CIMNamespaceName());
2579 mike           1.51      
2580 kumpf          1.104                 CIMInstance cimInstance = _getInstance(
2581 mike           1.51                      tmpNameSpace,
2582                                          tmpRef,
2583                                          false,
2584                                          includeQualifiers,
2585                                          includeClassOrigin,
2586                                          propertyList);
2587                          
2588                                      CIMObject cimObject(cimInstance);
2589 kumpf          1.71                  cimObject.setPath (names[i]);
2590                                      result.append(cimObject);
2591 mike           1.51              }
2592 mike           1.48          }
2593                          
2594 kumpf          1.58          PEG_METHOD_EXIT();
2595 mike           1.48          return result;
2596                          }
2597                          
2598 kumpf          1.68      Array<CIMObjectPath> CIMRepository::associatorNames(
2599 kumpf          1.85          const CIMNamespaceName& nameSpace,
2600 kumpf          1.68          const CIMObjectPath& objectName,
2601 kumpf          1.85          const CIMName& assocClass,
2602                              const CIMName& resultClass,
2603 mike           1.48          const String& role,
2604                              const String& resultRole)
2605                          {
2606 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::associatorNames");
2607 mike           1.51      
2608 kumpf          1.104         ReadLock lock(_lock);
2609                              Array<CIMObjectPath> result = _associatorNames(
2610                                  nameSpace, objectName, assocClass, resultClass, role, resultRole);
2611                          
2612                              PEG_METHOD_EXIT();
2613                              return result;
2614                          }
2615                          
2616                          Array<CIMObjectPath> CIMRepository::_associatorNames(
2617                              const CIMNamespaceName& nameSpace,
2618                              const CIMObjectPath& objectName,
2619                              const CIMName& assocClass,
2620                              const CIMName& resultClass,
2621                              const String& role,
2622                              const String& resultRole)
2623                          {
2624                              PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_associatorNames");
2625                          
2626 mike           1.48          Array<String> associatorNames;
2627                          
2628 kumpf          1.93          // The assocClass parameter implies subclasses, so retrieve them
2629                              Array<CIMName> assocClassList;
2630                              if (!assocClass.isNull())
2631                              {
2632                                  _nameSpaceManager.getSubClassNames(
2633                                      nameSpace, assocClass, true, assocClassList);
2634                                  assocClassList.append(assocClass);
2635                              }
2636                          
2637                              // The resultClass parameter implies subclasses, so retrieve them
2638                              Array<CIMName> resultClassList;
2639                              if (!resultClass.isNull())
2640                              {
2641                                  _nameSpaceManager.getSubClassNames(
2642                                      nameSpace, resultClass, true, resultClassList);
2643                                  resultClassList.append(resultClass);
2644                              }
2645                          
2646 kumpf          1.80          //
2647                              //  ATTN-CAKG-P2-20020726:  The following condition does not correctly
2648                              //  distinguish instanceNames from classNames in every case
2649                              //  The instanceName of a singleton instance of a keyless class also
2650                              //  has no key bindings
2651                              //
2652                              if (objectName.getKeyBindings ().size () == 0)
2653 mike           1.48          {
2654 kumpf          1.93              CIMName className = objectName.getClassName();
2655                          
2656                                  Array<CIMName> classList;
2657                                  _nameSpaceManager.getSuperClassNames(nameSpace, className, classList);
2658                                  classList.append(className);
2659                          
2660 schuur         1.112             Array<String> assocFileName = _nameSpaceManager.getAssocClassPath(nameSpace,NameSpaceRead);
2661 mike           1.48      
2662 schuur         1.112             for (int i=0,m=assocFileName.size(); i<m; i++) {
2663 mike           1.51              AssocClassTable::getAssociatorNames(
2664 schuur         1.112                    assocFileName[i],
2665 kumpf          1.93                  classList,
2666                                      assocClassList,
2667                                      resultClassList,
2668 mike           1.51                  role,
2669                                      resultRole,
2670                                      associatorNames);
2671 mike           1.48          }
2672 schuur         1.112         }
2673                          
2674                              else {
2675 kumpf          1.91              String assocFileName = _nameSpaceManager.getAssocInstPath(nameSpace);
2676 mike           1.48      
2677 mike           1.51              AssocInstTable::getAssociatorNames(
2678                                      assocFileName,
2679                                      objectName,
2680 kumpf          1.93                  assocClassList,
2681                                      resultClassList,
2682 mike           1.51                  role,
2683                                      resultRole,
2684                                      associatorNames);
2685 mike           1.48          }
2686                          
2687 kumpf          1.68          Array<CIMObjectPath> result;
2688 mike           1.48      
2689                              for (Uint32 i = 0, n = associatorNames.size(); i < n; i++)
2690                              {
2691 kumpf          1.68              CIMObjectPath r = associatorNames[i];
2692 mike           1.48      
2693                                  if (r.getHost().size() == 0)
2694                                      r.setHost(System::getHostName());
2695                          
2696 kumpf          1.79              if (r.getNameSpace().isNull())
2697 mike           1.48                  r.setNameSpace(nameSpace);
2698                          
2699 mike           1.51              result.append(r);
2700 mike           1.48          }
2701                          
2702 kumpf          1.58          PEG_METHOD_EXIT();
2703 mike           1.48          return result;
2704                          }
2705                          
2706 kumpf          1.71      Array<CIMObject> CIMRepository::references(
2707 kumpf          1.85          const CIMNamespaceName& nameSpace,
2708 kumpf          1.68          const CIMObjectPath& objectName,
2709 kumpf          1.85          const CIMName& resultClass,
2710 mike           1.48          const String& role,
2711                              Boolean includeQualifiers,
2712                              Boolean includeClassOrigin,
2713 mike           1.51          const CIMPropertyList& propertyList)
2714 mike           1.48      {
2715 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::references");
2716                          
2717 kumpf          1.104         ReadLock lock(_lock);
2718                          
2719                              Array<CIMObjectPath> names = _referenceNames(
2720 mike           1.51              nameSpace,
2721                                  objectName,
2722                                  resultClass,
2723                                  role);
2724 mike           1.48      
2725 kumpf          1.71          Array<CIMObject> result;
2726 mike           1.48      
2727                              for (Uint32 i = 0, n = names.size(); i < n; i++)
2728                              {
2729 kumpf          1.85              CIMNamespaceName tmpNameSpace = names[i].getNameSpace();
2730 mike           1.48      
2731 kumpf          1.85              if (tmpNameSpace.isNull())
2732 mike           1.51                  tmpNameSpace = nameSpace;
2733 mike           1.48      
2734 mike           1.51              // ATTN: getInstance() should this be able to handle instance names
2735                                  // with host names and namespaces?
2736 mike           1.48      
2737 kumpf          1.68              CIMObjectPath tmpRef = names[i];
2738 mike           1.51              tmpRef.setHost(String());
2739 kumpf          1.95              tmpRef.setNameSpace(CIMNamespaceName());
2740 mike           1.51      
2741 kumpf          1.80              //
2742                                  //  ATTN-CAKG-P2-20020726:  The following condition does not correctly
2743                                  //  distinguish instanceNames from classNames in every case
2744                                  //  The instanceName of a singleton instance of a keyless class also
2745                                  //  has no key bindings
2746                                  //
2747                                  if (objectName.getKeyBindings ().size () == 0)
2748 mike           1.51              {
2749 kumpf          1.104                 CIMClass cimClass = _getClass(
2750 mike           1.51                      tmpNameSpace,
2751                                          tmpRef.getClassName(),
2752                                          false,
2753                                          includeQualifiers,
2754                                          includeClassOrigin,
2755                                          propertyList);
2756                          
2757 kumpf          1.71                  CIMObject cimObject = CIMObject (cimClass);
2758                                      cimObject.setPath (names[i]);
2759                                      result.append (cimObject);
2760 mike           1.51              }
2761                                  else
2762                                  {
2763 kumpf          1.104                 CIMInstance instance = _getInstance(
2764 mike           1.51                      tmpNameSpace,
2765                                          tmpRef,
2766                                          false,
2767                                          includeQualifiers,
2768                                          includeClassOrigin,
2769                                          propertyList);
2770 mike           1.48      
2771 kumpf          1.71                  CIMObject cimObject = CIMObject (instance);
2772                                      cimObject.setPath (names[i]);
2773                                      result.append (cimObject);
2774 mike           1.51              }
2775 mike           1.48          }
2776                          
2777 kumpf          1.58          PEG_METHOD_EXIT();
2778 mike           1.48          return result;
2779                          }
2780                          
2781 kumpf          1.68      Array<CIMObjectPath> CIMRepository::referenceNames(
2782 kumpf          1.85          const CIMNamespaceName& nameSpace,
2783 kumpf          1.68          const CIMObjectPath& objectName,
2784 kumpf          1.85          const CIMName& resultClass,
2785 mike           1.48          const String& role)
2786                          {
2787 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::referenceNames");
2788                          
2789 kumpf          1.104         ReadLock lock(_lock);
2790                              Array<CIMObjectPath> result = _referenceNames(
2791                                  nameSpace, objectName, resultClass, role);
2792                          
2793                              PEG_METHOD_EXIT();
2794                              return result;
2795                          }
2796                          
2797                          Array<CIMObjectPath> CIMRepository::_referenceNames(
2798                              const CIMNamespaceName& nameSpace,
2799                              const CIMObjectPath& objectName,
2800                              const CIMName& resultClass,
2801                              const String& role)
2802                          {
2803                              PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_referenceNames");
2804                          
2805 mike           1.48          Array<String> tmpReferenceNames;
2806                          
2807 kumpf          1.93          // The resultClass parameter implies subclasses, so retrieve them
2808                              Array<CIMName> resultClassList;
2809 a.dunfey       1.120     
2810                          	try {
2811 kumpf          1.93          if (!resultClass.isNull())
2812                              {
2813                                  _nameSpaceManager.getSubClassNames(
2814                                      nameSpace, resultClass, true, resultClassList);
2815                                  resultClassList.append(resultClass);
2816                              }
2817 karl           1.86      
2818 kumpf          1.80          //  ATTN-CAKG-P2-20020726:  The following condition does not correctly
2819                              //  distinguish instanceNames from classNames in every case
2820                              //  The instanceName of a singleton instance of a keyless class also
2821                              //  has no key bindings
2822                              //
2823                              if (objectName.getKeyBindings ().size () == 0)
2824 mike           1.48          {
2825 kumpf          1.93              CIMName className = objectName.getClassName();
2826                          
2827                                  Array<CIMName> classList;
2828                                  _nameSpaceManager.getSuperClassNames(nameSpace, className, classList);
2829                                  classList.append(className);
2830                          
2831 schuur         1.112             Array<String> assocFileName = _nameSpaceManager.getAssocClassPath(nameSpace,NameSpaceRead);
2832 mike           1.48      
2833 schuur         1.112     	Boolean refs=false;
2834                                  for (int i=0,m=assocFileName.size(); !refs && i<m; i++)
2835                                     if (AssocClassTable::getReferenceNames(
2836                                            assocFileName[i],
2837 karl           1.86                  classList,
2838 kumpf          1.93                  resultClassList,
2839 mike           1.51                  role,
2840 schuur         1.112                       tmpReferenceNames)) refs|=true;
2841                          
2842                                  if (refs==false) {
2843 mike           1.51                  // Ignore error! It's okay not to have references.
2844                                  }
2845 mike           1.48          }
2846 schuur         1.112     
2847                              else {
2848 kumpf          1.91              String assocFileName = _nameSpaceManager.getAssocInstPath(nameSpace);
2849 mike           1.48      
2850 mike           1.51              if (!AssocInstTable::getReferenceNames(
2851                                      assocFileName,
2852                                      objectName,
2853 kumpf          1.93                  resultClassList,
2854 mike           1.51                  role,
2855                                      tmpReferenceNames))
2856 schuur         1.112     
2857 mike           1.51              {
2858                                      // Ignore error! It's okay not to have references.
2859                                  }
2860 mike           1.48          }
2861 a.dunfey       1.120     	}
2862 a.dunfey       1.121     	catch (CIMException& exception) {
2863 a.dunfey       1.120     		if(exception.getCode() == CIM_ERR_INVALID_CLASS) {
2864                          			throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, exception.getMessage());
2865                          		}
2866                          		else
2867                          			throw exception;
2868                          	}
2869 mike           1.48      
2870 kumpf          1.68          Array<CIMObjectPath> result;
2871 mike           1.48      
2872                              for (Uint32 i = 0, n = tmpReferenceNames.size(); i < n; i++)
2873                              {
2874 kumpf          1.68              CIMObjectPath r = tmpReferenceNames[i];
2875 mike           1.48      
2876                                  if (r.getHost().size() == 0)
2877                                      r.setHost(System::getHostName());
2878                          
2879 kumpf          1.79              if (r.getNameSpace().isNull())
2880 mike           1.48                  r.setNameSpace(nameSpace);
2881                          
2882 mike           1.51              result.append(r);
2883 mike           1.48          }
2884                          
2885 kumpf          1.58          PEG_METHOD_EXIT();
2886 mike           1.48          return result;
2887                          }
2888                          
2889                          CIMValue CIMRepository::getProperty(
2890 kumpf          1.85          const CIMNamespaceName& nameSpace,
2891 kumpf          1.68          const CIMObjectPath& instanceName,
2892 kumpf          1.85          const CIMName& propertyName)
2893 mike           1.48      {
2894 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::getProperty");
2895                          
2896 kumpf          1.104         ReadLock lock(_lock);
2897                          
2898 mike           1.53          //
2899                              // Get the index for this instance:
2900                              //
2901 mike           1.48      
2902 kumpf          1.85          CIMName className;
2903 mike           1.48          Uint32 index;
2904 mike           1.51          Uint32 size;
2905 mike           1.48      
2906 mike           1.53          if (!_getInstanceIndex(nameSpace, instanceName, className, index, size))
2907 kumpf          1.58          {
2908                                  PEG_METHOD_EXIT();
2909 mike           1.51              throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND, instanceName.toString());
2910 kumpf          1.58          }
2911 mike           1.48      
2912 mike           1.53          //
2913                              // Load the instance into memory:
2914                              //
2915 mike           1.48      
2916 mike           1.53          String path = _getInstanceDataFilePath(nameSpace, className);
2917 mike           1.48          CIMInstance cimInstance;
2918 mike           1.53      
2919 mike           1.51          if (!_loadInstance(path, cimInstance, index, size))
2920                              {
2921 kumpf          1.58              PEG_METHOD_EXIT();
2922 mike           1.51              throw CannotOpenFile(path);
2923                              }
2924 mike           1.48      
2925 mike           1.53          //
2926                              // Grab the property from the instance:
2927                              //
2928 mike           1.48      
2929                              Uint32 pos = cimInstance.findProperty(propertyName);
2930                          
2931 mike           1.51          // ATTN: This breaks if the property is simply null
2932 kumpf          1.77          if (pos == PEG_NOT_FOUND)
2933 kumpf          1.58          {
2934                                  PEG_METHOD_EXIT();
2935 mike           1.51              throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NO_SUCH_PROPERTY, "getProperty()");
2936 kumpf          1.58          }
2937 mike           1.48      
2938                              CIMProperty prop = cimInstance.getProperty(pos);
2939                          
2940 mike           1.53          //
2941                              // Return the value:
2942                              //
2943 mike           1.48      
2944 kumpf          1.58          PEG_METHOD_EXIT();
2945 mike           1.48          return prop.getValue();
2946                          }
2947                          
2948                          void CIMRepository::setProperty(
2949 kumpf          1.85          const CIMNamespaceName& nameSpace,
2950 kumpf          1.68          const CIMObjectPath& instanceName,
2951 kumpf          1.85          const CIMName& propertyName,
2952 chuck          1.110         const CIMValue& newValue,
2953                              const ContentLanguages& contentLangs)
2954 mike           1.48      {
2955 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::setProperty");
2956                          
2957 chuck          1.110         if (contentLangs.size() > 0)
2958                              {
2959                                throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
2960                                      MessageLoaderParms("Repository.CIMRepository.UNSUPPORTED_CONTENTLANG",
2961                          			       "The Content-Language header is not supported for this request"));
2962                              }
2963                          
2964 kumpf          1.104         // It is not necessary to control access to the ReadWriteSem _lock here.
2965                              // This method calls modifyInstance, which does its own access control.
2966                          
2967 mike           1.51          //
2968                              // Create the instance to pass to modifyInstance()
2969                              //
2970 mike           1.53      
2971 mike           1.51          CIMInstance instance(instanceName.getClassName());
2972                              instance.addProperty(CIMProperty(propertyName, newValue));
2973 kumpf          1.70          instance.setPath (instanceName);
2974 mike           1.51      
2975                              //
2976                              // Create the propertyList to pass to modifyInstance()
2977                              //
2978 mike           1.53      
2979 kumpf          1.79          Array<CIMName> propertyListArray;
2980 mike           1.51          propertyListArray.append(propertyName);
2981                              CIMPropertyList propertyList(propertyListArray);
2982                          
2983                              //
2984                              // Modify the instance to set the value of the given property
2985                              //
2986 kumpf          1.70          modifyInstance(nameSpace, instance, false, propertyList);
2987 kumpf          1.58      
2988                              PEG_METHOD_EXIT();
2989 mike           1.48      }
2990                          
2991                          CIMQualifierDecl CIMRepository::getQualifier(
2992 kumpf          1.85          const CIMNamespaceName& nameSpace,
2993                              const CIMName& qualifierName)
2994 mike           1.48      {
2995 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::getQualifier");
2996                          
2997 kumpf          1.104         ReadLock lock(_lock);
2998                              CIMQualifierDecl qualifierDecl = _getQualifier(nameSpace, qualifierName);
2999                          
3000                              PEG_METHOD_EXIT();
3001                              return qualifierDecl;
3002                          }
3003                          
3004                          CIMQualifierDecl CIMRepository::_getQualifier(
3005                              const CIMNamespaceName& nameSpace,
3006                              const CIMName& qualifierName)
3007                          {
3008                              PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_getQualifier");
3009                          
3010 mike           1.53          //
3011                              // Get path of qualifier file:
3012                              //
3013 mike           1.48      
3014                              String qualifierFilePath = _nameSpaceManager.getQualifierFilePath(
3015 schuur         1.112             nameSpace, qualifierName,NameSpaceRead);
3016 mike           1.48      
3017 mike           1.53          //
3018                              // Load qualifier:
3019                              //
3020 mike           1.48      
3021                              CIMQualifierDecl qualifierDecl;
3022                          
3023                              try
3024                              {
3025 schuur         1.114             _LoadObject(qualifierFilePath, qualifierDecl, streamer);
3026 mike           1.48          }
3027                              catch (CannotOpenFile&)
3028                              {
3029 kumpf          1.58              PEG_METHOD_EXIT();
3030 kumpf          1.85              throw PEGASUS_CIM_EXCEPTION
3031                                      (CIM_ERR_NOT_FOUND, qualifierName.getString());
3032 mike           1.48          }
3033                          
3034 kumpf          1.58          PEG_METHOD_EXIT();
3035 mike           1.48          return qualifierDecl;
3036                          }
3037                          
3038                          void CIMRepository::setQualifier(
3039 kumpf          1.85          const CIMNamespaceName& nameSpace,
3040 chuck          1.110         const CIMQualifierDecl& qualifierDecl,
3041                              const ContentLanguages& contentLangs)
3042 mike           1.48      {
3043 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::setQualifier");
3044 chuck          1.110     
3045                              if (contentLangs.size() > 0)
3046                              {
3047                                throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
3048                                      MessageLoaderParms("Repository.CIMRepository.UNSUPPORTED_CONTENTLANG",
3049                          			       "The Content-Language header is not supported for this request."));
3050                              }
3051 kumpf          1.58      
3052 kumpf          1.104         WriteLock lock(_lock);
3053                              _setQualifier(nameSpace, qualifierDecl);
3054                          
3055                              PEG_METHOD_EXIT();
3056                          }
3057                          
3058                          void CIMRepository::_setQualifier(
3059                              const CIMNamespaceName& nameSpace,
3060                              const CIMQualifierDecl& qualifierDecl)
3061                          {
3062                              PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_setQualifier");
3063                          
3064 mike           1.48          // -- Get path of qualifier file:
3065                          
3066                              String qualifierFilePath = _nameSpaceManager.getQualifierFilePath(
3067 schuur         1.112             nameSpace, qualifierDecl.getName(),NameSpaceWrite);
3068 mike           1.48      
3069 kumpf          1.75          // -- If qualifier already exists, throw exception:
3070 mike           1.48      
3071                              if (FileSystem::existsNoCase(qualifierFilePath))
3072 mike           1.53          {
3073 kumpf          1.58              PEG_METHOD_EXIT();
3074 mike           1.53              throw PEGASUS_CIM_EXCEPTION(
3075 a.arora        1.107                 CIM_ERR_NOT_SUPPORTED, qualifierDecl.getName().getString());
3076 mike           1.53          }
3077 mike           1.48      
3078                              // -- Save qualifier:
3079                          
3080 kumpf          1.66          Array<Sint8> qualifierDeclXml;
3081 schuur         1.114         streamer->encode(qualifierDeclXml, qualifierDecl);
3082                              //XmlWriter::appendQualifierDeclElement(qualifierDeclXml, qualifierDecl);
3083                              _SaveObject(qualifierFilePath, qualifierDeclXml,streamer);
3084 kumpf          1.58      
3085                              PEG_METHOD_EXIT();
3086 mike           1.48      }
3087                          
3088                          void CIMRepository::deleteQualifier(
3089 kumpf          1.85          const CIMNamespaceName& nameSpace,
3090                              const CIMName& qualifierName)
3091 mike           1.48      {
3092 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::deleteQualifier");
3093                          
3094 kumpf          1.104         WriteLock lock(_lock);
3095                          
3096 mike           1.48          // -- Get path of qualifier file:
3097                          
3098                              String qualifierFilePath = _nameSpaceManager.getQualifierFilePath(
3099 schuur         1.112             nameSpace, qualifierName,NameSpaceDelete);
3100 mike           1.48      
3101                              // -- Delete qualifier:
3102                          
3103                              if (!FileSystem::removeFileNoCase(qualifierFilePath))
3104 kumpf          1.58          {
3105                                  PEG_METHOD_EXIT();
3106 kumpf          1.85              throw PEGASUS_CIM_EXCEPTION
3107                                      (CIM_ERR_NOT_FOUND, qualifierName.getString());
3108 kumpf          1.58          }
3109                          
3110                              PEG_METHOD_EXIT();
3111 mike           1.48      }
3112                          
3113                          Array<CIMQualifierDecl> CIMRepository::enumerateQualifiers(
3114 kumpf          1.85          const CIMNamespaceName& nameSpace)
3115 mike           1.48      {
3116 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::enumerateQualifiers");
3117                          
3118 kumpf          1.104         ReadLock lock(_lock);
3119                          
3120 mike           1.48          String qualifiersRoot = _nameSpaceManager.getQualifiersRoot(nameSpace);
3121                          
3122                              Array<String> qualifierNames;
3123                          
3124                              if (!FileSystem::getDirectoryContents(qualifiersRoot, qualifierNames))
3125                              {
3126 kumpf          1.58              PEG_METHOD_EXIT();
3127 humberto       1.88              //l10n
3128                                  String str ="enumerateQualifiers()";
3129                                  //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
3130                                      //"enumerateQualifiers(): internal error");
3131 kumpf          1.99              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
3132                                      MessageLoaderParms("Repository.CIMRepository.INTERNAL_ERROR",
3133                                          "$0: internal error",
3134                                          str));
3135 humberto       1.88              //l10n end
3136 mike           1.48          }
3137                          
3138                              Array<CIMQualifierDecl> qualifiers;
3139                          
3140                              for (Uint32 i = 0; i < qualifierNames.size(); i++)
3141                              {
3142 chuck          1.109     #ifdef PEGASUS_REPOSITORY_ESCAPE_UTF8
3143                              // All chars above 0x7F will be escape.
3144                                CIMQualifierDecl qualifier =
3145                                      _getQualifier(nameSpace, escapeStringDecoder(qualifierNames[i]));
3146 chip           1.118     #else
3147 chuck          1.109           CIMQualifierDecl qualifier =
3148 kumpf          1.104                 _getQualifier(nameSpace, qualifierNames[i]);
3149 chuck          1.109     #endif
3150                                qualifiers.append(qualifier);
3151 mike           1.48          }
3152                          
3153 kumpf          1.58          PEG_METHOD_EXIT();
3154 mike           1.48          return qualifiers;
3155                          }
3156                          
3157 schuur         1.112     void CIMRepository::createNameSpace(const CIMNamespaceName& nameSpace,
3158                                  const NameSpaceAttributes &attributes)
3159 mike           1.48      {
3160 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::createNameSpace");
3161                          
3162 kumpf          1.104         WriteLock lock(_lock);
3163 schuur         1.112         _nameSpaceManager.createNameSpace(nameSpace, attributes);
3164                          
3165                              PEG_METHOD_EXIT();
3166                          }
3167                          
3168                          void CIMRepository::modifyNameSpace(const CIMNamespaceName& nameSpace,
3169                                  const NameSpaceAttributes &attributes)
3170                          {
3171                              PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::modifyNameSpace");
3172                          
3173                              WriteLock lock(_lock);
3174                              _nameSpaceManager.modifyNameSpace(nameSpace, attributes);
3175 kumpf          1.58      
3176                              PEG_METHOD_EXIT();
3177 mike           1.48      }
3178                          
3179 kumpf          1.85      Array<CIMNamespaceName> CIMRepository::enumerateNameSpaces() const
3180 mike           1.48      {
3181 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::enumerateNameSpaces");
3182                          
3183 kumpf          1.104         ReadLock lock(const_cast<ReadWriteSem&>(_lock));
3184                          
3185 kumpf          1.85          Array<CIMNamespaceName> nameSpaceNames;
3186 mike           1.48          _nameSpaceManager.getNameSpaceNames(nameSpaceNames);
3187 kumpf          1.58      
3188                              PEG_METHOD_EXIT();
3189 mike           1.48          return nameSpaceNames;
3190                          }
3191                          
3192 kumpf          1.85      void CIMRepository::deleteNameSpace(const CIMNamespaceName& nameSpace)
3193 mike           1.48      {
3194 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::deleteNameSpace");
3195                          
3196 kumpf          1.104         WriteLock lock(_lock);
3197 mike           1.48          _nameSpaceManager.deleteNameSpace(nameSpace);
3198 kumpf          1.58      
3199                              PEG_METHOD_EXIT();
3200 mike           1.48      }
3201                          
3202 schuur         1.112     Boolean CIMRepository::getNameSpaceAttributes(const CIMNamespaceName& nameSpace,
3203                                  NameSpaceAttributes &attributes)
3204                          {
3205                              PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::deleteNameSpace");
3206                          
3207                              ReadLock lock(const_cast<ReadWriteSem&>(_lock));
3208                              attributes.clear();
3209                              PEG_METHOD_EXIT();
3210                              return _nameSpaceManager.getNameSpaceAttributes(nameSpace, attributes);
3211                          }
3212                          
3213 schuur         1.115     Boolean CIMRepository::isRemoteNameSpace(const CIMNamespaceName& nameSpaceName,
3214                                  String & remoteInfo)
3215                          {
3216                              PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::isRemoteNamespace");
3217                              ReadLock lock(const_cast<ReadWriteSem&>(_lock));
3218                              PEG_METHOD_EXIT();
3219                              return _nameSpaceManager.isRemoteNameSpace(nameSpaceName, remoteInfo);
3220                          }
3221                          
3222 mike           1.51      //----------------------------------------------------------------------
3223                          //
3224 mike           1.53      // _getInstanceIndexFilePath()
3225 mike           1.51      //
3226 kumpf          1.104     //      returns the file path of the instance index file.
3227 mike           1.51      //
3228                          //----------------------------------------------------------------------
3229                          
3230 mike           1.53      String CIMRepository::_getInstanceIndexFilePath(
3231 kumpf          1.85          const CIMNamespaceName& nameSpace,
3232                              const CIMName& className) const
3233 mike           1.48      {
3234 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_getInstanceIndexFilePath");
3235                          
3236 mike           1.53          String tmp = _nameSpaceManager.getInstanceDataFileBase(
3237 kumpf          1.104             nameSpace, className);
3238 mike           1.53      
3239 mike           1.48          tmp.append(".idx");
3240 kumpf          1.58      
3241                              PEG_METHOD_EXIT();
3242 mike           1.48          return tmp;
3243                          }
3244                          
3245 mike           1.51      //----------------------------------------------------------------------
3246                          //
3247 mike           1.53      // _getInstanceDataFilePath()
3248 mike           1.51      //
3249 kumpf          1.104     //      returns the file path of the instance file.
3250 mike           1.51      //
3251                          //----------------------------------------------------------------------
3252                          
3253 mike           1.53      String CIMRepository::_getInstanceDataFilePath(
3254 kumpf          1.85          const CIMNamespaceName& nameSpace,
3255                              const CIMName& className) const
3256 mike           1.48      {
3257 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_getInstanceDataFilePath");
3258                          
3259 mike           1.53          String tmp = _nameSpaceManager.getInstanceDataFileBase(
3260 kumpf          1.104             nameSpace, className);
3261 mike           1.51          tmp.append(".instances");
3262 kumpf          1.104     
3263 kumpf          1.58          PEG_METHOD_EXIT();
3264 mike           1.48          return tmp;
3265 mike           1.51      }
3266                          
3267                          Boolean CIMRepository::_loadInstance(
3268                              const String& path,
3269                              CIMInstance& object,
3270                              Uint32 index,
3271                              Uint32 size)
3272                          {
3273 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_loadInstance");
3274                          
3275 mike           1.51          //
3276 mike           1.53          // Load instance (in XML) from instance file into memory:
3277 mike           1.51          //
3278                          
3279 mike           1.53          Array<Sint8> data;
3280 mike           1.51      
3281 mike           1.53          if (!InstanceDataFile::loadInstance(path, index, size, data))
3282 kumpf          1.58          {
3283                                  PEG_METHOD_EXIT();
3284 mike           1.51              return false;
3285 kumpf          1.58          }
3286 mike           1.51      
3287                              //
3288 mike           1.53          // Convert XML into an actual object:
3289 mike           1.51          //
3290                          
3291 schuur         1.114         streamer->decode(data, 0, object);
3292                              //XmlParser parser((char*)data.getData());
3293                              //XmlReader::getObject(parser, object);
3294 mike           1.51      
3295 kumpf          1.58          PEG_METHOD_EXIT();
3296 mike           1.51          return true;
3297 mike           1.48      }
3298                          
3299 bob            1.49      void CIMRepository::setDeclContext(RepositoryDeclContext *context)
3300                          {
3301 kumpf          1.58          PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::setDeclContext");
3302                          
3303 kumpf          1.104         WriteLock lock(_lock);
3304 kumpf          1.58          _context = context;
3305                          
3306                              PEG_METHOD_EXIT();
3307 bob            1.49      }
3308                          
3309 mike           1.48      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2