version 1.2.2.2, 2009/09/03 13:54:05
|
version 1.2.2.22, 2009/11/30 10:59:36
|
|
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include "CIMResponseData.h" | #include "CIMResponseData.h" |
#include "XmlWriter.h" |
#include <Pegasus/Common/Tracer.h> |
#include "SCMOXmlWriter.h" |
#include <Pegasus/Common/XmlWriter.h> |
#include "XmlReader.h" |
#include <Pegasus/Common/SCMOXmlWriter.h> |
#include "Tracer.h" |
#include <Pegasus/Common/XmlReader.h> |
|
#include <Pegasus/Common/CIMInternalXmlEncoder.h> |
|
#include <Pegasus/Common/SCMOInternalXmlEncoder.h> |
| |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
//----------------------------------------------------------------------------- |
// C++ objects interface handling |
// |
|
// CIMInstanceNamesResponseData |
// Instance Names handling |
// |
Array<CIMObjectPath>& CIMResponseData::getInstanceNames() |
//----------------------------------------------------------------------------- |
{ |
|
PEGASUS_DEBUG_ASSERT( |
//------------------------------------------------------------------------------ |
(_dataType==RESP_INSTNAMES || _dataType==RESP_OBJECTPATHS)); |
// Takes a binary stream of object paths from a CIMBuffer and stores it in the |
_resolveToCIM(); |
// responsedata. |
PEGASUS_DEBUG_ASSERT(_encoding==RESP_ENC_CIM || _encoding == 0); |
// @param hasLen Indicates if the binary object path stream is prepended with an |
return _instanceNames; |
// Uint32 value indicating the number of paths in the stream. |
} |
//------------------------------------------------------------------------------ |
|
bool CIMInstanceNamesResponseData::setBinaryCimInstanceNames( |
// Instance handling |
CIMBuffer& in, bool hasLen) |
CIMInstance& CIMResponseData::getInstance() |
|
{ |
|
PEGASUS_DEBUG_ASSERT(_dataType == RESP_INSTANCE); |
|
_resolveToCIM(); |
|
if (0 == _instances.size()) |
|
{ |
|
_instances.append(CIMInstance()); |
|
} |
|
return _instances[0]; |
|
} |
|
|
|
// Instances handling |
|
Array<CIMInstance>& CIMResponseData::getInstances() |
|
{ |
|
PEGASUS_DEBUG_ASSERT(_dataType == RESP_INSTANCES); |
|
_resolveToCIM(); |
|
return _instances; |
|
} |
|
|
|
// Objects handling |
|
Array<CIMObject>& CIMResponseData::getObjects() |
|
{ |
|
PEGASUS_DEBUG_ASSERT(_dataType == RESP_OBJECTS); |
|
_resolveToCIM(); |
|
return _objects; |
|
} |
|
|
|
// SCMO representation, single instance stored as one element array |
|
// object paths are represented as SCMOInstance |
|
Array<SCMOInstance>& CIMResponseData::getSCMO() |
|
{ |
|
_resolveToSCMO(); |
|
return _scmoInstances; |
|
} |
|
|
|
void CIMResponseData::setSCMO(const Array<SCMOInstance>& x) |
|
{ |
|
_scmoInstances=x; |
|
_encoding |= RESP_ENC_SCMO; |
|
} |
|
|
|
|
|
// Binary data is just a data stream |
|
Array<Uint8>& CIMResponseData::getBinary() |
|
{ |
|
PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_BINARY || _encoding == 0); |
|
return _binaryData; |
|
} |
|
|
|
bool CIMResponseData::setBinary(CIMBuffer& in, bool hasLen) |
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, | PEG_METHOD_ENTER(TRC_DISPATCHER, |
"CIMInstanceNamesResponseData::setBinaryCimInstanceNames"); |
"CIMResponseData::setBinary"); |
| |
if (hasLen) | if (hasLen) |
{ | { |
|
|
size_t remainingDataLength = in.capacity() - in.size(); | size_t remainingDataLength = in.capacity() - in.size(); |
_binaryData.append((Uint8*)in.getPtr(), remainingDataLength); | _binaryData.append((Uint8*)in.getPtr(), remainingDataLength); |
} | } |
|
_encoding |= RESP_ENC_BINARY; |
_resolveCallback = _resolveBinaryInstanceNames; |
|
_encoding = RESP_ENC_BINARY; |
|
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return true; | return true; |
}; |
} |
| |
bool CIMInstanceNamesResponseData::setXmlCimInstanceNames(CIMBuffer& in) |
bool CIMResponseData::setXml(CIMBuffer& in) |
|
{ |
|
switch (_dataType) |
|
{ |
|
case RESP_INSTANCE: |
|
{ |
|
Array<Sint8> inst; |
|
Array<Sint8> ref; |
|
CIMNamespaceName ns; |
|
String host; |
|
if (!in.getSint8A(inst)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML instance data!"); |
|
return false; |
|
} |
|
_instanceData.insert(0,inst); |
|
if (!in.getSint8A(ref)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML instance data (reference)!"); |
|
return false; |
|
} |
|
_referencesData.insert(0,ref); |
|
if (!in.getString(host)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML instance data (host)!"); |
|
return false; |
|
} |
|
_hostsData.insert(0,host); |
|
if (!in.getNamespaceName(ns)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML instance data (namespace)!"); |
|
return false; |
|
} |
|
_nameSpacesData.insert(0,ns); |
|
break; |
|
} |
|
case RESP_INSTANCES: |
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
|
"CIMInstanceNamesResponseData::setXmlCimInstanceNames"); |
|
|
|
Uint32 count; | Uint32 count; |
|
|
if (!in.getUint32(count)) | if (!in.getUint32(count)) |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, | PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
"Failed to get XML objectpath data (number of paths)!"); |
"Failed to get XML instance data (number of instance)!"); |
PEG_METHOD_EXIT(); |
|
return false; | return false; |
} | } |
|
|
for (Uint32 i = 0; i < count; i++) | for (Uint32 i = 0; i < count; i++) |
{ | { |
|
Array<Sint8> inst; |
Array<Sint8> ref; | Array<Sint8> ref; |
CIMNamespaceName ns; | CIMNamespaceName ns; |
String host; | String host; |
|
if (!in.getSint8A(inst)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML instance data (instances)!"); |
|
return false; |
|
} |
if (!in.getSint8A(ref)) | if (!in.getSint8A(ref)) |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, | PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
"Failed to get XML objectpath data (references)!"); |
"Failed to get XML instance data (references)!"); |
PEG_METHOD_EXIT(); |
|
return false; | return false; |
} | } |
|
|
if (!in.getString(host)) | if (!in.getString(host)) |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, | PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
"Failed to get XML instance data (host)!"); | "Failed to get XML instance data (host)!"); |
PEG_METHOD_EXIT(); |
|
return false; | return false; |
} | } |
|
|
if (!in.getNamespaceName(ns)) | if (!in.getNamespaceName(ns)) |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, | PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
"Failed to get XML instance data (namespace)!"); | "Failed to get XML instance data (namespace)!"); |
PEG_METHOD_EXIT(); |
|
return false; | return false; |
} | } |
|
_instanceData.append(inst); |
|
_referencesData.append(ref); |
|
_hostsData.append(host); |
|
_nameSpacesData.append(ns); |
|
} |
|
break; |
|
} |
|
case RESP_OBJECTS: |
|
{ |
|
Uint32 count; |
|
if (!in.getUint32(count)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML object data (number of objects)!"); |
|
return false; |
|
} |
|
for (Uint32 i = 0; i < count; i++) |
|
{ |
|
Array<Sint8> obj; |
|
Array<Sint8> ref; |
|
CIMNamespaceName ns; |
|
String host; |
|
if (!in.getSint8A(obj)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML object data (object)!"); |
|
return false; |
|
} |
|
if (!in.getSint8A(ref)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML object data (reference)!"); |
|
return false; |
|
} |
|
if (!in.getString(host)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML object data (host)!"); |
|
return false; |
|
} |
|
if (!in.getNamespaceName(ns)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML object data (namespace)!"); |
|
return false; |
|
} |
|
_instanceData.append(obj); |
_referencesData.append(ref); | _referencesData.append(ref); |
_hostsData.append(host); | _hostsData.append(host); |
_nameSpacesData.append(ns); | _nameSpacesData.append(ns); |
} | } |
|
break; |
|
} |
|
// internal xml encoding of instance names and object paths not |
|
// done today |
|
case RESP_INSTNAMES: |
|
case RESP_OBJECTPATHS: |
|
default: |
|
{ |
|
PEGASUS_DEBUG_ASSERT(false); |
|
} |
|
} |
|
_encoding |= RESP_ENC_XML; |
|
return true; |
|
} |
| |
_resolveCallback = _resolveXMLInstanceNames; |
// function used by OperationAggregator to aggregate response data in a |
_encoding = RESP_ENC_XML; |
// single ResponseData object |
|
void CIMResponseData::appendResponseData(const CIMResponseData & x) |
|
{ |
|
// as the Messages set the data types, this should be impossible |
|
PEGASUS_DEBUG_ASSERT(_dataType == x._dataType); |
|
_encoding |= x._encoding; |
| |
PEG_METHOD_EXIT(); |
// add all binary data |
return true; |
_binaryData.appendArray(x._binaryData); |
}; |
|
| |
|
// add all the C++ stuff |
|
_instanceNames.appendArray(x._instanceNames); |
|
_instances.appendArray(x._instances); |
|
_objects.appendArray(x._objects); |
| |
|
// add the SCMO instances |
|
_scmoInstances.appendArray(x._scmoInstances); |
| |
|
// add Xml encodings too |
|
_referencesData.appendArray(x._referencesData); |
|
_instanceData.appendArray(x._instanceData); |
|
_hostsData.appendArray(x._hostsData); |
|
_nameSpacesData.appendArray(x._nameSpacesData); |
|
} |
| |
//------------------------------------------------------------------------------ |
// Encoding responses into output format |
// Encodes the array of CIMObjectPath representation contained in the current |
void CIMResponseData::encodeBinaryResponse(CIMBuffer& out) |
// CIMResponseData object in binary response message format. |
|
// This code corresponds to method _resolveBinaryInstanceNames, which is used |
|
// revert a binary objectpath array representation back into an array of |
|
// CIMInstance |
|
//------------------------------------------------------------------------------ |
|
void CIMInstanceNamesResponseData::encodeBinaryResponse(CIMBuffer& out) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, | PEG_METHOD_ENTER(TRC_DISPATCHER, |
"CIMInstanceNamesResponseData::encodeBinaryResponse"); |
"CIMResponseData::encodeBinaryResponse"); |
| |
if (_resolveCallback && (_encoding == RESP_ENC_BINARY)) |
// Need to do a complete job here by transferring all contained data |
|
// into binary format and handing it out in the CIMBuffer |
|
if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY)) |
{ | { |
|
// 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()); |
} | } |
else |
if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)) |
{ | { |
_resolve(); |
out.putTypeMarker(BIN_TYPE_MARKER_CPPD); |
out.putObjectPathA(_instanceNames, false); |
switch (_dataType) |
} |
|
PEG_METHOD_EXIT(); |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// Encodes the array of CIMObjectPath representation contained in the current |
|
// CIMResponseData object in xml response message format. |
|
// This code corresponds to method _resolveXmlInstanceNames, which is used |
|
// revert a CIM-XML objectpath array representation back into an array of |
|
// CIMObjectPath. |
|
//------------------------------------------------------------------------------ |
|
void CIMInstanceNamesResponseData::encodeXmlResponse(Buffer& out) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
case RESP_INSTNAMES: |
"CIMInstanceNamesResponseData::encodeXmlResponse"); |
|
|
|
if (_resolveCallback && (_encoding == RESP_ENC_XML)) |
|
{ | { |
const Array<ArraySint8>& a = _referencesData; |
out.putObjectPathA(_instanceNames); |
|
break; |
for (Uint32 i = 0, n = a.size(); i < n; i++) |
} |
|
case RESP_INSTANCE: |
{ | { |
out.append((char*)a[i].getData(), a[i].size() - 1); |
if (0 == _instances.size()) |
|
{ |
|
_instances.append(CIMInstance()); |
} | } |
|
out.putInstance(_instances[0], true, true); |
|
break; |
} | } |
else |
case RESP_INSTANCES: |
{ | { |
_resolve(); |
out.putInstanceA(_instances); |
for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++) |
break; |
XmlWriter::appendInstanceNameElement(out,_instanceNames[i]); |
|
} | } |
PEG_METHOD_EXIT(); |
case RESP_OBJECTS: |
|
{ |
|
out.putObjectA(_objects); |
|
break; |
} | } |
|
case RESP_OBJECTPATHS: |
//------------------------------------------------------------------------------ |
|
// Instantiates an array of ObjectPath from a binary representation created by |
|
// the CIMBinMessageSerializer. |
|
// Returns true on success. |
|
//------------------------------------------------------------------------------ |
|
Boolean CIMInstanceNamesResponseData::_resolveBinaryInstanceNames( |
|
CIMInstanceNamesResponseData* data, |
|
Array<CIMObjectPath>& cops) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
out.putObjectPathA(_instanceNames); |
"CIMInstanceNamesResponseData::_resolveBinaryInstanceNames"); |
break; |
|
} |
cops.clear(); |
default: |
|
|
CIMBuffer in((char*)data->_binaryData.getData(), data->_binaryData.size()); |
|
|
|
while (in.more()) |
|
{ | { |
if (!in.getObjectPathA(cops)) |
PEGASUS_DEBUG_ASSERT(false); |
|
} |
|
} |
|
} |
|
if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO)) |
{ | { |
in.release(); |
out.putTypeMarker(BIN_TYPE_MARKER_SCMO); |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
out.putSCMOInstanceA(_scmoInstances); |
"Failed to resolve binary objectpath!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} | } |
|
if (RESP_ENC_XML == (_encoding & RESP_ENC_XML)) |
|
{ |
|
// This actually should not happen following general code logic |
|
PEGASUS_DEBUG_ASSERT(false); |
} | } |
| |
in.release(); |
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return true; |
|
} | } |
| |
|
void CIMResponseData::completeNamespace(const SCMOInstance * x) |
|
|
//------------------------------------------------------------------------------ |
|
// Instantiates an array of CIMObjectPath from an xml representation created by |
|
// the CIMBinMessageSerializer. |
|
// Returns true on success. |
|
//------------------------------------------------------------------------------ |
|
Boolean CIMInstanceNamesResponseData::_resolveXMLInstanceNames( |
|
CIMInstanceNamesResponseData* data, |
|
Array<CIMObjectPath>& cops) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
const char * ns; |
"CIMInstanceNamesResponseData::_resolveXMLInstanceNames"); |
Uint64 len; |
|
ns = x->getNameSpace_l(len); |
cops.clear(); |
// Both internal XML as well as binary always contain a namespace |
|
// don't have to do anything for those two encodings |
for (Uint32 i = 0; i < data->_referencesData.size(); i++) |
if ((RESP_ENC_BINARY == (_encoding&RESP_ENC_BINARY)) && (len != 0)) |
{ | { |
CIMObjectPath cop; |
_defaultNamespace = CIMNamespaceName(ns); |
|
} |
// Deserialize path: |
if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)) |
{ | { |
XmlParser parser((char*)data->_referencesData[i].getData()); |
CIMNamespaceName nsName(ns); |
|
switch (_dataType) |
if (XmlReader::getInstanceNameElement(parser, cop)) |
|
{ | { |
if (!data->_nameSpacesData[i].isNull()) |
case RESP_INSTANCE: |
cop.setNameSpace(data->_nameSpacesData[i]); |
{ |
|
if (_instances.size() > 0) |
if (data->_hostsData[i].size()) |
{ |
cop.setHost(data->_hostsData[i]); |
const CIMInstance& inst = _instances[0]; |
|
CIMObjectPath& p = |
|
const_cast<CIMObjectPath&>(inst.getPath()); |
|
if (p.getNameSpace().isNull()) |
|
{ |
|
p.setNameSpace(nsName); |
} | } |
} | } |
|
|
cops.append(cop); |
|
} | } |
|
case RESP_INSTANCES: |
PEG_METHOD_EXIT(); |
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// Instantiates an array of CIMObjectPath from an array of SCMOInstances |
|
// Returns true on success. |
|
//------------------------------------------------------------------------------ |
|
Boolean CIMInstanceNamesResponseData::_resolveSCMOInstanceNames( |
|
CIMInstanceNamesResponseData* data, |
|
Array<CIMObjectPath>& cops) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
for (Uint32 j = 0, n = _instances.size(); j < n; j++) |
"CIMInstanceNamesResponseData::_resolveSCMOInstanceNames"); |
|
|
|
cops.clear(); |
|
|
|
//--rk-->TBD: Do the actual coding here |
|
|
|
fprintf(stderr,"CIMInstanceNamesResponseData::_resolveSCMOInstanceNames() " |
|
"Poorly implemented!!!\n"); |
|
try |
|
{ | { |
for (Uint32 x=0; x < data->_scmoInstanceNames.size(); x++) |
const CIMInstance& inst = _instances[j]; |
|
CIMObjectPath& p = |
|
const_cast<CIMObjectPath&>(inst.getPath()); |
|
if (p.getNameSpace().isNull()) |
{ | { |
/*SCMODump dmp; |
p.setNameSpace(nsName); |
dmp.dumpSCMOInstanceKeyBindings(data->_scmoInstanceNames[x]);*/ |
|
CIMObjectPath cop; |
|
data->_scmoInstanceNames[x].getCIMObjectPath(cop); |
|
cops.append(cop); |
|
} | } |
} | } |
catch (CIMException& ex) |
break; |
{ |
|
fprintf(stderr, |
|
"CIMInstanceNamesResponseData::_resolveSCMOInstanceNames() " |
|
"Exception:\n%s\n",(const char*)ex.getMessage().getCString()); |
|
} | } |
catch (Exception& ex) |
case RESP_OBJECTS: |
|
{ |
|
for (Uint32 j = 0, n = _objects.size(); j < n; j++) |
{ | { |
fprintf(stderr, |
const CIMObject& object = _objects[j]; |
"CIMInstanceNamesResponseData::_resolveSCMOInstanceNames() " |
CIMObjectPath& p = |
"Exception:\n%s\n",(const char*)ex.getMessage().getCString()); |
const_cast<CIMObjectPath&>(object.getPath()); |
|
if (p.getNameSpace().isNull()) |
|
{ |
|
p.setNameSpace(nsName); |
|
} |
} | } |
catch (exception& ex) |
break; |
|
} |
|
case RESP_INSTNAMES: |
|
case RESP_OBJECTPATHS: |
|
{ |
|
for (Uint32 j = 0, n = _instanceNames.size(); j < n; j++) |
|
{ |
|
CIMObjectPath& p = _instanceNames[j]; |
|
if (p.getNameSpace().isNull()) |
{ | { |
fprintf(stderr, |
p.setNameSpace(nsName); |
"CIMInstanceNamesResponseData::_resolveSCMOInstanceNames() " |
|
"exception:\n%s\n",(const char*)ex.what()); |
|
} | } |
catch (...) |
} |
|
break; |
|
} |
|
default: |
{ | { |
fprintf(stderr, |
PEGASUS_DEBUG_ASSERT(false); |
"CIMInstanceNamesResponseData::_resolveSCMOInstanceNames() " |
|
"Exception: UNKNOWN\n"); |
|
} | } |
data->_resolveCallback = 0; |
|
|
|
PEG_METHOD_EXIT(); |
|
return true; |
|
} | } |
|
} |
|
if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO)) |
//----------------------------------------------------------------------------- |
|
// |
|
// CIMInstanceResponseData |
|
// |
|
//----------------------------------------------------------------------------- |
|
|
|
//------------------------------------------------------------------------------ |
|
// Takes a binary stream representing an instances from a CIMBuffer and stores |
|
// it in the responsedata. |
|
// @param hasLen Indicates if the binary instance stream is prepended with an |
|
// Uint32 value indicating the number of instances in the stream. |
|
//------------------------------------------------------------------------------ |
|
bool CIMInstanceResponseData::setBinaryCimInstance(CIMBuffer& in, bool hasLen) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++) |
"CIMInstanceResponseData::setBinaryCimInstance"); |
|
|
|
if (hasLen) |
|
{ | { |
if (!in.getUint8A(_binaryData)) |
SCMOInstance & scmoInst=_scmoInstances[j]; |
|
if (0 == scmoInst.getNameSpace()) |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
scmoInst.setNameSpace_l(ns,len); |
"Failed to get binary instance data!"); |
} |
PEG_METHOD_EXIT(); |
|
return false; |
|
} | } |
} | } |
else |
|
{ |
|
size_t remainingDataLength = in.capacity() - in.size(); |
|
|
|
_binaryData.append((Uint8*)in.getPtr(), remainingDataLength); |
|
} | } |
| |
_resolveCallback = _resolveBinaryInstance; |
|
_binaryEncoding = true; |
|
| |
PEG_METHOD_EXIT(); |
void CIMResponseData::completeHostNameAndNamespace( |
return true; |
const String & hn, |
}; |
const CIMNamespaceName & ns) |
|
|
bool CIMInstanceResponseData::setXmlCimInstance(CIMBuffer& in) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY)) |
"CIMInstanceResponseData::setXmlCimInstance"); |
|
|
|
if (!in.getSint8A(_instanceData)) |
|
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
// On binary need remember hostname and namespace in case someone |
"Failed to get XML instance data!"); |
// builds C++ default objects or Xml types from it later on |
PEG_METHOD_EXIT(); |
// -> usage: See resolveBinary() |
return false; |
_defaultNamespace=ns; |
|
_defaultHostname=hn; |
} | } |
|
// InternalXml does not support objectPath calls |
if (!in.getSint8A(_referenceData)) |
if ((RESP_ENC_XML == (_encoding & RESP_ENC_XML)) && |
|
(RESP_OBJECTS == _dataType)) |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
for (Uint32 j = 0, n = _referencesData.size(); j < n; j++) |
"Failed to get XML instance data (reference)!"); |
{ |
PEG_METHOD_EXIT(); |
if (0 == _hostsData[j].size()) |
return false; |
{ |
|
_hostsData[j]=hn; |
} | } |
|
if (_nameSpacesData[j].isNull()) |
if (!in.getString(_hostData)) |
|
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
_nameSpacesData[j]=ns; |
"Failed to get XML instance data (host)!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} | } |
|
} |
if (!in.getNamespaceName(_nameSpaceData)) |
} |
|
if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)) |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
switch (_dataType) |
"Failed to get XML instance data (namespace)!"); |
{ |
PEG_METHOD_EXIT(); |
case RESP_OBJECTS: |
return false; |
{ |
|
for (Uint32 j = 0, n = _objects.size(); j < n; j++) |
|
{ |
|
const CIMObject& object = _objects[j]; |
|
CIMObjectPath& p = |
|
const_cast<CIMObjectPath&>(object.getPath()); |
|
if (p.getHost().size()==0) |
|
{ |
|
p.setHost(hn); |
} | } |
|
if (p.getNameSpace().isNull()) |
_resolveCallback = _resolveXMLInstance; |
|
|
|
PEG_METHOD_EXIT(); |
|
return true; |
|
}; |
|
|
|
//------------------------------------------------------------------------------ |
|
// Encodes the CIMInstance representation contained in the current |
|
// CIMResponseData object in binary response message format. |
|
// This code corresponds to method _resolveBinaryInstance, which is used |
|
// revert a binary instance representation back into a CIMInstance |
|
//------------------------------------------------------------------------------ |
|
void CIMInstanceResponseData::encodeBinaryResponse(CIMBuffer& out) const |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
p.setNameSpace(ns); |
"CIMInstanceResponseData::encodeBinaryResponse"); |
} |
|
} |
if (_resolveCallback && _binaryEncoding) |
break; |
|
} |
|
case RESP_OBJECTPATHS: |
{ | { |
const Array<Uint8>& data = _binaryData; |
for (Uint32 j = 0, n = _instanceNames.size(); j < n; j++) |
out.putBytes(data.getData(), data.size()); |
{ |
|
CIMObjectPath& p = _instanceNames[j]; |
|
if (p.getHost().size() == 0) |
|
p.setHost(hn); |
|
if (p.getNameSpace().isNull()) |
|
p.setNameSpace(ns); |
} | } |
else |
break; |
|
} |
|
default: |
{ | { |
out.putInstance(_cimInstance, false, false); |
PEGASUS_DEBUG_ASSERT(false); |
} | } |
PEG_METHOD_EXIT(); |
|
} | } |
|
} |
//------------------------------------------------------------------------------ |
if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO)) |
// Encodes the CIMInstanc representation contained in the current |
|
// CIMResponseData object in xml response message format. |
|
// This code corresponds to method _resolveXmlInstance, which is used |
|
// revert a CIM-XML instance representation back into a CIMInstance. |
|
//------------------------------------------------------------------------------ |
|
void CIMInstanceResponseData::encodeXmlResponse(Buffer& out) const |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
CString hnCString=hn.getCString(); |
"CIMInstanceResponseData::encodeXmlResponse"); |
const char* hnChars = hnCString; |
|
Uint32 hnLen = strlen(hnChars); |
if (_resolveCallback && !_binaryEncoding) |
CString nsCString=ns.getString().getCString(); |
|
const char* nsChars=nsCString; |
|
Uint32 nsLen = strlen(nsChars); |
|
switch (_dataType) |
|
{ |
|
case RESP_OBJECTS: |
|
case RESP_OBJECTPATHS: |
{ | { |
out.append( (char*)_instanceData.getData(),_instanceData.size()-1); |
for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++) |
|
{ |
|
SCMOInstance & scmoInst=_scmoInstances[j]; |
|
if (0 == scmoInst.getHostName()) |
|
{ |
|
scmoInst.setHostName_l(hnChars,hnLen); |
} | } |
else |
if (0 == scmoInst.getNameSpace()) |
{ | { |
XmlWriter::appendInstanceElement(out, _cimInstance); |
scmoInst.setNameSpace_l(nsChars,nsLen); |
//SCMOXmlWriter::appendValueSCMOInstanceElement(out, _cimInstance); |
|
} | } |
PEG_METHOD_EXIT(); |
|
} | } |
|
break; |
//------------------------------------------------------------------------------ |
} |
// Instantiates a CIMInstance from a binary representation created by |
default: |
// the CIMBinMessageSerializer. |
|
// Returns true on success. |
|
//------------------------------------------------------------------------------ |
|
Boolean CIMInstanceResponseData::_resolveBinaryInstance( |
|
CIMInstanceResponseData* data, |
|
CIMInstance& instance) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
PEGASUS_DEBUG_ASSERT(false); |
"CIMInstanceResponseData::_resolveBinaryInstance"); |
} |
|
} |
CIMBuffer in((char*)data->_binaryData.getData(), data->_binaryData.size()); |
} |
|
} |
| |
if (!in.getInstance(instance)) |
void CIMResponseData::encodeXmlResponse(Buffer& out) |
{ | { |
instance = CIMInstance(); |
PEG_TRACE((TRC_XML, Tracer::LEVEL3, |
in.release(); |
"CIMResponseData::encodeXmlResponse(encoding=%X,content=%X)\n", |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
_encoding, |
"Failed to resolve binary instance!"); |
_dataType)); |
PEG_METHOD_EXIT(); |
|
return false; |
|
} |
|
| |
in.release(); |
// already existing Internal XML does not need to be encoded further |
PEG_METHOD_EXIT(); |
// binary input is not actually impossible here, but we have an established |
return true; |
// fallback |
|
if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY)) |
|
{ |
|
_resolveBinary(); |
} | } |
| |
//------------------------------------------------------------------------------ |
if (RESP_ENC_XML == (_encoding & RESP_ENC_XML)) |
// Instantiates a CIMInstance from an xml representation created by |
|
// the CIMBinMessageSerializer. |
|
// Returns true on success. |
|
//------------------------------------------------------------------------------ |
|
Boolean CIMInstanceResponseData::_resolveXMLInstance( |
|
CIMInstanceResponseData* data, |
|
CIMInstance& cimInstance) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
switch (_dataType) |
"CIMInstanceResponseData::_resolveXMLInstance"); |
{ |
|
case RESP_INSTANCE: |
// Deserialize instance: |
{ |
|
const Array<ArraySint8>& a = _instanceData; |
|
out.append((char*)a[0].getData(), a[0].size() - 1); |
|
break; |
|
} |
|
case RESP_INSTANCES: |
{ | { |
XmlParser parser((char*)data->_instanceData.getData()); |
const Array<ArraySint8>& a = _instanceData; |
|
const Array<ArraySint8>& b = _referencesData; |
| |
if (!XmlReader::getInstanceElement(parser, cimInstance)) |
for (Uint32 i = 0, n = a.size(); i < n; i++) |
{ | { |
cimInstance = CIMInstance(); |
out << STRLIT("<VALUE.NAMEDINSTANCE>\n"); |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
out.append((char*)b[i].getData(), b[i].size() - 1); |
"Failed to resolve XML instance, parser error!"); |
out.append((char*)a[i].getData(), a[i].size() - 1); |
PEG_METHOD_EXIT(); |
out << STRLIT("</VALUE.NAMEDINSTANCE>\n"); |
return false; |
|
} | } |
|
break; |
} | } |
|
case RESP_OBJECTS: |
// Deserialize path: |
|
{ | { |
XmlParser parser((char*)data->_referenceData.getData()); |
const Array<ArraySint8>& a = _instanceData; |
CIMObjectPath cimObjectPath; |
const Array<ArraySint8>& b = _referencesData; |
|
for (Uint32 i = 0, n = a.size(); i < n; i++) |
if (XmlReader::getValueReferenceElement(parser, cimObjectPath)) |
|
{ | { |
if (data->_hostData.size()) |
out << STRLIT("<VALUE.OBJECTWITHPATH>\n"); |
cimObjectPath.setHost(data->_hostData); |
out << STRLIT("<INSTANCEPATH>\n"); |
|
XmlWriter::appendNameSpacePathElement( |
if (!data->_nameSpaceData.isNull()) |
out, |
cimObjectPath.setNameSpace(data->_nameSpaceData); |
_hostsData[i], |
|
_nameSpacesData[i]); |
cimInstance.setPath(cimObjectPath); |
// Leave out the surrounding tags "<VALUE.REFERENCE>\n" |
|
// and "</VALUE.REFERENCE>\n" which are 18 and 19 characters |
|
// long |
|
out.append( |
|
((char*)b[i].getData())+18, |
|
b[i].size() - 1 - 18 -19); |
|
out << STRLIT("</INSTANCEPATH>\n"); |
|
// append instance body |
|
out.append((char*)a[i].getData(), a[i].size() - 1); |
|
out << STRLIT("</VALUE.OBJECTWITHPATH>\n"); |
|
} |
|
break; |
|
} |
|
// internal xml encoding of instance names and object paths not |
|
// done today |
|
case RESP_INSTNAMES: |
|
case RESP_OBJECTPATHS: |
|
default: |
|
{ |
|
PEGASUS_DEBUG_ASSERT(false); |
} | } |
} | } |
|
|
PEG_METHOD_EXIT(); |
|
return true; |
|
} | } |
| |
|
if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)) |
|
|
//----------------------------------------------------------------------------- |
|
// |
|
// CIMInstancesResponseData |
|
// |
|
//----------------------------------------------------------------------------- |
|
|
|
//------------------------------------------------------------------------------ |
|
// Takes a binary stream of instances from a CIMBuffer and stores it in the |
|
// responsedata. |
|
// @param hasLen Indicates if the binary instance stream is prepended with an |
|
// Uint32 value indicating the number of instances in the stream. |
|
//------------------------------------------------------------------------------ |
|
bool CIMInstancesResponseData::setBinaryCimInstances(CIMBuffer& in, bool hasLen) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
switch (_dataType) |
"CIMInstancesResponseData::setBinaryCimInstances"); |
|
|
|
if (hasLen) |
|
{ | { |
if (!in.getUint8A(_binaryData)) |
case RESP_INSTNAMES: |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++) |
"Failed to get binary instance data!"); |
{ |
PEG_METHOD_EXIT(); |
XmlWriter::appendInstanceNameElement(out,_instanceNames[i]); |
return false; |
|
} | } |
|
break; |
} | } |
else |
case RESP_INSTANCE: |
{ | { |
size_t remainingDataLength = in.capacity() - in.size(); |
if (_instances.size() > 0) |
_binaryData.append((Uint8*)in.getPtr(), remainingDataLength); |
{ |
|
XmlWriter::appendInstanceElement(out, _instances[0]); |
} | } |
|
break; |
_resolveCallback = _resolveBinaryInstances; |
} |
_encoding = RESP_ENC_BINARY; |
case RESP_INSTANCES: |
|
|
PEG_METHOD_EXIT(); |
|
return true; |
|
}; |
|
|
|
bool CIMInstancesResponseData::setXmlCimInstances(CIMBuffer& in) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
for (Uint32 i = 0, n = _instances.size(); i < n; i++) |
"CIMInstancesResponseData::setXmlCimInstances"); |
|
|
|
Uint32 count; |
|
|
|
if (!in.getUint32(count)) |
|
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
XmlWriter::appendValueNamedInstanceElement( |
"Failed to get XML instance data (number of instance)!"); |
out, _instances[i]); |
PEG_METHOD_EXIT(); |
|
return false; |
|
} | } |
|
break; |
for (Uint32 i = 0; i < count; i++) |
} |
|
case RESP_OBJECTS: |
{ | { |
Array<Sint8> inst; |
for (Uint32 i = 0; i < _objects.size(); i++) |
Array<Sint8> ref; |
|
CIMNamespaceName ns; |
|
String host; |
|
|
|
if (!in.getSint8A(inst)) |
|
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
XmlWriter::appendValueObjectWithPathElement( |
"Failed to get XML instance data (instances)!"); |
out, |
PEG_METHOD_EXIT(); |
_objects[i]); |
return false; |
|
} | } |
|
break; |
if (!in.getSint8A(ref)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML instance data (references)!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} | } |
|
case RESP_OBJECTPATHS: |
if (!in.getString(host)) |
|
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++) |
"Failed to get XML instance data (host)!"); |
{ |
PEG_METHOD_EXIT(); |
out << "<OBJECTPATH>\n"; |
return false; |
XmlWriter::appendValueReferenceElement( |
|
out, |
|
_instanceNames[i], |
|
false); |
|
out << "</OBJECTPATH>\n"; |
} | } |
|
break; |
if (!in.getNamespaceName(ns)) |
} |
|
default: |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
PEGASUS_DEBUG_ASSERT(false); |
"Failed to get XML instance data (namespace)!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} | } |
|
|
_instancesData.append(inst); |
|
_referencesData.append(ref); |
|
_hostsData.append(host); |
|
_nameSpacesData.append(ns); |
|
} | } |
|
} |
_resolveCallback = _resolveXMLInstances; |
if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO)) |
_encoding = RESP_ENC_XML; |
|
|
|
PEG_METHOD_EXIT(); |
|
return true; |
|
}; |
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------ |
|
// Encodes the array of CIMInstance representation contained in the current |
|
// CIMResponseData object in binary response message format. |
|
// This code corresponds to method _resolveBinaryInstances, which is used |
|
// revert a binary instance array representation back into an array of |
|
// CIMInstance |
|
//------------------------------------------------------------------------------ |
|
void CIMInstancesResponseData::encodeBinaryResponse(CIMBuffer& out) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
switch (_dataType) |
"CIMInstancesResponseData::encodeBinaryResponse"); |
|
|
|
if (_resolveCallback && (_encoding == RESP_ENC_BINARY)) |
|
{ | { |
const Array<Uint8>& data = _binaryData; |
case RESP_INSTNAMES: |
out.putBytes(data.getData(), data.size()); |
{ |
|
for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++) |
|
{ |
|
SCMOXmlWriter::appendInstanceNameElement( |
|
out, |
|
_scmoInstances[i]); |
} | } |
else |
break; |
|
} |
|
case RESP_INSTANCE: |
|
{ |
|
if (_scmoInstances.size() > 0) |
{ | { |
_resolve(); |
SCMOXmlWriter::appendInstanceElement(out,_scmoInstances[0]); |
out.putInstanceA(_namedInstances, false); |
|
} | } |
PEG_METHOD_EXIT(); |
break; |
} | } |
|
case RESP_INSTANCES: |
//------------------------------------------------------------------------------ |
|
// Encodes the array of CIMInstance representation contained in the current |
|
// CIMResponseData object in xml response message format. |
|
// This code corresponds to method _resolveXmlInstances, which is used |
|
// revert a CIM-XML object array representation back into an array of |
|
// CIMInstance. |
|
//------------------------------------------------------------------------------ |
|
void CIMInstancesResponseData::encodeXmlResponse(Buffer& out) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++) |
"CIMInstancesResponseData::encodeXmlResponse"); |
|
|
|
/* |
|
fprintf( |
|
stderr, |
|
"CIMInstancesResponseData::encodeXmlResponse\n"); |
|
fflush(stderr); |
|
*/ |
|
|
|
if (_resolveCallback && (_encoding == RESP_ENC_XML)) |
|
{ |
|
/* |
|
fprintf( |
|
stderr, |
|
"_resolveCallback && (_encoding == RESP_ENC_XML)\n"); |
|
fflush(stderr); |
|
*/ |
|
const Array<ArraySint8>& a = _instancesData; |
|
const Array<ArraySint8>& b = _referencesData; |
|
|
|
for (Uint32 i = 0, n = a.size(); i < n; i++) |
|
{ | { |
out << STRLIT("<VALUE.NAMEDINSTANCE>\n"); |
SCMOXmlWriter::appendValueSCMOInstanceElement( |
out.append((char*)b[i].getData(), b[i].size() - 1); |
out, |
out.append((char*)a[i].getData(), a[i].size() - 1); |
_scmoInstances[i]); |
out << STRLIT("</VALUE.NAMEDINSTANCE>\n"); |
|
} | } |
|
break; |
} | } |
else |
case RESP_OBJECTS: |
{ | { |
// DO NOT RESOLVE, use the SCMOXmlWriter to encode |
for (Uint32 i = 0; i < _scmoInstances.size(); i++) |
// _resolve(); |
|
for (Uint32 i = 0, n = _namedInstances.size(); i < n; i++) |
|
{ | { |
XmlWriter::appendValueNamedInstanceElement( |
SCMOXmlWriter::appendValueObjectWithPathElement( |
out, _namedInstances[i]); |
out, |
|
_scmoInstances[i]); |
|
} |
|
break; |
} | } |
|
case RESP_OBJECTPATHS: |
|
{ |
for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++) | for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++) |
{ | { |
SCMOXmlWriter::appendValueSCMOInstanceElement( |
out << "<OBJECTPATH>\n"; |
out, _scmoInstances[i]); |
SCMOXmlWriter::appendValueReferenceElement( |
|
out, |
/* |
_scmoInstances[i], |
fprintf( |
false); |
stderr, |
out << "</OBJECTPATH>\n"; |
"After appendValueNamedInstanceElement()\n%s", |
} |
out.getData()); |
break; |
fflush(stderr); |
} |
*/ |
default: |
|
{ |
|
PEGASUS_DEBUG_ASSERT(false); |
|
} |
} | } |
} | } |
PEG_METHOD_EXIT(); |
|
} | } |
| |
//------------------------------------------------------------------------------ |
// contrary to encodeXmlResponse this function encodes the Xml in a format |
// Instantiates an array of CIMInstances from a binary representation created by |
// not usable by clients |
// the CIMBinMessageSerializer. |
void CIMResponseData::encodeInternalXmlResponse(CIMBuffer& out) |
// Returns true on success. |
|
//------------------------------------------------------------------------------ |
|
Boolean CIMInstancesResponseData::_resolveBinaryInstances( |
|
CIMInstancesResponseData* data, |
|
Array<CIMInstance>& instances) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
PEG_TRACE((TRC_XML, Tracer::LEVEL3, |
"CIMInstancesResponseData::_resolveBinaryInstances"); |
"CIMResponseData::encodeInternalXmlResponse(encoding=%X,content=%X)\n", |
|
_encoding, |
|
_dataType)); |
| |
instances.clear(); |
// For mixed (CIM+SCMO) responses, we need to tell the receiver the |
|
// total number of instances. The totalSize variable is used to keep track |
|
// of this. |
|
Uint32 totalSize = 0; |
| |
CIMBuffer in((char*)data->_binaryData.getData(), data->_binaryData.size()); |
// already existing Internal XML does not need to be encoded further |
|
// binary input is not actually impossible here, but we have an established |
while (in.more()) |
// fallback |
|
if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY)) |
{ | { |
if (!in.getInstanceA(instances)) |
_resolveBinary(); |
|
} |
|
if ((0 == _encoding) || |
|
(RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))) |
{ | { |
in.release(); |
switch (_dataType) |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
{ |
"Failed to remove binary instance!"); |
case RESP_INSTANCE: |
PEG_METHOD_EXIT(); |
{ |
return false; |
if (0 == _instances.size()) |
|
{ |
|
_instances.append(CIMInstance()); |
|
} |
|
CIMInternalXmlEncoder::_putXMLInstance(out, _instances[0]); |
|
break; |
|
} |
|
case RESP_INSTANCES: |
|
{ |
|
Uint32 n = _instances.size(); |
|
totalSize = n + _scmoInstances.size(); |
|
out.putUint32(totalSize); |
|
for (Uint32 i = 0; i < n; i++) |
|
{ |
|
CIMInternalXmlEncoder::_putXMLNamedInstance( |
|
out, |
|
_instances[i]); |
|
} |
|
break; |
|
} |
|
case RESP_OBJECTS: |
|
{ |
|
Uint32 n = _objects.size(); |
|
totalSize = n + _scmoInstances.size(); |
|
out.putUint32(totalSize); |
|
for (Uint32 i = 0; i < n; i++) |
|
{ |
|
CIMInternalXmlEncoder::_putXMLObject(out, _objects[i]); |
|
} |
|
break; |
|
} |
|
// internal xml encoding of instance names and object paths not |
|
// done today |
|
case RESP_INSTNAMES: |
|
case RESP_OBJECTPATHS: |
|
default: |
|
{ |
|
PEGASUS_DEBUG_ASSERT(false); |
} | } |
} | } |
|
|
in.release(); |
|
PEG_METHOD_EXIT(); |
|
return true; |
|
} | } |
|
if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO)) |
|
|
|
|
//------------------------------------------------------------------------------ |
|
// Instantiates an array of CIMInstances from an xml representation created by |
|
// the CIMBinMessageSerializer. |
|
// Returns true on success. |
|
//------------------------------------------------------------------------------ |
|
Boolean CIMInstancesResponseData::_resolveXMLInstances( |
|
CIMInstancesResponseData* data, |
|
Array<CIMInstance>& instances) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
switch (_dataType) |
"CIMInstancesResponseData::_resolveXMLInstances"); |
|
|
|
instances.clear(); |
|
|
|
for (Uint32 i = 0; i < data->_instancesData.size(); i++) |
|
{ | { |
CIMInstance cimInstance; |
case RESP_INSTANCE: |
|
|
// Deserialize instance: |
|
{ | { |
XmlParser parser((char*)data->_instancesData[i].getData()); |
if (0 == _scmoInstances.size()) |
|
|
if (!XmlReader::getInstanceElement(parser, cimInstance)) |
|
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
_scmoInstances.append(SCMOInstance()); |
"Failed to resolve XML instance. Creating empty instance!"); |
|
cimInstance = CIMInstance(); |
|
} | } |
|
SCMOInternalXmlEncoder::_putXMLInstance(out, _scmoInstances[0]); |
|
break; |
} | } |
|
case RESP_INSTANCES: |
// Deserialize path: |
|
{ | { |
XmlParser parser((char*)data->_referencesData[i].getData()); |
Uint32 n = _scmoInstances.size(); |
CIMObjectPath cimObjectPath; |
// Only put the size when not already done above |
|
if (0==totalSize) |
if (XmlReader::getInstanceNameElement(parser, cimObjectPath)) |
|
{ | { |
if (!data->_nameSpacesData[i].isNull()) |
out.putUint32(n); |
cimObjectPath.setNameSpace(data->_nameSpacesData[i]); |
|
|
|
if (data->_hostsData[i].size()) |
|
cimObjectPath.setHost(data->_hostsData[i]); |
|
|
|
cimInstance.setPath(cimObjectPath); |
|
} |
|
} | } |
|
for (Uint32 i = 0; i < n; i++) |
instances.append(cimInstance); |
{ |
|
SCMOInternalXmlEncoder::_putXMLNamedInstance( |
|
out, |
|
_scmoInstances[i]); |
} | } |
|
break; |
PEG_METHOD_EXIT(); |
|
return true; |
|
} | } |
|
case RESP_OBJECTS: |
//------------------------------------------------------------------------------ |
|
// Instantiates an array of CIMInstances from an array of SCMOInstances |
|
// Returns true on success. |
|
//------------------------------------------------------------------------------ |
|
Boolean CIMInstancesResponseData::_resolveSCMOInstances( |
|
CIMInstancesResponseData* data, |
|
Array<CIMInstance>& instances) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
Uint32 n = _scmoInstances.size(); |
"CIMInstancesResponseData::_resolveSCMOInstances"); |
// Only put the size when not already done above |
|
if (0==totalSize) |
instances.clear(); |
|
|
|
//--rk-->TBD: Do the actual coding here |
|
|
|
fprintf(stderr,"CIMInstancesResponseData::_resolveSCMOInstances() " |
|
"Poorly implemented!!!\n"); |
|
try |
|
{ | { |
for (Uint32 x=0; x < data->_scmoInstances.size(); x++) |
out.putUint32(n); |
|
} |
|
for (Uint32 i = 0; i < n; i++) |
{ | { |
/*SCMODump dmp; |
SCMOInternalXmlEncoder::_putXMLObject( |
dmp.dumpSCMOInstanceKeyBindings(data->_scmoInstances[x]); |
out, |
dmp.dumpInstanceProperties(data->_scmoInstances[x]);*/ |
_scmoInstances[i]); |
CIMInstance newInstance; |
|
data->_scmoInstances[x].getCIMInstance(newInstance); |
|
instances.append(newInstance); |
|
} | } |
|
break; |
} | } |
catch (CIMException& ex) |
// internal xml encoding of instance names and object paths not |
|
// done today |
|
case RESP_INSTNAMES: |
|
case RESP_OBJECTPATHS: |
|
default: |
{ | { |
fprintf(stderr,"CIMInstancesResponseData::_resolveSCMOInstances() " |
PEGASUS_DEBUG_ASSERT(false); |
"Exception:\n%s\n",(const char*)ex.getMessage().getCString()); |
} |
|
} |
} | } |
catch (Exception& ex) |
} |
|
|
|
void CIMResponseData::_resolveToCIM() |
|
{ |
|
PEG_TRACE((TRC_XML, Tracer::LEVEL2, |
|
"CIMResponseData::_resolveToCIM(encoding=%X,content=%X)\n", |
|
_encoding, |
|
_dataType)); |
|
|
|
if (RESP_ENC_XML == (_encoding & RESP_ENC_XML)) |
{ | { |
fprintf(stderr,"CIMInstancesResponseData::_resolveSCMOInstances() " |
_resolveXmlToCIM(); |
"Exception:\n%s\n",(const char*)ex.getMessage().getCString()); |
|
} | } |
catch (exception& ex) |
if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY)) |
{ | { |
fprintf(stderr,"CIMInstancesResponseData::_resolveSCMOInstances() " |
_resolveBinary(); |
"exception:\n%s\n",(const char*)ex.what()); |
|
} | } |
catch (...) |
if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO)) |
{ | { |
fprintf(stderr,"CIMInstancesResponseData::_resolveSCMOInstances() " |
_resolveSCMOToCIM(); |
"Exception: UNKNOWN\n"); |
|
} | } |
data->_resolveCallback = 0; |
|
| |
PEG_METHOD_EXIT(); |
PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_CIM || _encoding == 0); |
return true; |
|
} | } |
| |
|
void CIMResponseData::_resolveToSCMO() |
//----------------------------------------------------------------------------- |
|
// |
|
// CIMObjectsResponseData |
|
// |
|
//----------------------------------------------------------------------------- |
|
|
|
|
|
//------------------------------------------------------------------------------ |
|
// Takes a binary stream of objects from a CIMBuffer and stores |
|
// it in the responsedata. |
|
// @param hasLen Indicates if the binary object stream is prepended with an |
|
// Uint32 value indicating the number of objects in the stream. |
|
//------------------------------------------------------------------------------ |
|
bool CIMObjectsResponseData::setBinaryCimObjects(CIMBuffer& in, bool hasLen) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
PEG_TRACE((TRC_XML, Tracer::LEVEL2, |
"CIMObjectsResponseData::setBinaryCimObjects"); |
"CIMResponseData::_resolveToSCMO(encoding=%X,content=%X)\n", |
|
_encoding, |
|
_dataType)); |
| |
if (hasLen) |
if (RESP_ENC_XML == (_encoding & RESP_ENC_XML)) |
{ |
|
if (!in.getUint8A(_binaryData)) |
|
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
_resolveXmlToSCMO(); |
"Failed to get binary object data!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} | } |
|
if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY)) |
|
{ |
|
_resolveBinary(); |
} | } |
else |
if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)) |
{ | { |
size_t remainingDataLength = in.capacity() - in.size(); |
_resolveCIMToSCMO(); |
_binaryData.append((Uint8*)in.getPtr(), remainingDataLength); |
} |
|
PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_SCMO || _encoding == 0); |
} | } |
| |
_resolveCallback = _resolveBinaryObjects; |
// helper functions to transform different formats into one-another |
_binaryEncoding = true; |
// functions work on the internal data and calling of them should be |
|
// avoided whenever possible |
PEG_METHOD_EXIT(); |
void CIMResponseData::_resolveBinary() |
return true; |
|
}; |
|
|
|
bool CIMObjectsResponseData::setXmlCimObjects(CIMBuffer& in) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, | PEG_METHOD_ENTER(TRC_DISPATCHER, |
"CIMObjectsResponseData::setXmlCimObjects"); |
"CIMResponseData::_resolveBinary"); |
| |
Uint32 count; |
CIMBuffer in((char*)_binaryData.getData(), _binaryData.size()); |
| |
if (!in.getUint32(count)) |
while (in.more()) |
|
{ |
|
Uint32 binaryTypeMarker=0; |
|
if(!in.getTypeMarker(binaryTypeMarker)) |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, | PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
"Failed to get XML object data (number of objects)!"); |
"Failed to get type marker for binary objects!"); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return false; |
in.release(); |
|
return; |
} | } |
| |
for (Uint32 i = 0; i < count; i++) |
if (BIN_TYPE_MARKER_SCMO==binaryTypeMarker) |
{ | { |
Array<Sint8> obj; |
if (!in.getSCMOInstanceA(_scmoInstances)) |
Array<Sint8> ref; |
|
CIMNamespaceName ns; |
|
String host; |
|
|
|
if (!in.getSint8A(obj)) |
|
{ | { |
|
_encoding &=(~RESP_ENC_BINARY); |
|
in.release(); |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, | PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
"Failed to get XML object data (object)!"); |
"Failed to resolve binary SCMOInstances!"); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return false; |
return; |
} | } |
| |
if (!in.getSint8A(ref)) |
_encoding |= RESP_ENC_SCMO; |
|
} |
|
else |
|
{ |
|
switch (_dataType) |
|
{ |
|
case RESP_INSTNAMES: |
|
case RESP_OBJECTPATHS: |
|
{ |
|
if (!in.getObjectPathA(_instanceNames)) |
{ | { |
|
_encoding &=(~RESP_ENC_BINARY); |
|
in.release(); |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, | PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
"Failed to get XML object data (reference)!"); |
"Failed to resolve binary CIMObjectPaths!"); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return false; |
return; |
} | } |
|
break; |
if (!in.getString(host)) |
} |
|
case RESP_INSTANCE: |
|
{ |
|
CIMInstance instance; |
|
if (!in.getInstance(instance)) |
{ | { |
|
_encoding &=(~RESP_ENC_BINARY); |
|
_encoding |= RESP_ENC_CIM; |
|
_instances.append(instance); |
|
in.release(); |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, | PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
"Failed to get XML object data (host)!"); |
"Failed to resolve binary instance!"); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return false; |
return; |
} | } |
| |
if (!in.getNamespaceName(ns)) |
_instances.append(instance); |
|
break; |
|
} |
|
case RESP_INSTANCES: |
{ | { |
|
if (!in.getInstanceA(_instances)) |
|
{ |
|
_encoding &=(~RESP_ENC_BINARY); |
|
in.release(); |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, | PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
"Failed to get XML object data (namespace)!"); |
"Failed to resolve binary CIMInstances!"); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return false; |
return; |
} | } |
|
break; |
_cimObjectsData.append(obj); |
|
_referencesData.append(ref); |
|
_hostsData.append(host); |
|
_nameSpacesData.append(ns); |
|
} | } |
|
case RESP_OBJECTS: |
_resolveCallback = _resolveXMLObjects; |
{ |
_binaryEncoding = false; |
if (!in.getObjectA(_objects)) |
|
{ |
|
in.release(); |
|
_encoding &=(~RESP_ENC_BINARY); |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to resolve binary CIMObjects!"); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return true; |
return; |
} | } |
|
break; |
//------------------------------------------------------------------------------ |
} |
// Encodes the array of CIMObject representation contained in the current |
default: |
// CIMResponseData object in binary response message format. |
|
// This code corresponds to method _resolveBinaryObjects, which is used |
|
// revert a binary object array representation back into an array of |
|
// CIMObject. |
|
//------------------------------------------------------------------------------ |
|
void CIMObjectsResponseData::encodeBinaryResponse(CIMBuffer& out) const |
|
{ |
|
PEG_METHOD_ENTER(TRC_DISPATCHER, |
|
"CIMObjectsResponseData::encodeBinaryResponse"); |
|
|
|
if (_resolveCallback && _binaryEncoding) |
|
{ | { |
const Array<Uint8>& data = _binaryData; |
PEGASUS_DEBUG_ASSERT(false); |
out.putBytes(data.getData(), data.size()); |
|
} | } |
else |
} // switch |
|
_encoding |= RESP_ENC_CIM; |
|
} // else SCMO |
|
} |
|
_encoding &=(~RESP_ENC_BINARY); |
|
// fix up the hostname and namespace for objects if defaults |
|
// were set |
|
if (_defaultHostname.size() > 0 && !_defaultNamespace.isNull()) |
{ | { |
out.putObjectA(_cimObjects); |
completeHostNameAndNamespace(_defaultHostname, _defaultNamespace); |
} | } |
|
in.release(); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
//------------------------------------------------------------------------------ |
void CIMResponseData::_resolveXmlToCIM() |
// Encodes the array of CIMObject representation contained in the current |
|
// CIMResponseData object in xml response message format. |
|
// This code corresponds to method _resolveXmlObjects, which is used |
|
// revert a CIM-XML object array representation back into an array of |
|
// CIMObject. |
|
//------------------------------------------------------------------------------ |
|
void CIMObjectsResponseData::encodeXmlResponse(Buffer& out) const |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
switch (_dataType) |
"CIMObjectsResponseData::encodeXmlResponse"); |
|
|
|
if (_resolveCallback && !_binaryEncoding) |
|
{ | { |
const Array<ArraySint8>& a = _cimObjectsData; |
// Xml encoding for instance names and object paths not used |
const Array<ArraySint8>& b = _referencesData; |
case RESP_OBJECTPATHS: |
|
case RESP_INSTNAMES: |
|
{ |
|
break; |
|
} |
|
case RESP_INSTANCE: |
|
{ |
|
CIMInstance cimInstance; |
|
// Deserialize instance: |
|
{ |
|
XmlParser parser((char*)_instanceData[0].getData()); |
| |
for (Uint32 i = 0, n = a.size(); i < n; i++) |
if (!XmlReader::getInstanceElement(parser, cimInstance)) |
{ | { |
out << STRLIT("<VALUE.OBJECTWITHPATH>\n"); |
cimInstance = CIMInstance(); |
out.append((char*)b[i].getData(), b[i].size() - 1); |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
out.append((char*)a[i].getData(), a[i].size() - 1); |
"Failed to resolve XML instance, parser error!"); |
out << STRLIT("</VALUE.OBJECTWITHPATH>\n"); |
|
} | } |
} | } |
else |
// Deserialize path: |
|
{ |
|
XmlParser parser((char*)_referencesData[0].getData()); |
|
CIMObjectPath cimObjectPath; |
|
|
|
if (XmlReader::getValueReferenceElement(parser, cimObjectPath)) |
|
{ |
|
if (_hostsData.size()) |
{ | { |
for (Uint32 i = 0; i < _cimObjects.size(); i++) |
cimObjectPath.setHost(_hostsData[0]); |
|
} |
|
if (!_nameSpacesData[0].isNull()) |
{ | { |
XmlWriter::appendValueObjectWithPathElement(out, _cimObjects[i]); |
cimObjectPath.setNameSpace(_nameSpacesData[0]); |
} | } |
|
cimInstance.setPath(cimObjectPath); |
|
// only if everything works we add the CIMInstance to the |
|
// array |
|
_instances.append(cimInstance); |
} | } |
PEG_METHOD_EXIT(); |
|
} | } |
|
break; |
//------------------------------------------------------------------------------ |
} |
// Instantiates an array of CIMObjects from a binary representation created by |
case RESP_INSTANCES: |
// the CIMBinMessageSerializer. |
|
// Returns true on success. |
|
//------------------------------------------------------------------------------ |
|
Boolean CIMObjectsResponseData::_resolveBinaryObjects( |
|
CIMObjectsResponseData* data, |
|
Array<CIMObject>& cimObjects) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
for (Uint32 i = 0; i < _instanceData.size(); i++) |
"CIMObjectsResponseData::_resolveBinaryObjects"); |
|
|
|
cimObjects.clear(); |
|
|
|
CIMBuffer in((char*)data->_binaryData.getData(), data->_binaryData.size()); |
|
|
|
while (in.more()) |
|
{ | { |
if (!in.getObjectA(cimObjects)) |
CIMInstance cimInstance; |
|
// Deserialize instance: |
{ | { |
in.release(); |
XmlParser parser((char*)_instanceData[i].getData()); |
| |
|
if (!XmlReader::getInstanceElement(parser, cimInstance)) |
|
{ |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, | PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
"Failed to resolve binary data!"); |
"Failed to resolve XML instance." |
PEG_METHOD_EXIT(); |
" Creating empty instance!"); |
return false; |
cimInstance = CIMInstance(); |
} | } |
} | } |
| |
in.release(); |
// Deserialize path: |
PEG_METHOD_EXIT(); |
{ |
return true; |
XmlParser parser((char*)_referencesData[i].getData()); |
} |
CIMObjectPath cimObjectPath; |
| |
//------------------------------------------------------------------------------ |
if (XmlReader::getInstanceNameElement(parser,cimObjectPath)) |
// Instantiates an array of CIMObjects from an xml representation created by |
|
// the CIMBinMessageSerializer. |
|
// Returns true on success. |
|
//------------------------------------------------------------------------------ |
|
Boolean CIMObjectsResponseData::_resolveXMLObjects( |
|
CIMObjectsResponseData* data, |
|
Array<CIMObject>& cimObjects) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
if (!_nameSpacesData[i].isNull()) |
"CIMObjectsResponseData::_resolveXMLObjects"); |
cimObjectPath.setNameSpace(_nameSpacesData[i]); |
|
|
|
if (_hostsData[i].size()) |
|
cimObjectPath.setHost(_hostsData[i]); |
| |
cimObjects.clear(); |
cimInstance.setPath(cimObjectPath); |
|
} |
|
} |
| |
for (Uint32 i=0, n=data->_cimObjectsData.size(); i<n; i++) |
_instances.append(cimInstance); |
|
} |
|
break; |
|
} |
|
case RESP_OBJECTS: |
|
{ |
|
for (Uint32 i=0, n=_instanceData.size(); i<n; i++) |
{ | { |
CIMObject cimObject; | CIMObject cimObject; |
| |
// Deserialize Objects: | // Deserialize Objects: |
{ | { |
XmlParser parser((char*)data->_cimObjectsData[i].getData()); |
XmlParser parser((char*)_instanceData[i].getData()); |
| |
CIMInstance cimInstance; | CIMInstance cimInstance; |
CIMClass cimClass; | CIMClass cimClass; |
|
|
| |
// Deserialize paths: | // Deserialize paths: |
{ | { |
XmlParser parser((char*)data->_referencesData[i].getData()); |
XmlParser parser((char*)_referencesData[i].getData()); |
CIMObjectPath cimObjectPath; | CIMObjectPath cimObjectPath; |
| |
if (XmlReader::getValueReferenceElement(parser, cimObjectPath)) |
if (XmlReader::getValueReferenceElement( |
|
parser, |
|
cimObjectPath)) |
{ | { |
if (!data->_nameSpacesData[i].isNull()) |
if (!_nameSpacesData[i].isNull()) |
cimObjectPath.setNameSpace(data->_nameSpacesData[i]); |
cimObjectPath.setNameSpace(_nameSpacesData[i]); |
| |
if (data->_hostsData[i].size()) |
if (_hostsData[i].size()) |
cimObjectPath.setHost(data->_hostsData[i]); |
cimObjectPath.setHost(_hostsData[i]); |
| |
cimObject.setPath(cimObjectPath); | cimObject.setPath(cimObjectPath); |
} | } |
} | } |
|
_objects.append(cimObject); |
|
} |
|
break; |
|
} |
|
default: |
|
{ |
|
PEGASUS_DEBUG_ASSERT(false); |
|
} |
|
} |
|
// Xml was resolved, release Xml content now |
|
_referencesData.clear(); |
|
_hostsData.clear(); |
|
_nameSpacesData.clear(); |
|
_instanceData.clear(); |
|
// remove Xml Encoding flag |
|
_encoding &=(~RESP_ENC_XML); |
|
// add CIM Encoding flag |
|
_encoding |=RESP_ENC_CIM; |
|
} |
| |
cimObjects.append(cimObject); |
void CIMResponseData::_resolveXmlToSCMO() |
|
{ |
|
// Not optimal, can probably be improved |
|
// but on the other hand, since using the binary format this case should |
|
// actually not ever happen. |
|
_resolveXmlToCIM(); |
|
_resolveCIMToSCMO(); |
} | } |
| |
PEG_METHOD_EXIT(); |
void CIMResponseData::_resolveSCMOToCIM() |
return true; |
{ |
|
switch(_dataType) |
|
{ |
|
case RESP_INSTNAMES: |
|
case RESP_OBJECTPATHS: |
|
{ |
|
for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++) |
|
{ |
|
CIMObjectPath newObjectPath; |
|
_scmoInstances[x].getCIMObjectPath(newObjectPath); |
|
_instanceNames.append(newObjectPath); |
|
} |
|
break; |
|
} |
|
case RESP_INSTANCE: |
|
{ |
|
if (_scmoInstances.size() > 0) |
|
{ |
|
CIMInstance newInstance; |
|
_scmoInstances[0].getCIMInstance(newInstance); |
|
_instances.append(newInstance); |
|
} |
|
break; |
|
} |
|
case RESP_INSTANCES: |
|
{ |
|
for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++) |
|
{ |
|
CIMInstance newInstance; |
|
_scmoInstances[x].getCIMInstance(newInstance); |
|
_instances.append(newInstance); |
|
} |
|
break; |
|
} |
|
case RESP_OBJECTS: |
|
{ |
|
for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++) |
|
{ |
|
CIMInstance newInstance; |
|
_scmoInstances[x].getCIMInstance(newInstance); |
|
_objects.append(CIMObject(newInstance)); |
|
} |
|
break; |
|
} |
|
default: |
|
{ |
|
PEGASUS_DEBUG_ASSERT(false); |
|
} |
|
} |
|
_scmoInstances.clear(); |
|
// remove CIM Encoding flag |
|
_encoding &=(~RESP_ENC_SCMO); |
|
// add SCMO Encoding flag |
|
_encoding |=RESP_ENC_CIM; |
|
} |
|
|
|
void CIMResponseData::_resolveCIMToSCMO() |
|
{ |
|
CString nsCString=_defaultNamespace.getString().getCString(); |
|
const char* _defNamespace = nsCString; |
|
Uint32 _defNamespaceLen; |
|
if (_defaultNamespace.isNull()) |
|
{ |
|
_defNamespaceLen=0; |
|
} |
|
else |
|
{ |
|
_defNamespaceLen=strlen(_defNamespace); |
|
} |
|
switch (_dataType) |
|
{ |
|
case RESP_INSTNAMES: |
|
{ |
|
for (Uint32 i=0,n=_instanceNames.size();i<n;i++) |
|
{ |
|
SCMOInstance addme( |
|
_instanceNames[i], |
|
_defNamespace, |
|
_defNamespaceLen); |
|
_scmoInstances.append(addme); |
|
} |
|
_instanceNames.clear(); |
|
break; |
|
} |
|
case RESP_INSTANCE: |
|
{ |
|
if (_instances.size() > 0) |
|
{ |
|
SCMOInstance addme( |
|
_instances[0], |
|
_defNamespace, |
|
_defNamespaceLen); |
|
_scmoInstances.clear(); |
|
_scmoInstances.append(addme); |
|
_instances.clear(); |
|
} |
|
break; |
|
} |
|
case RESP_INSTANCES: |
|
{ |
|
for (Uint32 i=0,n=_instances.size();i<n;i++) |
|
{ |
|
SCMOInstance addme( |
|
_instances[i], |
|
_defNamespace, |
|
_defNamespaceLen); |
|
_scmoInstances.append(addme); |
|
} |
|
_instances.clear(); |
|
break; |
|
} |
|
case RESP_OBJECTS: |
|
{ |
|
for (Uint32 i=0,n=_objects.size();i<n;i++) |
|
{ |
|
SCMOInstance addme( |
|
_objects[i], |
|
_defNamespace, |
|
_defNamespaceLen); |
|
_scmoInstances.append(addme); |
|
} |
|
_objects.clear(); |
|
break; |
|
} |
|
case RESP_OBJECTPATHS: |
|
{ |
|
for (Uint32 i=0,n=_instanceNames.size();i<n;i++) |
|
{ |
|
SCMOInstance addme( |
|
_instanceNames[i], |
|
_defNamespace, |
|
_defNamespaceLen); |
|
// TODO: More description about this. |
|
if (0 == _instanceNames[i].getKeyBindings().size()) |
|
{ |
|
// if there is no keybinding, this is a class |
|
addme.setIsClassOnly(true); |
|
} |
|
_scmoInstances.append(addme); |
|
} |
|
_instanceNames.clear(); |
|
break; |
|
} |
|
default: |
|
{ |
|
PEGASUS_DEBUG_ASSERT(false); |
|
} |
} | } |
| |
|
// remove CIM Encoding flag |
|
_encoding &=(~RESP_ENC_CIM); |
|
// add SCMO Encoding flag |
|
_encoding |=RESP_ENC_SCMO; |
|
} |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |