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

Diff for /pegasus/src/Pegasus/Common/CIMResponseData.cpp between version 1.5.2.12 and 1.5.2.25

version 1.5.2.12, 2013/09/29 19:09:50 version 1.5.2.25, 2014/04/27 22:54:45
Line 44 
Line 44 
 #include <Pegasus/Common/CIMInternalXmlEncoder.h> #include <Pegasus/Common/CIMInternalXmlEncoder.h>
 #include <Pegasus/Common/SCMOInternalXmlEncoder.h> #include <Pegasus/Common/SCMOInternalXmlEncoder.h>
  
 // KS_TODO_DELETE  
 #include <Pegasus/Common/Print.h>  
  
 PEGASUS_USING_STD; PEGASUS_USING_STD;
  
Line 54 
Line 52 
 // Defines debug code in CIMResponseData.  This under this // Defines debug code in CIMResponseData.  This under this
 // special compile flag so that it can be compiled independent of // special compile flag so that it can be compiled independent of
 // PEGASUS_DEBUG flags. // PEGASUS_DEBUG flags.
 #define CIMRESPONSEDATA_DEBUG  // #define CIMRESPONSEDATA_DEBUG
  
 #define LOCAL_MIN(a, b) ((a < b) ? a : b) #define LOCAL_MIN(a, b) ((a < b) ? a : b)
 // C++ objects interface handling  
  
 // KS_TODO Remove this completely when finished testing.  /*
 bool CIMResponseData::sizeValid()      Append an InstanceElement to the Buffer. This function accounts
       for the existence of a propertyList.
   */
   void CIMResponseData::_appendInstanceElement(
       Buffer& out,
       SCMOInstance _scmoInstance)
 { {
     PEGASUS_DEBUG_ASSERT(valid());      if(_propertyList.isNull())
 #ifdef CIMRESPONSEDATA_DEBUG  
     if (_size > 1000000)  
     {     {
         cout << "CIMResponseData::PSVALID _size too big " << _size << endl;          Array<Uint32> emptyNodes;
         PEG_TRACE((TRC_XML, Tracer::LEVEL4,          SCMOXmlWriter::appendInstanceElement(
                    "CIMResponseData::PSVALID _size too big %u",_size ));              out,
         return false;              _scmoInstance,
               false,
               emptyNodes);
     }     }
 #endif      else
     PEG_TRACE((TRC_XML, Tracer::LEVEL4,      {
         "CIMResponseData Size _size=%u", _size));          Array<propertyFilterNodesArray_t> propFilterNodesArrays;
     return true;          // This searches for an already created array of nodes,
           //if not found, creates it inside propFilterNodesArrays
           const Array<Uint32> & nodes=
               SCMOXmlWriter::getFilteredNodesArray(
                   propFilterNodesArrays,
                   _scmoInstance,
                   _propertyList);
           SCMOXmlWriter::appendInstanceElement(
               out,
               _scmoInstance,
               true,
               nodes);
 } }
   }
   
 // Instance Names handling // Instance Names handling
 Array<CIMObjectPath>& CIMResponseData::getInstanceNames() Array<CIMObjectPath>& CIMResponseData::getInstanceNames()
 { {
     PSVALID;  
     PEGASUS_DEBUG_ASSERT(     PEGASUS_DEBUG_ASSERT(
     (_dataType==RESP_INSTNAMES || _dataType==RESP_OBJECTPATHS));     (_dataType==RESP_INSTNAMES || _dataType==RESP_OBJECTPATHS));
     _resolveToCIM();     _resolveToCIM();
Line 175 
Line 189 
 { {
  
     PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setSCMO");     PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setSCMO");
     //// AutoMutex autoMut(testLock);  
     PSVALID;  
     _scmoInstances=x;     _scmoInstances=x;
     _encoding |= RESP_ENC_SCMO;     _encoding |= RESP_ENC_SCMO;
     _size += x.size();     _size += x.size();
Line 193 
Line 205 
 bool CIMResponseData::setBinary(CIMBuffer& in) bool CIMResponseData::setBinary(CIMBuffer& in)
 { {
     PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setBinary");     PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setBinary");
     //// AutoMutex autoMut(testLock);  
  
     // Append all serial data from the CIMBuffer to the local data store.     // Append all serial data from the CIMBuffer to the local data store.
     // Returns error if input not a serialized Uint8A     // Returns error if input not a serialized Uint8A
Line 211 
Line 222 
  
 bool CIMResponseData::setRemainingBinaryData(CIMBuffer& in) bool CIMResponseData::setRemainingBinaryData(CIMBuffer& in)
 { {
     //// AutoMutex autoMut(testLock);  
     PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setRemainingBinaryData");     PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setRemainingBinaryData");
  
     // Append any data that has not been deserialized already from     // Append any data that has not been deserialized already from
Line 385 
Line 395 
 { {
     PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::moveObjects");     PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::moveObjects");
  
     //// AutoMutex autoMut(testLock);  
   
     PEG_TRACE((TRC_XML, Tracer::LEVEL3,     PEG_TRACE((TRC_XML, Tracer::LEVEL3,
         "CIMResponseData::move(%u)", count));         "CIMResponseData::move(%u)", count));
  
Line 538 
Line 546 
     PEGASUS_ASSERT(rtnSize == (count - toMove));     PEGASUS_ASSERT(rtnSize == (count - toMove));
  
     _size += rtnSize;     _size += rtnSize;
   
       // insure that _size never goes negative.  This is probably a
       // diagnostics KS_TODO remove before release
       if (from._size >= rtnSize)
       {
   
     from._size -= rtnSize;     from._size -= rtnSize;
       }
       else
       {
           from._size = 0;
           //// KS_TODO Diagnostic since this should never occur
           PEG_TRACE((TRC_XML, Tracer::LEVEL1,
               "Size in from set to zero from= %u rtnSize= %u",
                   from._size, rtnSize));
       }
  
     //// KS_TODO diagnostic that we should be able to remove     //// KS_TODO diagnostic that we should be able to remove
     if (rtnSize != _size)     if (rtnSize != _size)
Line 608 
Line 631 
     }     }
     _size = rtnSize;     _size = rtnSize;
 } }
   
 // Return the number of CIM objects in the CIM Response data object  
 // //
 #define TEMPLOG PEG_TRACE((TRC_XML, Tracer::LEVEL4, \  // Return the number of CIM objects in the CIM Response data object by
  "rtnSize %u size %u line %u", rtnSize, _size, __LINE__))  // aggregating sizes of each of the encodings
 //#define TEMPLOG cout << "rtnSize " << rtnSize << " _size " << _size  //
 //<< " line " << __LINE__ << endl  
   
 Uint32 CIMResponseData::size() Uint32 CIMResponseData::size()
 { {
     AutoMutex autoMut(testLock);  
     PEG_METHOD_ENTER(TRC_XML,"CIMResponseData::size()");  
     PSVALID;  
 // If debug mode, add up all the individual size components to // If debug mode, add up all the individual size components to
 // determine overall size of this object.  Then compare this with // determine overall size of this object.  Then compare this with
 // the _size variable.  this is a good check on the completeness of the  // the _size variable.  This is a check on the completeness of the
 // size computations.  We should be able to remove this at some point // size computations.  We should be able to remove this at some point
 // but there are many sources of size info and we need to be sure we // but there are many sources of size info and we need to be sure we
 // have covered them all. // have covered them all.
 #ifdef PEGASUS_DEBUG  #ifdef CIMRESPONSEDATA_DEBUG
     PEGASUS_DEBUG_ASSERT(valid());            //KS_TEMP KS_TODO      PEGASUS_DEBUG_ASSERT(valid());
  
     Uint32 rtnSize = 0;     Uint32 rtnSize = 0;
     TEMPLOG;  
     if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))     if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
     {     {
         TEMPLOG;  
         switch (_dataType)         switch (_dataType)
         {         {
             case RESP_OBJECTPATHS:             case RESP_OBJECTPATHS:
Line 648 
Line 663 
                 rtnSize += _instanceData.size();                 rtnSize += _instanceData.size();
                 break;                 break;
         }         }
         PSVALID;  
         TEMPLOG;  
     }     }
     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
     {     {
         TEMPLOG;  
         // KS_PULL_TODO         // KS_PULL_TODO
         // Cannot resolve this one without actually processing         // Cannot resolve this one without actually processing
         // the data since it is a stream.         // the data since it is a stream.
         rtnSize += 0;         rtnSize += 0;
         //  KS_TODO flag on this one         //  KS_TODO flag on this one
         //// PEGASUS_ASSERT(false);  
         TEMPLOG;  
     }     }
  
     if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))     if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
     {     {
         PSVALID;  
         TEMPLOG;  
         rtnSize += _scmoInstances.size();         rtnSize += _scmoInstances.size();
         TEMPLOG;  
     }     }
  
     if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))     if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
     {     {
         PSVALID;  
         TEMPLOG;  
         switch (_dataType)         switch (_dataType)
         {         {
             case RESP_OBJECTPATHS:             case RESP_OBJECTPATHS:
Line 689 
Line 694 
                 rtnSize += _objects.size();                 rtnSize += _objects.size();
                 break;                 break;
         }         }
         PSVALID;  
         TEMPLOG;  
     }     }
     // Test of actual count against _size variable. KS_TODO diagnostic     // Test of actual count against _size variable. KS_TODO diagnostic
     if (rtnSize != _size)      Uint32 lsize = _size;
       if (rtnSize != lsize)
     {     {
         TEMPLOG;  
         PSVALID;  
         PEG_TRACE((TRC_XML, Tracer::LEVEL1,         PEG_TRACE((TRC_XML, Tracer::LEVEL1,
         "CIMResponseData::size ERROR. debug size mismatch."         "CIMResponseData::size ERROR. debug size mismatch."
             "Computed = %u. variable = %u",rtnSize, _size ));              "Computed = %u. variable = %u inc binary %s",rtnSize, _size,
         // KS_TEMP           boolToString(RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
         cout << "Size err Computed(rtnsize)=" << rtnSize << " _size=" << _size                                ));
              << " diff=" << (rtnSize - _size) << endl;  
         TEMPLOG;  
     }     }
     PEG_TRACE((TRC_XML, Tracer::LEVEL1, "ReturnSize=%u", _size ));     PEG_TRACE((TRC_XML, Tracer::LEVEL1, "ReturnSize=%u", _size ));
 #endif #endif
     PEG_METHOD_EXIT();  
     return _size;     return _size;
 } }
  
