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

   1 r.kieninger 1.1 //%LICENSE////////////////////////////////////////////////////////////////
   2                 //
   3                 // Licensed to The Open Group (TOG) under one or more contributor license
   4                 // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
   5                 // this work for additional information regarding copyright ownership.
   6                 // Each contributor licenses this file to you under the OpenPegasus Open
   7                 // Source License; you may not use this file except in compliance with the
   8                 // License.
   9                 //
  10                 // Permission is hereby granted, free of charge, to any person obtaining a
  11                 // copy of this software and associated documentation files (the "Software"),
  12                 // to deal in the Software without restriction, including without limitation
  13                 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  14                 // and/or sell copies of the Software, and to permit persons to whom the
  15                 // Software is furnished to do so, subject to the following conditions:
  16                 //
  17                 // The above copyright notice and this permission notice shall be included
  18                 // in all copies or substantial portions of the Software.
  19                 //
  20                 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  21                 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22 r.kieninger 1.1 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  23                 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  24                 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  25                 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  26                 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27                 //
  28                 //////////////////////////////////////////////////////////////////////////
  29                 //
  30 karl        1.5.2.7 // Class CIMResponseData encapsulates the possible types of response data
  31                     // representations and supplies conversion methods between these types.
  32                     // PEP#348 - The CMPI infrastructure using SCMO (Single Chunk Memory Objects)
  33                     // describes its usage in the server flow.
  34                     // The design document can be found on the OpenPegasus website openpegasus.org
  35                     // at https://collaboration.opengroup.org/pegasus/pp/documents/21210/PEP_348.pdf
  36                     //
  37 r.kieninger 1.1     //%/////////////////////////////////////////////////////////////////////////////
  38                     
  39                     #include "CIMResponseData.h"
  40 thilo.boehm 1.3     #include <Pegasus/Common/Tracer.h>
  41                     #include <Pegasus/Common/XmlWriter.h>
  42                     #include <Pegasus/Common/SCMOXmlWriter.h>
  43                     #include <Pegasus/Common/XmlReader.h>
  44                     #include <Pegasus/Common/CIMInternalXmlEncoder.h>
  45                     #include <Pegasus/Common/SCMOInternalXmlEncoder.h>
  46 r.kieninger 1.1     
  47 karl        1.5.2.5 
  48 r.kieninger 1.1     PEGASUS_USING_STD;
  49                     
  50                     PEGASUS_NAMESPACE_BEGIN
  51                     
  52 karl        1.5.2.11 // Defines debug code in CIMResponseData.  This under this
  53                      // special compile flag so that it can be compiled independent of
  54                      // PEGASUS_DEBUG flags.
  55                      #define CIMRESPONSEDATA_DEBUG
  56                      
  57 karl        1.5.2.1  #define LOCAL_MIN(a, b) ((a < b) ? a : b)
  58 thilo.boehm 1.3      // C++ objects interface handling
  59                      
  60 karl        1.5.2.7  // KS_TODO Remove this completely when finished testing.
  61 karl        1.5.2.5  bool CIMResponseData::sizeValid()
  62 karl        1.5.2.3  {
  63 karl        1.5.2.11     PEGASUS_DEBUG_ASSERT(valid());
  64                      #ifdef CIMRESPONSEDATA_DEBUG
  65 karl        1.5.2.5      if (_size > 1000000)
  66 karl        1.5.2.3      {
  67 karl        1.5.2.14         cout << "CIMResponseData::TEST_SIZE_VALID _size too big "
  68                                   << _size << endl;
  69 karl        1.5.2.5          PEG_TRACE((TRC_XML, Tracer::LEVEL4,
  70 karl        1.5.2.14                    "CIMResponseData::TEST_SIZE_VALID _size too big %u",_size ));
  71 karl        1.5.2.5          return false;
  72 karl        1.5.2.3      }
  73 karl        1.5.2.11 #endif
  74 karl        1.5.2.20 ////  KS TODO Remove this diagnostic completely
  75                      ////  PEG_TRACE((TRC_XML, Tracer::LEVEL4,
  76                      ////      "CIMResponseData Size _size=%u", _size));
  77 karl        1.5.2.5      return true;
  78 karl        1.5.2.3  }
  79 karl        1.5.2.15 
  80                      /*
  81                          Append an InstanceElement to the Buffer. This function accounts
  82                          for the existence of a propertyList.
  83                      */
  84                      void CIMResponseData::_appendInstanceElement(
  85                          Buffer& out,
  86                          SCMOInstance _scmoInstance)
  87                      {
  88                          if(_propertyList.isNull())
  89                          {
  90                              Array<Uint32> emptyNodes;
  91                              SCMOXmlWriter::appendInstanceElement(
  92                                  out,
  93                                  _scmoInstance,
  94                                  false,
  95                                  emptyNodes);
  96                          }
  97                          else
  98                          {
  99                              Array<propertyFilterNodesArray_t> propFilterNodesArrays;
 100 karl        1.5.2.15         // This searches for an already created array of nodes,
 101                              //if not found, creates it inside propFilterNodesArrays
 102                              const Array<Uint32> & nodes=
 103                                  SCMOXmlWriter::getFilteredNodesArray(
 104                                      propFilterNodesArrays,
 105                                      _scmoInstance,
 106                                      _propertyList);
 107                              SCMOXmlWriter::appendInstanceElement(
 108                                  out,
 109                                  _scmoInstance,
 110                                  true,
 111                                  nodes);
 112                          }
 113                      }
 114                      
 115 thilo.boehm 1.3      // Instance Names handling
 116                      Array<CIMObjectPath>& CIMResponseData::getInstanceNames()
 117                      {
 118 karl        1.5.2.14     TEST_SIZE_VALID;
 119 thilo.boehm 1.3          PEGASUS_DEBUG_ASSERT(
 120                          (_dataType==RESP_INSTNAMES || _dataType==RESP_OBJECTPATHS));
 121                          _resolveToCIM();
 122                          PEGASUS_DEBUG_ASSERT(_encoding==RESP_ENC_CIM || _encoding == 0);
 123                          return _instanceNames;
 124                      }
 125                      
 126 karl        1.5.2.1  // Get a single instance as a CIM instance.
 127                      // This converts all of the objects in the response data to
 128                      // CIM form as part of the conversion.
 129                      // If there are no instances in the object, returns CIMInstance(),
 130                      // an empty instance.
 131 thilo.boehm 1.3      CIMInstance& CIMResponseData::getInstance()
 132                      {
 133                          PEGASUS_DEBUG_ASSERT(_dataType == RESP_INSTANCE);
 134                          _resolveToCIM();
 135                          if (0 == _instances.size())
 136                          {
 137                              _instances.append(CIMInstance());
 138                          }
 139                          return _instances[0];
 140                      }
 141                      
 142                      // Instances handling
 143                      Array<CIMInstance>& CIMResponseData::getInstances()
 144                      {
 145                          PEGASUS_DEBUG_ASSERT(_dataType == RESP_INSTANCES);
 146                          _resolveToCIM();
 147                          return _instances;
 148                      }
 149                      
 150 karl        1.5.2.1  // Instances handling specifically for the client where the call may
 151                      // get either instances or objects and must convert them to instances
 152                      // NOTE: This is a temporary solution to satisfy the BinaryCodec passing
 153                      // of data to the client where the data could be either instances or
 154                      // objects.  The correct solution is to convert back when the provider, etc.
 155                      // returns the data to the server.  We must convert to that solution but
 156                      // this keeps it working for the moment.
 157                      Array<CIMInstance>& CIMResponseData::getInstancesFromInstancesOrObjects()
 158                      {
 159                          if (_dataType == RESP_INSTANCES)
 160                          {
 161                              _resolveToCIM();
 162                              return _instances;
 163                          }
 164                          else if (_dataType == RESP_OBJECTS)
 165                          {
 166                              _resolveToCIM();
 167                              for (Uint32 i = 0 ; i < _objects.size() ; i++)
 168                              {
 169                                  _instances.append((CIMInstance)_objects[i]);
 170                              }
 171 karl        1.5.2.1          return _instances;
 172                      
 173                          }
 174 karl        1.5.2.11     PEGASUS_ASSERT(false);
 175 karl        1.5.2.1  }
 176                      
 177 thilo.boehm 1.3      // Objects handling
 178                      Array<CIMObject>& CIMResponseData::getObjects()
 179                      {
 180 karl        1.5.2.11     PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::getObjects");
 181 thilo.boehm 1.3          PEGASUS_DEBUG_ASSERT(_dataType == RESP_OBJECTS);
 182                          _resolveToCIM();
 183 karl        1.5.2.11     PEG_METHOD_EXIT();
 184 thilo.boehm 1.3          return _objects;
 185                      }
 186                      
 187                      // SCMO representation, single instance stored as one element array
 188                      // object paths are represented as SCMOInstance
 189 karl        1.5.2.7  // Resolve all of the information in the CIMResponseData container to
 190                      // SCMO  and return all scmoInstances.
 191                      // Note that since the SCMO representation,
 192                      // a is single instance stored as one element array and object paths are
 193                      // represented as SCMOInstance this returns array of SCMOInstance.
 194 thilo.boehm 1.3      Array<SCMOInstance>& CIMResponseData::getSCMO()
 195                      {
 196 karl        1.5.2.11     PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::getSCMO");
 197 karl        1.5.2.7      // This function resolves to instances and so cannot handle responses to
 198                          // the associators,etc.requests that return classes (input object path with
 199                          // no keys). That issue is resolved however, since CIMResponseData uses the
 200                          // _isClassOperation variable (set by the request) to determine whether
 201                          // the responses are classpaths or instancepaths and the default is
 202                          // false(instancePaths) so that this should always produce instance paths.
 203                      
 204 thilo.boehm 1.3          _resolveToSCMO();
 205 karl        1.5.2.11     PEG_METHOD_EXIT();
 206 thilo.boehm 1.3          return _scmoInstances;
 207                      }
 208                      
 209 karl        1.5.2.1  // set an array of SCMOInstances into the response data object
 210 thilo.boehm 1.3      void CIMResponseData::setSCMO(const Array<SCMOInstance>& x)
 211                      {
 212 karl        1.5.2.11 
 213                          PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setSCMO");
 214 karl        1.5.2.9      //// AutoMutex autoMut(testLock);
 215 karl        1.5.2.14     TEST_SIZE_VALID;
 216 thilo.boehm 1.3          _scmoInstances=x;
 217                          _encoding |= RESP_ENC_SCMO;
 218 karl        1.5.2.1      _size += x.size();
 219 karl        1.5.2.11     PEG_METHOD_EXIT();
 220 thilo.boehm 1.3      }
 221                      
 222                      // Binary data is just a data stream
 223                      Array<Uint8>& CIMResponseData::getBinary()
 224                      {
 225                          PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_BINARY || _encoding == 0);
 226                          return _binaryData;
 227                      }
 228                      
 229 karl        1.5      bool CIMResponseData::setBinary(CIMBuffer& in)
 230 r.kieninger 1.1      {
 231 karl        1.5          PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setBinary");
 232 r.kieninger 1.1      
 233 karl        1.5          // Append all serial data from the CIMBuffer to the local data store.
 234                          // Returns error if input not a serialized Uint8A
 235                          if (!in.getUint8A(_binaryData))
 236                          {
 237                              PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 238                                  "Failed to get binary input data!");
 239                              PEG_METHOD_EXIT();
 240                              return false;
 241 r.kieninger 1.1          }
 242 karl        1.5          _encoding |= RESP_ENC_BINARY;
 243                          PEG_METHOD_EXIT();
 244                          return true;
 245                      }
 246                      
 247                      bool CIMResponseData::setRemainingBinaryData(CIMBuffer& in)
 248                      {
 249                          PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setRemainingBinaryData");
 250                      
 251                          // Append any data that has not been deserialized already from
 252                          // the CIMBuffer.
 253                          size_t remainingDataLength = in.remainingDataLength();
 254                          _binaryData.append((Uint8*)in.getPtr(), remainingDataLength);
 255                      
 256 thilo.boehm 1.3          _encoding |= RESP_ENC_BINARY;
 257 r.kieninger 1.1          PEG_METHOD_EXIT();
 258                          return true;
 259 thilo.boehm 1.3      }
 260 r.kieninger 1.1      
 261 thilo.boehm 1.3      bool CIMResponseData::setXml(CIMBuffer& in)
 262 r.kieninger 1.1      {
 263 karl        1.5.2.12     PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setXml");
 264                      
 265 thilo.boehm 1.3          switch (_dataType)
 266 r.kieninger 1.1          {
 267 thilo.boehm 1.3              case RESP_INSTANCE:
 268                              {
 269                                  Array<Sint8> inst;
 270                                  Array<Sint8> ref;
 271                                  CIMNamespaceName ns;
 272                                  String host;
 273                                  if (!in.getSint8A(inst))
 274                                  {
 275                                      PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 276                                          "Failed to get XML instance data!");
 277                                      return false;
 278                                  }
 279                                  _instanceData.insert(0,inst);
 280                                  if (!in.getSint8A(ref))
 281                                  {
 282                                      PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 283                                          "Failed to get XML instance data (reference)!");
 284                                      return false;
 285                                  }
 286                                  _referencesData.insert(0,ref);
 287                                  if (!in.getString(host))
 288 thilo.boehm 1.3                  {
 289                                      PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 290                                          "Failed to get XML instance data (host)!");
 291                                      return false;
 292                                  }
 293                                  _hostsData.insert(0,host);
 294                                  if (!in.getNamespaceName(ns))
 295                                  {
 296                                      PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 297                                          "Failed to get XML instance data (namespace)!");
 298                                      return false;
 299                                  }
 300                                  _nameSpacesData.insert(0,ns);
 301 karl        1.5.2.1              _size++;
 302 thilo.boehm 1.3                  break;
 303                              }
 304                              case RESP_INSTANCES:
 305                              {
 306                                  Uint32 count;
 307                                  if (!in.getUint32(count))
 308                                  {
 309                                      PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 310                                          "Failed to get XML instance data (number of instance)!");
 311                                      return false;
 312                                  }
 313                                  for (Uint32 i = 0; i < count; i++)
 314                                  {
 315                                      Array<Sint8> inst;
 316                                      Array<Sint8> ref;
 317                                      CIMNamespaceName ns;
 318                                      String host;
 319                                      if (!in.getSint8A(inst))
 320                                      {
 321                                          PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 322                                              "Failed to get XML instance data (instances)!");
 323 thilo.boehm 1.3                          return false;
 324                                      }
 325                                      if (!in.getSint8A(ref))
 326                                      {
 327                                          PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 328                                              "Failed to get XML instance data (references)!");
 329                                          return false;
 330                                      }
 331                                      if (!in.getString(host))
 332                                      {
 333                                          PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 334                                              "Failed to get XML instance data (host)!");
 335                                          return false;
 336                                      }
 337                                      if (!in.getNamespaceName(ns))
 338                                      {
 339                                          PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 340                                              "Failed to get XML instance data (namespace)!");
 341                                          return false;
 342                                      }
 343                                      _instanceData.append(inst);
 344 thilo.boehm 1.3                      _referencesData.append(ref);
 345                                      _hostsData.append(host);
 346                                      _nameSpacesData.append(ns);
 347                                  }
 348 karl        1.5.2.1              _size += count;
 349 thilo.boehm 1.3                  break;
 350                              }
 351                              case RESP_OBJECTS:
 352                              {
 353                                  Uint32 count;
 354                                  if (!in.getUint32(count))
 355                                  {
 356                                      PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 357                                          "Failed to get XML object data (number of objects)!");
 358                                      return false;
 359                                  }
 360                                  for (Uint32 i = 0; i < count; i++)
 361                                  {
 362                                      Array<Sint8> obj;
 363                                      Array<Sint8> ref;
 364                                      CIMNamespaceName ns;
 365                                      String host;
 366                                      if (!in.getSint8A(obj))
 367                                      {
 368                                          PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 369                                              "Failed to get XML object data (object)!");
 370 thilo.boehm 1.3                          return false;
 371                                      }
 372                                      if (!in.getSint8A(ref))
 373                                      {
 374                                          PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 375                                              "Failed to get XML object data (reference)!");
 376                                          return false;
 377                                      }
 378                                      if (!in.getString(host))
 379                                      {
 380                                          PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 381                                              "Failed to get XML object data (host)!");
 382                                          return false;
 383                                      }
 384                                      if (!in.getNamespaceName(ns))
 385                                      {
 386                                          PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 387                                              "Failed to get XML object data (namespace)!");
 388                                          return false;
 389                                      }
 390                                      _instanceData.append(obj);
 391 thilo.boehm 1.3                      _referencesData.append(ref);
 392                                      _hostsData.append(host);
 393                                      _nameSpacesData.append(ns);
 394                                  }
 395 karl        1.5.2.1              _size += count;
 396 thilo.boehm 1.3                  break;
 397                              }
 398                              // internal xml encoding of instance names and object paths not
 399                              // done today
 400                              case RESP_INSTNAMES:
 401                              case RESP_OBJECTPATHS:
 402                              default:
 403                              {
 404 karl        1.5.2.11             PEGASUS_ASSERT(false);
 405 thilo.boehm 1.3              }
 406 r.kieninger 1.1          }
 407 thilo.boehm 1.3          _encoding |= RESP_ENC_XML;
 408 karl        1.5.2.12 
 409                          PEG_METHOD_EXIT();
 410 thilo.boehm 1.3          return true;
 411                      }
 412 r.kieninger 1.1      
 413 karl        1.5.2.1  // Move the number of objects defined by the input parameter from
 414                      // one CIMResponse Object to another CIMResponse Object.
 415 karl        1.5.2.8  // Returns the new size of the CIMResponseData object.
 416                      // NOTE: This is not protected by a mutex so the user must be certain
 417                      // that the from object is not used during the move.
 418 karl        1.5.2.1  Uint32 CIMResponseData::moveObjects(CIMResponseData & from, Uint32 count)
 419                      {
 420 karl        1.5.2.11     PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::moveObjects");
 421                      
 422 karl        1.5.2.9      //// AutoMutex autoMut(testLock);
 423                      
 424 karl        1.5.2.1      PEG_TRACE((TRC_XML, Tracer::LEVEL3,
 425                              "CIMResponseData::move(%u)", count));
 426                      
 427 karl        1.5.2.11     PEGASUS_DEBUG_ASSERT(valid());                 // KS_TEMP
 428                          PEGASUS_DEBUG_ASSERT(_size == 0);    // Validate size == 0 or fix below
 429 karl        1.5.2.1      PEGASUS_DEBUG_ASSERT(_dataType == from._dataType);
 430 karl        1.5.2.11 
 431 karl        1.5.2.1      Uint32 rtnSize = 0;
 432                          Uint32 toMove = count;
 433                      
 434                          if (RESP_ENC_XML == (from._encoding & RESP_ENC_XML))
 435                          {
 436                              switch (_dataType)
 437                              {
 438                                  case RESP_OBJECTPATHS:
 439                                  case RESP_INSTNAMES:
 440                                      break;
 441                                  case RESP_INSTANCE:
 442                                      {
 443                                          if (from._instanceData.size() > 0)
 444                                          {
 445                                              // temp test to assure all sizes are the same.
 446 karl        1.5.2.11                         PEGASUS_DEBUG_ASSERT(from._hostsData.size() ==
 447 karl        1.5.2.1                                          from._instanceData.size());
 448 karl        1.5.2.11                         PEGASUS_DEBUG_ASSERT(from._referencesData.size() ==
 449 karl        1.5.2.1                                          from._instanceData.size());
 450 karl        1.5.2.11                         PEGASUS_DEBUG_ASSERT(from._nameSpacesData.size() ==
 451 karl        1.5.2.1                                          from._instanceData.size());
 452                                              _instanceData.append(from._instanceData.getData(),1);
 453                                              from._instanceData.remove(0, 1);
 454                                              _referencesData.append(
 455                                                  from._referencesData.getData(),1);
 456                                              from._referencesData.remove(0, 1);
 457                                              if (_hostsData.size())
 458                                              {
 459                                                  _hostsData.append(from._hostsData.getData(),1);
 460                                                  from._hostsData.remove(0, 1);
 461                                              }
 462                                              if (_nameSpacesData.size())
 463                                              {
 464                                                  _nameSpacesData.append(
 465                                                      from._nameSpacesData.getData(),1);
 466                                                  from._nameSpacesData.remove(0, 1);
 467                                              }
 468                                              rtnSize += 1;
 469                                              toMove--;
 470                                              _encoding |= RESP_ENC_XML;
 471                                          }
 472 karl        1.5.2.1                  }
 473                                      break;
 474                      
 475 karl        1.5.2.11             // KS-TODO The above could probably be folded into the following.
 476 karl        1.5.2.1              // Need something like an assert if there is ever more than
 477                                  // one instance in _instanceData for type RESP_INSTANCE
 478                                  case RESP_INSTANCES:
 479                                  case RESP_OBJECTS:
 480                                      {
 481                                          Uint32 moveCount = LOCAL_MIN(toMove,
 482                                                                       from._instanceData.size());
 483                      
 484 karl        1.5.2.11                     PEGASUS_DEBUG_ASSERT(from._referencesData.size() ==
 485 karl        1.5.2.1                                      from._instanceData.size());
 486                                          _instanceData.append(from._instanceData.getData(),
 487                                                               moveCount);
 488                                          from._instanceData.remove(0, moveCount);
 489                                          _referencesData.append(from._referencesData.getData(),
 490                                                                 moveCount);
 491                                          from._referencesData.remove(0, moveCount);
 492 karl        1.5.2.12                     _hostsData.append(from._hostsData.getData(),
 493                                                               moveCount);
 494                                          from._hostsData.remove(0, moveCount);
 495                                          _nameSpacesData.append(from._nameSpacesData.getData(),
 496                                                               moveCount);
 497                                          from._nameSpacesData.remove(0, moveCount);
 498 karl        1.5.2.1                      rtnSize += moveCount;
 499                                          toMove -= moveCount;
 500                                          _encoding |= RESP_ENC_XML;
 501                                      }
 502                                      break;
 503                              }
 504                          }
 505                          if (RESP_ENC_BINARY == (from._encoding & RESP_ENC_BINARY))
 506                          {
 507                              // Cannot resolve this one without actually processing
 508 karl        1.5.2.11         // the data since it is a stream. Concluded that we do not
 509                              // want to do that since cost higher than gain.  Therefore we do
 510                              // not allow this option.  Should only mean that provider agent
 511                              // cannot generate binary for pull operations.
 512 karl        1.5.2.1          rtnSize += 0;
 513                              PEGASUS_ASSERT(false);
 514                          }
 515                      
 516                          if (RESP_ENC_SCMO == (from._encoding & RESP_ENC_SCMO))
 517                          {
 518                              Uint32 moveCount = LOCAL_MIN(toMove, from._scmoInstances.size());
 519                      
 520                              _scmoInstances.append(from._scmoInstances.getData(), moveCount);
 521                              from._scmoInstances.remove(0, moveCount);
 522                              rtnSize += moveCount;
 523                              toMove -= moveCount;
 524                              _encoding |= RESP_ENC_SCMO;
 525                          }
 526                      
 527                          if (RESP_ENC_CIM == (from._encoding & RESP_ENC_CIM))
 528                          {
 529                              switch (_dataType)
 530                              {
 531                                  case RESP_OBJECTPATHS:
 532                                  case RESP_INSTNAMES:
 533 karl        1.5.2.1                  {
 534                                          Uint32 moveCount = LOCAL_MIN(toMove,
 535                                                                       from._instanceNames.size());
 536                      
 537                                          _instanceNames.append(
 538                                              from._instanceNames.getData(), moveCount);
 539                                          from._instanceNames.remove(0, moveCount);
 540                                          rtnSize += moveCount;
 541                                          toMove -= moveCount;
 542                                          _encoding |= RESP_ENC_CIM;
 543                                      }
 544                                      break;
 545                                  case RESP_INSTANCE:
 546                                  case RESP_INSTANCES:
 547                                      {
 548                      
 549                                          Uint32 moveCount = LOCAL_MIN(toMove,
 550                                                                       from._instances.size());
 551                      
 552                                          _instances.append(from._instances.getData(), moveCount);
 553                                          from._instances.remove(0, moveCount);
 554 karl        1.5.2.1                      rtnSize += moveCount;
 555                                          toMove -= moveCount;
 556                                          _encoding |= RESP_ENC_CIM;
 557                                      }
 558                                      break;
 559                                  case RESP_OBJECTS:
 560                                      {
 561                                          Uint32 moveCount = LOCAL_MIN(toMove,
 562                                                                       from._objects.size());
 563                                          _objects.append(from._objects.getData(), moveCount);
 564                                          from._objects.remove(0, moveCount);
 565                                          rtnSize += moveCount;
 566                                          toMove -= moveCount;
 567                                          _encoding |= RESP_ENC_CIM;
 568                                      }
 569                                      break;
 570                              }
 571                          }
 572                          PEGASUS_ASSERT(rtnSize == (count - toMove));
 573                      
 574                          _size += rtnSize;
 575 karl        1.5.2.13 
 576                          // insure that _size never goes negative.  This is probably a
 577                          // diagnostics KS_TODO remove before release
 578                          if (from._size >= rtnSize)
 579                          {
 580                      
 581                              from._size -= rtnSize;
 582                          }
 583                          else
 584                          {
 585                              from._size = 0;
 586                              //// KS_TODO Diagnostic since this should never occur
 587                              PEG_TRACE((TRC_XML, Tracer::LEVEL1,
 588                                  "Size in from set to zero from= %u rtnSize= %u",
 589                                      from._size, rtnSize));
 590                          }
 591 karl        1.5.2.2  
 592 karl        1.5.2.11     //// KS_TODO diagnostic that we should be able to remove
 593 karl        1.5.2.2      if (rtnSize != _size)
 594                          {
 595                              PEG_TRACE((TRC_XML, Tracer::LEVEL1,
 596                                  "Size calc error _size %u rtnSWize = %u", _size, rtnSize));
 597                          }
 598 karl        1.5.2.9      PEG_METHOD_EXIT();
 599 karl        1.5.2.1      return rtnSize;
 600                      }
 601                      
 602 karl        1.5.2.12 Boolean CIMResponseData::hasBinaryData() const
 603                      {
 604                          return (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY));
 605                      }
 606                      // Sets the _size variable based on the internal size counts.
 607                      void CIMResponseData::setSize()
 608                      {
 609                          PEGASUS_DEBUG_ASSERT(valid());            //KS_TEMP KS_TODO
 610                      
 611                          Uint32 rtnSize = 0;
 612                          if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
 613                          {
 614                              switch (_dataType)
 615                              {
 616                                  case RESP_OBJECTPATHS:
 617                                  case RESP_INSTNAMES:
 618                                      break;
 619                                  case RESP_INSTANCE:
 620                                      rtnSize +=1;
 621                                      break;
 622                                  case RESP_INSTANCES:
 623 karl        1.5.2.12             case RESP_OBJECTS:
 624                                      rtnSize += _instanceData.size();
 625                                      break;
 626                              }
 627                          }
 628                          if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
 629                          {
 630                              // KS_PULL_TODO
 631                              // Cannot resolve this one without actually processing
 632                              // the data since it is a stream.
 633                              rtnSize += 0;
 634                          }
 635                      
 636                          if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
 637                          {
 638                              rtnSize += _scmoInstances.size();
 639                          }
 640                      
 641                          if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
 642                          {
 643                              switch (_dataType)
 644 karl        1.5.2.12         {
 645                                  case RESP_OBJECTPATHS:
 646                                  case RESP_INSTNAMES:
 647                                      rtnSize += _instanceNames.size();
 648                                      break;
 649                                  case RESP_INSTANCE:
 650                                  case RESP_INSTANCES:
 651                                      rtnSize += _instances.size();
 652                                      break;
 653                                  case RESP_OBJECTS:
 654                                      rtnSize += _objects.size();
 655                                      break;
 656                              }
 657                          }
 658                          _size = rtnSize;
 659                      }
 660                      
 661 karl        1.5.2.1  // Return the number of CIM objects in the CIM Response data object
 662                      //
 663 karl        1.5.2.19 ////#define TEMPLOG PEG_TRACE((TRC_XML, Tracer::LEVEL4, \
 664                      //// "rtnSize %u size %u line %u", rtnSize, _size, __LINE__))
 665                      #define TEMPLOG
 666 karl        1.5.2.3  
 667 karl        1.5.2.1  Uint32 CIMResponseData::size()
 668                      {
 669 karl        1.5.2.8      AutoMutex autoMut(testLock);
 670 karl        1.5.2.1      PEG_METHOD_ENTER(TRC_XML,"CIMResponseData::size()");
 671 karl        1.5.2.14     TEST_SIZE_VALID;
 672 karl        1.5.2.1  // If debug mode, add up all the individual size components to
 673                      // determine overall size of this object.  Then compare this with
 674                      // the _size variable.  this is a good check on the completeness of the
 675                      // size computations.  We should be able to remove this at some point
 676                      // but there are many sources of size info and we need to be sure we
 677                      // have covered them all.
 678                      #ifdef PEGASUS_DEBUG
 679 karl        1.5.2.11     PEGASUS_DEBUG_ASSERT(valid());            //KS_TEMP KS_TODO
 680 karl        1.5.2.1  
 681                          Uint32 rtnSize = 0;
 682 karl        1.5.2.3      TEMPLOG;
 683 karl        1.5.2.1      if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
 684                          {
 685 karl        1.5.2.3          TEMPLOG;
 686 karl        1.5.2.1          switch (_dataType)
 687                              {
 688                                  case RESP_OBJECTPATHS:
 689                                  case RESP_INSTNAMES:
 690                                      break;
 691                                  case RESP_INSTANCE:
 692                                      rtnSize +=1;
 693                                      break;
 694                                  case RESP_INSTANCES:
 695                                  case RESP_OBJECTS:
 696                                      rtnSize += _instanceData.size();
 697                                      break;
 698                              }
 699 karl        1.5.2.14         TEST_SIZE_VALID;
 700 karl        1.5.2.3          TEMPLOG;
 701 karl        1.5.2.1      }
 702                          if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
 703                          {
 704 karl        1.5.2.3          TEMPLOG;
 705 karl        1.5.2.1          // KS_PULL_TODO
 706                              // Cannot resolve this one without actually processing
 707                              // the data since it is a stream.
 708                              rtnSize += 0;
 709 karl        1.5.2.8          //  KS_TODO flag on this one
 710                              //// PEGASUS_ASSERT(false);
 711 karl        1.5.2.3          TEMPLOG;
 712 karl        1.5.2.1      }
 713                      
 714                          if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
 715                          {
 716 karl        1.5.2.14         TEST_SIZE_VALID;
 717 karl        1.5.2.3          TEMPLOG;
 718 karl        1.5.2.1          rtnSize += _scmoInstances.size();
 719 karl        1.5.2.3          TEMPLOG;
 720 karl        1.5.2.1      }
 721                      
 722                          if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
 723                          {
 724 karl        1.5.2.14         TEST_SIZE_VALID;
 725 karl        1.5.2.3          TEMPLOG;
 726 karl        1.5.2.1          switch (_dataType)
 727                              {
 728                                  case RESP_OBJECTPATHS:
 729                                  case RESP_INSTNAMES:
 730                                      rtnSize += _instanceNames.size();
 731                                      break;
 732                                  case RESP_INSTANCE:
 733                                  case RESP_INSTANCES:
 734                                      rtnSize += _instances.size();
 735                                      break;
 736                                  case RESP_OBJECTS:
 737                                      rtnSize += _objects.size();
 738                                      break;
 739                              }
 740 karl        1.5.2.14         TEST_SIZE_VALID;
 741 karl        1.5.2.3          TEMPLOG;
 742 karl        1.5.2.1      }
 743 karl        1.5.2.9      // Test of actual count against _size variable. KS_TODO diagnostic
 744 karl        1.5.2.22     Uint32 lsize = _size;
 745                          if (rtnSize != lsize)
 746 karl        1.5.2.1      {
 747 karl        1.5.2.3          TEMPLOG;
 748 karl        1.5.2.14         TEST_SIZE_VALID;
 749 karl        1.5.2.1          PEG_TRACE((TRC_XML, Tracer::LEVEL1,
 750                              "CIMResponseData::size ERROR. debug size mismatch."
 751 karl        1.5.2.22             "Computed = %u. variable = %u inc binary %s",rtnSize, _size,
 752                               boolToString(RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
 753                                                    ));
 754 karl        1.5.2.2          // KS_TEMP
 755 karl        1.5.2.22         cout << "Size err Computed(rtnsize)=" << rtnSize << " _size=" << lsize
 756                                   << " diff=" << (rtnSize - lsize)
 757                                    << " inc Binary= "  
 758                                   << boolToString(RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
 759                                   << endl;
 760 karl        1.5.2.3          TEMPLOG;
 761 karl        1.5.2.1      }
 762 karl        1.5.2.8      PEG_TRACE((TRC_XML, Tracer::LEVEL1, "ReturnSize=%u", _size ));
 763 karl        1.5.2.1  #endif
 764                          PEG_METHOD_EXIT();
 765                          return _size;
 766                      }
 767                      
 768 thilo.boehm 1.3      // function used by OperationAggregator to aggregate response data in a
 769 karl        1.5.2.1  // single ResponseData object. Adds all data in the from ResponseData object
 770                      // input variable to the target ResponseData object
 771                      // target array
 772 thilo.boehm 1.3      void CIMResponseData::appendResponseData(const CIMResponseData & x)
 773                      {
 774 karl        1.5.2.11     PEG_METHOD_ENTER(TRC_DISPATCHER,
 775                              "CIMResponseData::appendResponseData");
 776 karl        1.5.2.9      //// AutoMutex autoMut(testLock);
 777 karl        1.5.2.1      // Confirm that the CIMResponseData type matches the type
 778                          // of the data being appended
 779                      
 780 karl        1.5.2.11     PEGASUS_DEBUG_ASSERT(valid());            // KS_TEMP
 781 thilo.boehm 1.3          PEGASUS_DEBUG_ASSERT(_dataType == x._dataType);
 782                          _encoding |= x._encoding;
 783                      
 784                          // add all binary data
 785                          _binaryData.appendArray(x._binaryData);
 786 karl        1.5.2.1      // KS_TBD TODO PULL Add the counter incrementer for binary
 787 thilo.boehm 1.3      
 788                          // add all the C++ stuff
 789                          _instanceNames.appendArray(x._instanceNames);
 790 karl        1.5.2.1      _size += x._instanceNames.size();
 791 thilo.boehm 1.3          _instances.appendArray(x._instances);
 792 karl        1.5.2.1      _size += x._instances.size();
 793 thilo.boehm 1.3          _objects.appendArray(x._objects);
 794 karl        1.5.2.1      _size += x._objects.size();
 795 thilo.boehm 1.3      
 796                          // add the SCMO instances
 797                          _scmoInstances.appendArray(x._scmoInstances);
 798 karl        1.5.2.1      _size += x._scmoInstances.size();
 799 thilo.boehm 1.3      
 800 karl        1.5.2.1      // add Xml encodings
 801 karl        1.5.2.13     // KS_TODO these are temporary. delete before release
 802                          PEGASUS_ASSERT(x._referencesData.size() == x._instanceData.size());
 803                          PEGASUS_ASSERT(x._instanceData.size() == x._hostsData.size());
 804                          PEGASUS_ASSERT(x._instanceData.size() == x._nameSpacesData.size());
 805                      
 806 thilo.boehm 1.3          _referencesData.appendArray(x._referencesData);
 807                          _instanceData.appendArray(x._instanceData);
 808                          _hostsData.appendArray(x._hostsData);
 809                          _nameSpacesData.appendArray(x._nameSpacesData);
 810 karl        1.5.2.13     _size += x._instanceData.size();
 811                      
 812 karl        1.5.2.6      // transfer property list
 813                          _propertyList = x._propertyList;
 814 karl        1.5.2.11 
 815                          PEG_METHOD_EXIT();
 816 thilo.boehm 1.3      }
 817 r.kieninger 1.1      
 818 thilo.boehm 1.3      // Encoding responses into output format
 819                      void CIMResponseData::encodeBinaryResponse(CIMBuffer& out)
 820 r.kieninger 1.1      {
 821                          PEG_METHOD_ENTER(TRC_DISPATCHER,
 822 thilo.boehm 1.3              "CIMResponseData::encodeBinaryResponse");
 823 r.kieninger 1.1      
 824 karl        1.5.2.14     TEST_SIZE_VALID;
 825 karl        1.5.2.3  
 826 thilo.boehm 1.3          // Need to do a complete job here by transferring all contained data
 827                          // into binary format and handing it out in the CIMBuffer
 828 karl        1.5.2.1      // KS_TODO
 829 thilo.boehm 1.3          if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
 830 r.kieninger 1.1          {
 831 karl        1.5.2.3          PEGASUS_ASSERT(false);   // KS_TEMP
 832 karl        1.5.2.4  
 833 thilo.boehm 1.3              // Binary does NOT need a marker as it consists of C++ and SCMO
 834 r.kieninger 1.1              const Array<Uint8>& data = _binaryData;
 835                              out.putBytes(data.getData(), data.size());
 836                          }
 837 karl        1.5.2.1  
 838 thilo.boehm 1.3          if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
 839 r.kieninger 1.1          {
 840 thilo.boehm 1.3              out.putTypeMarker(BIN_TYPE_MARKER_CPPD);
 841                              switch (_dataType)
 842                              {
 843                                  case RESP_INSTNAMES:
 844                                  {
 845                                      out.putObjectPathA(_instanceNames);
 846                                      break;
 847                                  }
 848                                  case RESP_INSTANCE:
 849                                  {
 850                                      if (0 == _instances.size())
 851                                      {
 852                                          _instances.append(CIMInstance());
 853                                      }
 854                                      out.putInstance(_instances[0], true, true);
 855                                      break;
 856                                  }
 857                                  case RESP_INSTANCES:
 858                                  {
 859                                      out.putInstanceA(_instances);
 860                                      break;
 861 thilo.boehm 1.3                  }
 862                                  case RESP_OBJECTS:
 863                                  {
 864                                      out.putObjectA(_objects);
 865                                      break;
 866                                  }
 867                                  case RESP_OBJECTPATHS:
 868                                  {
 869                                      out.putObjectPathA(_instanceNames);
 870                                      break;
 871                                  }
 872                                  default:
 873                                  {
 874 karl        1.5.2.16                 PEGASUS_DEBUG_ASSERT(false);
 875 thilo.boehm 1.3                  }
 876                              }
 877 r.kieninger 1.1          }
 878 thilo.boehm 1.3          if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
 879 r.kieninger 1.1          {
 880 thilo.boehm 1.3              out.putTypeMarker(BIN_TYPE_MARKER_SCMO);
 881                              out.putSCMOInstanceA(_scmoInstances);
 882 r.kieninger 1.1          }
 883 thilo.boehm 1.3          if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
 884 r.kieninger 1.1          {
 885 thilo.boehm 1.3              // This actually should not happen following general code logic
 886 karl        1.5.2.16         PEGASUS_DEBUG_ASSERT(false);
 887 r.kieninger 1.1          }
 888 thilo.boehm 1.3      
 889 r.kieninger 1.1          PEG_METHOD_EXIT();
 890                      }
 891                      
 892 thilo.boehm 1.3      void CIMResponseData::completeNamespace(const SCMOInstance * x)
 893 r.kieninger 1.1      {
 894 thilo.boehm 1.3          const char * ns;
 895                          Uint32 len;
 896                          ns = x->getNameSpace_l(len);
 897                          // Both internal XML as well as binary always contain a namespace
 898                          // don't have to do anything for those two encodings
 899                          if ((RESP_ENC_BINARY == (_encoding&RESP_ENC_BINARY)) && (len != 0))
 900 r.kieninger 1.1          {
 901 thilo.boehm 1.3              _defaultNamespace = CIMNamespaceName(ns);
 902 r.kieninger 1.1          }
 903 thilo.boehm 1.3          if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
 904 r.kieninger 1.1          {
 905 thilo.boehm 1.3              CIMNamespaceName nsName(ns);
 906                              switch (_dataType)
 907 r.kieninger 1.1              {
 908 thilo.boehm 1.3                  case RESP_INSTANCE:
 909                                  {
 910                                      if (_instances.size() > 0)
 911                                      {
 912                                          const CIMInstance& inst = _instances[0];
 913                                          CIMObjectPath& p =
 914                                              const_cast<CIMObjectPath&>(inst.getPath());
 915                                          if (p.getNameSpace().isNull())
 916                                          {
 917                                              p.setNameSpace(nsName);
 918                                          }
 919                                      }
 920 karl        1.5.2.3                  break;
 921 thilo.boehm 1.3                  }
 922                                  case RESP_INSTANCES:
 923                                  {
 924                                      for (Uint32 j = 0, n = _instances.size(); j < n; j++)
 925                                      {
 926                                          const CIMInstance& inst = _instances[j];
 927                                          CIMObjectPath& p =
 928                                              const_cast<CIMObjectPath&>(inst.getPath());
 929                                          if (p.getNameSpace().isNull())
 930                                          {
 931                                              p.setNameSpace(nsName);
 932                                          }
 933                                      }
 934                                      break;
 935                                  }
 936                                  case RESP_OBJECTS:
 937                                  {
 938                                      for (Uint32 j = 0, n = _objects.size(); j < n; j++)
 939                                      {
 940                                          const CIMObject& object = _objects[j];
 941                                          CIMObjectPath& p =
 942 thilo.boehm 1.3                              const_cast<CIMObjectPath&>(object.getPath());
 943                                          if (p.getNameSpace().isNull())
 944                                          {
 945                                              p.setNameSpace(nsName);
 946                                          }
 947                                      }
 948                                      break;
 949                                  }
 950                                  case RESP_INSTNAMES:
 951                                  case RESP_OBJECTPATHS:
 952                                  {
 953                                      for (Uint32 j = 0, n = _instanceNames.size(); j < n; j++)
 954                                      {
 955                                          CIMObjectPath& p = _instanceNames[j];
 956                                          if (p.getNameSpace().isNull())
 957                                          {
 958                                              p.setNameSpace(nsName);
 959                                          }
 960                                      }
 961                                      break;
 962                                  }
 963 thilo.boehm 1.3                  default:
 964                                  {
 965                                      PEGASUS_DEBUG_ASSERT(false);
 966                                  }
 967 r.kieninger 1.1              }
 968                          }
 969 karl        1.5.2.11 
 970 thilo.boehm 1.3          if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
 971 r.kieninger 1.1          {
 972 thilo.boehm 1.3              for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++)
 973 r.kieninger 1.1              {
 974 thilo.boehm 1.3                  SCMOInstance & scmoInst=_scmoInstances[j];
 975                                  if (0 == scmoInst.getNameSpace())
 976                                  {
 977                                      scmoInst.setNameSpace_l(ns,len);
 978                                  }
 979 r.kieninger 1.1              }
 980                          }
 981                      }
 982                      
 983 thilo.boehm 1.3      void CIMResponseData::completeHostNameAndNamespace(
 984                          const String & hn,
 985 karl        1.5.2.12     const CIMNamespaceName & ns,
 986                          Boolean isPullOperation)
 987 r.kieninger 1.1      {
 988 karl        1.5.2.1      PEG_METHOD_ENTER(TRC_DISPATCHER,
 989                              "CIMResponseData::completeHostNameAndNamespace");
 990                      
 991 karl        1.5.2.11     PEGASUS_DEBUG_ASSERT(valid());            // KS_TEMP
 992 karl        1.5.2.1  
 993 karl        1.5.2.13     Uint32 count = 0;      //// KS_TODO this counter is just diagnostic
 994                      
 995                              PEG_TRACE(( TRC_DISPATCHER, Tracer::LEVEL4,   // KS_TODO TEMP
 996                                "completeHostNameAndNamespace Setting hostName, etc "
 997                                "host %s ns %s set for dataType=%u encoding=%u isPull=%s",
 998                                    (const char *)hn.getCString(),
 999                                    (const char *)ns.getString().getCString(),
1000                                    _dataType, _encoding, boolToString(isPullOperation) ));
1001                      
1002 thilo.boehm 1.3          if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
1003                          {
1004 karl        1.5.2.13         // On binary need to remember hostname and namespace in case someone
1005                              // builds C++ default objects or Xml types later i.e.
1006 thilo.boehm 1.3              // -> usage: See resolveBinary()
1007                              _defaultNamespace=ns;
1008                              _defaultHostname=hn;
1009 karl        1.5.2.13         count++;
1010 thilo.boehm 1.3          }
1011                          // InternalXml does not support objectPath calls
1012                          if ((RESP_ENC_XML == (_encoding & RESP_ENC_XML)) &&
1013                                  (RESP_OBJECTS == _dataType))
1014                          {
1015                              for (Uint32 j = 0, n = _referencesData.size(); j < n; j++)
1016                              {
1017                                  if (0 == _hostsData[j].size())
1018                                  {
1019                                      _hostsData[j]=hn;
1020 karl        1.5.2.13                 count++;
1021 thilo.boehm 1.3                  }
1022                                  if (_nameSpacesData[j].isNull())
1023                                  {
1024                                      _nameSpacesData[j]=ns;
1025                                  }
1026                              }
1027                          }
1028 karl        1.5.2.12     // Need to set for Pull Enumeration operations
1029                          if ((RESP_ENC_XML == (_encoding & RESP_ENC_XML)) &&
1030                                  ((RESP_INSTANCES == _dataType) || isPullOperation))
1031                          {
1032                              for (Uint32 j = 0, n = _referencesData.size(); j < n; j++)
1033                              {
1034                                  if (0 == _hostsData[j].size())
1035                                  {
1036 karl        1.5.2.13                 count++;
1037 karl        1.5.2.12                 _hostsData[j]=hn;
1038                                  }
1039                                  if (_nameSpacesData[j].isNull())
1040                                  {
1041                                      _nameSpacesData[j]=ns;
1042                                  }
1043                      
1044 karl        1.5.2.13             // KS_TODO Remove Diagnostic
1045 karl        1.5.2.12             PEG_TRACE(( TRC_DISPATCHER, Tracer::LEVEL4,
1046                                    "completeHostNameAndNamespace Setting hostName, etc "
1047                                    "host %s ns %s set to _hostData %s _namespaceData %s",
1048                                        (const char *)hn.getCString(),
1049                                        (const char *)ns.getString().getCString(),
1050                                        (const char *)_hostsData[j].getCString(),
1051                                        (const char *)_nameSpacesData[j].getString().getCString() ));
1052                              }
1053                          }
1054                      
1055 thilo.boehm 1.3          if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
1056 r.kieninger 1.1          {
1057 thilo.boehm 1.3              switch (_dataType)
1058 r.kieninger 1.2              {
1059 karl        1.5.2.1              // Instances added to account for namedInstance in Pull operations.
1060                                  case RESP_INSTANCES:
1061                      
1062                                      for (Uint32 j = 0, n = _instances.size(); j < n; j++)
1063                                      {
1064                                          const CIMInstance& instance = _instances[j];
1065                                          CIMObjectPath& p =
1066                                              const_cast<CIMObjectPath&>(instance.getPath());
1067                                          if (p.getHost().size()==0)
1068                                          {
1069 karl        1.5.2.13                         count++;
1070 karl        1.5.2.1                          p.setHost(hn);
1071                                          }
1072                                          if (p.getNameSpace().isNull())
1073                                          {
1074                                              p.setNameSpace(ns);
1075                                          }
1076                                      }
1077 thilo.boehm 1.3                  case RESP_OBJECTS:
1078                                  {
1079                                      for (Uint32 j = 0, n = _objects.size(); j < n; j++)
1080                                      {
1081                                          const CIMObject& object = _objects[j];
1082                                          CIMObjectPath& p =
1083                                              const_cast<CIMObjectPath&>(object.getPath());
1084                                          if (p.getHost().size()==0)
1085                                          {
1086 karl        1.5.2.13                         count++;
1087 thilo.boehm 1.3                              p.setHost(hn);
1088                                          }
1089                                          if (p.getNameSpace().isNull())
1090                                          {
1091                                              p.setNameSpace(ns);
1092                                          }
1093                                      }
1094                                      break;
1095                                  }
1096 karl        1.5.2.1              // INSTNAMES added to account for instance paths in pull name
1097                                  // operations
1098                                  case RESP_INSTNAMES:
1099 thilo.boehm 1.3                  case RESP_OBJECTPATHS:
1100                                  {
1101                                      for (Uint32 j = 0, n = _instanceNames.size(); j < n; j++)
1102                                      {
1103                                          CIMObjectPath& p = _instanceNames[j];
1104                                          if (p.getHost().size() == 0)
1105 karl        1.5.2.11                     {
1106 karl        1.5.2.13                         count++;
1107 thilo.boehm 1.3                              p.setHost(hn);
1108 karl        1.5.2.11                     }
1109 thilo.boehm 1.3                          if (p.getNameSpace().isNull())
1110 karl        1.5.2.11                     {
1111 thilo.boehm 1.3                              p.setNameSpace(ns);
1112 karl        1.5.2.11                     }
1113 thilo.boehm 1.3                      }
1114                                      break;
1115                                  }
1116                                  default:
1117                                  {
1118 karl        1.5.2.16                 PEGASUS_DEBUG_ASSERT(false);
1119 thilo.boehm 1.3                  }
1120 r.kieninger 1.2              }
1121                          }
1122 thilo.boehm 1.3          if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
1123 r.kieninger 1.2          {
1124 thilo.boehm 1.3              CString hnCString=hn.getCString();
1125                              const char* hnChars = hnCString;
1126                              Uint32 hnLen = strlen(hnChars);
1127                              CString nsCString=ns.getString().getCString();
1128                              const char* nsChars=nsCString;
1129                              Uint32 nsLen = strlen(nsChars);
1130                              switch (_dataType)
1131                              {
1132 karl        1.5.2.1              // KS_PULL add Instances and InstNames to cover pull operations
1133                                  // KS_PULL - Confirm that this OK.
1134                                  case RESP_INSTNAMES:
1135                                  case RESP_INSTANCES:
1136 thilo.boehm 1.3                  case RESP_OBJECTS:
1137                                  case RESP_OBJECTPATHS:
1138                                  {
1139                                      for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++)
1140                                      {
1141 karl        1.5.2.13                     count++;
1142 thilo.boehm 1.3                          SCMOInstance & scmoInst=_scmoInstances[j];
1143 karl        1.5.2.7                      scmoInst.completeHostNameAndNamespace(
1144                                              hnChars,
1145                                              hnLen,
1146                                              nsChars,
1147                                              nsLen);
1148 thilo.boehm 1.3                      }
1149                                      break;
1150                                  }
1151                                  default:
1152                                  {
1153 karl        1.5.2.16                 PEGASUS_DEBUG_ASSERT(false);
1154 thilo.boehm 1.3                  }
1155                              }
1156 r.kieninger 1.1          }
1157 karl        1.5.2.13     PEG_TRACE(( TRC_DISPATCHER, Tracer::LEVEL4,   // KS_TODO TEMP
1158 karl        1.5.2.17       "completeHostNameAndNamespace Set hostName, etc count %u "
1159 karl        1.5.2.13       "host %s ns %s set for dataType=%u encoding=%u isPull=%s",
1160                                count,
1161                                (const char *)hn.getCString(),
1162                                (const char *)ns.getString().getCString(),
1163                                _dataType, _encoding, boolToString(isPullOperation) ));
1164                      
1165                      
1166 karl        1.5.2.1      PEG_METHOD_EXIT();
1167 thilo.boehm 1.3      }
1168 r.kieninger 1.1      
1169 karl        1.5.2.1  // NOTE: The reason for the isPullResponse variable is that there are
1170                      // some variations in ouput to Xml depending on whether the responses
1171 karl        1.5.2.7  // are one of the pull responses or not
1172 karl        1.5.2.15 void CIMResponseData::encodeXmlResponse(Buffer& out,
1173                          Boolean isPullResponse,
1174                          Boolean encodeInstanceOnly)
1175 r.kieninger 1.1      {
1176 karl        1.5.2.11     PEG_METHOD_ENTER(TRC_DISPATCHER,
1177                              "CIMResponseData::encodeXmlResponse");
1178 karl        1.5.2.6  
1179 thilo.boehm 1.3          PEG_TRACE((TRC_XML, Tracer::LEVEL3,
1180 karl        1.5.2.21         "CIMResponseData::encodeXmlResponse(encoding=%X,dataType=%X, isPull= %s"
1181                              " encodeInstanceOnly= %s)",
1182 thilo.boehm 1.3              _encoding,
1183 karl        1.5.2.11         _dataType,
1184 karl        1.5.2.21         boolToString(isPullResponse),
1185                              boolToString(encodeInstanceOnly) ));
1186 karl        1.5.2.7  
1187 thilo.boehm 1.3          // already existing Internal XML does not need to be encoded further
1188                          // binary input is not actually impossible here, but we have an established
1189                          // fallback
1190                          if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
1191 r.kieninger 1.1          {
1192 karl        1.5.2.13         _resolveBinaryToSCMO();
1193 r.kieninger 1.1          }
1194 thilo.boehm 1.3          if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
1195 r.kieninger 1.1          {
1196 thilo.boehm 1.3              switch (_dataType)
1197 r.kieninger 1.1              {
1198 thilo.boehm 1.3                  case RESP_INSTANCE:
1199                                  {
1200                                      const Array<ArraySint8>& a = _instanceData;
1201                                      out.append((char*)a[0].getData(), a[0].size() - 1);
1202                                      break;
1203                                  }
1204                                  case RESP_INSTANCES:
1205                                  {
1206                                      const Array<ArraySint8>& a = _instanceData;
1207                                      const Array<ArraySint8>& b = _referencesData;
1208 r.kieninger 1.1      
1209 thilo.boehm 1.3                      for (Uint32 i = 0, n = a.size(); i < n; i++)
1210                                      {
1211 karl        1.5.2.1                      if (isPullResponse)
1212                                          {
1213 karl        1.5.2.13                         // KS_TODO these are temporary. delete before release
1214                                              PEGASUS_ASSERT(a.size() == b.size());
1215                                              PEGASUS_ASSERT(a.size() == _hostsData.size());
1216                                              PEGASUS_ASSERT(a.size() == _nameSpacesData.size());
1217                      
1218 karl        1.5.2.1                          out << STRLIT("<VALUE.INSTANCEWITHPATH>\n");
1219 karl        1.5.2.13                         out << STRLIT("<INSTANCEPATH>\n");
1220                                              XmlWriter::appendNameSpacePathElement(out,
1221                                                  _hostsData[i],
1222                                                  _nameSpacesData[i]);
1223                                              out.append((char*)b[i].getData(), b[i].size() - 1);
1224                                              out << STRLIT("</INSTANCEPATH>\n");
1225                                              out.append((char *)a[i].getData(), a[i].size() - 1);
1226 karl        1.5.2.1                          out << STRLIT("</VALUE.INSTANCEWITHPATH>\n");
1227                                          }
1228                                          else
1229                                          {
1230 karl        1.5.2.13                         out << STRLIT("<VALUE.NAMEDINSTANCE>\n");
1231                                              out.append((char*)b[i].getData(), b[i].size() - 1);
1232                                              out.append((char *)a[i].getData(), a[i].size() - 1);
1233 karl        1.5.2.1                          out << STRLIT("</VALUE.NAMEDINSTANCE>\n");
1234                                          }
1235 thilo.boehm 1.3                      }
1236                                      break;
1237                                  }
1238                                  case RESP_OBJECTS:
1239                                  {
1240                                      const Array<ArraySint8>& a = _instanceData;
1241                                      const Array<ArraySint8>& b = _referencesData;
1242 karl        1.5.2.13 
1243 thilo.boehm 1.3                      for (Uint32 i = 0, n = a.size(); i < n; i++)
1244                                      {
1245 karl        1.5.2.21                     if (isPullResponse)
1246                                          {
1247                                              out << STRLIT("<VALUE.INSTANCEWITHPATH>\n");
1248                                          }
1249                                          else
1250                                          {
1251                                              out << STRLIT("<VALUE.OBJECTWITHPATH>\n");
1252                                          }
1253 thilo.boehm 1.3                          out << STRLIT("<INSTANCEPATH>\n");
1254                                          XmlWriter::appendNameSpacePathElement(
1255                                                  out,
1256                                                  _hostsData[i],
1257                                                  _nameSpacesData[i]);
1258 karl        1.5.2.21 
1259                                          if (isPullResponse)
1260                                          {
1261                                              out.append((char*)b[i].getData(),b[i].size()-1);
1262                                          }
1263                                          else
1264                                          {
1265                                              // Leave out the surrounding tags "<VALUE.REFERENCE>\n"
1266                                              // and "</VALUE.REFERENCE>\n" which are 18 and 19
1267                                              // characters long
1268                                              //// KS_TODO Should be able to do this by properly
1269                                              //// building in the CIMXmlInternalEncoder
1270                                              out.append(
1271                                                  ((char*)b[i].getData())+18,
1272                                                  b[i].size() - 1 - 18 -19);
1273                                          }
1274                      
1275 thilo.boehm 1.3                          out << STRLIT("</INSTANCEPATH>\n");
1276                                          // append instance body
1277                                          out.append((char*)a[i].getData(), a[i].size() - 1);
1278 karl        1.5.2.21                     if (isPullResponse)
1279                                          {
1280                                              out << STRLIT("</VALUE.INSTANCEWITHPATH>\n");
1281                                          }
1282                                          else
1283                                          {
1284                                              out << STRLIT("</VALUE.OBJECTWITHPATH>\n");
1285                                          }
1286 thilo.boehm 1.3                      }
1287                                      break;
1288                                  }
1289                                  // internal xml encoding of instance names and object paths not
1290                                  // done today
1291                                  case RESP_INSTNAMES:
1292                                  case RESP_OBJECTPATHS:
1293                                  default:
1294                                  {
1295 karl        1.5.2.11                 PEGASUS_ASSERT(false);
1296 thilo.boehm 1.3                  }
1297 r.kieninger 1.1              }
1298 thilo.boehm 1.3          }
1299 r.kieninger 1.1      
1300 thilo.boehm 1.3          if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
1301                          {
1302                              switch (_dataType)
1303 r.kieninger 1.1              {
1304 thilo.boehm 1.3                  case RESP_INSTNAMES:
1305                                  {
1306                                      for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++)
1307                                      {
1308 karl        1.5.2.1                      // Element type is different for Pull responses
1309                                          if (isPullResponse)
1310                                          {
1311                                              XmlWriter::appendInstancePathElement(out,
1312                                                  _instanceNames[i]);
1313                                          }
1314                                          else
1315                                          {
1316                                              XmlWriter::appendInstanceNameElement(out,
1317                                                  _instanceNames[i]);
1318                                          }
1319 thilo.boehm 1.3                      }
1320                                      break;
1321                                  }
1322                                  case RESP_INSTANCE:
1323                                  {
1324                                      if (_instances.size() > 0)
1325                                      {
1326 karl        1.5.2.3                      XmlWriter::appendInstanceElement(
1327 karl        1.5.2.7                          out,
1328 karl        1.5.2.3                          _instances[0],
1329                                              _includeQualifiers,
1330                                              _includeClassOrigin,
1331                                              _propertyList);
1332 thilo.boehm 1.3                      }
1333                                      break;
1334                                  }
1335                                  case RESP_INSTANCES:
1336                                  {
1337                                      for (Uint32 i = 0, n = _instances.size(); i < n; i++)
1338                                      {
1339 karl        1.5.2.1                      if (isPullResponse)
1340                                          {
1341 karl        1.5.2.15                         if (encodeInstanceOnly)
1342                                              {
1343                                                  XmlWriter::appendInstanceElement(
1344                                                      out,
1345                                                      _instances[i],
1346 karl        1.5.2.18                                 _includeQualifiers,
1347 karl        1.5.2.15                                 _includeClassOrigin,
1348                                                      _propertyList);
1349                                              }
1350                                              else
1351                                              {
1352                                                  XmlWriter::appendValueInstanceWithPathElement(
1353                                                      out,
1354                                                      _instances[i],
1355 karl        1.5.2.18                                 _includeQualifiers,
1356 karl        1.5.2.15                                 _includeClassOrigin,
1357                                                      _propertyList);
1358                                              }
1359 karl        1.5.2.1                      }
1360                                          else
1361                                          {
1362                                              XmlWriter::appendValueNamedInstanceElement(
1363 karl        1.5.2.3                              out,
1364                                                  _instances[i],
1365                                                  _includeQualifiers,
1366                                                  _includeClassOrigin,
1367                                                  _propertyList);
1368 karl        1.5.2.1                      }
1369 thilo.boehm 1.3                      }
1370                                      break;
1371                                  }
1372                                  case RESP_OBJECTS:
1373                                  {
1374                                      for (Uint32 i = 0; i < _objects.size(); i++)
1375                                      {
1376 karl        1.5.2.1                      // If pull, map to instances
1377                                          if (isPullResponse)
1378                                          {
1379                                              CIMInstance x = (CIMInstance)_objects[i];
1380                                              XmlWriter::appendValueInstanceWithPathElement(
1381 karl        1.5.2.21                             out,
1382                                                  x,
1383 karl        1.5.2.3                              _includeQualifiers,
1384                                                  _includeClassOrigin,
1385                                                  _propertyList);
1386 karl        1.5.2.1                      }
1387                                          else
1388                                          {
1389                                              XmlWriter::appendValueObjectWithPathElement(
1390 karl        1.5.2.3                              out,
1391                                                  _objects[i],
1392                                                  _includeQualifiers,
1393                                                  _includeClassOrigin,
1394 karl        1.5.2.7                              _isClassOperation,
1395 karl        1.5.2.3                              _propertyList);
1396 karl        1.5.2.1                      }
1397 thilo.boehm 1.3                      }
1398                                      break;
1399                                  }
1400                                  case RESP_OBJECTPATHS:
1401                                  {
1402                                      for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++)
1403                                      {
1404 karl        1.5.2.1                      // ObjectPaths come from providers for pull operations
1405 karl        1.5.2.21                     // but are encoded as instancePathElements. If pull
1406                                          // only instances allowed.
1407 karl        1.5.2.1                      if (isPullResponse)
1408                                          {
1409 karl        1.5.2.21                         XmlWriter::appendInstancePathElement(
1410                                                  out,
1411 karl        1.5.2.1                             _instanceNames[i]);
1412                                          }
1413                                          else
1414                                          {
1415 karl        1.5.2.21                         //Append The path element (Class or instance)
1416 karl        1.5.2.1                          out << "<OBJECTPATH>\n";
1417 karl        1.5.2.21                         XmlWriter::appendClassOrInstancePathElement(
1418 karl        1.5.2.1                              out,
1419                                                  _instanceNames[i],
1420 karl        1.5.2.21                             _isClassOperation);
1421 karl        1.5.2.1                          out << "</OBJECTPATH>\n";
1422                                          }
1423 thilo.boehm 1.3                      }
1424                                      break;
1425                                  }
1426                                  default:
1427                                  {
1428 karl        1.5.2.11                 PEGASUS_ASSERT(false);
1429 thilo.boehm 1.3                  }
1430 r.kieninger 1.1              }
1431 thilo.boehm 1.3          }
1432                          if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
1433                          {
1434                              switch (_dataType)
1435 r.kieninger 1.1              {
1436 thilo.boehm 1.3                  case RESP_INSTNAMES:
1437                                  {
1438 karl        1.5.2.15                 for (Uint32 i = 0, n = _scmoInstances.size();i < n; i++)
1439 thilo.boehm 1.3                      {
1440 karl        1.5.2.15                     if (isPullResponse)
1441 karl        1.5.2.6                      {
1442                                              SCMOXmlWriter::appendInstancePathElement(
1443 karl        1.5.2.15                            out,
1444                                                 _scmoInstances[i]);
1445 karl        1.5.2.6                      }
1446 karl        1.5.2.15                     else
1447 karl        1.5.2.6                      {
1448                                              SCMOXmlWriter::appendInstanceNameElement(
1449                                                  out,
1450                                                  _scmoInstances[i]);
1451                                          }
1452 thilo.boehm 1.3                      }
1453                                      break;
1454                                  }
1455                                  case RESP_INSTANCE:
1456                                  {
1457                                      if (_scmoInstances.size() > 0)
1458                                      {
1459 karl        1.5.2.15                     _appendInstanceElement(out, _scmoInstances[0]);
1460 thilo.boehm 1.3                      }
1461                                      break;
1462                                  }
1463                                  case RESP_INSTANCES:
1464                                  {
1465 karl        1.5.2.3                  if (isPullResponse)
1466 thilo.boehm 1.3                      {
1467 karl        1.5.2.15                     // pull and encodeInstanceOnly (i.e. response to
1468                                          // OpenQueryInstances and pullInstances
1469                                          if (encodeInstanceOnly)
1470                                          {
1471                                              for (Uint32 i = 0, n = _scmoInstances.size();i < n; i++)
1472                                              {
1473                                                  _appendInstanceElement(out, _scmoInstances[i]);
1474                                              }
1475                                          }
1476                                          else
1477                                          {
1478                                              SCMOXmlWriter::appendValueSCMOInstanceWithPathElements(
1479                                                  out, _scmoInstances, _propertyList);
1480                                          }
1481 thilo.boehm 1.3                      }
1482 karl        1.5.2.3                  else
1483                                      {
1484                                          SCMOXmlWriter::appendValueSCMOInstanceElements(
1485                                              out, _scmoInstances, _propertyList);
1486                                      }
1487 thilo.boehm 1.3                      break;
1488                                  }
1489                                  case RESP_OBJECTS:
1490                                  {
1491 karl        1.5.2.3                  if (isPullResponse)
1492 thilo.boehm 1.3                      {
1493 karl        1.5.2.3                      SCMOXmlWriter::appendValueSCMOInstanceWithPathElements(
1494                                              out,_scmoInstances, _propertyList);
1495                                      }
1496                                      else
1497                                      {
1498                                          // KS_TODO why is this one named element rather than
1499                                          // elements
1500                                          SCMOXmlWriter::appendValueObjectWithPathElement(
1501                                              out, _scmoInstances, _propertyList);
1502 thilo.boehm 1.3                      }
1503                                      break;
1504                                  }
1505                                  case RESP_OBJECTPATHS:
1506                                  {
1507                                      for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++)
1508                                      {
1509 karl        1.5.2.1                      if (isPullResponse)
1510                                          {
1511                                              SCMOXmlWriter::appendInstancePathElement(out,
1512                                                  _scmoInstances[i]);
1513                                          }
1514                                          else
1515                                          {
1516                                              out << "<OBJECTPATH>\n";
1517 karl        1.5.2.21                         SCMOXmlWriter::appendClassOrInstancePathElement(
1518                                                  out, _scmoInstances[i]);
1519 karl        1.5.2.1                          out << "</OBJECTPATH>\n";
1520                                          }
1521 thilo.boehm 1.3                      }
1522                                      break;
1523                                  }
1524                                  default:
1525                                  {
1526 karl        1.5.2.11                 PEGASUS_ASSERT(false);
1527 thilo.boehm 1.3                  }
1528 r.kieninger 1.1              }
1529                          }
1530 karl        1.5.2.11     PEG_METHOD_EXIT();
1531 thilo.boehm 1.3      }
1532 r.kieninger 1.1      
1533 thilo.boehm 1.3      // contrary to encodeXmlResponse this function encodes the Xml in a format
1534                      // not usable by clients
1535 karl        1.5.2.21 void CIMResponseData::encodeInternalXmlResponse(CIMBuffer& out,
1536                          Boolean isPullOperation)
1537 thilo.boehm 1.3      {
1538 karl        1.5.2.11     PEG_METHOD_ENTER(TRC_DISPATCHER,
1539                              "CIMResponseData::encodeInternalXmlResponse");
1540                      
1541 thilo.boehm 1.3          PEG_TRACE((TRC_XML, Tracer::LEVEL3,
1542 karl        1.5.2.21         "CIMResponseData::encodeInternalXmlResponse(encoding=%X,content=%X"
1543                              " isPullOperation=%s)",
1544 thilo.boehm 1.3              _encoding,
1545 karl        1.5.2.21         _dataType,
1546                              boolToString(isPullOperation)));
1547                      
1548 thilo.boehm 1.3          // For mixed (CIM+SCMO) responses, we need to tell the receiver the
1549                          // total number of instances. The totalSize variable is used to keep track
1550                          // of this.
1551                          Uint32 totalSize = 0;
1552 r.kieninger 1.1      
1553 thilo.boehm 1.3          // already existing Internal XML does not need to be encoded further
1554                          // binary input is not actually impossible here, but we have an established
1555                          // fallback
1556                          if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
1557                          {
1558 karl        1.5.2.13         _resolveBinaryToSCMO();
1559 thilo.boehm 1.3          }
1560                          if ((0 == _encoding) ||
1561                              (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)))
1562                          {
1563                              switch (_dataType)
1564                              {
1565                                  case RESP_INSTANCE:
1566                                  {
1567                                      if (0 == _instances.size())
1568                                      {
1569                                          _instances.append(CIMInstance());
1570 karl        1.5.2.3                      CIMInternalXmlEncoder::_putXMLInstance(
1571                                              out,
1572                                              _instances[0]);
1573                                          break;
1574 thilo.boehm 1.3                      }
1575 karl        1.5.2.3                  CIMInternalXmlEncoder::_putXMLInstance(
1576                                          out,
1577                                          _instances[0],
1578                                          _includeQualifiers,
1579                                          _includeClassOrigin,
1580                                          _propertyList);
1581 thilo.boehm 1.3                      break;
1582                                  }
1583                                  case RESP_INSTANCES:
1584                                  {
1585                                      Uint32 n = _instances.size();
1586                                      totalSize = n + _scmoInstances.size();
1587                                      out.putUint32(totalSize);
1588                                      for (Uint32 i = 0; i < n; i++)
1589                                      {
1590                                          CIMInternalXmlEncoder::_putXMLNamedInstance(
1591                                              out,
1592 karl        1.5.2.3                          _instances[i],
1593                                              _includeQualifiers,
1594                                              _includeClassOrigin,
1595                                              _propertyList);
1596 thilo.boehm 1.3                      }
1597                                      break;
1598                                  }
1599                                  case RESP_OBJECTS:
1600                                  {
1601                                      Uint32 n = _objects.size();
1602                                      totalSize = n + _scmoInstances.size();
1603                                      out.putUint32(totalSize);
1604                                      for (Uint32 i = 0; i < n; i++)
1605                                      {
1606 karl        1.5.2.21                     // if is pull map to instances.
1607                                          if (isPullOperation)
1608                                          {
1609                                              CIMInternalXmlEncoder::_putXMLNamedInstance(
1610                                                  out,
1611                                                  (CIMInstance)_objects[i],
1612                                                  _includeQualifiers,
1613                                                  _includeClassOrigin,
1614                                                  _propertyList);
1615                                          }
1616                                          else
1617                                          {
1618                                              CIMInternalXmlEncoder::_putXMLObject(
1619                                                  out,
1620                                                  _objects[i],
1621                                                  _includeQualifiers,
1622                                                  _includeClassOrigin,
1623                                                  _propertyList);
1624                                          }
1625 thilo.boehm 1.3                      }
1626                                      break;
1627                                  }
1628                                  // internal xml encoding of instance names and object paths not
1629                                  // done today
1630                                  case RESP_INSTNAMES:
1631                                  case RESP_OBJECTPATHS:
1632                                  default:
1633                                  {
1634 karl        1.5.2.16                 PEGASUS_DEBUG_ASSERT(false);
1635 thilo.boehm 1.3                  }
1636                              }
1637                          }
1638                          if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
1639                          {
1640                              switch (_dataType)
1641                              {
1642                                  case RESP_INSTANCE:
1643                                  {
1644                                      if (0 == _scmoInstances.size())
1645                                      {
1646                                          _scmoInstances.append(SCMOInstance());
1647                                      }
1648 karl        1.5.2.3                  SCMOInternalXmlEncoder::_putXMLInstance(
1649 karl        1.5.2.7                      out,
1650 karl        1.5.2.3                      _scmoInstances[0],
1651                                          _propertyList);
1652 thilo.boehm 1.3                      break;
1653                                  }
1654                                  case RESP_INSTANCES:
1655                                  {
1656                                      Uint32 n = _scmoInstances.size();
1657                                      // Only put the size when not already done above
1658                                      if (0==totalSize)
1659                                      {
1660                                          out.putUint32(n);
1661                                      }
1662 karl        1.5.2.3                  SCMOInternalXmlEncoder::_putXMLNamedInstance(
1663                                          out,
1664                                          _scmoInstances,
1665                                          _propertyList);
1666 thilo.boehm 1.3                      break;
1667                                  }
1668                                  case RESP_OBJECTS:
1669                                  {
1670                                      Uint32 n = _scmoInstances.size();
1671                                      // Only put the size when not already done above
1672                                      if (0==totalSize)
1673                                      {
1674                                          out.putUint32(n);
1675                                      }
1676 karl        1.5.2.21                     // if is pull map to instances.
1677                                      if (isPullOperation)
1678                                      {
1679                                          SCMOInternalXmlEncoder::_putXMLNamedInstance(
1680                                              out,
1681                                              _scmoInstances,
1682                                              _propertyList);
1683                                      }
1684                                      else
1685                                      {
1686                                          SCMOInternalXmlEncoder::_putXMLObject(
1687                                              out,
1688                                              _scmoInstances,
1689                                              _propertyList);
1690                                      }
1691 thilo.boehm 1.3                      break;
1692                                  }
1693                                  // internal xml encoding of instance names and object paths not
1694                                  // done today
1695                                  case RESP_INSTNAMES:
1696                                  case RESP_OBJECTPATHS:
1697                                  default:
1698                                  {
1699 karl        1.5.2.16                 PEGASUS_DEBUG_ASSERT(false);
1700 thilo.boehm 1.3                  }
1701                              }
1702                          }
1703 karl        1.5.2.11     PEG_METHOD_EXIT();
1704 thilo.boehm 1.3      }
1705 r.kieninger 1.1      
1706 thilo.boehm 1.3      void CIMResponseData::_resolveToCIM()
1707 r.kieninger 1.1      {
1708 r.kieninger 1.4          PEG_TRACE((TRC_XML, Tracer::LEVEL3,
1709                              "CIMResponseData::_resolveToCIM(encoding=%X,content=%X)",
1710 thilo.boehm 1.3              _encoding,
1711                              _dataType));
1712 r.kieninger 1.1      
1713 thilo.boehm 1.3          if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
1714                          {
1715                              _resolveXmlToCIM();
1716                          }
1717                          if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
1718 r.kieninger 1.1          {
1719 karl        1.5.2.13         _resolveBinaryToSCMO();
1720 r.kieninger 1.1          }
1721 thilo.boehm 1.3          if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
1722 r.kieninger 1.1          {
1723 thilo.boehm 1.3              _resolveSCMOToCIM();
1724 r.kieninger 1.1          }
1725 thilo.boehm 1.3      
1726                          PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_CIM || _encoding == 0);
1727 r.kieninger 1.1      }
1728                      
1729 karl        1.5.2.13 // Resolve any binary data to SCMO. This externalfunction added because we
1730                      // cannot do a move on Binary data so convert it a to movable format
1731                      void CIMResponseData::resolveBinaryToSCMO()
1732                      {
1733                          PEG_METHOD_ENTER(TRC_DISPATCHER,
1734                              "CIMResponseData::resolveBinaryToSCMO");
1735                          if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
1736                          {
1737                              _resolveBinaryToSCMO();
1738                          }
1739                          PEG_METHOD_EXIT();
1740                      }
1741                      
1742 thilo.boehm 1.3      void CIMResponseData::_resolveToSCMO()
1743 r.kieninger 1.1      {
1744 r.kieninger 1.4          PEG_TRACE((TRC_XML, Tracer::LEVEL3,
1745                              "CIMResponseData::_resolveToSCMO(encoding=%X,content=%X)",
1746 thilo.boehm 1.3              _encoding,
1747                              _dataType));
1748 r.kieninger 1.1      
1749 thilo.boehm 1.3          if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
1750                          {
1751                              _resolveXmlToSCMO();
1752                          }
1753                          if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
1754 r.kieninger 1.1          {
1755 karl        1.5.2.13         _resolveBinaryToSCMO();
1756 r.kieninger 1.1          }
1757 thilo.boehm 1.3          if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
1758 r.kieninger 1.1          {
1759 thilo.boehm 1.3              _resolveCIMToSCMO();
1760 r.kieninger 1.1          }
1761 thilo.boehm 1.3          PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_SCMO || _encoding == 0);
1762 r.kieninger 1.1      }
1763                      
1764 thilo.boehm 1.3      // helper functions to transform different formats into one-another
1765                      // functions work on the internal data and calling of them should be
1766                      // avoided whenever possible
1767 karl        1.5.2.13 void CIMResponseData::_resolveBinaryToSCMO()
1768 r.kieninger 1.1      {
1769                          PEG_METHOD_ENTER(TRC_DISPATCHER,
1770 karl        1.5.2.13         "CIMResponseData::_resolveBinaryToSCMO");
1771 r.kieninger 1.1      
1772 thilo.boehm 1.3          CIMBuffer in((char*)_binaryData.getData(), _binaryData.size());
1773 r.kieninger 1.1      
1774 r.kieninger 1.2          while (in.more())
1775 r.kieninger 1.1          {
1776 thilo.boehm 1.3              Uint32 binaryTypeMarker=0;
1777                              if(!in.getTypeMarker(binaryTypeMarker))
1778 r.kieninger 1.2              {
1779                                  PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1780 thilo.boehm 1.3                      "Failed to get type marker for binary objects!");
1781 r.kieninger 1.2                  PEG_METHOD_EXIT();
1782 thilo.boehm 1.3                  in.release();
1783                                  return;
1784                              }
1785                      
1786                              if (BIN_TYPE_MARKER_SCMO==binaryTypeMarker)
1787                              {
1788                                  if (!in.getSCMOInstanceA(_scmoInstances))
1789                                  {
1790                                      _encoding &=(~RESP_ENC_BINARY);
1791                                      in.release();
1792                                      PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1793                                          "Failed to resolve binary SCMOInstances!");
1794                                      PEG_METHOD_EXIT();
1795                                      return;
1796                                  }
1797                      
1798                                  _encoding |= RESP_ENC_SCMO;
1799 r.kieninger 1.2              }
1800 thilo.boehm 1.3              else
1801                              {
1802                                  switch (_dataType)
1803                                  {
1804                                      case RESP_INSTNAMES:
1805                                      case RESP_OBJECTPATHS:
1806                                      {
1807                                          if (!in.getObjectPathA(_instanceNames))
1808                                          {
1809                                              _encoding &=(~RESP_ENC_BINARY);
1810                                              in.release();
1811                                              PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1812                                                  "Failed to resolve binary CIMObjectPaths!");
1813                                              PEG_METHOD_EXIT();
1814                                              return;
1815                                          }
1816                                          break;
1817                                      }
1818                                      case RESP_INSTANCE:
1819                                      {
1820                                          CIMInstance instance;
1821 thilo.boehm 1.3                          if (!in.getInstance(instance))
1822                                          {
1823                                              _encoding &=(~RESP_ENC_BINARY);
1824                                              _encoding |= RESP_ENC_CIM;
1825                                              _instances.append(instance);
1826                                              in.release();
1827                                              PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1828                                                  "Failed to resolve binary instance!");
1829                                              PEG_METHOD_EXIT();
1830                                              return;
1831                                          }
1832                      
1833                                          _instances.append(instance);
1834                                          break;
1835                                      }
1836                                      case RESP_INSTANCES:
1837                                      {
1838                                          if (!in.getInstanceA(_instances))
1839                                          {
1840                                              _encoding &=(~RESP_ENC_BINARY);
1841                                              in.release();
1842 thilo.boehm 1.3                              PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1843                                                  "Failed to resolve binary CIMInstances!");
1844                                              PEG_METHOD_EXIT();
1845                                              return;
1846                                          }
1847                                          break;
1848                                      }
1849                                      case RESP_OBJECTS:
1850                                      {
1851                                          if (!in.getObjectA(_objects))
1852                                          {
1853                                              in.release();
1854                                              _encoding &=(~RESP_ENC_BINARY);
1855                                              PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1856                                                  "Failed to resolve binary CIMObjects!");
1857                                              PEG_METHOD_EXIT();
1858                                              return;
1859                                          }
1860                                          break;
1861                                      }
1862                                      default:
1863 thilo.boehm 1.3                      {
1864 karl        1.5.2.16                     PEGASUS_DEBUG_ASSERT(false);
1865 thilo.boehm 1.3                      }
1866                                  } // switch
1867                                  _encoding |= RESP_ENC_CIM;
1868                              } // else SCMO
1869                          }
1870                          _encoding &=(~RESP_ENC_BINARY);
1871                          // fix up the hostname and namespace for objects if defaults
1872                          // were set
1873                          if (_defaultHostname.size() > 0 && !_defaultNamespace.isNull())
1874                          {
1875                              completeHostNameAndNamespace(_defaultHostname, _defaultNamespace);
1876 r.kieninger 1.1          }
1877                          in.release();
1878                          PEG_METHOD_EXIT();
1879                      }
1880                      
1881 karl        1.5.2.7  
1882                      void CIMResponseData::_deserializeObject(Uint32 idx,CIMObject& cimObject)
1883                      {
1884 karl        1.5.2.11 
1885                          PEG_METHOD_ENTER(TRC_DISPATCHER,
1886                              "CIMResponseData::_deserializeObject");
1887 karl        1.5.2.7      // Only start the parser when instance data is present.
1888                          if (0 != _instanceData[idx].size())
1889                          {
1890                              CIMInstance cimInstance;
1891                              CIMClass cimClass;
1892                      
1893                              XmlParser parser((char*)_instanceData[idx].getData());
1894                      
1895                              if (XmlReader::getInstanceElement(parser, cimInstance))
1896                              {
1897                                  cimObject = CIMObject(cimInstance);
1898                                  return;
1899                              }
1900                      
1901                              if (XmlReader::getClassElement(parser, cimClass))
1902                              {
1903                                  cimObject = CIMObject(cimClass);
1904                                  return;
1905                              }
1906                              PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1907                                  "Failed to resolve XML object data, parser error!");
1908 karl        1.5.2.7      }
1909 karl        1.5.2.11     PEG_METHOD_EXIT();
1910 karl        1.5.2.7  }
1911                      
1912                      void CIMResponseData::_deserializeInstance(Uint32 idx,CIMInstance& cimInstance)
1913                      {
1914 karl        1.5.2.11     PEG_METHOD_ENTER(TRC_DISPATCHER,
1915                              "CIMResponseData::_deserializeInstance");
1916 karl        1.5.2.7      // Only start the parser when instance data is present.
1917                          if (0 != _instanceData[idx].size())
1918                          {
1919                              XmlParser parser((char*)_instanceData[idx].getData());
1920                              if (XmlReader::getInstanceElement(parser, cimInstance))
1921                              {
1922                                  return;
1923                              }
1924                              PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1925                                  "Failed to resolve XML instance, parser error!");
1926                          }
1927                          // reset instance when parsing may not be successfull or
1928                          // no instance is present.
1929                          cimInstance = CIMInstance();
1930 karl        1.5.2.11 
1931                          PEG_METHOD_EXIT();
1932 karl        1.5.2.7  }
1933                      
1934                      Boolean CIMResponseData::_deserializeReference(
1935                          Uint32 idx,
1936                          CIMObjectPath& cimObjectPath)
1937                      {
1938                          // Only start the parser when reference data is present.
1939                          if (0 != _referencesData[idx].size())
1940                          {
1941                              XmlParser parser((char*)_referencesData[idx].getData());
1942                              if (XmlReader::getValueReferenceElement(parser, cimObjectPath))
1943                              {
1944                                  if (_hostsData[idx].size())
1945                                  {
1946                                      cimObjectPath.setHost(_hostsData[idx]);
1947                                  }
1948                                  if (!_nameSpacesData[idx].isNull())
1949                                  {
1950                                      cimObjectPath.setNameSpace(_nameSpacesData[idx]);
1951                                  }
1952                                  return true;
1953 karl        1.5.2.7          }
1954                              PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1955                                  "Failed to resolve XML reference, parser error!");
1956                      
1957                          }
1958                          return false;
1959                      }
1960                      
1961                      Boolean CIMResponseData::_deserializeInstanceName(
1962                          Uint32 idx,
1963                          CIMObjectPath& cimObjectPath)
1964                      {
1965                          // Only start the parser when instance name data is present.
1966                          if (0 != _referencesData[idx].size())
1967                          {
1968                              XmlParser parser((char*)_referencesData[idx].getData());
1969                              if (XmlReader::getInstanceNameElement(parser, cimObjectPath))
1970                              {
1971                                  if (_hostsData[idx].size())
1972                                  {
1973                                      cimObjectPath.setHost(_hostsData[idx]);
1974 karl        1.5.2.7              }
1975                                  if (!_nameSpacesData[idx].isNull())
1976                                  {
1977                                      cimObjectPath.setNameSpace(_nameSpacesData[idx]);
1978                                  }
1979                                  return true;
1980                              }
1981                              PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1982                                  "Failed to resolve XML instance name, parser error!");
1983                      
1984                          }
1985                          return false;
1986                      }
1987                      
1988 thilo.boehm 1.3      void CIMResponseData::_resolveXmlToCIM()
1989 r.kieninger 1.1      {
1990 karl        1.5.2.11     PEG_METHOD_ENTER(TRC_DISPATCHER,
1991                              "CIMResponseData::_resolveXmlToCIM");
1992                      
1993 thilo.boehm 1.3          switch (_dataType)
1994 r.kieninger 1.1          {
1995 thilo.boehm 1.3              // Xml encoding for instance names and object paths not used
1996                              case RESP_OBJECTPATHS:
1997                              case RESP_INSTNAMES:
1998                              {
1999                                  break;
2000                              }
2001                              case RESP_INSTANCE:
2002 r.kieninger 1.1              {
2003 thilo.boehm 1.3                  CIMInstance cimInstance;
2004 karl        1.5.2.7              CIMObjectPath cimObjectPath;
2005 r.kieninger 1.1      
2006 karl        1.5.2.7              _deserializeInstance(0,cimInstance);
2007                                  if (_deserializeReference(0,cimObjectPath))
2008 r.kieninger 1.1                  {
2009 karl        1.5.2.7                  cimInstance.setPath(cimObjectPath);
2010                                      // A single CIMInstance has to have an objectpath.
2011                                      // So only add it when an objectpath exists.
2012                                      _instances.append(cimInstance);
2013 r.kieninger 1.1                  }
2014 thilo.boehm 1.3                  break;
2015 r.kieninger 1.1              }
2016 thilo.boehm 1.3              case RESP_INSTANCES:
2017                              {
2018                                  for (Uint32 i = 0; i < _instanceData.size(); i++)
2019                                  {
2020                                      CIMInstance cimInstance;
2021 karl        1.5.2.7                  CIMObjectPath cimObjectPath;
2022 thilo.boehm 1.3      
2023 karl        1.5.2.7                  _deserializeInstance(i,cimInstance);
2024                                      if (_deserializeInstanceName(i,cimObjectPath))
2025 thilo.boehm 1.3                      {
2026 karl        1.5.2.7                      cimInstance.setPath(cimObjectPath);
2027 thilo.boehm 1.3                      }
2028 karl        1.5.2.7                  // enumarate instances can be without name
2029 thilo.boehm 1.3                      _instances.append(cimInstance);
2030                                  }
2031                                  break;
2032                              }
2033                              case RESP_OBJECTS:
2034 r.kieninger 1.1              {
2035 thilo.boehm 1.3                  for (Uint32 i=0, n=_instanceData.size(); i<n; i++)
2036 r.kieninger 1.1                  {
2037 thilo.boehm 1.3                      CIMObject cimObject;
2038 karl        1.5.2.7                  CIMObjectPath cimObjectPath;
2039 r.kieninger 1.1      
2040 karl        1.5.2.7                  _deserializeObject(i,cimObject);
2041                                      if (_deserializeReference(i,cimObjectPath))
2042 thilo.boehm 1.3                      {
2043 karl        1.5.2.7                      cimObject.setPath(cimObjectPath);
2044 thilo.boehm 1.3                      }
2045                                      _objects.append(cimObject);
2046 r.kieninger 1.1                  }
2047 thilo.boehm 1.3                  break;
2048                              }
2049                              default:
2050                              {
2051 karl        1.5.2.11             PEGASUS_ASSERT(false);
2052 r.kieninger 1.1              }
2053                          }
2054 thilo.boehm 1.3          // Xml was resolved, release Xml content now
2055                          _referencesData.clear();
2056                          _hostsData.clear();
2057                          _nameSpacesData.clear();
2058                          _instanceData.clear();
2059                          // remove Xml Encoding flag
2060                          _encoding &=(~RESP_ENC_XML);
2061                          // add CIM Encoding flag
2062                          _encoding |=RESP_ENC_CIM;
2063 karl        1.5.2.11 
2064                          PEG_METHOD_EXIT();
2065 thilo.boehm 1.3      }
2066 r.kieninger 1.1      
2067 thilo.boehm 1.3      void CIMResponseData::_resolveXmlToSCMO()
2068                      {
2069 karl        1.5.2.11     PEG_METHOD_ENTER(TRC_DISPATCHER,
2070                              "CIMResponseData::_resolveXmlToSCMO");
2071 thilo.boehm 1.3          // Not optimal, can probably be improved
2072                          // but on the other hand, since using the binary format this case should
2073                          // actually not ever happen.
2074                          _resolveXmlToCIM();
2075                          _resolveCIMToSCMO();
2076 karl        1.5.2.11 
2077                          PEG_METHOD_EXIT();
2078 r.kieninger 1.1      }
2079                      
2080 thilo.boehm 1.3      void CIMResponseData::_resolveSCMOToCIM()
2081 r.kieninger 1.1      {
2082 karl        1.5.2.11     PEG_METHOD_ENTER(TRC_DISPATCHER,
2083                              "CIMResponseData::_resolveSCMOToCIM");
2084 thilo.boehm 1.3          switch(_dataType)
2085 r.kieninger 1.2          {
2086 thilo.boehm 1.3              case RESP_INSTNAMES:
2087                              case RESP_OBJECTPATHS:
2088 r.kieninger 1.2              {
2089 thilo.boehm 1.3                  for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
2090                                  {
2091                                      CIMObjectPath newObjectPath;
2092                                      _scmoInstances[x].getCIMObjectPath(newObjectPath);
2093                                      _instanceNames.append(newObjectPath);
2094                                  }
2095                                  break;
2096 r.kieninger 1.2              }
2097 thilo.boehm 1.3              case RESP_INSTANCE:
2098 r.kieninger 1.1              {
2099 thilo.boehm 1.3                  if (_scmoInstances.size() > 0)
2100                                  {
2101                                      CIMInstance newInstance;
2102                                      _scmoInstances[0].getCIMInstance(newInstance);
2103                                      _instances.append(newInstance);
2104                                  }
2105                                  break;
2106 r.kieninger 1.1              }
2107 thilo.boehm 1.3              case RESP_INSTANCES:
2108 r.kieninger 1.1              {
2109 thilo.boehm 1.3                  for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
2110                                  {
2111                                      CIMInstance newInstance;
2112                                      _scmoInstances[x].getCIMInstance(newInstance);
2113                                      _instances.append(newInstance);
2114                                  }
2115                                  break;
2116 r.kieninger 1.1              }
2117 thilo.boehm 1.3              case RESP_OBJECTS:
2118 r.kieninger 1.1              {
2119 thilo.boehm 1.3                  for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
2120                                  {
2121                                      CIMInstance newInstance;
2122                                      _scmoInstances[x].getCIMInstance(newInstance);
2123                                      _objects.append(CIMObject(newInstance));
2124                                  }
2125                                  break;
2126 r.kieninger 1.1              }
2127 thilo.boehm 1.3              default:
2128 r.kieninger 1.1              {
2129 karl        1.5.2.16             PEGASUS_DEBUG_ASSERT(false);
2130 r.kieninger 1.1              }
2131                          }
2132 thilo.boehm 1.3          _scmoInstances.clear();
2133                          // remove CIM Encoding flag
2134                          _encoding &=(~RESP_ENC_SCMO);
2135                          // add SCMO Encoding flag
2136                          _encoding |=RESP_ENC_CIM;
2137 karl        1.5.2.11 
2138                          PEG_METHOD_EXIT();
2139 r.kieninger 1.1      }
2140                      
2141 thilo.boehm 1.3      void CIMResponseData::_resolveCIMToSCMO()
2142 r.kieninger 1.1      {
2143 karl        1.5.2.11     PEG_METHOD_ENTER(TRC_DISPATCHER,
2144                              "CIMResponseData::_resolveCIMToSCMO");
2145 thilo.boehm 1.3          CString nsCString=_defaultNamespace.getString().getCString();
2146                          const char* _defNamespace = nsCString;
2147                          Uint32 _defNamespaceLen;
2148                          if (_defaultNamespace.isNull())
2149 r.kieninger 1.1          {
2150 thilo.boehm 1.3              _defNamespaceLen=0;
2151 r.kieninger 1.1          }
2152                          else
2153                          {
2154 thilo.boehm 1.3              _defNamespaceLen=strlen(_defNamespace);
2155 r.kieninger 1.1          }
2156 thilo.boehm 1.3          switch (_dataType)
2157 r.kieninger 1.1          {
2158 thilo.boehm 1.3              case RESP_INSTNAMES:
2159 r.kieninger 1.1              {
2160 thilo.boehm 1.3                  for (Uint32 i=0,n=_instanceNames.size();i<n;i++)
2161                                  {
2162                                      SCMOInstance addme(
2163                                          _instanceNames[i],
2164                                          _defNamespace,
2165                                          _defNamespaceLen);
2166                                      _scmoInstances.append(addme);
2167                                  }
2168                                  _instanceNames.clear();
2169                                  break;
2170 r.kieninger 1.1              }
2171 thilo.boehm 1.3              case RESP_INSTANCE:
2172 r.kieninger 1.2              {
2173 thilo.boehm 1.3                  if (_instances.size() > 0)
2174                                  {
2175                                      SCMOInstance addme(
2176                                          _instances[0],
2177                                          _defNamespace,
2178                                          _defNamespaceLen);
2179                                      _scmoInstances.clear();
2180                                      _scmoInstances.append(addme);
2181                                      _instances.clear();
2182                                  }
2183                                  break;
2184 r.kieninger 1.2              }
2185 thilo.boehm 1.3              case RESP_INSTANCES:
2186 r.kieninger 1.1              {
2187 thilo.boehm 1.3                  for (Uint32 i=0,n=_instances.size();i<n;i++)
2188 r.kieninger 1.1                  {
2189 thilo.boehm 1.3                      SCMOInstance addme(
2190                                          _instances[i],
2191                                          _defNamespace,
2192                                          _defNamespaceLen);
2193                                      _scmoInstances.append(addme);
2194 r.kieninger 1.1                  }
2195 thilo.boehm 1.3                  _instances.clear();
2196                                  break;
2197                              }
2198                              case RESP_OBJECTS:
2199                              {
2200                                  for (Uint32 i=0,n=_objects.size();i<n;i++)
2201 r.kieninger 1.1                  {
2202 thilo.boehm 1.3                      SCMOInstance addme(
2203                                          _objects[i],
2204                                          _defNamespace,
2205                                          _defNamespaceLen);
2206                                      _scmoInstances.append(addme);
2207 r.kieninger 1.1                  }
2208 thilo.boehm 1.3                  _objects.clear();
2209                                  break;
2210                              }
2211                              case RESP_OBJECTPATHS:
2212                              {
2213                                  for (Uint32 i=0,n=_instanceNames.size();i<n;i++)
2214 r.kieninger 1.1                  {
2215 thilo.boehm 1.3                      SCMOInstance addme(
2216                                          _instanceNames[i],
2217                                          _defNamespace,
2218                                          _defNamespaceLen);
2219 karl        1.5.2.7                  if (_isClassOperation)
2220 thilo.boehm 1.3                      {
2221                                          addme.setIsClassOnly(true);
2222                                      }
2223                                      _scmoInstances.append(addme);
2224 r.kieninger 1.1                  }
2225 thilo.boehm 1.3                  _instanceNames.clear();
2226                                  break;
2227 r.kieninger 1.1              }
2228 thilo.boehm 1.3              default:
2229 r.kieninger 1.1              {
2230 karl        1.5.2.16             PEGASUS_DEBUG_ASSERT(false);
2231 r.kieninger 1.1              }
2232                          }
2233                      
2234 thilo.boehm 1.3          // remove CIM Encoding flag
2235                          _encoding &=(~RESP_ENC_CIM);
2236                          // add SCMO Encoding flag
2237                          _encoding |=RESP_ENC_SCMO;
2238 karl        1.5.2.11 
2239                          PEG_METHOD_EXIT();
2240 r.kieninger 1.1      }
2241                      
2242 karl        1.5.2.1  /**
2243                       * Validate the magic object for this CIMResponseData. This
2244                       * compiles only in debug mode and can be use to validate the
2245                       * CIMResponseData object
2246                       *
2247                       * @return Boolean True if valid object.
2248                       */
2249 karl        1.5.2.10 Boolean CIMResponseData::valid() const
2250 karl        1.5.2.1  {
2251                          return _magic;
2252                      }
2253                      
2254 karl        1.5.2.3  void CIMResponseData::setRequestProperties(
2255                          const Boolean includeQualifiers,
2256                          const Boolean includeClassOrigin,
2257                          const CIMPropertyList& propertyList)
2258                      {
2259                          _includeQualifiers = includeQualifiers;
2260                          _includeClassOrigin = includeClassOrigin;
2261 karl        1.5.2.7      _propertyList = propertyList;
2262                      }
2263                      
2264                      void CIMResponseData::setIsClassOperation(Boolean b)
2265                      {
2266                          _isClassOperation = b;
2267 karl        1.5.2.3  }
2268                      
2269 karl        1.5.2.21 //// KS_TODO Remove. Diagnostic Displays below before commit to head
2270 karl        1.5.2.12 void CIMResponseData::traceResponseData()
2271                      {
2272                          PEG_TRACE((TRC_XML, Tracer::LEVEL3,
2273 karl        1.5.2.21         "%s", (const char*)toStringTraceResponseData().getCString() ));
2274                      }
2275                      String CIMResponseData::toStringTraceResponseData()
2276                      {
2277                          int rtnSize;
2278                          char *p;
2279                      
2280                          int allocSize = 256;
2281                      
2282                          if ((p = (char*)malloc(allocSize)) == NULL)
2283                          {
2284                              return String();
2285                          }
2286                      
2287                          do
2288                          {
2289                              rtnSize = snprintf(p, allocSize,
2290 karl        1.5.2.12         "CIMResponseData::traceResponseData(encoding=%X,dataType=%X "
2291 karl        1.5.2.13         " size=%u C++instNamecount=%u c++Instances=%u c++Objects=%u "
2292                              "scomInstances=%u XMLInstData=%u binaryData=%u "
2293                              "xmlref=%u xmlinst=%u, xmlhost=%u xmlns=%u",
2294 karl        1.5.2.12         _encoding,_dataType, _size,
2295                              _instanceNames.size(),_instances.size(), _objects.size(),
2296                              _scmoInstances.size(),_instanceData.size(),_binaryData.size(),
2297                              _referencesData.size(), _instanceData.size(), _hostsData.size(),
2298 karl        1.5.2.21         _nameSpacesData.size());
2299                      
2300                              // return if successful if not negative and
2301                              // returns less than allocated size.
2302                              if (rtnSize > -1 && rtnSize < allocSize)
2303                              {
2304                                  break;
2305                              }
2306                      
2307                              // increment alloc size. Assumes that positive return is
2308                              // expected size and negative is error.
2309                              allocSize = (rtnSize > -1)? (rtnSize + 1) : allocSize * 2;
2310                      
2311                          } while((p = (char*)peg_inln_realloc(p, allocSize)) != NULL);
2312                      
2313                          // Free allocated memory and return formatted output in String
2314                          String rtnStr(p);
2315                          free(p);
2316                          return(rtnStr);
2317 karl        1.5.2.12 }
2318                      
2319 karl        1.5.2.21 
2320 r.kieninger 1.1      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2