(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 thilo.boehm 1.3 // C++ objects interface handling
  45                 
  46                 // Instance Names handling
  47                 Array<CIMObjectPath>& CIMResponseData::getInstanceNames()
  48                 {
  49                     PEGASUS_DEBUG_ASSERT(
  50                     (_dataType==RESP_INSTNAMES || _dataType==RESP_OBJECTPATHS));
  51                     _resolveToCIM();
  52                     PEGASUS_DEBUG_ASSERT(_encoding==RESP_ENC_CIM || _encoding == 0);
  53                     return _instanceNames;
  54                 }
  55                 
  56                 // Instance handling
  57                 CIMInstance& CIMResponseData::getInstance()
  58                 {
  59                     PEGASUS_DEBUG_ASSERT(_dataType == RESP_INSTANCE);
  60                     _resolveToCIM();
  61                     if (0 == _instances.size())
  62                     {
  63                         _instances.append(CIMInstance());
  64                     }
  65 thilo.boehm 1.3     return _instances[0];
  66                 }
  67                 
  68                 // Instances handling
  69                 Array<CIMInstance>& CIMResponseData::getInstances()
  70                 {
  71                     PEGASUS_DEBUG_ASSERT(_dataType == RESP_INSTANCES);
  72                     _resolveToCIM();
  73                     return _instances;
  74                 }
  75                 
  76                 // Objects handling
  77                 Array<CIMObject>& CIMResponseData::getObjects()
  78                 {
  79                     PEGASUS_DEBUG_ASSERT(_dataType == RESP_OBJECTS);
  80                     _resolveToCIM();
  81                     return _objects;
  82                 }
  83                 
  84                 // SCMO representation, single instance stored as one element array
  85                 // object paths are represented as SCMOInstance
  86 thilo.boehm 1.3 Array<SCMOInstance>& CIMResponseData::getSCMO()
  87                 {
  88                     _resolveToSCMO();
  89                     return _scmoInstances;
  90                 }
  91                 
  92                 void CIMResponseData::setSCMO(const Array<SCMOInstance>& x)
  93                 {
  94                     _scmoInstances=x;
  95                     _encoding |= RESP_ENC_SCMO;
  96                 }
  97                 
  98                 
  99                 // Binary data is just a data stream
 100                 Array<Uint8>& CIMResponseData::getBinary()
 101                 {
 102                     PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_BINARY || _encoding == 0);
 103                     return _binaryData;
 104                 }
 105                 
 106 karl        1.5 bool CIMResponseData::setBinary(CIMBuffer& in)
 107 r.kieninger 1.1 {
 108 karl        1.5     PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setBinary");
 109 r.kieninger 1.1 
 110 karl        1.5     // Append all serial data from the CIMBuffer to the local data store.
 111                     // Returns error if input not a serialized Uint8A
 112                     if (!in.getUint8A(_binaryData))
 113                     {
 114                         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 115                             "Failed to get binary input data!");
 116                         PEG_METHOD_EXIT();
 117                         return false;
 118 r.kieninger 1.1     }
 119 karl        1.5     _encoding |= RESP_ENC_BINARY;
 120                     PEG_METHOD_EXIT();
 121                     return true;
 122                 }
 123                 
 124                 bool CIMResponseData::setRemainingBinaryData(CIMBuffer& in)
 125                 {
 126                     PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setRemainingBinaryData");
 127                 
 128                     // Append any data that has not been deserialized already from
 129                     // the CIMBuffer.
 130                     size_t remainingDataLength = in.remainingDataLength();
 131                     _binaryData.append((Uint8*)in.getPtr(), remainingDataLength);
 132                 
 133 thilo.boehm 1.3     _encoding |= RESP_ENC_BINARY;
 134 r.kieninger 1.1     PEG_METHOD_EXIT();
 135                     return true;
 136 thilo.boehm 1.3 }
 137 r.kieninger 1.1 
 138 thilo.boehm 1.3 bool CIMResponseData::setXml(CIMBuffer& in)
 139 r.kieninger 1.1 {
 140 thilo.boehm 1.3     switch (_dataType)
 141 r.kieninger 1.1     {
 142 thilo.boehm 1.3         case RESP_INSTANCE:
 143                         {
 144                             Array<Sint8> inst;
 145                             Array<Sint8> ref;
 146                             CIMNamespaceName ns;
 147                             String host;
 148                             if (!in.getSint8A(inst))
 149                             {
 150                                 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 151                                     "Failed to get XML instance data!");
 152                                 return false;
 153                             }
 154                             _instanceData.insert(0,inst);
 155                             if (!in.getSint8A(ref))
 156                             {
 157                                 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 158                                     "Failed to get XML instance data (reference)!");
 159                                 return false;
 160                             }
 161                             _referencesData.insert(0,ref);
 162                             if (!in.getString(host))
 163 thilo.boehm 1.3             {
 164                                 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 165                                     "Failed to get XML instance data (host)!");
 166                                 return false;
 167                             }
 168                             _hostsData.insert(0,host);
 169                             if (!in.getNamespaceName(ns))
 170                             {
 171                                 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 172                                     "Failed to get XML instance data (namespace)!");
 173                                 return false;
 174                             }
 175                             _nameSpacesData.insert(0,ns);
 176                             break;
 177                         }
 178                         case RESP_INSTANCES:
 179                         {
 180                             Uint32 count;
 181                             if (!in.getUint32(count))
 182                             {
 183                                 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 184 thilo.boehm 1.3                     "Failed to get XML instance data (number of instance)!");
 185                                 return false;
 186                             }
 187                             for (Uint32 i = 0; i < count; i++)
 188                             {
 189                                 Array<Sint8> inst;
 190                                 Array<Sint8> ref;
 191                                 CIMNamespaceName ns;
 192                                 String host;
 193                                 if (!in.getSint8A(inst))
 194                                 {
 195                                     PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 196                                         "Failed to get XML instance data (instances)!");
 197                                     return false;
 198                                 }
 199                                 if (!in.getSint8A(ref))
 200                                 {
 201                                     PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 202                                         "Failed to get XML instance data (references)!");
 203                                     return false;
 204                                 }
 205 thilo.boehm 1.3                 if (!in.getString(host))
 206                                 {
 207                                     PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 208                                         "Failed to get XML instance data (host)!");
 209                                     return false;
 210                                 }
 211                                 if (!in.getNamespaceName(ns))
 212                                 {
 213                                     PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 214                                         "Failed to get XML instance data (namespace)!");
 215                                     return false;
 216                                 }
 217                                 _instanceData.append(inst);
 218                                 _referencesData.append(ref);
 219                                 _hostsData.append(host);
 220                                 _nameSpacesData.append(ns);
 221                             }
 222                             break;
 223                         }
 224                         case RESP_OBJECTS:
 225                         {
 226 thilo.boehm 1.3             Uint32 count;
 227                             if (!in.getUint32(count))
 228                             {
 229                                 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 230                                     "Failed to get XML object data (number of objects)!");
 231                                 return false;
 232                             }
 233                             for (Uint32 i = 0; i < count; i++)
 234                             {
 235                                 Array<Sint8> obj;
 236                                 Array<Sint8> ref;
 237                                 CIMNamespaceName ns;
 238                                 String host;
 239                                 if (!in.getSint8A(obj))
 240                                 {
 241                                     PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 242                                         "Failed to get XML object data (object)!");
 243                                     return false;
 244                                 }
 245                                 if (!in.getSint8A(ref))
 246                                 {
 247 thilo.boehm 1.3                     PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 248                                         "Failed to get XML object data (reference)!");
 249                                     return false;
 250                                 }
 251                                 if (!in.getString(host))
 252                                 {
 253                                     PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 254                                         "Failed to get XML object data (host)!");
 255                                     return false;
 256                                 }
 257                                 if (!in.getNamespaceName(ns))
 258                                 {
 259                                     PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
 260                                         "Failed to get XML object data (namespace)!");
 261                                     return false;
 262                                 }
 263                                 _instanceData.append(obj);
 264                                 _referencesData.append(ref);
 265                                 _hostsData.append(host);
 266                                 _nameSpacesData.append(ns);
 267                             }
 268 thilo.boehm 1.3             break;
 269                         }
 270                         // internal xml encoding of instance names and object paths not
 271                         // done today
 272                         case RESP_INSTNAMES:
 273                         case RESP_OBJECTPATHS:
 274                         default:
 275                         {
 276                             PEGASUS_DEBUG_ASSERT(false);
 277                         }
 278 r.kieninger 1.1     }
 279 thilo.boehm 1.3     _encoding |= RESP_ENC_XML;
 280                     return true;
 281                 }
 282 r.kieninger 1.1 
 283 thilo.boehm 1.3 // function used by OperationAggregator to aggregate response data in a
 284                 // single ResponseData object
 285                 void CIMResponseData::appendResponseData(const CIMResponseData & x)
 286                 {
 287                     // as the Messages set the data types, this should be impossible
 288                     PEGASUS_DEBUG_ASSERT(_dataType == x._dataType);
 289                     _encoding |= x._encoding;
 290                 
 291                     // add all binary data
 292                     _binaryData.appendArray(x._binaryData);
 293                 
 294                     // add all the C++ stuff
 295                     _instanceNames.appendArray(x._instanceNames);
 296                     _instances.appendArray(x._instances);
 297                     _objects.appendArray(x._objects);
 298                 
 299                     // add the SCMO instances
 300                     _scmoInstances.appendArray(x._scmoInstances);
 301                 
 302                     // add Xml encodings too
 303                     _referencesData.appendArray(x._referencesData);
 304 thilo.boehm 1.3     _instanceData.appendArray(x._instanceData);
 305                     _hostsData.appendArray(x._hostsData);
 306                     _nameSpacesData.appendArray(x._nameSpacesData);
 307                 }
 308 r.kieninger 1.1 
 309 thilo.boehm 1.3 // Encoding responses into output format
 310                 void CIMResponseData::encodeBinaryResponse(CIMBuffer& out)
 311 r.kieninger 1.1 {
 312                     PEG_METHOD_ENTER(TRC_DISPATCHER,
 313 thilo.boehm 1.3         "CIMResponseData::encodeBinaryResponse");
 314                     // Need to do a complete job here by transferring all contained data
 315                     // into binary format and handing it out in the CIMBuffer
 316                     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
 317 r.kieninger 1.1     {
 318 thilo.boehm 1.3         // Binary does NOT need a marker as it consists of C++ and SCMO
 319 r.kieninger 1.1         const Array<Uint8>& data = _binaryData;
 320                         out.putBytes(data.getData(), data.size());
 321                     }
 322 thilo.boehm 1.3     if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
 323 r.kieninger 1.1     {
 324 thilo.boehm 1.3         out.putTypeMarker(BIN_TYPE_MARKER_CPPD);
 325                         switch (_dataType)
 326                         {
 327                             case RESP_INSTNAMES:
 328                             {
 329                                 out.putObjectPathA(_instanceNames);
 330                                 break;
 331                             }
 332                             case RESP_INSTANCE:
 333                             {
 334                                 if (0 == _instances.size())
 335                                 {
 336                                     _instances.append(CIMInstance());
 337                                 }
 338                                 out.putInstance(_instances[0], true, true);
 339                                 break;
 340                             }
 341                             case RESP_INSTANCES:
 342                             {
 343                                 out.putInstanceA(_instances);
 344                                 break;
 345 thilo.boehm 1.3             }
 346                             case RESP_OBJECTS:
 347                             {
 348                                 out.putObjectA(_objects);
 349                                 break;
 350                             }
 351                             case RESP_OBJECTPATHS:
 352                             {
 353                                 out.putObjectPathA(_instanceNames);
 354                                 break;
 355                             }
 356                             default:
 357                             {
 358                                 PEGASUS_DEBUG_ASSERT(false);
 359                             }
 360                         }
 361 r.kieninger 1.1     }
 362 thilo.boehm 1.3     if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
 363 r.kieninger 1.1     {
 364 thilo.boehm 1.3         out.putTypeMarker(BIN_TYPE_MARKER_SCMO);
 365                         out.putSCMOInstanceA(_scmoInstances);
 366 r.kieninger 1.1     }
 367 thilo.boehm 1.3     if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
 368 r.kieninger 1.1     {
 369 thilo.boehm 1.3         // This actually should not happen following general code logic
 370                         PEGASUS_DEBUG_ASSERT(false);
 371 r.kieninger 1.1     }
 372 thilo.boehm 1.3 
 373 r.kieninger 1.1     PEG_METHOD_EXIT();
 374                 }
 375                 
 376 thilo.boehm 1.3 void CIMResponseData::completeNamespace(const SCMOInstance * x)
 377 r.kieninger 1.1 {
 378 thilo.boehm 1.3     const char * ns;
 379                     Uint32 len;
 380                     ns = x->getNameSpace_l(len);
 381                     // Both internal XML as well as binary always contain a namespace
 382                     // don't have to do anything for those two encodings
 383                     if ((RESP_ENC_BINARY == (_encoding&RESP_ENC_BINARY)) && (len != 0))
 384 r.kieninger 1.1     {
 385 thilo.boehm 1.3         _defaultNamespace = CIMNamespaceName(ns);
 386 r.kieninger 1.1     }
 387 thilo.boehm 1.3     if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
 388 r.kieninger 1.1     {
 389 thilo.boehm 1.3         CIMNamespaceName nsName(ns);
 390                         switch (_dataType)
 391 r.kieninger 1.1         {
 392 thilo.boehm 1.3             case RESP_INSTANCE:
 393                             {
 394                                 if (_instances.size() > 0)
 395                                 {
 396                                     const CIMInstance& inst = _instances[0];
 397                                     CIMObjectPath& p =
 398                                         const_cast<CIMObjectPath&>(inst.getPath());
 399                                     if (p.getNameSpace().isNull())
 400                                     {
 401                                         p.setNameSpace(nsName);
 402                                     }
 403                                 }
 404                             }
 405                             case RESP_INSTANCES:
 406                             {
 407                                 for (Uint32 j = 0, n = _instances.size(); j < n; j++)
 408                                 {
 409                                     const CIMInstance& inst = _instances[j];
 410                                     CIMObjectPath& p =
 411                                         const_cast<CIMObjectPath&>(inst.getPath());
 412                                     if (p.getNameSpace().isNull())
 413 thilo.boehm 1.3                     {
 414                                         p.setNameSpace(nsName);
 415                                     }
 416                                 }
 417                                 break;
 418                             }
 419                             case RESP_OBJECTS:
 420                             {
 421                                 for (Uint32 j = 0, n = _objects.size(); j < n; j++)
 422                                 {
 423                                     const CIMObject& object = _objects[j];
 424                                     CIMObjectPath& p =
 425                                         const_cast<CIMObjectPath&>(object.getPath());
 426                                     if (p.getNameSpace().isNull())
 427                                     {
 428                                         p.setNameSpace(nsName);
 429                                     }
 430                                 }
 431                                 break;
 432                             }
 433                             case RESP_INSTNAMES:
 434 thilo.boehm 1.3             case RESP_OBJECTPATHS:
 435                             {
 436                                 for (Uint32 j = 0, n = _instanceNames.size(); j < n; j++)
 437                                 {
 438                                     CIMObjectPath& p = _instanceNames[j];
 439                                     if (p.getNameSpace().isNull())
 440                                     {
 441                                         p.setNameSpace(nsName);
 442                                     }
 443                                 }
 444                                 break;
 445                             }
 446                             default:
 447                             {
 448                                 PEGASUS_DEBUG_ASSERT(false);
 449                             }
 450 r.kieninger 1.1         }
 451                     }
 452 thilo.boehm 1.3     if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
 453 r.kieninger 1.1     {
 454 thilo.boehm 1.3         for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++)
 455 r.kieninger 1.1         {
 456 thilo.boehm 1.3             SCMOInstance & scmoInst=_scmoInstances[j];
 457                             if (0 == scmoInst.getNameSpace())
 458                             {
 459                                 scmoInst.setNameSpace_l(ns,len);
 460                             }
 461 r.kieninger 1.1         }
 462                     }
 463                 }
 464                 
 465                 
 466 thilo.boehm 1.3 void CIMResponseData::completeHostNameAndNamespace(
 467                     const String & hn,
 468                     const CIMNamespaceName & ns)
 469 r.kieninger 1.1 {
 470 thilo.boehm 1.3     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
 471                     {
 472                         // On binary need remember hostname and namespace in case someone
 473                         // builds C++ default objects or Xml types from it later on
 474                         // -> usage: See resolveBinary()
 475                         _defaultNamespace=ns;
 476                         _defaultHostname=hn;
 477                     }
 478                     // InternalXml does not support objectPath calls
 479                     if ((RESP_ENC_XML == (_encoding & RESP_ENC_XML)) &&
 480                             (RESP_OBJECTS == _dataType))
 481                     {
 482                         for (Uint32 j = 0, n = _referencesData.size(); j < n; j++)
 483                         {
 484                             if (0 == _hostsData[j].size())
 485                             {
 486                                 _hostsData[j]=hn;
 487                             }
 488                             if (_nameSpacesData[j].isNull())
 489                             {
 490                                 _nameSpacesData[j]=ns;
 491 thilo.boehm 1.3             }
 492                         }
 493                     }
 494                     if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
 495 r.kieninger 1.1     {
 496 thilo.boehm 1.3         switch (_dataType)
 497 r.kieninger 1.2         {
 498 thilo.boehm 1.3             case RESP_OBJECTS:
 499                             {
 500                                 for (Uint32 j = 0, n = _objects.size(); j < n; j++)
 501                                 {
 502                                     const CIMObject& object = _objects[j];
 503                                     CIMObjectPath& p =
 504                                         const_cast<CIMObjectPath&>(object.getPath());
 505                                     if (p.getHost().size()==0)
 506                                     {
 507                                         p.setHost(hn);
 508                                     }
 509                                     if (p.getNameSpace().isNull())
 510                                     {
 511                                         p.setNameSpace(ns);
 512                                     }
 513                                 }
 514                                 break;
 515                             }
 516                             case RESP_OBJECTPATHS:
 517                             {
 518                                 for (Uint32 j = 0, n = _instanceNames.size(); j < n; j++)
 519 thilo.boehm 1.3                 {
 520                                     CIMObjectPath& p = _instanceNames[j];
 521                                     if (p.getHost().size() == 0)
 522                                         p.setHost(hn);
 523                                     if (p.getNameSpace().isNull())
 524                                         p.setNameSpace(ns);
 525                                 }
 526                                 break;
 527                             }
 528                             default:
 529                             {
 530                                 PEGASUS_DEBUG_ASSERT(false);
 531                             }
 532 r.kieninger 1.2         }
 533                     }
 534 thilo.boehm 1.3     if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
 535 r.kieninger 1.2     {
 536 thilo.boehm 1.3         CString hnCString=hn.getCString();
 537                         const char* hnChars = hnCString;
 538                         Uint32 hnLen = strlen(hnChars);
 539                         CString nsCString=ns.getString().getCString();
 540                         const char* nsChars=nsCString;
 541                         Uint32 nsLen = strlen(nsChars);
 542                         switch (_dataType)
 543                         {
 544                             case RESP_OBJECTS:
 545                             case RESP_OBJECTPATHS:
 546                             {
 547                                 for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++)
 548                                 {
 549                                     SCMOInstance & scmoInst=_scmoInstances[j];
 550                                     if (0 == scmoInst.getHostName())
 551                                     {
 552                                         scmoInst.setHostName_l(hnChars,hnLen);
 553                                     }
 554                                     if (0 == scmoInst.getNameSpace())
 555                                     {
 556                                         scmoInst.setNameSpace_l(nsChars,nsLen);
 557 thilo.boehm 1.3                     }
 558                                 }
 559                                 break;
 560                             }
 561                             default:
 562                             {
 563                                 PEGASUS_DEBUG_ASSERT(false);
 564                             }
 565                         }
 566 r.kieninger 1.1     }
 567 thilo.boehm 1.3 }
 568 r.kieninger 1.1 
 569 thilo.boehm 1.3 void CIMResponseData::encodeXmlResponse(Buffer& out)
 570 r.kieninger 1.1 {
 571 thilo.boehm 1.3     PEG_TRACE((TRC_XML, Tracer::LEVEL3,
 572 r.kieninger 1.4         "CIMResponseData::encodeXmlResponse(encoding=%X,content=%X)",
 573 thilo.boehm 1.3         _encoding,
 574                         _dataType));
 575 anusha.kandepu 1.6     
 576 thilo.boehm    1.3     // already existing Internal XML does not need to be encoded further
 577                        // binary input is not actually impossible here, but we have an established
 578                        // fallback
 579                        if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
 580 r.kieninger    1.1     {
 581 thilo.boehm    1.3         _resolveBinary();
 582 r.kieninger    1.1     }
 583 thilo.boehm    1.3     if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
 584 r.kieninger    1.1     {
 585 thilo.boehm    1.3         switch (_dataType)
 586 r.kieninger    1.1         {
 587 thilo.boehm    1.3             case RESP_INSTANCE:
 588                                {
 589                                    const Array<ArraySint8>& a = _instanceData;
 590                                    out.append((char*)a[0].getData(), a[0].size() - 1);
 591                                    break;
 592                                }
 593                                case RESP_INSTANCES:
 594                                {
 595                                    const Array<ArraySint8>& a = _instanceData;
 596                                    const Array<ArraySint8>& b = _referencesData;
 597 r.kieninger    1.1 
 598 thilo.boehm    1.3                 for (Uint32 i = 0, n = a.size(); i < n; i++)
 599                                    {
 600                                        out << STRLIT("<VALUE.NAMEDINSTANCE>\n");
 601                                        out.append((char*)b[i].getData(), b[i].size() - 1);
 602                                        out.append((char*)a[i].getData(), a[i].size() - 1);
 603                                        out << STRLIT("</VALUE.NAMEDINSTANCE>\n");
 604                                    }
 605                                    break;
 606                                }
 607                                case RESP_OBJECTS:
 608                                {
 609                                    const Array<ArraySint8>& a = _instanceData;
 610                                    const Array<ArraySint8>& b = _referencesData;
 611                                    for (Uint32 i = 0, n = a.size(); i < n; i++)
 612                                    {
 613                                        out << STRLIT("<VALUE.OBJECTWITHPATH>\n");
 614                                        out << STRLIT("<INSTANCEPATH>\n");
 615                                        XmlWriter::appendNameSpacePathElement(
 616                                                out,
 617                                                _hostsData[i],
 618                                                _nameSpacesData[i]);
 619 thilo.boehm    1.3                     // Leave out the surrounding tags "<VALUE.REFERENCE>\n"
 620                                        // and "</VALUE.REFERENCE>\n" which are 18 and 19 characters
 621                                        // long
 622                                        out.append(
 623                                            ((char*)b[i].getData())+18,
 624                                            b[i].size() - 1 - 18 -19);
 625                                        out << STRLIT("</INSTANCEPATH>\n");
 626                                        // append instance body
 627                                        out.append((char*)a[i].getData(), a[i].size() - 1);
 628                                        out << STRLIT("</VALUE.OBJECTWITHPATH>\n");
 629                                    }
 630                                    break;
 631                                }
 632                                // internal xml encoding of instance names and object paths not
 633                                // done today
 634                                case RESP_INSTNAMES:
 635                                case RESP_OBJECTPATHS:
 636                                default:
 637                                {
 638                                    PEGASUS_DEBUG_ASSERT(false);
 639                                }
 640 r.kieninger    1.1         }
 641 thilo.boehm    1.3     }
 642 r.kieninger    1.1 
 643 thilo.boehm    1.3     if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
 644                        {
 645 anusha.kandepu 1.6         _propertyList.fillCIMNameTags();
 646 thilo.boehm    1.3         switch (_dataType)
 647 r.kieninger    1.1         {
 648 thilo.boehm    1.3             case RESP_INSTNAMES:
 649                                {
 650                                    for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++)
 651                                    {
 652                                        XmlWriter::appendInstanceNameElement(out,_instanceNames[i]);
 653                                    }
 654                                    break;
 655                                }
 656                                case RESP_INSTANCE:
 657                                {
 658                                    if (_instances.size() > 0)
 659                                    {
 660 anusha.kandepu 1.6                     XmlWriter::appendInstanceElement(
 661                                            out, 
 662                                            _instances[0],
 663                                            _includeQualifiers,
 664                                            _includeClassOrigin,
 665                                            _propertyList);
 666 thilo.boehm    1.3                 }
 667                                    break;
 668                                }
 669                                case RESP_INSTANCES:
 670                                {
 671                                    for (Uint32 i = 0, n = _instances.size(); i < n; i++)
 672                                    {
 673                                        XmlWriter::appendValueNamedInstanceElement(
 674 anusha.kandepu 1.6                         out, 
 675                                            _instances[i],
 676                                            _includeQualifiers,
 677                                            _includeClassOrigin,
 678                                            _propertyList);
 679 thilo.boehm    1.3                 }
 680                                    break;
 681                                }
 682                                case RESP_OBJECTS:
 683                                {
 684                                    for (Uint32 i = 0; i < _objects.size(); i++)
 685                                    {
 686                                        XmlWriter::appendValueObjectWithPathElement(
 687                                            out,
 688 anusha.kandepu 1.6                         _objects[i],
 689                                            _includeQualifiers,
 690                                            _includeClassOrigin,
 691                                            _propertyList);
 692 thilo.boehm    1.3                 }
 693                                    break;
 694                                }
 695                                case RESP_OBJECTPATHS:
 696                                {
 697                                    for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++)
 698                                    {
 699                                        out << "<OBJECTPATH>\n";
 700                                        XmlWriter::appendValueReferenceElement(
 701                                            out,
 702                                            _instanceNames[i],
 703                                            false);
 704                                        out << "</OBJECTPATH>\n";
 705                                    }
 706                                    break;
 707                                }
 708                                default:
 709                                {
 710                                    PEGASUS_DEBUG_ASSERT(false);
 711                                }
 712 r.kieninger    1.1         }
 713 thilo.boehm    1.3     }
 714                        if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
 715                        {
 716                            switch (_dataType)
 717 r.kieninger    1.1         {
 718 thilo.boehm    1.3             case RESP_INSTNAMES:
 719                                {
 720                                    for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++)
 721                                    {
 722                                        SCMOXmlWriter::appendInstanceNameElement(
 723                                            out,
 724                                            _scmoInstances[i]);
 725 anusha.kandepu 1.6 
 726 thilo.boehm    1.3                 }
 727                                    break;
 728                                }
 729                                case RESP_INSTANCE:
 730                                {
 731                                    if (_scmoInstances.size() > 0)
 732                                    {
 733 anusha.kandepu 1.6                     if(_propertyList.isNull())
 734                                        {
 735                                            Array<Uint32> emptyNodes; 
 736                                            SCMOXmlWriter::appendInstanceElement(
 737                                                out,
 738                                                _scmoInstances[0],
 739                                                false,
 740                                                emptyNodes);
 741                                        }
 742                                        else
 743                                        {
 744                                            Array<propertyFilterNodesArray_t> propFilterNodesArrays;
 745                                            // This searches for an already created array of nodes, 
 746                                            //if not found, creates it inside propFilterNodesArrays 
 747                                            const Array<Uint32> & nodes= 
 748                                                SCMOXmlWriter::getFilteredNodesArray( 
 749                                                    propFilterNodesArrays, 
 750                                                    _scmoInstances[0], 
 751                                                    _propertyList);
 752                                            SCMOXmlWriter::appendInstanceElement(
 753                                                out,
 754 anusha.kandepu 1.6                             _scmoInstances[0],
 755                                                true,
 756                                                nodes); 
 757                                        }  
 758 thilo.boehm    1.3                 }
 759                                    break;
 760                                }
 761                                case RESP_INSTANCES:
 762                                {
 763 anusha.kandepu 1.6                 SCMOXmlWriter::appendValueSCMOInstanceElements(
 764                                        out,
 765                                        _scmoInstances,
 766                                        _propertyList);
 767 thilo.boehm    1.3                 break;
 768                                }
 769                                case RESP_OBJECTS:
 770                                {
 771 anusha.kandepu 1.6                 SCMOXmlWriter::appendValueObjectWithPathElement(
 772                                        out,
 773                                       _scmoInstances,
 774                                      _propertyList);
 775 thilo.boehm    1.3                 break;
 776                                }
 777                                case RESP_OBJECTPATHS:
 778                                {
 779                                    for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++)
 780                                    {
 781                                        out << "<OBJECTPATH>\n";
 782                                        SCMOXmlWriter::appendValueReferenceElement(
 783                                            out,
 784                                            _scmoInstances[i],
 785                                            false);
 786                                        out << "</OBJECTPATH>\n";
 787                                    }
 788                                    break;
 789                                }
 790                                default:
 791                                {
 792                                    PEGASUS_DEBUG_ASSERT(false);
 793                                }
 794 r.kieninger    1.1         }
 795                        }
 796 thilo.boehm    1.3 }
 797 r.kieninger    1.1 
 798 thilo.boehm    1.3 // contrary to encodeXmlResponse this function encodes the Xml in a format
 799                    // not usable by clients
 800                    void CIMResponseData::encodeInternalXmlResponse(CIMBuffer& out)
 801                    {
 802                        PEG_TRACE((TRC_XML, Tracer::LEVEL3,
 803 r.kieninger    1.4         "CIMResponseData::encodeInternalXmlResponse(encoding=%X,content=%X)",
 804 thilo.boehm    1.3         _encoding,
 805                            _dataType));
 806                        // For mixed (CIM+SCMO) responses, we need to tell the receiver the
 807                        // total number of instances. The totalSize variable is used to keep track
 808                        // of this.
 809                        Uint32 totalSize = 0;
 810 r.kieninger    1.1 
 811 thilo.boehm    1.3     // already existing Internal XML does not need to be encoded further
 812                        // binary input is not actually impossible here, but we have an established
 813                        // fallback
 814                        if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
 815                        {
 816                            _resolveBinary();
 817                        }
 818                        if ((0 == _encoding) ||
 819                            (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)))
 820                        {
 821 anusha.kandepu 1.6         _propertyList.fillCIMNameTags();
 822 thilo.boehm    1.3         switch (_dataType)
 823                            {
 824                                case RESP_INSTANCE:
 825                                {
 826                                    if (0 == _instances.size())
 827                                    {
 828                                        _instances.append(CIMInstance());
 829 anusha.kandepu 1.6                     CIMInternalXmlEncoder::_putXMLInstance(
 830                                            out,
 831                                            _instances[0]);
 832                                        break;
 833 thilo.boehm    1.3                 }
 834 anusha.kandepu 1.6                 CIMInternalXmlEncoder::_putXMLInstance(
 835                                        out,
 836                                        _instances[0],
 837                                        _includeQualifiers,
 838                                        _includeClassOrigin,
 839                                        _propertyList);
 840 thilo.boehm    1.3                 break;
 841                                }
 842                                case RESP_INSTANCES:
 843                                {
 844                                    Uint32 n = _instances.size();
 845                                    totalSize = n + _scmoInstances.size();
 846                                    out.putUint32(totalSize);
 847                                    for (Uint32 i = 0; i < n; i++)
 848                                    {
 849                                        CIMInternalXmlEncoder::_putXMLNamedInstance(
 850                                            out,
 851 anusha.kandepu 1.6                         _instances[i],
 852                                            _includeQualifiers,
 853                                            _includeClassOrigin,
 854                                            _propertyList);
 855 thilo.boehm    1.3                 }
 856                                    break;
 857                                }
 858                                case RESP_OBJECTS:
 859                                {
 860                                    Uint32 n = _objects.size();
 861                                    totalSize = n + _scmoInstances.size();
 862                                    out.putUint32(totalSize);
 863                                    for (Uint32 i = 0; i < n; i++)
 864                                    {
 865 anusha.kandepu 1.6                     CIMInternalXmlEncoder::_putXMLObject(
 866                                            out,
 867                                            _objects[i],
 868                                            _includeQualifiers,
 869                                            _includeClassOrigin,
 870                                            _propertyList);
 871 thilo.boehm    1.3                 }
 872                                    break;
 873                                }
 874                                // internal xml encoding of instance names and object paths not
 875                                // done today
 876                                case RESP_INSTNAMES:
 877                                case RESP_OBJECTPATHS:
 878                                default:
 879                                {
 880                                    PEGASUS_DEBUG_ASSERT(false);
 881                                }
 882                            }
 883                        }
 884                        if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
 885                        {
 886                            switch (_dataType)
 887                            {
 888                                case RESP_INSTANCE:
 889                                {
 890                                    if (0 == _scmoInstances.size())
 891                                    {
 892 thilo.boehm    1.3                     _scmoInstances.append(SCMOInstance());
 893                                    }
 894 anusha.kandepu 1.6                 SCMOInternalXmlEncoder::_putXMLInstance(
 895                                        out, 
 896                                        _scmoInstances[0],
 897                                        _propertyList);
 898 thilo.boehm    1.3                 break;
 899                                }
 900                                case RESP_INSTANCES:
 901                                {
 902                                    Uint32 n = _scmoInstances.size();
 903                                    // Only put the size when not already done above
 904                                    if (0==totalSize)
 905                                    {
 906                                        out.putUint32(n);
 907                                    }
 908 anusha.kandepu 1.6                 SCMOInternalXmlEncoder::_putXMLNamedInstance(
 909                                        out,
 910                                        _scmoInstances,
 911                                        _propertyList);
 912 thilo.boehm    1.3                 break;
 913                                }
 914                                case RESP_OBJECTS:
 915                                {
 916                                    Uint32 n = _scmoInstances.size();
 917                                    // Only put the size when not already done above
 918                                    if (0==totalSize)
 919                                    {
 920                                        out.putUint32(n);
 921                                    }
 922 anusha.kandepu 1.6                 SCMOInternalXmlEncoder::_putXMLObject(
 923                                        out,
 924                                        _scmoInstances,
 925                                        _propertyList);
 926 thilo.boehm    1.3                 break;
 927                                }
 928                                // internal xml encoding of instance names and object paths not
 929                                // done today
 930                                case RESP_INSTNAMES:
 931                                case RESP_OBJECTPATHS:
 932                                default:
 933                                {
 934                                    PEGASUS_DEBUG_ASSERT(false);
 935                                }
 936                            }
 937                        }
 938 anusha.kandepu 1.6 
 939 thilo.boehm    1.3 }
 940 r.kieninger    1.1 
 941 thilo.boehm    1.3 void CIMResponseData::_resolveToCIM()
 942 r.kieninger    1.1 {
 943 r.kieninger    1.4     PEG_TRACE((TRC_XML, Tracer::LEVEL3,
 944                            "CIMResponseData::_resolveToCIM(encoding=%X,content=%X)",
 945 thilo.boehm    1.3         _encoding,
 946                            _dataType));
 947 r.kieninger    1.1 
 948 thilo.boehm    1.3     if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
 949                        {
 950                            _resolveXmlToCIM();
 951                        }
 952                        if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
 953 r.kieninger    1.1     {
 954 thilo.boehm    1.3         _resolveBinary();
 955 r.kieninger    1.1     }
 956 thilo.boehm    1.3     if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
 957 r.kieninger    1.1     {
 958 thilo.boehm    1.3         _resolveSCMOToCIM();
 959 r.kieninger    1.1     }
 960 thilo.boehm    1.3 
 961                        PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_CIM || _encoding == 0);
 962 r.kieninger    1.1 }
 963                    
 964 thilo.boehm    1.3 void CIMResponseData::_resolveToSCMO()
 965 r.kieninger    1.1 {
 966 r.kieninger    1.4     PEG_TRACE((TRC_XML, Tracer::LEVEL3,
 967                            "CIMResponseData::_resolveToSCMO(encoding=%X,content=%X)",
 968 thilo.boehm    1.3         _encoding,
 969                            _dataType));
 970 r.kieninger    1.1 
 971 thilo.boehm    1.3     if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
 972                        {
 973                            _resolveXmlToSCMO();
 974                        }
 975                        if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
 976 r.kieninger    1.1     {
 977 thilo.boehm    1.3         _resolveBinary();
 978 r.kieninger    1.1     }
 979 thilo.boehm    1.3     if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
 980 r.kieninger    1.1     {
 981 thilo.boehm    1.3         _resolveCIMToSCMO();
 982 r.kieninger    1.1     }
 983 thilo.boehm    1.3     PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_SCMO || _encoding == 0);
 984 r.kieninger    1.1 }
 985                    
 986 thilo.boehm    1.3 // helper functions to transform different formats into one-another
 987                    // functions work on the internal data and calling of them should be
 988                    // avoided whenever possible
 989                    void CIMResponseData::_resolveBinary()
 990 r.kieninger    1.1 {
 991                        PEG_METHOD_ENTER(TRC_DISPATCHER,
 992 thilo.boehm    1.3         "CIMResponseData::_resolveBinary");
 993 r.kieninger    1.1 
 994 thilo.boehm    1.3     CIMBuffer in((char*)_binaryData.getData(), _binaryData.size());
 995 r.kieninger    1.1 
 996 r.kieninger    1.2     while (in.more())
 997 r.kieninger    1.1     {
 998 thilo.boehm    1.3         Uint32 binaryTypeMarker=0;
 999                            if(!in.getTypeMarker(binaryTypeMarker))
1000 r.kieninger    1.2         {
1001                                PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1002 thilo.boehm    1.3                 "Failed to get type marker for binary objects!");
1003 r.kieninger    1.2             PEG_METHOD_EXIT();
1004 thilo.boehm    1.3             in.release();
1005                                return;
1006                            }
1007                    
1008                            if (BIN_TYPE_MARKER_SCMO==binaryTypeMarker)
1009                            {
1010                                if (!in.getSCMOInstanceA(_scmoInstances))
1011                                {
1012                                    _encoding &=(~RESP_ENC_BINARY);
1013                                    in.release();
1014                                    PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1015                                        "Failed to resolve binary SCMOInstances!");
1016                                    PEG_METHOD_EXIT();
1017                                    return;
1018                                }
1019                    
1020                                _encoding |= RESP_ENC_SCMO;
1021 r.kieninger    1.2         }
1022 thilo.boehm    1.3         else
1023                            {
1024                                switch (_dataType)
1025                                {
1026                                    case RESP_INSTNAMES:
1027                                    case RESP_OBJECTPATHS:
1028                                    {
1029                                        if (!in.getObjectPathA(_instanceNames))
1030                                        {
1031                                            _encoding &=(~RESP_ENC_BINARY);
1032                                            in.release();
1033                                            PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1034                                                "Failed to resolve binary CIMObjectPaths!");
1035                                            PEG_METHOD_EXIT();
1036                                            return;
1037                                        }
1038                                        break;
1039                                    }
1040                                    case RESP_INSTANCE:
1041                                    {
1042                                        CIMInstance instance;
1043 thilo.boehm    1.3                     if (!in.getInstance(instance))
1044                                        {
1045                                            _encoding &=(~RESP_ENC_BINARY);
1046                                            _encoding |= RESP_ENC_CIM;
1047                                            _instances.append(instance);
1048                                            in.release();
1049                                            PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1050                                                "Failed to resolve binary instance!");
1051                                            PEG_METHOD_EXIT();
1052                                            return;
1053                                        }
1054                    
1055                                        _instances.append(instance);
1056                                        break;
1057                                    }
1058                                    case RESP_INSTANCES:
1059                                    {
1060                                        if (!in.getInstanceA(_instances))
1061                                        {
1062                                            _encoding &=(~RESP_ENC_BINARY);
1063                                            in.release();
1064 thilo.boehm    1.3                         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1065                                                "Failed to resolve binary CIMInstances!");
1066                                            PEG_METHOD_EXIT();
1067                                            return;
1068                                        }
1069                                        break;
1070                                    }
1071                                    case RESP_OBJECTS:
1072                                    {
1073                                        if (!in.getObjectA(_objects))
1074                                        {
1075                                            in.release();
1076                                            _encoding &=(~RESP_ENC_BINARY);
1077                                            PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1078                                                "Failed to resolve binary CIMObjects!");
1079                                            PEG_METHOD_EXIT();
1080                                            return;
1081                                        }
1082                                        break;
1083                                    }
1084                                    default:
1085 thilo.boehm    1.3                 {
1086                                        PEGASUS_DEBUG_ASSERT(false);
1087                                    }
1088                                } // switch
1089                                _encoding |= RESP_ENC_CIM;
1090                            } // else SCMO
1091                        }
1092                        _encoding &=(~RESP_ENC_BINARY);
1093                        // fix up the hostname and namespace for objects if defaults
1094                        // were set
1095                        if (_defaultHostname.size() > 0 && !_defaultNamespace.isNull())
1096                        {
1097                            completeHostNameAndNamespace(_defaultHostname, _defaultNamespace);
1098 r.kieninger    1.1     }
1099                        in.release();
1100                        PEG_METHOD_EXIT();
1101                    }
1102                    
1103 thilo.boehm    1.3 void CIMResponseData::_resolveXmlToCIM()
1104 r.kieninger    1.1 {
1105 thilo.boehm    1.3     switch (_dataType)
1106 r.kieninger    1.1     {
1107 thilo.boehm    1.3         // Xml encoding for instance names and object paths not used
1108                            case RESP_OBJECTPATHS:
1109                            case RESP_INSTNAMES:
1110                            {
1111                                break;
1112                            }
1113                            case RESP_INSTANCE:
1114 r.kieninger    1.1         {
1115 thilo.boehm    1.3             CIMInstance cimInstance;
1116                                // Deserialize instance:
1117                                {
1118                                    XmlParser parser((char*)_instanceData[0].getData());
1119 r.kieninger    1.1 
1120 thilo.boehm    1.3                 if (!XmlReader::getInstanceElement(parser, cimInstance))
1121                                    {
1122                                        cimInstance = CIMInstance();
1123                                        PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1124                                            "Failed to resolve XML instance, parser error!");
1125                                    }
1126                                }
1127                                // Deserialize path:
1128 r.kieninger    1.1             {
1129 thilo.boehm    1.3                 XmlParser parser((char*)_referencesData[0].getData());
1130                                    CIMObjectPath cimObjectPath;
1131                    
1132                                    if (XmlReader::getValueReferenceElement(parser, cimObjectPath))
1133                                    {
1134                                        if (_hostsData.size())
1135                                        {
1136                                            cimObjectPath.setHost(_hostsData[0]);
1137                                        }
1138                                        if (!_nameSpacesData[0].isNull())
1139                                        {
1140                                            cimObjectPath.setNameSpace(_nameSpacesData[0]);
1141                                        }
1142                                        cimInstance.setPath(cimObjectPath);
1143                                        // only if everything works we add the CIMInstance to the
1144                                        // array
1145                                        _instances.append(cimInstance);
1146                                    }
1147 r.kieninger    1.1             }
1148 thilo.boehm    1.3             break;
1149 r.kieninger    1.1         }
1150 thilo.boehm    1.3         case RESP_INSTANCES:
1151                            {
1152                                for (Uint32 i = 0; i < _instanceData.size(); i++)
1153                                {
1154                                    CIMInstance cimInstance;
1155                                    // Deserialize instance:
1156                                    {
1157                                        XmlParser parser((char*)_instanceData[i].getData());
1158                    
1159                                        if (!XmlReader::getInstanceElement(parser, cimInstance))
1160                                        {
1161                                            PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1162                                                "Failed to resolve XML instance."
1163                                                    " Creating empty instance!");
1164                                            cimInstance = CIMInstance();
1165                                        }
1166                                    }
1167                    
1168                                    // Deserialize path:
1169                                    {
1170                                        XmlParser parser((char*)_referencesData[i].getData());
1171 thilo.boehm    1.3                     CIMObjectPath cimObjectPath;
1172                    
1173                                        if (XmlReader::getInstanceNameElement(parser,cimObjectPath))
1174                                        {
1175                                            if (!_nameSpacesData[i].isNull())
1176                                                cimObjectPath.setNameSpace(_nameSpacesData[i]);
1177                    
1178                                            if (_hostsData[i].size())
1179                                                cimObjectPath.setHost(_hostsData[i]);
1180                    
1181                                            cimInstance.setPath(cimObjectPath);
1182                                        }
1183                                    }
1184 r.kieninger    1.1 
1185 thilo.boehm    1.3                 _instances.append(cimInstance);
1186                                }
1187                                break;
1188                            }
1189                            case RESP_OBJECTS:
1190 r.kieninger    1.1         {
1191 thilo.boehm    1.3             for (Uint32 i=0, n=_instanceData.size(); i<n; i++)
1192 r.kieninger    1.1             {
1193 thilo.boehm    1.3                 CIMObject cimObject;
1194 r.kieninger    1.1 
1195 thilo.boehm    1.3                 // Deserialize Objects:
1196                                    {
1197                                        XmlParser parser((char*)_instanceData[i].getData());
1198                    
1199                                        CIMInstance cimInstance;
1200                                        CIMClass cimClass;
1201                    
1202                                        if (XmlReader::getInstanceElement(parser, cimInstance))
1203                                        {
1204                                            cimObject = CIMObject(cimInstance);
1205                                        }
1206                                        else if (XmlReader::getClassElement(parser, cimClass))
1207                                        {
1208                                            cimObject = CIMObject(cimClass);
1209                                        }
1210                                        else
1211                                        {
1212                                            PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1213                                                "Failed to get XML object data!");
1214                                        }
1215                                    }
1216 thilo.boehm    1.3 
1217                                    // Deserialize paths:
1218                                    {
1219                                        XmlParser parser((char*)_referencesData[i].getData());
1220                                        CIMObjectPath cimObjectPath;
1221                    
1222                                        if (XmlReader::getValueReferenceElement(
1223                                                parser,
1224                                                cimObjectPath))
1225                                        {
1226                                            if (!_nameSpacesData[i].isNull())
1227                                                cimObjectPath.setNameSpace(_nameSpacesData[i]);
1228                    
1229                                            if (_hostsData[i].size())
1230                                                cimObjectPath.setHost(_hostsData[i]);
1231                    
1232                                            cimObject.setPath(cimObjectPath);
1233                                        }
1234                                    }
1235                                    _objects.append(cimObject);
1236 r.kieninger    1.1             }
1237 thilo.boehm    1.3             break;
1238                            }
1239                            default:
1240                            {
1241                                PEGASUS_DEBUG_ASSERT(false);
1242 r.kieninger    1.1         }
1243                        }
1244 thilo.boehm    1.3     // Xml was resolved, release Xml content now
1245                        _referencesData.clear();
1246                        _hostsData.clear();
1247                        _nameSpacesData.clear();
1248                        _instanceData.clear();
1249                        // remove Xml Encoding flag
1250                        _encoding &=(~RESP_ENC_XML);
1251                        // add CIM Encoding flag
1252                        _encoding |=RESP_ENC_CIM;
1253                    }
1254 r.kieninger    1.1 
1255 thilo.boehm    1.3 void CIMResponseData::_resolveXmlToSCMO()
1256                    {
1257                        // Not optimal, can probably be improved
1258                        // but on the other hand, since using the binary format this case should
1259                        // actually not ever happen.
1260                        _resolveXmlToCIM();
1261                        _resolveCIMToSCMO();
1262 r.kieninger    1.1 }
1263                    
1264 thilo.boehm    1.3 void CIMResponseData::_resolveSCMOToCIM()
1265 r.kieninger    1.1 {
1266 thilo.boehm    1.3     switch(_dataType)
1267 r.kieninger    1.2     {
1268 thilo.boehm    1.3         case RESP_INSTNAMES:
1269                            case RESP_OBJECTPATHS:
1270 r.kieninger    1.2         {
1271 thilo.boehm    1.3             for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
1272                                {
1273                                    CIMObjectPath newObjectPath;
1274                                    _scmoInstances[x].getCIMObjectPath(newObjectPath);
1275                                    _instanceNames.append(newObjectPath);
1276                                }
1277                                break;
1278 r.kieninger    1.2         }
1279 thilo.boehm    1.3         case RESP_INSTANCE:
1280 r.kieninger    1.1         {
1281 thilo.boehm    1.3             if (_scmoInstances.size() > 0)
1282                                {
1283                                    CIMInstance newInstance;
1284                                    _scmoInstances[0].getCIMInstance(newInstance);
1285                                    _instances.append(newInstance);
1286                                }
1287                                break;
1288 r.kieninger    1.1         }
1289 thilo.boehm    1.3         case RESP_INSTANCES:
1290 r.kieninger    1.1         {
1291 thilo.boehm    1.3             for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
1292                                {
1293                                    CIMInstance newInstance;
1294                                    _scmoInstances[x].getCIMInstance(newInstance);
1295                                    _instances.append(newInstance);
1296                                }
1297                                break;
1298 r.kieninger    1.1         }
1299 thilo.boehm    1.3         case RESP_OBJECTS:
1300 r.kieninger    1.1         {
1301 thilo.boehm    1.3             for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
1302                                {
1303                                    CIMInstance newInstance;
1304                                    _scmoInstances[x].getCIMInstance(newInstance);
1305                                    _objects.append(CIMObject(newInstance));
1306                                }
1307                                break;
1308 r.kieninger    1.1         }
1309 thilo.boehm    1.3         default:
1310 r.kieninger    1.1         {
1311 thilo.boehm    1.3             PEGASUS_DEBUG_ASSERT(false);
1312 r.kieninger    1.1         }
1313                        }
1314 thilo.boehm    1.3     _scmoInstances.clear();
1315                        // remove CIM Encoding flag
1316                        _encoding &=(~RESP_ENC_SCMO);
1317                        // add SCMO Encoding flag
1318                        _encoding |=RESP_ENC_CIM;
1319 r.kieninger    1.1 }
1320                    
1321 thilo.boehm    1.3 void CIMResponseData::_resolveCIMToSCMO()
1322 r.kieninger    1.1 {
1323 thilo.boehm    1.3     CString nsCString=_defaultNamespace.getString().getCString();
1324                        const char* _defNamespace = nsCString;
1325                        Uint32 _defNamespaceLen;
1326                        if (_defaultNamespace.isNull())
1327 r.kieninger    1.1     {
1328 thilo.boehm    1.3         _defNamespaceLen=0;
1329 r.kieninger    1.1     }
1330                        else
1331                        {
1332 thilo.boehm    1.3         _defNamespaceLen=strlen(_defNamespace);
1333 r.kieninger    1.1     }
1334 thilo.boehm    1.3     switch (_dataType)
1335 r.kieninger    1.1     {
1336 thilo.boehm    1.3         case RESP_INSTNAMES:
1337 r.kieninger    1.1         {
1338 thilo.boehm    1.3             for (Uint32 i=0,n=_instanceNames.size();i<n;i++)
1339                                {
1340                                    SCMOInstance addme(
1341                                        _instanceNames[i],
1342                                        _defNamespace,
1343                                        _defNamespaceLen);
1344                                    _scmoInstances.append(addme);
1345                                }
1346                                _instanceNames.clear();
1347                                break;
1348 r.kieninger    1.1         }
1349 thilo.boehm    1.3         case RESP_INSTANCE:
1350 r.kieninger    1.2         {
1351 thilo.boehm    1.3             if (_instances.size() > 0)
1352                                {
1353                                    SCMOInstance addme(
1354                                        _instances[0],
1355                                        _defNamespace,
1356                                        _defNamespaceLen);
1357                                    _scmoInstances.clear();
1358                                    _scmoInstances.append(addme);
1359                                    _instances.clear();
1360                                }
1361                                break;
1362 r.kieninger    1.2         }
1363 thilo.boehm    1.3         case RESP_INSTANCES:
1364 r.kieninger    1.1         {
1365 thilo.boehm    1.3             for (Uint32 i=0,n=_instances.size();i<n;i++)
1366 r.kieninger    1.1             {
1367 thilo.boehm    1.3                 SCMOInstance addme(
1368                                        _instances[i],
1369                                        _defNamespace,
1370                                        _defNamespaceLen);
1371                                    _scmoInstances.append(addme);
1372 r.kieninger    1.1             }
1373 thilo.boehm    1.3             _instances.clear();
1374                                break;
1375                            }
1376                            case RESP_OBJECTS:
1377                            {
1378                                for (Uint32 i=0,n=_objects.size();i<n;i++)
1379 r.kieninger    1.1             {
1380 thilo.boehm    1.3                 SCMOInstance addme(
1381                                        _objects[i],
1382                                        _defNamespace,
1383                                        _defNamespaceLen);
1384                                    _scmoInstances.append(addme);
1385 r.kieninger    1.1             }
1386 thilo.boehm    1.3             _objects.clear();
1387                                break;
1388                            }
1389                            case RESP_OBJECTPATHS:
1390                            {
1391                                for (Uint32 i=0,n=_instanceNames.size();i<n;i++)
1392 r.kieninger    1.1             {
1393 thilo.boehm    1.3                 SCMOInstance addme(
1394                                        _instanceNames[i],
1395                                        _defNamespace,
1396                                        _defNamespaceLen);
1397                                    // TODO: More description about this.
1398                                    if (0 == _instanceNames[i].getKeyBindings().size())
1399                                    {
1400                                        // if there is no keybinding, this is a class
1401                                        addme.setIsClassOnly(true);
1402                                    }
1403                                    _scmoInstances.append(addme);
1404 r.kieninger    1.1             }
1405 thilo.boehm    1.3             _instanceNames.clear();
1406                                break;
1407 r.kieninger    1.1         }
1408 thilo.boehm    1.3         default:
1409 r.kieninger    1.1         {
1410 thilo.boehm    1.3             PEGASUS_DEBUG_ASSERT(false);
1411 r.kieninger    1.1         }
1412                        }
1413                    
1414 thilo.boehm    1.3     // remove CIM Encoding flag
1415                        _encoding &=(~RESP_ENC_CIM);
1416                        // add SCMO Encoding flag
1417                        _encoding |=RESP_ENC_SCMO;
1418 r.kieninger    1.1 }
1419                    
1420 anusha.kandepu 1.6 void CIMResponseData::setRequestProperties(
1421                        const Boolean includeQualifiers,
1422                        const Boolean includeClassOrigin,
1423                        const CIMPropertyList& propertyList)
1424                    {
1425                        _includeQualifiers = includeQualifiers;
1426                        _includeClassOrigin = includeClassOrigin;
1427                        _propertyList = propertyList; 
1428                    }
1429                    void CIMResponseData::getRequestProperties(
1430                        Boolean & includeQualifiers,
1431                        Boolean & includeClassOrigin,
1432                        CIMPropertyList& propertyList)
1433                    {
1434                        includeQualifiers = _includeQualifiers;
1435                        includeClassOrigin = _includeClassOrigin;
1436                        propertyList = _propertyList;
1437                    } 
1438                    
1439 r.kieninger    1.1 PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2