Line 719 
Line 718 
 { {
     PEG_METHOD_ENTER(TRC_DISPATCHER,     PEG_METHOD_ENTER(TRC_DISPATCHER,
         "CIMResponseData::appendResponseData");         "CIMResponseData::appendResponseData");
     //// AutoMutex autoMut(testLock);  
     // Confirm that the CIMResponseData type matches the type     // Confirm that the CIMResponseData type matches the type
     // of the data being appended     // of the data being appended
  
Line 744 
Line 742 
     _size += x._scmoInstances.size();     _size += x._scmoInstances.size();
  
     // add Xml encodings     // add Xml encodings
     // KS_TBD - FIX _Size stuff here also.      // KS_TODO these are temporary. delete before release
       PEGASUS_ASSERT(x._referencesData.size() == x._instanceData.size());
       PEGASUS_ASSERT(x._instanceData.size() == x._hostsData.size());
       PEGASUS_ASSERT(x._instanceData.size() == x._nameSpacesData.size());
   
     _referencesData.appendArray(x._referencesData);     _referencesData.appendArray(x._referencesData);
     _instanceData.appendArray(x._instanceData);     _instanceData.appendArray(x._instanceData);
     _hostsData.appendArray(x._hostsData);     _hostsData.appendArray(x._hostsData);
     _nameSpacesData.appendArray(x._nameSpacesData);     _nameSpacesData.appendArray(x._nameSpacesData);
       _size += x._instanceData.size();
  
     // transfer property list     // transfer property list
     _propertyList = x._propertyList;     _propertyList = x._propertyList;
Line 762 
Line 765 
     PEG_METHOD_ENTER(TRC_DISPATCHER,     PEG_METHOD_ENTER(TRC_DISPATCHER,
         "CIMResponseData::encodeBinaryResponse");         "CIMResponseData::encodeBinaryResponse");
  
     PSVALID;  
   
     // Need to do a complete job here by transferring all contained data     // Need to do a complete job here by transferring all contained data
     // into binary format and handing it out in the CIMBuffer     // into binary format and handing it out in the CIMBuffer
     // KS_TODO     // KS_TODO
     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
     {     {
         PEGASUS_ASSERT(false);   // KS_TEMP  
   
         // Binary does NOT need a marker as it consists of C++ and SCMO         // Binary does NOT need a marker as it consists of C++ and SCMO
         const Array<Uint8>& data = _binaryData;         const Array<Uint8>& data = _binaryData;
         out.putBytes(data.getData(), data.size());         out.putBytes(data.getData(), data.size());
Line 812 
Line 811 
             }             }
             default:             default:
             {             {
                 PEGASUS_ASSERT(false);                  PEGASUS_DEBUG_ASSERT(false);
             }             }
         }         }
     }     }
