(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                 //%/////////////////////////////////////////////////////////////////////////////
  31                 
  32                 #include "CIMResponseData.h"
  33 thilo.boehm 1.3 #include <Pegasus/Common/Tracer.h>
  34                 #include <Pegasus/Common/XmlWriter.h>
  35                 #include <Pegasus/Common/SCMOXmlWriter.h>
  36                 #include <Pegasus/Common/XmlReader.h>
  37                 #include <Pegasus/Common/CIMInternalXmlEncoder.h>
  38                 #include <Pegasus/Common/SCMOInternalXmlEncoder.h>
  39 r.kieninger 1.1 
  40 karl        1.5.2.5 // KS_TODO_DELETE
  41                     #include <Pegasus/Common/Print.h>
  42                     
  43 r.kieninger 1.1     PEGASUS_USING_STD;
  44                     
  45                     PEGASUS_NAMESPACE_BEGIN
  46                     
  47 karl        1.5.2.1 #define LOCAL_MIN(a, b) ((a < b) ? a : b)
  48 thilo.boehm 1.3     // C++ objects interface handling
  49                     
  50 karl        1.5.2.5 // KS_TODO Remove this completely.
  51                     bool CIMResponseData::sizeValid()
  52 karl        1.5.2.3 {
  53 karl        1.5.2.5     TRACELINE; 
  54                         //////cout << _size << endl;
  55 karl        1.5.2.3     PEGASUS_ASSERT(valid());
  56 karl        1.5.2.5     if (_size > 1000000)
  57 karl        1.5.2.3     {
  58 karl        1.5.2.5         TRACELINE;
  59                             PEG_TRACE((TRC_XML, Tracer::LEVEL4,
  60                                        "CIMResponseData::PSVALID _size too big %u",_size ));
  61                             return false;
  62 karl        1.5.2.3     }
  63                         PEG_TRACE((TRC_XML, Tracer::LEVEL4,
  64                             "CIMResponseData Size _size=%u", _size));
  65 karl        1.5.2.5     return true;
  66 karl        1.5.2.3 }
  67 thilo.boehm 1.3     // Instance Names handling
  68                     Array<CIMObjectPath>& CIMResponseData::getInstanceNames()
  69                     {
  70 karl        1.5.2.5     TRACELINE;
  71                         PSVALID;
  72 thilo.boehm 1.3         PEGASUS_DEBUG_ASSERT(
  73                         (_dataType==RESP_INSTNAMES || _dataType==RESP_OBJECTPATHS));
  74                         _resolveToCIM();
  75                         PEGASUS_DEBUG_ASSERT(_encoding==RESP_ENC_CIM || _encoding == 0);
  76                         return _instanceNames;
  77                     }
  78                     
  79 karl        1.5.2.1 // Get a single instance as a CIM instance.
  80                     // This converts all of the objects in the response data to
  81                     // CIM form as part of the conversion.
  82                     // If there are no instances in the object, returns CIMInstance(),
  83                     // an empty instance.
  84 thilo.boehm 1.3     CIMInstance& CIMResponseData::getInstance()
  85                     {
  86 karl        1.5.2.5     TRACELINE;
  87 thilo.boehm 1.3         PEGASUS_DEBUG_ASSERT(_dataType == RESP_INSTANCE);
  88                         _resolveToCIM();
  89                         if (0 == _instances.size())
  90                         {
  91                             _instances.append(CIMInstance());
  92                         }
  93                         return _instances[0];
  94                     }
  95                     
  96                     // Instances handling
  97                     Array<CIMInstance>& CIMResponseData::getInstances()
  98                     {
  99 karl        1.5.2.5     TRACELINE;
 100 thilo.boehm 1.3         PEGASUS_DEBUG_ASSERT(_dataType == RESP_INSTANCES);
 101                         _resolveToCIM();
 102                         return _instances;
 103                     }
 104                     
 105 karl        1.5.2.1 // Instances handling specifically for the client where the call may
 106                     // get either instances or objects and must convert them to instances
 107                     // NOTE: This is a temporary solution to satisfy the BinaryCodec passing
 108                     // of data to the client where the data could be either instances or
 109                     // objects.  The correct solution is to convert back when the provider, etc.
 110                     // returns the data to the server.  We must convert to that solution but
 111                     // this keeps it working for the moment.
 112                     Array<CIMInstance>& CIMResponseData::getInstancesFromInstancesOrObjects()
 113                     {
 114 karl        1.5.2.5     TRACELINE;
 115 karl        1.5.2.1     if (_dataType == RESP_INSTANCES)
 116                         {
 117                             _resolveToCIM();
 118                             return _instances;
 119                         }
 120                         else if (_dataType == RESP_OBJECTS)
 121                         {
 122                             _resolveToCIM();
 123                             for (Uint32 i = 0 ; i < _objects.size() ; i++)
 124                             {
 125                                 _instances.append((CIMInstance)_objects[i]);
 126                             }
 127                             return _instances;
 128                     
 129                         }
 130                         PEGASUS_DEBUG_ASSERT(false);
 131                     }
 132                     
 133 thilo.boehm 1.3     // Objects handling
 134                     Array<CIMObject>& CIMResponseData::getObjects()
 135                     {
 136 karl        1.5.2.5     TRACELINE;
 137 thilo.boehm 1.3         PEGASUS_DEBUG_ASSERT(_dataType == RESP_OBJECTS);
 138                         _resolveToCIM();
 139                         return _objects;
 140                     }
 141                     
 142                     // SCMO representation, single instance stored as one element array
 143                     // object paths are represented as SCMOInstance
 144                     Array<SCMOInstance>& CIMResponseData::getSCMO()
 145                     {
 146 karl        1.5.2.5     TRACELINE;
 147 thilo.boehm 1.3         _resolveToSCMO();
 148                         return _scmoInstances;
 149                     }
 150                     
 151 karl        1.5.2.1 // set an array of SCMOInstances into the response data object
 152 thilo.boehm 1.3     void CIMResponseData::setSCMO(const Array<SCMOInstance>& x)
 153                     {
 154 karl        1.5.2.5     TRACELINE;
 155                         PSVALID;
 156 thilo.boehm 1.3         _scmoInstances=x;
 157                         _encoding |= RESP_ENC_SCMO;
 158 karl        1.5.2.1     _size += x.size();
 159 thilo.boehm 1.3     }
 160                     
 161                     // Binary data is just a data stream
 162                     Array<Uint8>& CIMResponseData::getBinary()
 163                     {
 164 karl        1.5.2.5     TRACELINE;
 165 thilo.boehm 1.3         PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_BINARY || _encoding == 0);
 166                         return _binaryData;
 167                     }
 168                     
 169 karl        1.5     bool CIMResponseData::setBinary(CIMBuffer& in)
 170 r.kieninger 1.1     {
 171 karl        1.5.2.5     TRACELINE;
 172 karl        1.5         PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setBinary");
 173 r.kieninger 1.1     
 174 karl        1.5         // Append all serial data from the CIMBuffer to the local data store.
 175                         // Returns error if input not a serialized Uint8A
 176                         if (!in.getUint8A(_binaryData))
 177                         {
 178                             PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 179                                 "Failed to get binary input data!");
 180                             PEG_METHOD_EXIT();
 181                             return false;
 182 r.kieninger 1.1         }
 183 karl        1.5         _encoding |= RESP_ENC_BINARY;
 184                         PEG_METHOD_EXIT();
 185                         return true;
 186                     }
 187                     
 188                     bool CIMResponseData::setRemainingBinaryData(CIMBuffer& in)
 189                     {
 190 karl        1.5.2.5     TRACELINE;
 191 karl        1.5         PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setRemainingBinaryData");
 192                     
 193                         // Append any data that has not been deserialized already from
 194                         // the CIMBuffer.
 195                         size_t remainingDataLength = in.remainingDataLength();
 196                         _binaryData.append((Uint8*)in.getPtr(), remainingDataLength);
 197                     
 198 thilo.boehm 1.3         _encoding |= RESP_ENC_BINARY;
 199 r.kieninger 1.1         PEG_METHOD_EXIT();
 200                         return true;
 201 thilo.boehm 1.3     }
 202 r.kieninger 1.1     
 203 thilo.boehm 1.3     bool CIMResponseData::setXml(CIMBuffer& in)
 204 r.kieninger 1.1     {
 205 karl        1.5.2.5     TRACELINE;
 206                         PSVALID;
 207 thilo.boehm 1.3         switch (_dataType)
 208 r.kieninger 1.1         {
 209 thilo.boehm 1.3             case RESP_INSTANCE:
 210                             {
 211                                 Array<Sint8> inst;
 212                                 Array<Sint8> ref;
 213                                 CIMNamespaceName ns;
 214                                 String host;
 215                                 if (!in.getSint8A(inst))
 216                                 {
 217                                     PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 218                                         "Failed to get XML instance data!");
 219                                     return false;
 220                                 }
 221                                 _instanceData.insert(0,inst);
 222                                 if (!in.getSint8A(ref))
 223                                 {
 224                                     PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 225                                         "Failed to get XML instance data (reference)!");
 226                                     return false;
 227                                 }
 228                                 _referencesData.insert(0,ref);
 229                                 if (!in.getString(host))
 230 thilo.boehm 1.3                 {
 231                                     PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 232                                         "Failed to get XML instance data (host)!");
 233                                     return false;
 234                                 }
 235                                 _hostsData.insert(0,host);
 236                                 if (!in.getNamespaceName(ns))
 237                                 {
 238                                     PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 239                                         "Failed to get XML instance data (namespace)!");
 240                                     return false;
 241                                 }
 242                                 _nameSpacesData.insert(0,ns);
 243 karl        1.5.2.1             _size++;
 244 thilo.boehm 1.3                 break;
 245                             }
 246                             case RESP_INSTANCES:
 247                             {
 248                                 Uint32 count;
 249                                 if (!in.getUint32(count))
 250                                 {
 251                                     PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 252                                         "Failed to get XML instance data (number of instance)!");
 253                                     return false;
 254                                 }
 255                                 for (Uint32 i = 0; i < count; i++)
 256                                 {
 257                                     Array<Sint8> inst;
 258                                     Array<Sint8> ref;
 259                                     CIMNamespaceName ns;
 260                                     String host;
 261                                     if (!in.getSint8A(inst))
 262                                     {
 263                                         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 264                                             "Failed to get XML instance data (instances)!");
 265 thilo.boehm 1.3                         return false;
 266                                     }
 267                                     if (!in.getSint8A(ref))
 268                                     {
 269                                         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 270                                             "Failed to get XML instance data (references)!");
 271                                         return false;
 272                                     }
 273                                     if (!in.getString(host))
 274                                     {
 275                                         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 276                                             "Failed to get XML instance data (host)!");
 277                                         return false;
 278                                     }
 279                                     if (!in.getNamespaceName(ns))
 280                                     {
 281                                         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 282                                             "Failed to get XML instance data (namespace)!");
 283                                         return false;
 284                                     }
 285                                     _instanceData.append(inst);
 286 thilo.boehm 1.3                     _referencesData.append(ref);
 287                                     _hostsData.append(host);
 288                                     _nameSpacesData.append(ns);
 289                                 }
 290 karl        1.5.2.1             _size += count;
 291 thilo.boehm 1.3                 break;
 292                             }
 293                             case RESP_OBJECTS:
 294                             {
 295                                 Uint32 count;
 296                                 if (!in.getUint32(count))
 297                                 {
 298                                     PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 299                                         "Failed to get XML object data (number of objects)!");
 300                                     return false;
 301                                 }
 302                                 for (Uint32 i = 0; i < count; i++)
 303                                 {
 304                                     Array<Sint8> obj;
 305                                     Array<Sint8> ref;
 306                                     CIMNamespaceName ns;
 307                                     String host;
 308                                     if (!in.getSint8A(obj))
 309                                     {
 310                                         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 311                                             "Failed to get XML object data (object)!");
 312 thilo.boehm 1.3                         return false;
 313                                     }
 314                                     if (!in.getSint8A(ref))
 315                                     {
 316                                         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 317                                             "Failed to get XML object data (reference)!");
 318                                         return false;
 319                                     }
 320                                     if (!in.getString(host))
 321                                     {
 322                                         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 323                                             "Failed to get XML object data (host)!");
 324                                         return false;
 325                                     }
 326                                     if (!in.getNamespaceName(ns))
 327                                     {
 328                                         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 329                                             "Failed to get XML object data (namespace)!");
 330                                         return false;
 331                                     }
 332                                     _instanceData.append(obj);
 333 thilo.boehm 1.3                     _referencesData.append(ref);
 334                                     _hostsData.append(host);
 335                                     _nameSpacesData.append(ns);
 336                                 }
 337 karl        1.5.2.1             _size += count;
 338 thilo.boehm 1.3                 break;
 339                             }
 340                             // internal xml encoding of instance names and object paths not
 341                             // done today
 342                             case RESP_INSTNAMES:
 343                             case RESP_OBJECTPATHS:
 344                             default:
 345                             {
 346                                 PEGASUS_DEBUG_ASSERT(false);
 347                             }
 348 r.kieninger 1.1         }
 349 thilo.boehm 1.3         _encoding |= RESP_ENC_XML;
 350                         return true;
 351                     }
 352 r.kieninger 1.1     
 353 karl        1.5.2.1 // Move the number of objects defined by the input parameter from
 354                     // one CIMResponse Object to another CIMResponse Object.
 355                     Uint32 CIMResponseData::moveObjects(CIMResponseData & from, Uint32 count)
 356                     {
 357 karl        1.5.2.5     TRACELINE;
 358 karl        1.5.2.1     PEG_TRACE((TRC_XML, Tracer::LEVEL3,
 359                             "CIMResponseData::move(%u)", count));
 360                     
 361                         PEGASUS_ASSERT(valid());                 // KS_TEMP
 362                         if (_dataType != from._dataType)         // KS_TEMP
 363                         {
 364                             printf("ERROR moveObjects _dataType %u. from._dataType %u\n",
 365                             _dataType, from._dataType);
 366                         }
 367                         PEGASUS_DEBUG_ASSERT(_dataType == from._dataType);
 368                         Uint32 rtnSize = 0;
 369                         Uint32 toMove = count;
 370                     //  printf("count to move = %u encoding %u from.size %u to.size %u\n",
 371                     //          count, from._encoding, from._size, _size);
 372                     
 373                         if (RESP_ENC_XML == (from._encoding & RESP_ENC_XML))
 374                         {
 375                             switch (_dataType)
 376                             {
 377                                 case RESP_OBJECTPATHS:
 378                                 case RESP_INSTNAMES:
 379 karl        1.5.2.1                 break;
 380                                 case RESP_INSTANCE:
 381                                     {
 382                                         Uint32 moveCount = toMove;
 383                                         if (from._instanceData.size() > 0)
 384                                         {
 385                                             // temp test to assure all sizes are the same.
 386                                             PEGASUS_ASSERT(from._hostsData.size() ==
 387                                                             from._instanceData.size());
 388                                             PEGASUS_ASSERT(from._referencesData.size() ==
 389                                                             from._instanceData.size());
 390                                             PEGASUS_ASSERT(from._nameSpacesData.size() ==
 391                                                             from._instanceData.size());
 392                                             _instanceData.append(from._instanceData.getData(),1);
 393                                             from._instanceData.remove(0, 1);
 394                                             _referencesData.append(
 395                                                 from._referencesData.getData(),1);
 396                                             from._referencesData.remove(0, 1);
 397                                             if (_hostsData.size())
 398                                             {
 399                                                 _hostsData.append(from._hostsData.getData(),1);
 400 karl        1.5.2.1                             from._hostsData.remove(0, 1);
 401                                             }
 402                                             if (_nameSpacesData.size())
 403                                             {
 404                                                 _nameSpacesData.append(
 405                                                     from._nameSpacesData.getData(),1);
 406                                                 from._nameSpacesData.remove(0, 1);
 407                                             }
 408                                             rtnSize += 1;
 409                                             toMove--;
 410                                             _encoding |= RESP_ENC_XML;
 411                                         }
 412                                     }
 413                                     break;
 414                     
 415                                 // The above should probably be folded into the following.
 416                                 // Need something like an assert if there is ever more than
 417                                 // one instance in _instanceData for type RESP_INSTANCE
 418                                 case RESP_INSTANCES:
 419                                 case RESP_OBJECTS:
 420                                     {
 421 karl        1.5.2.1                     Uint32 moveCount = LOCAL_MIN(toMove,
 422                                                                      from._instanceData.size());
 423                     
 424                                         PEGASUS_ASSERT(from._referencesData.size() ==
 425                                                         from._instanceData.size());
 426                                         _instanceData.append(from._instanceData.getData(),
 427                                                              moveCount);
 428                                         from._instanceData.remove(0, moveCount);
 429                                         _referencesData.append(from._referencesData.getData(),
 430                                                                moveCount);
 431                                         from._referencesData.remove(0, moveCount);
 432                                         rtnSize += moveCount;
 433                                         toMove -= moveCount;
 434                                         _encoding |= RESP_ENC_XML;
 435                                     }
 436                                     break;
 437                             }
 438                         }
 439                         if (RESP_ENC_BINARY == (from._encoding & RESP_ENC_BINARY))
 440                         {
 441                             // KS_PULL TBD Add binary move function
 442 karl        1.5.2.1         // Cannot resolve this one without actually processing
 443                             // the data since it is a stream.
 444                             rtnSize += 0;
 445                             PEGASUS_ASSERT(false);
 446                         }
 447                     
 448                         if (RESP_ENC_SCMO == (from._encoding & RESP_ENC_SCMO))
 449                         {
 450                             Uint32 moveCount = LOCAL_MIN(toMove, from._scmoInstances.size());
 451                     
 452                             _scmoInstances.append(from._scmoInstances.getData(), moveCount);
 453                             from._scmoInstances.remove(0, moveCount);
 454                             rtnSize += moveCount;
 455                             toMove -= moveCount;
 456                             _encoding |= RESP_ENC_SCMO;
 457                         }
 458                     
 459                         if (RESP_ENC_CIM == (from._encoding & RESP_ENC_CIM))
 460                         {
 461                             switch (_dataType)
 462                             {
 463 karl        1.5.2.1             case RESP_OBJECTPATHS:
 464                                 case RESP_INSTNAMES:
 465                                     {
 466                                         Uint32 moveCount = LOCAL_MIN(toMove,
 467                                                                      from._instanceNames.size());
 468                     
 469                                         _instanceNames.append(
 470                                             from._instanceNames.getData(), moveCount);
 471                                         from._instanceNames.remove(0, moveCount);
 472                                         rtnSize += moveCount;
 473                                         toMove -= moveCount;
 474                                         _encoding |= RESP_ENC_CIM;
 475                                     }
 476                                     break;
 477                                 case RESP_INSTANCE:
 478                                 case RESP_INSTANCES:
 479                                     {
 480                     
 481                                         Uint32 moveCount = LOCAL_MIN(toMove,
 482                                                                      from._instances.size());
 483                     
 484 karl        1.5.2.1                     _instances.append(from._instances.getData(), moveCount);
 485                                         from._instances.remove(0, moveCount);
 486                                         rtnSize += moveCount;
 487                                         toMove -= moveCount;
 488                                         _encoding |= RESP_ENC_CIM;
 489                                     }
 490                                     break;
 491                                 case RESP_OBJECTS:
 492                                     {
 493                                         Uint32 moveCount = LOCAL_MIN(toMove,
 494                                                                      from._objects.size());
 495                                         _objects.append(from._objects.getData(), moveCount);
 496                                         from._objects.remove(0, moveCount);
 497                                         rtnSize += moveCount;
 498                                         toMove -= moveCount;
 499                                         _encoding |= RESP_ENC_CIM;
 500                                     }
 501                                     break;
 502                             }
 503                         }
 504                         PEGASUS_ASSERT(rtnSize == (count - toMove));
 505 karl        1.5.2.1 
 506                         _size += rtnSize;
 507                         from._size -= rtnSize;
 508 karl        1.5.2.2 
 509                         if (rtnSize != _size)
 510                         {
 511                             PEG_TRACE((TRC_XML, Tracer::LEVEL1,
 512                                 "Size calc error _size %u rtnSWize = %u", _size, rtnSize));
 513                         }
 514                         //PEGASUS_ASSERT(rtnSize == _size);
 515 karl        1.5.2.1 
 516                         return rtnSize;
 517                     }
 518                     
 519                     // Return the number of CIM objects in the CIM Response data object
 520                     //
 521 karl        1.5.2.3 #define TEMPLOG PEG_TRACE((TRC_XML, Tracer::LEVEL4, \
 522                      "rtnSize %u size %u", rtnSize, _size))
 523                     
 524 karl        1.5.2.1 Uint32 CIMResponseData::size()
 525                     {
 526 karl        1.5.2.5     TRACELINE;
 527 karl        1.5.2.1     PEG_METHOD_ENTER(TRC_XML,"CIMResponseData::size()");
 528 karl        1.5.2.5     PSVALID;
 529 karl        1.5.2.1 // If debug mode, add up all the individual size components to
 530                     // determine overall size of this object.  Then compare this with
 531                     // the _size variable.  this is a good check on the completeness of the
 532                     // size computations.  We should be able to remove this at some point
 533                     // but there are many sources of size info and we need to be sure we
 534                     // have covered them all.
 535                     #ifdef PEGASUS_DEBUG
 536                         PEGASUS_ASSERT(valid());            //KS_TEMP
 537                     
 538                         Uint32 rtnSize = 0;
 539 karl        1.5.2.3     TEMPLOG;
 540 karl        1.5.2.1     if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
 541                         {
 542 karl        1.5.2.3         TEMPLOG;
 543 karl        1.5.2.1         switch (_dataType)
 544                             {
 545                                 case RESP_OBJECTPATHS:
 546                                 case RESP_INSTNAMES:
 547                                     break;
 548                                 case RESP_INSTANCE:
 549                                     rtnSize +=1;
 550                                     break;
 551                                 case RESP_INSTANCES:
 552                                 case RESP_OBJECTS:
 553                                     rtnSize += _instanceData.size();
 554                                     break;
 555                             }
 556 karl        1.5.2.5         PSVALID;
 557 karl        1.5.2.3         TEMPLOG;
 558 karl        1.5.2.1     }
 559                         if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
 560                         {
 561 karl        1.5.2.3         TEMPLOG;
 562 karl        1.5.2.1         // KS_PULL_TODO
 563                             // Cannot resolve this one without actually processing
 564                             // the data since it is a stream.
 565                             rtnSize += 0;
 566                             //PEGASUS_ASSERT(false);
 567 karl        1.5.2.3         TEMPLOG;
 568 karl        1.5.2.1     }
 569                     
 570                         if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
 571                         {
 572 karl        1.5.2.5         PSVALID;
 573 karl        1.5.2.3         TEMPLOG;
 574 karl        1.5.2.1         rtnSize += _scmoInstances.size();
 575 karl        1.5.2.3         TEMPLOG;
 576 karl        1.5.2.1     }
 577                     
 578                         if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
 579                         {
 580 karl        1.5.2.5         PSVALID;
 581 karl        1.5.2.3         TEMPLOG;
 582 karl        1.5.2.1         switch (_dataType)
 583                             {
 584                                 case RESP_OBJECTPATHS:
 585                                 case RESP_INSTNAMES:
 586                                     rtnSize += _instanceNames.size();
 587                                     break;
 588                                 case RESP_INSTANCE:
 589                                 case RESP_INSTANCES:
 590                                     rtnSize += _instances.size();
 591                                     break;
 592                                 case RESP_OBJECTS:
 593                                     rtnSize += _objects.size();
 594                                     break;
 595                             }
 596 karl        1.5.2.5         PSVALID;
 597 karl        1.5.2.3         TEMPLOG;
 598 karl        1.5.2.1     }
 599                         // Test of actual count against _size variable.
 600                         if (rtnSize != _size)
 601                         {
 602 karl        1.5.2.5         PSVALID;
 603 karl        1.5.2.3         TEMPLOG;
 604 karl        1.5.2.1         PEG_TRACE((TRC_XML, Tracer::LEVEL1,
 605                             "CIMResponseData::size ERROR. debug size mismatch."
 606                                 "Computed = %u. variable = %u",rtnSize, _size ));
 607 karl        1.5.2.2         // KS_TEMP
 608                             cout << "Size err " << rtnSize << " " << _size << endl;
 609 karl        1.5.2.3         TEMPLOG;
 610 karl        1.5.2.1     }
 611 karl        1.5.2.2     //PEGASUS_TEST_ASSERT(rtnSize == _size);
 612 karl        1.5.2.1 #endif
 613                         PEG_METHOD_EXIT();
 614                         return _size;
 615                     }
 616                     
 617 thilo.boehm 1.3     // function used by OperationAggregator to aggregate response data in a
 618 karl        1.5.2.1 // single ResponseData object. Adds all data in the from ResponseData object
 619                     // input variable to the target ResponseData object
 620                     // target array
 621 thilo.boehm 1.3     void CIMResponseData::appendResponseData(const CIMResponseData & x)
 622                     {
 623 karl        1.5.2.5     TRACELINE;
 624 karl        1.5.2.1     // Confirm that the CIMResponseData type matches the type
 625                         // of the data being appended
 626                     
 627                         PEGASUS_ASSERT(valid());            // KS_TEMP
 628 thilo.boehm 1.3         PEGASUS_DEBUG_ASSERT(_dataType == x._dataType);
 629                         _encoding |= x._encoding;
 630                     
 631                         // add all binary data
 632                         _binaryData.appendArray(x._binaryData);
 633 karl        1.5.2.1     // KS_TBD TODO PULL Add the counter incrementer for binary
 634 thilo.boehm 1.3     
 635                         // add all the C++ stuff
 636                         _instanceNames.appendArray(x._instanceNames);
 637 karl        1.5.2.1     _size += x._instanceNames.size();
 638 thilo.boehm 1.3         _instances.appendArray(x._instances);
 639 karl        1.5.2.1     _size += x._instances.size();
 640 thilo.boehm 1.3         _objects.appendArray(x._objects);
 641 karl        1.5.2.1     _size += x._objects.size();
 642 thilo.boehm 1.3     
 643                         // add the SCMO instances
 644                         _scmoInstances.appendArray(x._scmoInstances);
 645 karl        1.5.2.1     _size += x._scmoInstances.size();
 646 thilo.boehm 1.3     
 647 karl        1.5.2.1     // add Xml encodings
 648                         // KS_TBD - FIX _Size stuff here also.
 649 thilo.boehm 1.3         _referencesData.appendArray(x._referencesData);
 650                         _instanceData.appendArray(x._instanceData);
 651                         _hostsData.appendArray(x._hostsData);
 652                         _nameSpacesData.appendArray(x._nameSpacesData);
 653 karl        1.5.2.6 
 654                         // transfer property list
 655                         _propertyList = x._propertyList;
 656 thilo.boehm 1.3     }
 657 r.kieninger 1.1     
 658 thilo.boehm 1.3     // Encoding responses into output format
 659                     void CIMResponseData::encodeBinaryResponse(CIMBuffer& out)
 660 r.kieninger 1.1     {
 661 karl        1.5.2.5     TRACELINE;
 662 r.kieninger 1.1         PEG_METHOD_ENTER(TRC_DISPATCHER,
 663 thilo.boehm 1.3             "CIMResponseData::encodeBinaryResponse");
 664 r.kieninger 1.1     
 665 karl        1.5.2.5     PSVALID;
 666 karl        1.5.2.3 
 667 thilo.boehm 1.3         // Need to do a complete job here by transferring all contained data
 668                         // into binary format and handing it out in the CIMBuffer
 669 karl        1.5.2.1     // KS_TODO
 670 thilo.boehm 1.3         if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
 671 r.kieninger 1.1         {
 672 karl        1.5.2.3         PEGASUS_ASSERT(false);   // KS_TEMP
 673 karl        1.5.2.4 
 674 thilo.boehm 1.3             // Binary does NOT need a marker as it consists of C++ and SCMO
 675 r.kieninger 1.1             const Array<Uint8>& data = _binaryData;
 676                             out.putBytes(data.getData(), data.size());
 677                         }
 678 karl        1.5.2.1 
 679 thilo.boehm 1.3         if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
 680 r.kieninger 1.1         {
 681 thilo.boehm 1.3             out.putTypeMarker(BIN_TYPE_MARKER_CPPD);
 682                             switch (_dataType)
 683                             {
 684                                 case RESP_INSTNAMES:
 685                                 {
 686                                     out.putObjectPathA(_instanceNames);
 687                                     break;
 688                                 }
 689                                 case RESP_INSTANCE:
 690                                 {
 691                                     if (0 == _instances.size())
 692                                     {
 693                                         _instances.append(CIMInstance());
 694                                     }
 695                                     out.putInstance(_instances[0], true, true);
 696                                     break;
 697                                 }
 698                                 case RESP_INSTANCES:
 699                                 {
 700                                     out.putInstanceA(_instances);
 701                                     break;
 702 thilo.boehm 1.3                 }
 703                                 case RESP_OBJECTS:
 704                                 {
 705                                     out.putObjectA(_objects);
 706                                     break;
 707                                 }
 708                                 case RESP_OBJECTPATHS:
 709                                 {
 710                                     out.putObjectPathA(_instanceNames);
 711                                     break;
 712                                 }
 713                                 default:
 714                                 {
 715                                     PEGASUS_DEBUG_ASSERT(false);
 716                                 }
 717                             }
 718 r.kieninger 1.1         }
 719 thilo.boehm 1.3         if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
 720 r.kieninger 1.1         {
 721 thilo.boehm 1.3             out.putTypeMarker(BIN_TYPE_MARKER_SCMO);
 722                             out.putSCMOInstanceA(_scmoInstances);
 723 r.kieninger 1.1         }
 724 thilo.boehm 1.3         if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
 725 r.kieninger 1.1         {
 726 thilo.boehm 1.3             // This actually should not happen following general code logic
 727                             PEGASUS_DEBUG_ASSERT(false);
 728 r.kieninger 1.1         }
 729 thilo.boehm 1.3     
 730 r.kieninger 1.1         PEG_METHOD_EXIT();
 731                     }
 732                     
 733 thilo.boehm 1.3     void CIMResponseData::completeNamespace(const SCMOInstance * x)
 734 r.kieninger 1.1     {
 735 karl        1.5.2.5     TRACELINE;
 736 thilo.boehm 1.3         const char * ns;
 737                         Uint32 len;
 738                         ns = x->getNameSpace_l(len);
 739                         // Both internal XML as well as binary always contain a namespace
 740                         // don't have to do anything for those two encodings
 741                         if ((RESP_ENC_BINARY == (_encoding&RESP_ENC_BINARY)) && (len != 0))
 742 r.kieninger 1.1         {
 743 thilo.boehm 1.3             _defaultNamespace = CIMNamespaceName(ns);
 744 r.kieninger 1.1         }
 745 thilo.boehm 1.3         if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
 746 r.kieninger 1.1         {
 747 thilo.boehm 1.3             CIMNamespaceName nsName(ns);
 748                             switch (_dataType)
 749 r.kieninger 1.1             {
 750 thilo.boehm 1.3                 case RESP_INSTANCE:
 751                                 {
 752                                     if (_instances.size() > 0)
 753                                     {
 754                                         const CIMInstance& inst = _instances[0];
 755                                         CIMObjectPath& p =
 756                                             const_cast<CIMObjectPath&>(inst.getPath());
 757                                         if (p.getNameSpace().isNull())
 758                                         {
 759                                             p.setNameSpace(nsName);
 760                                         }
 761                                     }
 762 karl        1.5.2.3                 break;
 763 thilo.boehm 1.3                 }
 764                                 case RESP_INSTANCES:
 765                                 {
 766                                     for (Uint32 j = 0, n = _instances.size(); j < n; j++)
 767                                     {
 768                                         const CIMInstance& inst = _instances[j];
 769                                         CIMObjectPath& p =
 770                                             const_cast<CIMObjectPath&>(inst.getPath());
 771                                         if (p.getNameSpace().isNull())
 772                                         {
 773                                             p.setNameSpace(nsName);
 774                                         }
 775                                     }
 776                                     break;
 777                                 }
 778                                 case RESP_OBJECTS:
 779                                 {
 780                                     for (Uint32 j = 0, n = _objects.size(); j < n; j++)
 781                                     {
 782                                         const CIMObject& object = _objects[j];
 783                                         CIMObjectPath& p =
 784 thilo.boehm 1.3                             const_cast<CIMObjectPath&>(object.getPath());
 785                                         if (p.getNameSpace().isNull())
 786                                         {
 787                                             p.setNameSpace(nsName);
 788                                         }
 789                                     }
 790                                     break;
 791                                 }
 792                                 case RESP_INSTNAMES:
 793                                 case RESP_OBJECTPATHS:
 794                                 {
 795                                     for (Uint32 j = 0, n = _instanceNames.size(); j < n; j++)
 796                                     {
 797                                         CIMObjectPath& p = _instanceNames[j];
 798                                         if (p.getNameSpace().isNull())
 799                                         {
 800                                             p.setNameSpace(nsName);
 801                                         }
 802                                     }
 803                                     break;
 804                                 }
 805 thilo.boehm 1.3                 default:
 806                                 {
 807                                     PEGASUS_DEBUG_ASSERT(false);
 808                                 }
 809 r.kieninger 1.1             }
 810                         }
 811 thilo.boehm 1.3         if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
 812 r.kieninger 1.1         {
 813 thilo.boehm 1.3             for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++)
 814 r.kieninger 1.1             {
 815 thilo.boehm 1.3                 SCMOInstance & scmoInst=_scmoInstances[j];
 816                                 if (0 == scmoInst.getNameSpace())
 817                                 {
 818                                     scmoInst.setNameSpace_l(ns,len);
 819                                 }
 820 r.kieninger 1.1             }
 821                         }
 822                     }
 823                     
 824 thilo.boehm 1.3     void CIMResponseData::completeHostNameAndNamespace(
 825                         const String & hn,
 826                         const CIMNamespaceName & ns)
 827 r.kieninger 1.1     {
 828 karl        1.5.2.5     TRACELINE;
 829 karl        1.5.2.1     PEG_METHOD_ENTER(TRC_DISPATCHER,
 830                             "CIMResponseData::completeHostNameAndNamespace");
 831                     
 832                         PEGASUS_ASSERT(valid());            // KS_TEMP
 833                     
 834 thilo.boehm 1.3         if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
 835                         {
 836                             // On binary need remember hostname and namespace in case someone
 837                             // builds C++ default objects or Xml types from it later on
 838                             // -> usage: See resolveBinary()
 839                             _defaultNamespace=ns;
 840                             _defaultHostname=hn;
 841                         }
 842                         // InternalXml does not support objectPath calls
 843                         if ((RESP_ENC_XML == (_encoding & RESP_ENC_XML)) &&
 844                                 (RESP_OBJECTS == _dataType))
 845                         {
 846                             for (Uint32 j = 0, n = _referencesData.size(); j < n; j++)
 847                             {
 848                                 if (0 == _hostsData[j].size())
 849                                 {
 850                                     _hostsData[j]=hn;
 851                                 }
 852                                 if (_nameSpacesData[j].isNull())
 853                                 {
 854                                     _nameSpacesData[j]=ns;
 855 thilo.boehm 1.3                 }
 856                             }
 857                         }
 858                         if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
 859 r.kieninger 1.1         {
 860 thilo.boehm 1.3             switch (_dataType)
 861 r.kieninger 1.2             {
 862 karl        1.5.2.1             // Instances added to account for namedInstance in Pull operations.
 863                                 case RESP_INSTANCES:
 864                     
 865                                     for (Uint32 j = 0, n = _instances.size(); j < n; j++)
 866                                     {
 867                                         const CIMInstance& instance = _instances[j];
 868                                         CIMObjectPath& p =
 869                                             const_cast<CIMObjectPath&>(instance.getPath());
 870                                         if (p.getHost().size()==0)
 871                                         {
 872                                             p.setHost(hn);
 873                                         }
 874                                         if (p.getNameSpace().isNull())
 875                                         {
 876                                             p.setNameSpace(ns);
 877                                         }
 878                                     }
 879 thilo.boehm 1.3                 case RESP_OBJECTS:
 880                                 {
 881                                     for (Uint32 j = 0, n = _objects.size(); j < n; j++)
 882                                     {
 883                                         const CIMObject& object = _objects[j];
 884                                         CIMObjectPath& p =
 885                                             const_cast<CIMObjectPath&>(object.getPath());
 886                                         if (p.getHost().size()==0)
 887                                         {
 888                                             p.setHost(hn);
 889                                         }
 890                                         if (p.getNameSpace().isNull())
 891                                         {
 892                                             p.setNameSpace(ns);
 893                                         }
 894                                     }
 895                                     break;
 896                                 }
 897 karl        1.5.2.1             // INSTNAMES added to account for instance paths in pull name
 898                                 // operations
 899                                 case RESP_INSTNAMES:
 900 thilo.boehm 1.3                 case RESP_OBJECTPATHS:
 901                                 {
 902                                     for (Uint32 j = 0, n = _instanceNames.size(); j < n; j++)
 903                                     {
 904                                         CIMObjectPath& p = _instanceNames[j];
 905                                         if (p.getHost().size() == 0)
 906                                             p.setHost(hn);
 907                                         if (p.getNameSpace().isNull())
 908                                             p.setNameSpace(ns);
 909                                     }
 910                                     break;
 911                                 }
 912                                 default:
 913                                 {
 914                                     PEGASUS_DEBUG_ASSERT(false);
 915                                 }
 916 r.kieninger 1.2             }
 917                         }
 918 thilo.boehm 1.3         if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
 919 r.kieninger 1.2         {
 920 thilo.boehm 1.3             CString hnCString=hn.getCString();
 921                             const char* hnChars = hnCString;
 922                             Uint32 hnLen = strlen(hnChars);
 923                             CString nsCString=ns.getString().getCString();
 924                             const char* nsChars=nsCString;
 925                             Uint32 nsLen = strlen(nsChars);
 926                             switch (_dataType)
 927                             {
 928 karl        1.5.2.1             // KS_PULL add Instances and InstNames to cover pull operations
 929                                 // KS_PULL - Confirm that this OK.
 930                                 case RESP_INSTNAMES:
 931                                 case RESP_INSTANCES:
 932 thilo.boehm 1.3                 case RESP_OBJECTS:
 933                                 case RESP_OBJECTPATHS:
 934                                 {
 935                                     for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++)
 936                                     {
 937                                         SCMOInstance & scmoInst=_scmoInstances[j];
 938                                         if (0 == scmoInst.getHostName())
 939                                         {
 940                                             scmoInst.setHostName_l(hnChars,hnLen);
 941                                         }
 942                                         if (0 == scmoInst.getNameSpace())
 943                                         {
 944                                             scmoInst.setNameSpace_l(nsChars,nsLen);
 945                                         }
 946                                     }
 947                                     break;
 948                                 }
 949                                 default:
 950                                 {
 951                                     PEGASUS_DEBUG_ASSERT(false);
 952                                 }
 953 thilo.boehm 1.3             }
 954 r.kieninger 1.1         }
 955 karl        1.5.2.1     PEG_METHOD_EXIT();
 956 thilo.boehm 1.3     }
 957 r.kieninger 1.1     
 958 karl        1.5.2.1 // NOTE: The reason for the isPullResponse variable is that there are
 959                     // some variations in ouput to Xml depending on whether the responses
 960                     // are one of the pull responses or the original responsed
 961                     void CIMResponseData::encodeXmlResponse(Buffer& out, Boolean isPullResponse)
 962 r.kieninger 1.1     {
 963 karl        1.5.2.5     TRACELINE;
 964 karl        1.5.2.6 
 965 thilo.boehm 1.3         PEG_TRACE((TRC_XML, Tracer::LEVEL3,
 966 karl        1.5.2.6         "CIMResponseData::encodeXmlResponse(encoding=%X,dataType=%X)",
 967 thilo.boehm 1.3             _encoding,
 968                             _dataType));
 969 karl        1.5.2.5     
 970 thilo.boehm 1.3         // already existing Internal XML does not need to be encoded further
 971                         // binary input is not actually impossible here, but we have an established
 972                         // fallback
 973                         if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
 974 r.kieninger 1.1         {
 975 thilo.boehm 1.3             _resolveBinary();
 976 r.kieninger 1.1         }
 977 thilo.boehm 1.3         if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
 978 r.kieninger 1.1         {
 979 thilo.boehm 1.3             switch (_dataType)
 980 r.kieninger 1.1             {
 981 thilo.boehm 1.3                 case RESP_INSTANCE:
 982                                 {
 983                                     const Array<ArraySint8>& a = _instanceData;
 984                                     out.append((char*)a[0].getData(), a[0].size() - 1);
 985                                     break;
 986                                 }
 987                                 case RESP_INSTANCES:
 988                                 {
 989                                     const Array<ArraySint8>& a = _instanceData;
 990                                     const Array<ArraySint8>& b = _referencesData;
 991 r.kieninger 1.1     
 992 thilo.boehm 1.3                     for (Uint32 i = 0, n = a.size(); i < n; i++)
 993                                     {
 994 karl        1.5.2.1                     if (isPullResponse)
 995                                         {
 996                                             out << STRLIT("<VALUE.INSTANCEWITHPATH>\n");
 997                                         }
 998                                         else
 999                                         {
1000                                             out << STRLIT("<VALUE.NAMEDINSTANCE>\n");
1001                                         }
1002 thilo.boehm 1.3                         out.append((char*)b[i].getData(), b[i].size() - 1);
1003                                         out.append((char*)a[i].getData(), a[i].size() - 1);
1004 karl        1.5.2.1                     if (isPullResponse)
1005                                         {
1006                                             out << STRLIT("</VALUE.INSTANCEWITHPATH>\n");
1007                                         }
1008                                         else
1009                                         {
1010                                             out << STRLIT("</VALUE.NAMEDINSTANCE>\n");
1011                                         }
1012 thilo.boehm 1.3                     }
1013                                     break;
1014                                 }
1015                                 case RESP_OBJECTS:
1016                                 {
1017                                     const Array<ArraySint8>& a = _instanceData;
1018                                     const Array<ArraySint8>& b = _referencesData;
1019                                     for (Uint32 i = 0, n = a.size(); i < n; i++)
1020                                     {
1021                                         out << STRLIT("<VALUE.OBJECTWITHPATH>\n");
1022                                         out << STRLIT("<INSTANCEPATH>\n");
1023                                         XmlWriter::appendNameSpacePathElement(
1024                                                 out,
1025                                                 _hostsData[i],
1026                                                 _nameSpacesData[i]);
1027                                         // Leave out the surrounding tags "<VALUE.REFERENCE>\n"
1028                                         // and "</VALUE.REFERENCE>\n" which are 18 and 19 characters
1029                                         // long
1030                                         out.append(
1031                                             ((char*)b[i].getData())+18,
1032                                             b[i].size() - 1 - 18 -19);
1033 thilo.boehm 1.3                         out << STRLIT("</INSTANCEPATH>\n");
1034                                         // append instance body
1035                                         out.append((char*)a[i].getData(), a[i].size() - 1);
1036                                         out << STRLIT("</VALUE.OBJECTWITHPATH>\n");
1037                                     }
1038                                     break;
1039                                 }
1040                                 // internal xml encoding of instance names and object paths not
1041                                 // done today
1042                                 case RESP_INSTNAMES:
1043                                 case RESP_OBJECTPATHS:
1044                                 default:
1045                                 {
1046                                     PEGASUS_DEBUG_ASSERT(false);
1047                                 }
1048 r.kieninger 1.1             }
1049 thilo.boehm 1.3         }
1050 r.kieninger 1.1     
1051 thilo.boehm 1.3         if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
1052                         {
1053                             switch (_dataType)
1054 r.kieninger 1.1             {
1055 thilo.boehm 1.3                 case RESP_INSTNAMES:
1056                                 {
1057                                     for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++)
1058                                     {
1059 karl        1.5.2.1                     // Element type is different for Pull responses
1060                                         if (isPullResponse)
1061                                         {
1062                                             XmlWriter::appendInstancePathElement(out,
1063                                                 _instanceNames[i]);
1064                                         }
1065                                         else
1066                                         {
1067                                             XmlWriter::appendInstanceNameElement(out,
1068                                                 _instanceNames[i]);
1069                                         }
1070 thilo.boehm 1.3                     }
1071                                     break;
1072                                 }
1073                                 case RESP_INSTANCE:
1074                                 {
1075                                     if (_instances.size() > 0)
1076                                     {
1077 karl        1.5.2.3                     XmlWriter::appendInstanceElement(
1078                                             out, 
1079                                             _instances[0],
1080                                             _includeQualifiers,
1081                                             _includeClassOrigin,
1082                                             _propertyList);
1083 thilo.boehm 1.3                     }
1084                                     break;
1085                                 }
1086                                 case RESP_INSTANCES:
1087                                 {
1088                                     for (Uint32 i = 0, n = _instances.size(); i < n; i++)
1089                                     {
1090 karl        1.5.2.5                     /// KS_TODO_DELETE
1091                                         ////PrintInstance(cout, _instances[i]);
1092 karl        1.5.2.1                     if (isPullResponse)
1093                                         {
1094                                             XmlWriter::appendValueInstanceWithPathElement(
1095 karl        1.5.2.3                             out,
1096                                                 _instances[i],
1097                                                 _includeQualifiers,
1098                                                 _includeClassOrigin,
1099                                                 _propertyList);
1100 karl        1.5.2.1                     }
1101                                         else
1102                                         {
1103                                             XmlWriter::appendValueNamedInstanceElement(
1104 karl        1.5.2.3                             out,
1105                                                 _instances[i],
1106                                                 _includeQualifiers,
1107                                                 _includeClassOrigin,
1108                                                 _propertyList);
1109 karl        1.5.2.1                     }
1110 thilo.boehm 1.3                     }
1111                                     break;
1112                                 }
1113                                 case RESP_OBJECTS:
1114                                 {
1115                                     for (Uint32 i = 0; i < _objects.size(); i++)
1116                                     {
1117 karl        1.5.2.1                     // If pull, map to instances
1118                                         if (isPullResponse)
1119                                         {
1120                                             CIMInstance x = (CIMInstance)_objects[i];
1121                                             XmlWriter::appendValueInstanceWithPathElement(
1122 karl        1.5.2.3                             out, x,
1123                                                 _includeQualifiers,
1124                                                 _includeClassOrigin,
1125                                                 _propertyList);
1126 karl        1.5.2.1                     }
1127                                         else
1128                                         {
1129                                             XmlWriter::appendValueObjectWithPathElement(
1130 karl        1.5.2.3                             out,
1131                                                 _objects[i],
1132                                                 _includeQualifiers,
1133                                                 _includeClassOrigin,
1134                                                 _propertyList);
1135 karl        1.5.2.1                     }
1136 thilo.boehm 1.3                     }
1137                                     break;
1138                                 }
1139                                 case RESP_OBJECTPATHS:
1140                                 {
1141                                     for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++)
1142                                     {
1143 karl        1.5.2.1                     // ObjectPaths come from providers for pull operations
1144                                         // but are encoded as instancePathElements
1145                                         if (isPullResponse)
1146                     
1147                                         {
1148                                             XmlWriter::appendInstancePathElement(out,
1149                                                _instanceNames[i]);
1150                                         }
1151                                         else
1152                                         {
1153                                             out << "<OBJECTPATH>\n";
1154                                             XmlWriter::appendValueReferenceElement(
1155                                                 out,
1156                                                 _instanceNames[i],
1157                                                 false);
1158                                             out << "</OBJECTPATH>\n";
1159                                         }
1160 thilo.boehm 1.3                     }
1161                                     break;
1162                                 }
1163                                 default:
1164                                 {
1165                                     PEGASUS_DEBUG_ASSERT(false);
1166                                 }
1167 r.kieninger 1.1             }
1168 thilo.boehm 1.3         }
1169                         if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
1170                         {
1171                             switch (_dataType)
1172 r.kieninger 1.1             {
1173 thilo.boehm 1.3                 case RESP_INSTNAMES:
1174                                 {
1175 karl        1.5.2.6                 if (isPullResponse)
1176 thilo.boehm 1.3                     {
1177 karl        1.5.2.6                     for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++)
1178                                         {
1179                                             SCMOXmlWriter::appendInstancePathElement(
1180                                                 out,
1181                                                 _scmoInstances[i]);
1182 karl        1.5.2.3 
1183 karl        1.5.2.6                     }
1184                                     }
1185                                     else
1186                                     {
1187                                         for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++)
1188                                         {
1189                                             SCMOXmlWriter::appendInstanceNameElement(
1190                                                 out,
1191                                                 _scmoInstances[i]);
1192                     
1193                                         }
1194 thilo.boehm 1.3                     }
1195                                     break;
1196                                 }
1197                                 case RESP_INSTANCE:
1198                                 {
1199                                     if (_scmoInstances.size() > 0)
1200                                     {
1201 karl        1.5.2.3                     if(_propertyList.isNull())
1202                                         {
1203                                             Array<Uint32> emptyNodes; 
1204                                             SCMOXmlWriter::appendInstanceElement(
1205                                                 out,
1206                                                 _scmoInstances[0],
1207                                                 false,
1208                                                 emptyNodes);
1209                                         }
1210                                         else
1211                                         {
1212                                             Array<propertyFilterNodesArray_t> propFilterNodesArrays;
1213                                             // This searches for an already created array of nodes, 
1214                                             //if not found, creates it inside propFilterNodesArrays 
1215                                             const Array<Uint32> & nodes= 
1216                                                 SCMOXmlWriter::getFilteredNodesArray( 
1217                                                     propFilterNodesArrays, 
1218                                                     _scmoInstances[0], 
1219                                                     _propertyList);
1220                                             SCMOXmlWriter::appendInstanceElement(
1221                                                 out,
1222 karl        1.5.2.3                             _scmoInstances[0],
1223                                                 true,
1224                                                 nodes); 
1225                                         }  
1226 thilo.boehm 1.3                     }
1227                                     break;
1228                                 }
1229                                 case RESP_INSTANCES:
1230                                 {
1231 karl        1.5.2.3                 if (isPullResponse)
1232 thilo.boehm 1.3                     {
1233 karl        1.5.2.3                     SCMOXmlWriter::appendValueSCMOInstanceWithPathElements(
1234                                             out, _scmoInstances, _propertyList);
1235 thilo.boehm 1.3                     }
1236 karl        1.5.2.3                 else
1237                                     {
1238                                         SCMOXmlWriter::appendValueSCMOInstanceElements(
1239                                             out, _scmoInstances, _propertyList);
1240                                     }
1241 thilo.boehm 1.3                     break;
1242                                 }
1243                                 case RESP_OBJECTS:
1244                                 {
1245 karl        1.5.2.3                 if (isPullResponse)
1246 thilo.boehm 1.3                     {
1247 karl        1.5.2.3                     SCMOXmlWriter::appendValueSCMOInstanceWithPathElements(
1248                                             out,_scmoInstances, _propertyList);
1249                                     }
1250                                     else
1251                                     {
1252                                         // KS_TODO why is this one named element rather than
1253                                         // elements
1254                                         SCMOXmlWriter::appendValueObjectWithPathElement(
1255                                             out, _scmoInstances, _propertyList);
1256 thilo.boehm 1.3                     }
1257                                     break;
1258                                 }
1259                                 case RESP_OBJECTPATHS:
1260                                 {
1261                                     for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++)
1262                                     {
1263 karl        1.5.2.1                     if (isPullResponse)
1264                                         {
1265                                             SCMOXmlWriter::appendInstancePathElement(out,
1266                                                 _scmoInstances[i]);
1267                                         }
1268                                         else
1269                                         {
1270                                             out << "<OBJECTPATH>\n";
1271                                             SCMOXmlWriter::appendValueReferenceElement(
1272                                                 out, _scmoInstances[i],
1273                                                 false);
1274                                             out << "</OBJECTPATH>\n";
1275                                         }
1276 thilo.boehm 1.3                     }
1277                                     break;
1278                                 }
1279                                 default:
1280                                 {
1281                                     PEGASUS_DEBUG_ASSERT(false);
1282                                 }
1283 r.kieninger 1.1             }
1284                         }
1285 thilo.boehm 1.3     }
1286 r.kieninger 1.1     
1287 thilo.boehm 1.3     // contrary to encodeXmlResponse this function encodes the Xml in a format
1288                     // not usable by clients
1289                     void CIMResponseData::encodeInternalXmlResponse(CIMBuffer& out)
1290                     {
1291 karl        1.5.2.5     TRACELINE;
1292 thilo.boehm 1.3         PEG_TRACE((TRC_XML, Tracer::LEVEL3,
1293 r.kieninger 1.4             "CIMResponseData::encodeInternalXmlResponse(encoding=%X,content=%X)",
1294 thilo.boehm 1.3             _encoding,
1295                             _dataType));
1296                         // For mixed (CIM+SCMO) responses, we need to tell the receiver the
1297                         // total number of instances. The totalSize variable is used to keep track
1298                         // of this.
1299                         Uint32 totalSize = 0;
1300 r.kieninger 1.1     
1301 thilo.boehm 1.3         // already existing Internal XML does not need to be encoded further
1302                         // binary input is not actually impossible here, but we have an established
1303                         // fallback
1304                         if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
1305                         {
1306                             _resolveBinary();
1307                         }
1308                         if ((0 == _encoding) ||
1309                             (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)))
1310                         {
1311                             switch (_dataType)
1312                             {
1313                                 case RESP_INSTANCE:
1314                                 {
1315                                     if (0 == _instances.size())
1316                                     {
1317                                         _instances.append(CIMInstance());
1318 karl        1.5.2.3                     CIMInternalXmlEncoder::_putXMLInstance(
1319                                             out,
1320                                             _instances[0]);
1321                                         break;
1322 thilo.boehm 1.3                     }
1323 karl        1.5.2.3                 CIMInternalXmlEncoder::_putXMLInstance(
1324                                         out,
1325                                         _instances[0],
1326                                         _includeQualifiers,
1327                                         _includeClassOrigin,
1328                                         _propertyList);
1329 thilo.boehm 1.3                     break;
1330                                 }
1331                                 case RESP_INSTANCES:
1332                                 {
1333                                     Uint32 n = _instances.size();
1334                                     totalSize = n + _scmoInstances.size();
1335                                     out.putUint32(totalSize);
1336                                     for (Uint32 i = 0; i < n; i++)
1337                                     {
1338                                         CIMInternalXmlEncoder::_putXMLNamedInstance(
1339                                             out,
1340 karl        1.5.2.3                         _instances[i],
1341                                             _includeQualifiers,
1342                                             _includeClassOrigin,
1343                                             _propertyList);
1344 thilo.boehm 1.3                     }
1345                                     break;
1346                                 }
1347                                 case RESP_OBJECTS:
1348                                 {
1349                                     Uint32 n = _objects.size();
1350                                     totalSize = n + _scmoInstances.size();
1351                                     out.putUint32(totalSize);
1352                                     for (Uint32 i = 0; i < n; i++)
1353                                     {
1354 karl        1.5.2.3                     CIMInternalXmlEncoder::_putXMLObject(
1355                                             out,
1356                                             _objects[i],
1357                                             _includeQualifiers,
1358                                             _includeClassOrigin,
1359                                             _propertyList);
1360 thilo.boehm 1.3                     }
1361                                     break;
1362                                 }
1363                                 // internal xml encoding of instance names and object paths not
1364                                 // done today
1365                                 case RESP_INSTNAMES:
1366                                 case RESP_OBJECTPATHS:
1367                                 default:
1368                                 {
1369                                     PEGASUS_DEBUG_ASSERT(false);
1370                                 }
1371                             }
1372                         }
1373                         if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
1374                         {
1375                             switch (_dataType)
1376                             {
1377                                 case RESP_INSTANCE:
1378                                 {
1379                                     if (0 == _scmoInstances.size())
1380                                     {
1381 thilo.boehm 1.3                         _scmoInstances.append(SCMOInstance());
1382                                     }
1383 karl        1.5.2.3                 SCMOInternalXmlEncoder::_putXMLInstance(
1384 karl        1.5.2.5                     out, 
1385 karl        1.5.2.3                     _scmoInstances[0],
1386                                         _propertyList);
1387 thilo.boehm 1.3                     break;
1388                                 }
1389                                 case RESP_INSTANCES:
1390                                 {
1391                                     Uint32 n = _scmoInstances.size();
1392                                     // Only put the size when not already done above
1393                                     if (0==totalSize)
1394                                     {
1395                                         out.putUint32(n);
1396                                     }
1397 karl        1.5.2.3                 SCMOInternalXmlEncoder::_putXMLNamedInstance(
1398                                         out,
1399                                         _scmoInstances,
1400                                         _propertyList);
1401 thilo.boehm 1.3                     break;
1402                                 }
1403                                 case RESP_OBJECTS:
1404                                 {
1405                                     Uint32 n = _scmoInstances.size();
1406                                     // Only put the size when not already done above
1407                                     if (0==totalSize)
1408                                     {
1409                                         out.putUint32(n);
1410                                     }
1411 karl        1.5.2.3                 SCMOInternalXmlEncoder::_putXMLObject(
1412                                         out,
1413                                         _scmoInstances,
1414                                         _propertyList);
1415 thilo.boehm 1.3                     break;
1416                                 }
1417                                 // internal xml encoding of instance names and object paths not
1418                                 // done today
1419                                 case RESP_INSTNAMES:
1420                                 case RESP_OBJECTPATHS:
1421                                 default:
1422                                 {
1423                                     PEGASUS_DEBUG_ASSERT(false);
1424                                 }
1425                             }
1426                         }
1427 karl        1.5.2.3 
1428 thilo.boehm 1.3     }
1429 r.kieninger 1.1     
1430 thilo.boehm 1.3     void CIMResponseData::_resolveToCIM()
1431 r.kieninger 1.1     {
1432 karl        1.5.2.5     TRACELINE;
1433 r.kieninger 1.4         PEG_TRACE((TRC_XML, Tracer::LEVEL3,
1434                             "CIMResponseData::_resolveToCIM(encoding=%X,content=%X)",
1435 thilo.boehm 1.3             _encoding,
1436                             _dataType));
1437 r.kieninger 1.1     
1438 thilo.boehm 1.3         if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
1439                         {
1440                             _resolveXmlToCIM();
1441                         }
1442                         if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
1443 r.kieninger 1.1         {
1444 thilo.boehm 1.3             _resolveBinary();
1445 r.kieninger 1.1         }
1446 thilo.boehm 1.3         if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
1447 r.kieninger 1.1         {
1448 thilo.boehm 1.3             _resolveSCMOToCIM();
1449 r.kieninger 1.1         }
1450 thilo.boehm 1.3     
1451                         PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_CIM || _encoding == 0);
1452 r.kieninger 1.1     }
1453                     
1454 thilo.boehm 1.3     void CIMResponseData::_resolveToSCMO()
1455 r.kieninger 1.1     {
1456 karl        1.5.2.5     TRACELINE;
1457 r.kieninger 1.4         PEG_TRACE((TRC_XML, Tracer::LEVEL3,
1458                             "CIMResponseData::_resolveToSCMO(encoding=%X,content=%X)",
1459 thilo.boehm 1.3             _encoding,
1460                             _dataType));
1461 r.kieninger 1.1     
1462 thilo.boehm 1.3         if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
1463                         {
1464                             _resolveXmlToSCMO();
1465                         }
1466                         if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
1467 r.kieninger 1.1         {
1468 thilo.boehm 1.3             _resolveBinary();
1469 r.kieninger 1.1         }
1470 thilo.boehm 1.3         if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
1471 r.kieninger 1.1         {
1472 thilo.boehm 1.3             _resolveCIMToSCMO();
1473 r.kieninger 1.1         }
1474 thilo.boehm 1.3         PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_SCMO || _encoding == 0);
1475 r.kieninger 1.1     }
1476                     
1477 thilo.boehm 1.3     // helper functions to transform different formats into one-another
1478                     // functions work on the internal data and calling of them should be
1479                     // avoided whenever possible
1480                     void CIMResponseData::_resolveBinary()
1481 r.kieninger 1.1     {
1482 karl        1.5.2.5     TRACELINE;
1483 r.kieninger 1.1         PEG_METHOD_ENTER(TRC_DISPATCHER,
1484 thilo.boehm 1.3             "CIMResponseData::_resolveBinary");
1485 r.kieninger 1.1     
1486 thilo.boehm 1.3         CIMBuffer in((char*)_binaryData.getData(), _binaryData.size());
1487 r.kieninger 1.1     
1488 r.kieninger 1.2         while (in.more())
1489 r.kieninger 1.1         {
1490 thilo.boehm 1.3             Uint32 binaryTypeMarker=0;
1491                             if(!in.getTypeMarker(binaryTypeMarker))
1492 r.kieninger 1.2             {
1493                                 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1494 thilo.boehm 1.3                     "Failed to get type marker for binary objects!");
1495 r.kieninger 1.2                 PEG_METHOD_EXIT();
1496 thilo.boehm 1.3                 in.release();
1497                                 return;
1498                             }
1499                     
1500                             if (BIN_TYPE_MARKER_SCMO==binaryTypeMarker)
1501                             {
1502                                 if (!in.getSCMOInstanceA(_scmoInstances))
1503                                 {
1504                                     _encoding &=(~RESP_ENC_BINARY);
1505                                     in.release();
1506                                     PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1507                                         "Failed to resolve binary SCMOInstances!");
1508                                     PEG_METHOD_EXIT();
1509                                     return;
1510                                 }
1511                     
1512                                 _encoding |= RESP_ENC_SCMO;
1513 r.kieninger 1.2             }
1514 thilo.boehm 1.3             else
1515                             {
1516                                 switch (_dataType)
1517                                 {
1518                                     case RESP_INSTNAMES:
1519                                     case RESP_OBJECTPATHS:
1520                                     {
1521                                         if (!in.getObjectPathA(_instanceNames))
1522                                         {
1523                                             _encoding &=(~RESP_ENC_BINARY);
1524                                             in.release();
1525                                             PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1526                                                 "Failed to resolve binary CIMObjectPaths!");
1527                                             PEG_METHOD_EXIT();
1528                                             return;
1529                                         }
1530                                         break;
1531                                     }
1532                                     case RESP_INSTANCE:
1533                                     {
1534                                         CIMInstance instance;
1535 thilo.boehm 1.3                         if (!in.getInstance(instance))
1536                                         {
1537                                             _encoding &=(~RESP_ENC_BINARY);
1538                                             _encoding |= RESP_ENC_CIM;
1539                                             _instances.append(instance);
1540                                             in.release();
1541                                             PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1542                                                 "Failed to resolve binary instance!");
1543                                             PEG_METHOD_EXIT();
1544                                             return;
1545                                         }
1546                     
1547                                         _instances.append(instance);
1548                                         break;
1549                                     }
1550                                     case RESP_INSTANCES:
1551                                     {
1552                                         if (!in.getInstanceA(_instances))
1553                                         {
1554                                             _encoding &=(~RESP_ENC_BINARY);
1555                                             in.release();
1556 thilo.boehm 1.3                             PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1557                                                 "Failed to resolve binary CIMInstances!");
1558                                             PEG_METHOD_EXIT();
1559                                             return;
1560                                         }
1561                                         break;
1562                                     }
1563                                     case RESP_OBJECTS:
1564                                     {
1565                                         if (!in.getObjectA(_objects))
1566                                         {
1567                                             in.release();
1568                                             _encoding &=(~RESP_ENC_BINARY);
1569                                             PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1570                                                 "Failed to resolve binary CIMObjects!");
1571                                             PEG_METHOD_EXIT();
1572                                             return;
1573                                         }
1574                                         break;
1575                                     }
1576                                     default:
1577 thilo.boehm 1.3                     {
1578                                         PEGASUS_DEBUG_ASSERT(false);
1579                                     }
1580                                 } // switch
1581                                 _encoding |= RESP_ENC_CIM;
1582                             } // else SCMO
1583                         }
1584                         _encoding &=(~RESP_ENC_BINARY);
1585                         // fix up the hostname and namespace for objects if defaults
1586                         // were set
1587                         if (_defaultHostname.size() > 0 && !_defaultNamespace.isNull())
1588                         {
1589                             completeHostNameAndNamespace(_defaultHostname, _defaultNamespace);
1590 r.kieninger 1.1         }
1591                         in.release();
1592                         PEG_METHOD_EXIT();
1593                     }
1594                     
1595 thilo.boehm 1.3     void CIMResponseData::_resolveXmlToCIM()
1596 r.kieninger 1.1     {
1597 karl        1.5.2.5     TRACELINE;
1598 thilo.boehm 1.3         switch (_dataType)
1599 r.kieninger 1.1         {
1600 thilo.boehm 1.3             // Xml encoding for instance names and object paths not used
1601                             case RESP_OBJECTPATHS:
1602                             case RESP_INSTNAMES:
1603                             {
1604                                 break;
1605                             }
1606                             case RESP_INSTANCE:
1607 r.kieninger 1.1             {
1608 thilo.boehm 1.3                 CIMInstance cimInstance;
1609                                 // Deserialize instance:
1610                                 {
1611                                     XmlParser parser((char*)_instanceData[0].getData());
1612 r.kieninger 1.1     
1613 thilo.boehm 1.3                     if (!XmlReader::getInstanceElement(parser, cimInstance))
1614                                     {
1615                                         cimInstance = CIMInstance();
1616                                         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1617                                             "Failed to resolve XML instance, parser error!");
1618                                     }
1619                                 }
1620                                 // Deserialize path:
1621 r.kieninger 1.1                 {
1622 thilo.boehm 1.3                     XmlParser parser((char*)_referencesData[0].getData());
1623                                     CIMObjectPath cimObjectPath;
1624                     
1625                                     if (XmlReader::getValueReferenceElement(parser, cimObjectPath))
1626                                     {
1627                                         if (_hostsData.size())
1628                                         {
1629                                             cimObjectPath.setHost(_hostsData[0]);
1630                                         }
1631                                         if (!_nameSpacesData[0].isNull())
1632                                         {
1633                                             cimObjectPath.setNameSpace(_nameSpacesData[0]);
1634                                         }
1635                                         cimInstance.setPath(cimObjectPath);
1636                                         // only if everything works we add the CIMInstance to the
1637                                         // array
1638                                         _instances.append(cimInstance);
1639                                     }
1640 r.kieninger 1.1                 }
1641 thilo.boehm 1.3                 break;
1642 r.kieninger 1.1             }
1643 thilo.boehm 1.3             case RESP_INSTANCES:
1644                             {
1645                                 for (Uint32 i = 0; i < _instanceData.size(); i++)
1646                                 {
1647                                     CIMInstance cimInstance;
1648                                     // Deserialize instance:
1649                                     {
1650                                         XmlParser parser((char*)_instanceData[i].getData());
1651                     
1652                                         if (!XmlReader::getInstanceElement(parser, cimInstance))
1653                                         {
1654                                             PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1655                                                 "Failed to resolve XML instance."
1656                                                     " Creating empty instance!");
1657                                             cimInstance = CIMInstance();
1658                                         }
1659                                     }
1660                     
1661                                     // Deserialize path:
1662                                     {
1663                                         XmlParser parser((char*)_referencesData[i].getData());
1664 thilo.boehm 1.3                         CIMObjectPath cimObjectPath;
1665                     
1666                                         if (XmlReader::getInstanceNameElement(parser,cimObjectPath))
1667                                         {
1668                                             if (!_nameSpacesData[i].isNull())
1669                                                 cimObjectPath.setNameSpace(_nameSpacesData[i]);
1670                     
1671                                             if (_hostsData[i].size())
1672                                                 cimObjectPath.setHost(_hostsData[i]);
1673                     
1674                                             cimInstance.setPath(cimObjectPath);
1675                                         }
1676                                     }
1677 r.kieninger 1.1     
1678 thilo.boehm 1.3                     _instances.append(cimInstance);
1679                                 }
1680                                 break;
1681                             }
1682                             case RESP_OBJECTS:
1683 r.kieninger 1.1             {
1684 thilo.boehm 1.3                 for (Uint32 i=0, n=_instanceData.size(); i<n; i++)
1685 r.kieninger 1.1                 {
1686 thilo.boehm 1.3                     CIMObject cimObject;
1687 r.kieninger 1.1     
1688 thilo.boehm 1.3                     // Deserialize Objects:
1689                                     {
1690                                         XmlParser parser((char*)_instanceData[i].getData());
1691                     
1692                                         CIMInstance cimInstance;
1693                                         CIMClass cimClass;
1694                     
1695                                         if (XmlReader::getInstanceElement(parser, cimInstance))
1696                                         {
1697                                             cimObject = CIMObject(cimInstance);
1698                                         }
1699                                         else if (XmlReader::getClassElement(parser, cimClass))
1700                                         {
1701                                             cimObject = CIMObject(cimClass);
1702                                         }
1703                                         else
1704                                         {
1705                                             PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1706                                                 "Failed to get XML object data!");
1707                                         }
1708                                     }
1709 thilo.boehm 1.3     
1710                                     // Deserialize paths:
1711                                     {
1712                                         XmlParser parser((char*)_referencesData[i].getData());
1713                                         CIMObjectPath cimObjectPath;
1714                     
1715                                         if (XmlReader::getValueReferenceElement(
1716                                                 parser,
1717                                                 cimObjectPath))
1718                                         {
1719                                             if (!_nameSpacesData[i].isNull())
1720                                                 cimObjectPath.setNameSpace(_nameSpacesData[i]);
1721                     
1722                                             if (_hostsData[i].size())
1723                                                 cimObjectPath.setHost(_hostsData[i]);
1724                     
1725                                             cimObject.setPath(cimObjectPath);
1726                                         }
1727                                     }
1728                                     _objects.append(cimObject);
1729 r.kieninger 1.1                 }
1730 thilo.boehm 1.3                 break;
1731                             }
1732                             default:
1733                             {
1734                                 PEGASUS_DEBUG_ASSERT(false);
1735 r.kieninger 1.1             }
1736                         }
1737 thilo.boehm 1.3         // Xml was resolved, release Xml content now
1738                         _referencesData.clear();
1739                         _hostsData.clear();
1740                         _nameSpacesData.clear();
1741                         _instanceData.clear();
1742                         // remove Xml Encoding flag
1743                         _encoding &=(~RESP_ENC_XML);
1744                         // add CIM Encoding flag
1745                         _encoding |=RESP_ENC_CIM;
1746                     }
1747 r.kieninger 1.1     
1748 thilo.boehm 1.3     void CIMResponseData::_resolveXmlToSCMO()
1749                     {
1750 karl        1.5.2.5     TRACELINE;
1751 thilo.boehm 1.3         // Not optimal, can probably be improved
1752                         // but on the other hand, since using the binary format this case should
1753                         // actually not ever happen.
1754                         _resolveXmlToCIM();
1755                         _resolveCIMToSCMO();
1756 r.kieninger 1.1     }
1757                     
1758 thilo.boehm 1.3     void CIMResponseData::_resolveSCMOToCIM()
1759 r.kieninger 1.1     {
1760 karl        1.5.2.5     TRACELINE;
1761 thilo.boehm 1.3         switch(_dataType)
1762 r.kieninger 1.2         {
1763 thilo.boehm 1.3             case RESP_INSTNAMES:
1764                             case RESP_OBJECTPATHS:
1765 r.kieninger 1.2             {
1766 thilo.boehm 1.3                 for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
1767                                 {
1768                                     CIMObjectPath newObjectPath;
1769                                     _scmoInstances[x].getCIMObjectPath(newObjectPath);
1770                                     _instanceNames.append(newObjectPath);
1771                                 }
1772                                 break;
1773 r.kieninger 1.2             }
1774 thilo.boehm 1.3             case RESP_INSTANCE:
1775 r.kieninger 1.1             {
1776 thilo.boehm 1.3                 if (_scmoInstances.size() > 0)
1777                                 {
1778                                     CIMInstance newInstance;
1779                                     _scmoInstances[0].getCIMInstance(newInstance);
1780                                     _instances.append(newInstance);
1781                                 }
1782                                 break;
1783 r.kieninger 1.1             }
1784 thilo.boehm 1.3             case RESP_INSTANCES:
1785 r.kieninger 1.1             {
1786 thilo.boehm 1.3                 for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
1787                                 {
1788                                     CIMInstance newInstance;
1789                                     _scmoInstances[x].getCIMInstance(newInstance);
1790                                     _instances.append(newInstance);
1791                                 }
1792                                 break;
1793 r.kieninger 1.1             }
1794 thilo.boehm 1.3             case RESP_OBJECTS:
1795 r.kieninger 1.1             {
1796 thilo.boehm 1.3                 for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
1797                                 {
1798                                     CIMInstance newInstance;
1799                                     _scmoInstances[x].getCIMInstance(newInstance);
1800                                     _objects.append(CIMObject(newInstance));
1801                                 }
1802                                 break;
1803 r.kieninger 1.1             }
1804 thilo.boehm 1.3             default:
1805 r.kieninger 1.1             {
1806 thilo.boehm 1.3                 PEGASUS_DEBUG_ASSERT(false);
1807 r.kieninger 1.1             }
1808                         }
1809 thilo.boehm 1.3         _scmoInstances.clear();
1810                         // remove CIM Encoding flag
1811                         _encoding &=(~RESP_ENC_SCMO);
1812                         // add SCMO Encoding flag
1813                         _encoding |=RESP_ENC_CIM;
1814 r.kieninger 1.1     }
1815                     
1816 thilo.boehm 1.3     void CIMResponseData::_resolveCIMToSCMO()
1817 r.kieninger 1.1     {
1818 karl        1.5.2.5     TRACELINE;
1819 thilo.boehm 1.3         CString nsCString=_defaultNamespace.getString().getCString();
1820                         const char* _defNamespace = nsCString;
1821                         Uint32 _defNamespaceLen;
1822                         if (_defaultNamespace.isNull())
1823 r.kieninger 1.1         {
1824 thilo.boehm 1.3             _defNamespaceLen=0;
1825 r.kieninger 1.1         }
1826                         else
1827                         {
1828 thilo.boehm 1.3             _defNamespaceLen=strlen(_defNamespace);
1829 r.kieninger 1.1         }
1830 thilo.boehm 1.3         switch (_dataType)
1831 r.kieninger 1.1         {
1832 thilo.boehm 1.3             case RESP_INSTNAMES:
1833 r.kieninger 1.1             {
1834 thilo.boehm 1.3                 for (Uint32 i=0,n=_instanceNames.size();i<n;i++)
1835                                 {
1836                                     SCMOInstance addme(
1837                                         _instanceNames[i],
1838                                         _defNamespace,
1839                                         _defNamespaceLen);
1840                                     _scmoInstances.append(addme);
1841                                 }
1842                                 _instanceNames.clear();
1843                                 break;
1844 r.kieninger 1.1             }
1845 thilo.boehm 1.3             case RESP_INSTANCE:
1846 r.kieninger 1.2             {
1847 thilo.boehm 1.3                 if (_instances.size() > 0)
1848                                 {
1849                                     SCMOInstance addme(
1850                                         _instances[0],
1851                                         _defNamespace,
1852                                         _defNamespaceLen);
1853                                     _scmoInstances.clear();
1854                                     _scmoInstances.append(addme);
1855                                     _instances.clear();
1856                                 }
1857                                 break;
1858 r.kieninger 1.2             }
1859 thilo.boehm 1.3             case RESP_INSTANCES:
1860 r.kieninger 1.1             {
1861 thilo.boehm 1.3                 for (Uint32 i=0,n=_instances.size();i<n;i++)
1862 r.kieninger 1.1                 {
1863 thilo.boehm 1.3                     SCMOInstance addme(
1864                                         _instances[i],
1865                                         _defNamespace,
1866                                         _defNamespaceLen);
1867                                     _scmoInstances.append(addme);
1868 r.kieninger 1.1                 }
1869 thilo.boehm 1.3                 _instances.clear();
1870                                 break;
1871                             }
1872                             case RESP_OBJECTS:
1873                             {
1874                                 for (Uint32 i=0,n=_objects.size();i<n;i++)
1875 r.kieninger 1.1                 {
1876 thilo.boehm 1.3                     SCMOInstance addme(
1877                                         _objects[i],
1878                                         _defNamespace,
1879                                         _defNamespaceLen);
1880                                     _scmoInstances.append(addme);
1881 r.kieninger 1.1                 }
1882 thilo.boehm 1.3                 _objects.clear();
1883                                 break;
1884                             }
1885                             case RESP_OBJECTPATHS:
1886                             {
1887                                 for (Uint32 i=0,n=_instanceNames.size();i<n;i++)
1888 r.kieninger 1.1                 {
1889 thilo.boehm 1.3                     SCMOInstance addme(
1890                                         _instanceNames[i],
1891                                         _defNamespace,
1892                                         _defNamespaceLen);
1893                                     // TODO: More description about this.
1894                                     if (0 == _instanceNames[i].getKeyBindings().size())
1895                                     {
1896                                         // if there is no keybinding, this is a class
1897                                         addme.setIsClassOnly(true);
1898                                     }
1899                                     _scmoInstances.append(addme);
1900 r.kieninger 1.1                 }
1901 thilo.boehm 1.3                 _instanceNames.clear();
1902                                 break;
1903 r.kieninger 1.1             }
1904 thilo.boehm 1.3             default:
1905 r.kieninger 1.1             {
1906 thilo.boehm 1.3                 PEGASUS_DEBUG_ASSERT(false);
1907 r.kieninger 1.1             }
1908                         }
1909                     
1910 thilo.boehm 1.3         // remove CIM Encoding flag
1911                         _encoding &=(~RESP_ENC_CIM);
1912                         // add SCMO Encoding flag
1913                         _encoding |=RESP_ENC_SCMO;
1914 r.kieninger 1.1     }
1915                     
1916 karl        1.5.2.1 /**
1917                      * Validate the magic object for this CIMResponseData. This
1918                      * compiles only in debug mode and can be use to validate the
1919                      * CIMResponseData object
1920                      *
1921                      * @return Boolean True if valid object.
1922                      */
1923                     Boolean CIMResponseData::valid()
1924                     {
1925                         return _magic;
1926                     }
1927                     
1928 karl        1.5.2.3 void CIMResponseData::setRequestProperties(
1929                         const Boolean includeQualifiers,
1930                         const Boolean includeClassOrigin,
1931                         const CIMPropertyList& propertyList)
1932                     {
1933 karl        1.5.2.5     TRACELINE;
1934 karl        1.5.2.3     _includeQualifiers = includeQualifiers;
1935                         _includeClassOrigin = includeClassOrigin;
1936                         _propertyList = propertyList; 
1937                     }
1938                     
1939 r.kieninger 1.1     PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2