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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2