Line 824 
Line 823 
     if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))     if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
     {     {
         // This actually should not happen following general code logic         // This actually should not happen following general code logic
         PEGASUS_ASSERT(false);          PEGASUS_DEBUG_ASSERT(false);
     }     }
  
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
Line 931 
Line 930 
  
     PEGASUS_DEBUG_ASSERT(valid());            // KS_TEMP     PEGASUS_DEBUG_ASSERT(valid());            // KS_TEMP
  
       Uint32 count = 0;      //// KS_TODO this counter is just diagnostic
   
           PEG_TRACE(( TRC_DISPATCHER, Tracer::LEVEL4,   // KS_TODO TEMP
             "completeHostNameAndNamespace Setting hostName, etc "
             "host %s ns %s set for dataType=%u encoding=%u isPull=%s",
                 (const char *)hn.getCString(),
                 (const char *)ns.getString().getCString(),
                 _dataType, _encoding, boolToString(isPullOperation) ));
   
     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
     {     {
         // On binary need remember hostname and namespace in case someone          // On binary need to remember hostname and namespace in case someone
         // builds C++ default objects or Xml types from it later on          // builds C++ default objects or Xml types later i.e.
         // -> usage: See resolveBinary()         // -> usage: See resolveBinary()
         _defaultNamespace=ns;         _defaultNamespace=ns;
         _defaultHostname=hn;         _defaultHostname=hn;
           count++;
     }     }
     // InternalXml does not support objectPath calls     // InternalXml does not support objectPath calls
     if ((RESP_ENC_XML == (_encoding & RESP_ENC_XML)) &&     if ((RESP_ENC_XML == (_encoding & RESP_ENC_XML)) &&
Line 948 
Line 957 
             if (0 == _hostsData[j].size())             if (0 == _hostsData[j].size())
             {             {
                 _hostsData[j]=hn;                 _hostsData[j]=hn;
                   count++;
             }             }
             if (_nameSpacesData[j].isNull())             if (_nameSpacesData[j].isNull())
             {             {
Line 963 
Line 973 
         {         {
             if (0 == _hostsData[j].size())             if (0 == _hostsData[j].size())
             {             {
                   count++;
                 _hostsData[j]=hn;                 _hostsData[j]=hn;
             }             }
             if (_nameSpacesData[j].isNull())             if (_nameSpacesData[j].isNull())
Line 970 
Line 981 
                 _nameSpacesData[j]=ns;                 _nameSpacesData[j]=ns;
             }             }
  
             // TODO Remove Diagnostic              // KS_TODO Remove Diagnostic
             PEG_TRACE(( TRC_DISPATCHER, Tracer::LEVEL4,             PEG_TRACE(( TRC_DISPATCHER, Tracer::LEVEL4,
               "completeHostNameAndNamespace Setting hostName, etc "               "completeHostNameAndNamespace Setting hostName, etc "
               "host %s ns %s set to _hostData %s _namespaceData %s",               "host %s ns %s set to _hostData %s _namespaceData %s",
Line 995 
Line 1006 
                         const_cast<CIMObjectPath&>(instance.getPath());                         const_cast<CIMObjectPath&>(instance.getPath());
                     if (p.getHost().size()==0)                     if (p.getHost().size()==0)
                     {                     {
                           count++;
                         p.setHost(hn);                         p.setHost(hn);
                     }                     }
                     if (p.getNameSpace().isNull())                     if (p.getNameSpace().isNull())
Line 1011 
Line 1023 
                         const_cast<CIMObjectPath&>(object.getPath());                         const_cast<CIMObjectPath&>(object.getPath());
                     if (p.getHost().size()==0)                     if (p.getHost().size()==0)
                     {                     {
                           count++;
                         p.setHost(hn);                         p.setHost(hn);
                     }                     }
                     if (p.getNameSpace().isNull())                     if (p.getNameSpace().isNull())
Line 1030 
Line 1043 
                     CIMObjectPath& p = _instanceNames[j];                     CIMObjectPath& p = _instanceNames[j];
                     if (p.getHost().size() == 0)                     if (p.getHost().size() == 0)
                     {                     {
                           count++;
                         p.setHost(hn);                         p.setHost(hn);
                     }                     }
                     if (p.getNameSpace().isNull())                     if (p.getNameSpace().isNull())
Line 1041 
Line 1055 
             }             }
             default:             default:
             {             {
                 PEGASUS_ASSERT(false);                  PEGASUS_DEBUG_ASSERT(false);
             }             }
         }         }
     }     }
Line 1064 
Line 1078 
             {             {
                 for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++)                 for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++)
                 {                 {
                       count++;
                     SCMOInstance & scmoInst=_scmoInstances[j];                     SCMOInstance & scmoInst=_scmoInstances[j];
                     scmoInst.completeHostNameAndNamespace(                     scmoInst.completeHostNameAndNamespace(
                         hnChars,                         hnChars,
Line 1075 
Line 1090 
             }             }
             default:             default:
             {             {
                 PEGASUS_ASSERT(false);                  PEGASUS_DEBUG_ASSERT(false);
             }             }
         }         }
     }     }
       PEG_TRACE(( TRC_DISPATCHER, Tracer::LEVEL4,   // KS_TODO TEMP
         "completeHostNameAndNamespace Set hostName, etc count %u "
         "host %s ns %s set for dataType=%u encoding=%u isPull=%s",
             count,
             (const char *)hn.getCString(),
             (const char *)ns.getString().getCString(),
             _dataType, _encoding, boolToString(isPullOperation) ));
   
   
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
  
 // NOTE: The reason for the isPullResponse variable is that there are // NOTE: The reason for the isPullResponse variable is that there are
 // some variations in ouput to Xml depending on whether the responses // some variations in ouput to Xml depending on whether the responses
 // are one of the pull responses or not // are one of the pull responses or not
 void CIMResponseData::encodeXmlResponse(Buffer& out, Boolean isPullResponse)  void CIMResponseData::encodeXmlResponse(Buffer& out,
       Boolean isPullResponse,
       Boolean encodeInstanceOnly)
 { {
     PEG_METHOD_ENTER(TRC_DISPATCHER,     PEG_METHOD_ENTER(TRC_DISPATCHER,
         "CIMResponseData::encodeXmlResponse");         "CIMResponseData::encodeXmlResponse");
  
     PEG_TRACE((TRC_XML, Tracer::LEVEL3,     PEG_TRACE((TRC_XML, Tracer::LEVEL3,
         "CIMResponseData::encodeXmlResponse(encoding=%X,dataType=%X, pull= %s)",          "CIMResponseData::encodeXmlResponse(encoding=%X,dataType=%X, isPull= %s"
           " encodeInstanceOnly= %s)",
         _encoding,         _encoding,
         _dataType,         _dataType,
         (isPullResponse? "true" : "false")));          boolToString(isPullResponse),
           boolToString(encodeInstanceOnly) ));
  
     // already existing Internal XML does not need to be encoded further     // already existing Internal XML does not need to be encoded further
     // binary input is not actually impossible here, but we have an established     // binary input is not actually impossible here, but we have an established
     // fallback     // fallback
     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
     {     {
         _resolveBinary();          _resolveBinaryToSCMO();
     }     }
     if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))     if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
     {     {
Line 1122 
Line 1150 
                 {                 {
                     if (isPullResponse)                     if (isPullResponse)
                     {                     {
                           // KS_TODO these are temporary. delete before release
                           PEGASUS_ASSERT(a.size() == b.size());
                           PEGASUS_ASSERT(a.size() == _hostsData.size());
                           PEGASUS_ASSERT(a.size() == _nameSpacesData.size());
   
                         out << STRLIT("<VALUE.INSTANCEWITHPATH>\n");                         out << STRLIT("<VALUE.INSTANCEWITHPATH>\n");
                     }                          out << STRLIT("<INSTANCEPATH>\n");
                     else                          XmlWriter::appendNameSpacePathElement(out,
                     {                              _hostsData[i],
                         out << STRLIT("<VALUE.NAMEDINSTANCE>\n");                              _nameSpacesData[i]);
                     }  
                     out.append((char*)b[i].getData(), b[i].size() - 1);                     out.append((char*)b[i].getData(), b[i].size() - 1);
                           out << STRLIT("</INSTANCEPATH>\n");
                     out.append((char*)a[i].getData(), a[i].size() - 1);                     out.append((char*)a[i].getData(), a[i].size() - 1);
                     if (isPullResponse)  
                     {  
                         out << STRLIT("</VALUE.INSTANCEWITHPATH>\n");                         out << STRLIT("</VALUE.INSTANCEWITHPATH>\n");
                     }                     }
                     else                     else
                     {                     {
                           out << STRLIT("<VALUE.NAMEDINSTANCE>\n");
                           out.append((char*)b[i].getData(), b[i].size() - 1);
                           out.append((char *)a[i].getData(), a[i].size() - 1);
                         out << STRLIT("</VALUE.NAMEDINSTANCE>\n");                         out << STRLIT("</VALUE.NAMEDINSTANCE>\n");
                     }                     }
                 }                 }
Line 1145 
Line 1179 
             {             {
                 const Array<ArraySint8>& a = _instanceData;                 const Array<ArraySint8>& a = _instanceData;
                 const Array<ArraySint8>& b = _referencesData;                 const Array<ArraySint8>& b = _referencesData;
   
                 for (Uint32 i = 0, n = a.size(); i < n; i++)                 for (Uint32 i = 0, n = a.size(); i < n; i++)
                 {                 {
                       if (isPullResponse)
                       {
                           out << STRLIT("<VALUE.INSTANCEWITHPATH>\n");
                       }
                       else
                       {
                     out << STRLIT("<VALUE.OBJECTWITHPATH>\n");                     out << STRLIT("<VALUE.OBJECTWITHPATH>\n");
                       }
                     out << STRLIT("<INSTANCEPATH>\n");                     out << STRLIT("<INSTANCEPATH>\n");
                     XmlWriter::appendNameSpacePathElement(                     XmlWriter::appendNameSpacePathElement(
                             out,                             out,
                             _hostsData[i],                             _hostsData[i],
                             _nameSpacesData[i]);                             _nameSpacesData[i]);
   
                       if (isPullResponse)
                       {
                           out.append((char*)b[i].getData(),b[i].size()-1);
                       }
                       else
                       {
                     // Leave out the surrounding tags "<VALUE.REFERENCE>\n"                     // Leave out the surrounding tags "<VALUE.REFERENCE>\n"
                     // and "</VALUE.REFERENCE>\n" which are 18 and 19 characters                          // and "</VALUE.REFERENCE>\n" which are 18 and 19
                     // long                          // characters long
                           //// KS_TODO Should be able to do this by properly
                           //// building in the CIMXmlInternalEncoder
                     out.append(                     out.append(
                         ((char*)b[i].getData())+18,                         ((char*)b[i].getData())+18,
                         b[i].size() - 1 - 18 -19);                         b[i].size() - 1 - 18 -19);
                       }
   
                     out << STRLIT("</INSTANCEPATH>\n");                     out << STRLIT("</INSTANCEPATH>\n");
                     // append instance body                     // append instance body
                     out.append((char*)a[i].getData(), a[i].size() - 1);                     out.append((char*)a[i].getData(), a[i].size() - 1);
                       if (isPullResponse)
                       {
                           out << STRLIT("</VALUE.INSTANCEWITHPATH>\n");
                       }
                       else
                       {
                     out << STRLIT("</VALUE.OBJECTWITHPATH>\n");                     out << STRLIT("</VALUE.OBJECTWITHPATH>\n");
                 }                 }
                   }
                 break;                 break;
             }             }
             // internal xml encoding of instance names and object paths not             // internal xml encoding of instance names and object paths not
Line 1218 
Line 1278 
                 {                 {
                     if (isPullResponse)                     if (isPullResponse)
                     {                     {
                           if (encodeInstanceOnly)
                           {
                               XmlWriter::appendInstanceElement(
                                   out,
                                   _instances[i],
                                   _includeQualifiers,
                                   _includeClassOrigin,
                                   _propertyList);
                           }
                           else
                           {
                         XmlWriter::appendValueInstanceWithPathElement(                         XmlWriter::appendValueInstanceWithPathElement(
                             out,                             out,
                             _instances[i],                             _instances[i],
Line 1225 
Line 1296 
                             _includeClassOrigin,                             _includeClassOrigin,
                             _propertyList);                             _propertyList);
                     }                     }
                       }
                     else                     else
                     {                     {
                         XmlWriter::appendValueNamedInstanceElement(                         XmlWriter::appendValueNamedInstanceElement(
Line 1246 
Line 1318 
                     {                     {
                         CIMInstance x = (CIMInstance)_objects[i];                         CIMInstance x = (CIMInstance)_objects[i];
                         XmlWriter::appendValueInstanceWithPathElement(                         XmlWriter::appendValueInstanceWithPathElement(
                             out, x,                              out,
                               x,
                             _includeQualifiers,                             _includeQualifiers,
                             _includeClassOrigin,                             _includeClassOrigin,
                             _propertyList);                             _propertyList);
Line 1269 
Line 1342 
                 for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++)                 for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++)
                 {                 {
                     // ObjectPaths come from providers for pull operations                     // ObjectPaths come from providers for pull operations
                     // but are encoded as instancePathElements                      // but are encoded as instancePathElements. If pull
                       // only instances allowed.
                     if (isPullResponse)                     if (isPullResponse)
   
                     {                     {
                         XmlWriter::appendInstancePathElement(out,                          XmlWriter::appendInstancePathElement(
                               out,
                            _instanceNames[i]);                            _instanceNames[i]);
                     }                     }
                     else                     else
                     {                     {
                           //Append The path element (Class or instance)
                         out << "<OBJECTPATH>\n";                         out << "<OBJECTPATH>\n";
                         XmlWriter::appendValueReferenceElement(                          XmlWriter::appendClassOrInstancePathElement(
                             out,                             out,
                             _instanceNames[i],                             _instanceNames[i],
                         _isClassOperation,                              _isClassOperation);
                             false);  
                         out << "</OBJECTPATH>\n";                         out << "</OBJECTPATH>\n";
                     }                     }
                 }                 }
Line 1301 
Line 1375 
         {         {
             case RESP_INSTNAMES:             case RESP_INSTNAMES:
             {             {
                 if (isPullResponse)  
                 {  
                     for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++)                     for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++)
                     {                     {
                       if (isPullResponse)
                       {
                         SCMOXmlWriter::appendInstancePathElement(                         SCMOXmlWriter::appendInstancePathElement(
                             out,                             out,
                             _scmoInstances[i]);                             _scmoInstances[i]);
   
                     }  
                 }                 }
                 else                 else
                 {                 {
                     for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++)  
                     {  
                         SCMOXmlWriter::appendInstanceNameElement(                         SCMOXmlWriter::appendInstanceNameElement(
                             out,                             out,
                             _scmoInstances[i]);                             _scmoInstances[i]);
   
                     }                     }
                 }                 }
                 break;                 break;
Line 1327 
Line 1396 
             {             {
                 if (_scmoInstances.size() > 0)                 if (_scmoInstances.size() > 0)
                 {                 {
                     if(_propertyList.isNull())                      _appendInstanceElement(out, _scmoInstances[0]);
                     {  
                         Array<Uint32> emptyNodes;  
                         SCMOXmlWriter::appendInstanceElement(  
                             out,  
                             _scmoInstances[0],  
                             false,  
                             emptyNodes);  
                     }  
                     else  
                     {  
                         Array<propertyFilterNodesArray_t> propFilterNodesArrays;  
                         // This searches for an already created array of nodes,  
                         //if not found, creates it inside propFilterNodesArrays  
                         const Array<Uint32> & nodes=  
                             SCMOXmlWriter::getFilteredNodesArray(  
                                 propFilterNodesArrays,  
                                 _scmoInstances[0],  
                                 _propertyList);  
                         SCMOXmlWriter::appendInstanceElement(  
                             out,  
                             _scmoInstances[0],  
                             true,  
                             nodes);  
                     }  
                 }                 }
                 break;                 break;
             }             }
Line 1359 
Line 1404 
             {             {
                 if (isPullResponse)                 if (isPullResponse)
                 {                 {
                       // pull and encodeInstanceOnly (i.e. response to
                       // OpenQueryInstances and pullInstances
                       if (encodeInstanceOnly)
                       {
                           for (Uint32 i = 0, n = _scmoInstances.size();i < n; i++)
                           {
                               _appendInstanceElement(out, _scmoInstances[i]);
                           }
                       }
                       else
                       {
                     SCMOXmlWriter::appendValueSCMOInstanceWithPathElements(                     SCMOXmlWriter::appendValueSCMOInstanceWithPathElements(
                         out, _scmoInstances, _propertyList);                         out, _scmoInstances, _propertyList);
                 }                 }
                   }
                 else                 else
                 {                 {
                     SCMOXmlWriter::appendValueSCMOInstanceElements(                     SCMOXmlWriter::appendValueSCMOInstanceElements(
Line 1397 
Line 1454 
                     else                     else
                     {                     {
                         out << "<OBJECTPATH>\n";                         out << "<OBJECTPATH>\n";
                         SCMOXmlWriter::appendValueReferenceElement(                          SCMOXmlWriter::appendClassOrInstancePathElement(
                             out, _scmoInstances[i],                              out, _scmoInstances[i]);
                             false);  
                         out << "</OBJECTPATH>\n";                         out << "</OBJECTPATH>\n";
                     }                     }
                 }                 }
Line 1411 
Line 1467 
             }             }
         }         }
     }     }
   
     PEG_METHOD_EXIT();     PEG_METHOD_EXIT();
 } }
  
 // contrary to encodeXmlResponse this function encodes the Xml in a format // contrary to encodeXmlResponse this function encodes the Xml in a format
 // not usable by clients // not usable by clients
 void CIMResponseData::encodeInternalXmlResponse(CIMBuffer& out)  void CIMResponseData::encodeInternalXmlResponse(CIMBuffer& out,
       Boolean isPullOperation)
 { {
     PEG_METHOD_ENTER(TRC_DISPATCHER,     PEG_METHOD_ENTER(TRC_DISPATCHER,
         "CIMResponseData::encodeInternalXmlResponse");         "CIMResponseData::encodeInternalXmlResponse");
  
     PEG_TRACE((TRC_XML, Tracer::LEVEL3,     PEG_TRACE((TRC_XML, Tracer::LEVEL3,
         "CIMResponseData::encodeInternalXmlResponse(encoding=%X,content=%X)",          "CIMResponseData::encodeInternalXmlResponse(encoding=%X,content=%X"
           " isPullOperation=%s)",
         _encoding,         _encoding,
         _dataType));          _dataType,
           boolToString(isPullOperation)));
   
     // For mixed (CIM+SCMO) responses, we need to tell the receiver the     // For mixed (CIM+SCMO) responses, we need to tell the receiver the
     // total number of instances. The totalSize variable is used to keep track     // total number of instances. The totalSize variable is used to keep track
     // of this.     // of this.
Line 1436 
Line 1495 
     // fallback     // fallback
     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
     {     {
         _resolveBinary();          _resolveBinaryToSCMO();
     }     }
     if ((0 == _encoding) ||     if ((0 == _encoding) ||
         (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)))         (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)))
Line 1484 
Line 1543 
                 out.putUint32(totalSize);                 out.putUint32(totalSize);
                 for (Uint32 i = 0; i < n; i++)                 for (Uint32 i = 0; i < n; i++)
                 {                 {
                       // if is pull map to instances.
                       if (isPullOperation)
                       {
                           CIMInternalXmlEncoder::_putXMLNamedInstance(
                               out,
                               (CIMInstance)_objects[i],
                               _includeQualifiers,
                               _includeClassOrigin,
                               _propertyList);
                       }
                       else
                       {
                     CIMInternalXmlEncoder::_putXMLObject(                     CIMInternalXmlEncoder::_putXMLObject(
                         out,                         out,
                         _objects[i],                         _objects[i],
Line 1491 
Line 1562 
                         _includeClassOrigin,                         _includeClassOrigin,
                         _propertyList);                         _propertyList);
                 }                 }
                   }
                 break;                 break;
             }             }
             // internal xml encoding of instance names and object paths not             // internal xml encoding of instance names and object paths not
Line 1499 
Line 1571 
             case RESP_OBJECTPATHS:             case RESP_OBJECTPATHS:
             default:             default:
             {             {
                 PEGASUS_ASSERT(false);                  PEGASUS_DEBUG_ASSERT(false);
             }             }
         }         }
     }     }
Line 1541 
Line 1613 
                 {                 {
                     out.putUint32(n);                     out.putUint32(n);
                 }                 }
                       // if is pull map to instances.
                   if (isPullOperation)
                   {
                       SCMOInternalXmlEncoder::_putXMLNamedInstance(
                           out,
                           _scmoInstances,
                           _propertyList);
                   }
                   else
                   {
                 SCMOInternalXmlEncoder::_putXMLObject(                 SCMOInternalXmlEncoder::_putXMLObject(
                     out,                     out,
                     _scmoInstances,                     _scmoInstances,
                     _propertyList);                     _propertyList);
                   }
                 break;                 break;
             }             }
             // internal xml encoding of instance names and object paths not             // internal xml encoding of instance names and object paths not
Line 1553 
Line 1636 
             case RESP_OBJECTPATHS:             case RESP_OBJECTPATHS:
             default:             default:
             {             {
                 PEGASUS_ASSERT(false);                  PEGASUS_DEBUG_ASSERT(false);
             }             }
         }         }
     }     }
Line 1573 
Line 1656 
     }     }
     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
     {     {
         _resolveBinary();          _resolveBinaryToSCMO();
     }     }
     if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))     if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
     {     {
Line 1583 
Line 1666 
     PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_CIM || _encoding == 0);     PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_CIM || _encoding == 0);
 } }
  
   // Resolve any binary data to SCMO. This externalfunction added because we
   // cannot do a move on Binary data so convert it a to movable format
   void CIMResponseData::resolveBinaryToSCMO()
   {
       PEG_METHOD_ENTER(TRC_DISPATCHER,
           "CIMResponseData::resolveBinaryToSCMO");
       if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
       {
           _resolveBinaryToSCMO();
       }
       PEG_METHOD_EXIT();
   }
   
 void CIMResponseData::_resolveToSCMO() void CIMResponseData::_resolveToSCMO()
 { {
     PEG_TRACE((TRC_XML, Tracer::LEVEL3,     PEG_TRACE((TRC_XML, Tracer::LEVEL3,
Line 1596 
Line 1692 
     }     }
     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))     if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
     {     {
         _resolveBinary();          _resolveBinaryToSCMO();
     }     }
     if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))     if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
     {     {
Line 1608 
Line 1704 
 // helper functions to transform different formats into one-another // helper functions to transform different formats into one-another
 // functions work on the internal data and calling of them should be // functions work on the internal data and calling of them should be
 // avoided whenever possible // avoided whenever possible
 void CIMResponseData::_resolveBinary()  void CIMResponseData::_resolveBinaryToSCMO()
 { {
     PEG_METHOD_ENTER(TRC_DISPATCHER,     PEG_METHOD_ENTER(TRC_DISPATCHER,
         "CIMResponseData::_resolveBinary");          "CIMResponseData::_resolveBinaryToSCMO");
  
     CIMBuffer in((char*)_binaryData.getData(), _binaryData.size());     CIMBuffer in((char*)_binaryData.getData(), _binaryData.size());
  
Line 1705 
Line 1801 
                 }                 }
                 default:                 default:
                 {                 {
                     PEGASUS_ASSERT(false);                      PEGASUS_DEBUG_ASSERT(false);
                 }                 }
             } // switch             } // switch
             _encoding |= RESP_ENC_CIM;             _encoding |= RESP_ENC_CIM;
Line 1970 
Line 2066 
         }         }
         default:         default:
         {         {
             PEGASUS_ASSERT(false);              PEGASUS_DEBUG_ASSERT(false);
         }         }
     }     }
     _scmoInstances.clear();     _scmoInstances.clear();
Line 2071 
Line 2167 
         }         }
         default:         default:
         {         {
             PEGASUS_ASSERT(false);              PEGASUS_DEBUG_ASSERT(false);
         }         }
     }     }
  
Line 2110 
Line 2206 
     _isClassOperation = b;     _isClassOperation = b;
 } }
  
 //// KS_TODO Remove. Diagnostic Display  //// KS_TODO Remove. Diagnostic Displays below before commit to head
 void CIMResponseData::traceResponseData() void CIMResponseData::traceResponseData()
 { {
     PEG_TRACE((TRC_XML, Tracer::LEVEL3,     PEG_TRACE((TRC_XML, Tracer::LEVEL3,
           "%s", (const char*)toStringTraceResponseData().getCString() ));
   }
   String CIMResponseData::toStringTraceResponseData()
   {
       int rtnSize;
       char *p;
   
       int allocSize = 256;
   
       if ((p = (char*)malloc(allocSize)) == NULL)
       {
           return String();
       }
   
       do
       {
           rtnSize = snprintf(p, allocSize,
         "CIMResponseData::traceResponseData(encoding=%X,dataType=%X "         "CIMResponseData::traceResponseData(encoding=%X,dataType=%X "
         " size %u C++instNamecount %u c++Instances %u c++Objects %u "          " size=%u C++instNamecount=%u c++Instances=%u c++Objects=%u "
         "scomInstances %u XMLInstData %u binaryuData %u "          "scomInstances=%u XMLInstData=%u binaryData=%u "
         "xmlref %u xmlinst %u, xmlhost %u xmlns %u",          "xmlref=%u xmlinst=%u, xmlhost=%u xmlns=%u",
         _encoding,_dataType, _size,         _encoding,_dataType, _size,
         _instanceNames.size(),_instances.size(), _objects.size(),         _instanceNames.size(),_instances.size(), _objects.size(),
         _scmoInstances.size(),_instanceData.size(),_binaryData.size(),         _scmoInstances.size(),_instanceData.size(),_binaryData.size(),
         _referencesData.size(), _instanceData.size(), _hostsData.size(),         _referencesData.size(), _instanceData.size(), _hostsData.size(),
         _nameSpacesData.size()        ));          _nameSpacesData.size());
   
           // return if successful if not negative and
           // returns less than allocated size.
           if (rtnSize > -1 && rtnSize < allocSize)
           {
               break;
           }
   
           // increment alloc size. Assumes that positive return is
           // expected size and negative is error.
           allocSize = (rtnSize > -1)? (rtnSize + 1) : allocSize * 2;
   
       } while((p = (char*)peg_inln_realloc(p, allocSize)) != NULL);
   
       // Free allocated memory and return formatted output in String
       String rtnStr(p);
       free(p);
       return(rtnStr);
 } }
  
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.5.2.12  
changed lines
  Added in v.1.5.2.25

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2