version 1.2.2.4, 2009/10/01 09:33:36
|
version 1.2.2.19, 2009/11/19 16:39:01
|
|
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#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], false, false); |
|
break; |
} | } |
else |
case RESP_INSTANCES: |
{ | { |
_resolve(); |
out.putInstanceA(_instances, false); |
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); |
|
// Both internal XML as well as binary always contain a namespace |
|
// don't have to do anything for those two encodings |
|
if ((RESP_ENC_BINARY == (_encoding&RESP_ENC_BINARY)) && (len != 0)) |
|
{ |
|
_defaultNamespace = (char*)malloc(len+1); |
|
if (0==_defaultNamespace) |
|
{ |
|
return; |
|
} |
|
memcpy(_defaultNamespace, ns, len+1); |
|
_defaultNamespaceLen = len; |
|
} |
| |
cops.clear(); |
|
| |
for (Uint32 i = 0; i < data->_referencesData.size(); i++) |
if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)) |
{ | { |
CIMObjectPath cop; |
CIMNamespaceName nsName(ns); |
|
switch (_dataType) |
// Deserialize path: |
|
{ | { |
XmlParser parser((char*)data->_referencesData[i].getData()); |
case RESP_INSTANCE: |
|
|
if (XmlReader::getInstanceNameElement(parser, cop)) |
|
{ | { |
if (!data->_nameSpacesData[i].isNull()) |
if (_instances.size() > 0) |
cop.setNameSpace(data->_nameSpacesData[i]); |
{ |
|
const CIMInstance& inst = _instances[0]; |
if (data->_hostsData[i].size()) |
CIMObjectPath& p = |
cop.setHost(data->_hostsData[i]); |
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: |
{ | { |
fprintf(stderr, |
for (Uint32 j = 0, n = _objects.size(); j < n; j++) |
"CIMInstanceNamesResponseData::_resolveSCMOInstanceNames() " |
|
"Exception:\n%s\n",(const char*)ex.getMessage().getCString()); |
|
} |
|
catch (exception& ex) |
|
{ | { |
fprintf(stderr, |
const CIMObject& object = _objects[j]; |
"CIMInstanceNamesResponseData::_resolveSCMOInstanceNames() " |
CIMObjectPath& p = |
"exception:\n%s\n",(const char*)ex.what()); |
const_cast<CIMObjectPath&>(object.getPath()); |
} |
if (p.getNameSpace().isNull()) |
catch (...) |
|
{ | { |
fprintf(stderr, |
p.setNameSpace(nsName); |
"CIMInstanceNamesResponseData::_resolveSCMOInstanceNames() " |
|
"Exception: UNKNOWN\n"); |
|
} | } |
data->_resolveCallback = 0; |
|
|
|
PEG_METHOD_EXIT(); |
|
return true; |
|
} | } |
|
break; |
|
} |
//----------------------------------------------------------------------------- |
case RESP_INSTNAMES: |
// |
case RESP_OBJECTPATHS: |
// 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 = _instanceNames.size(); j < n; j++) |
"CIMInstanceResponseData::setBinaryCimInstance"); |
|
|
|
if (hasLen) |
|
{ | { |
if (!in.getUint8A(_binaryData)) |
CIMObjectPath& p = _instanceNames[j]; |
|
if (p.getNameSpace().isNull()) |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
p.setNameSpace(nsName); |
"Failed to get binary instance data!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} | } |
} | } |
else |
break; |
|
} |
|
default: |
{ | { |
size_t remainingDataLength = in.capacity() - in.size(); |
PEGASUS_DEBUG_ASSERT(false); |
|
|
_binaryData.append((Uint8*)in.getPtr(), remainingDataLength); |
|
} | } |
|
} |
_resolveCallback = _resolveBinaryInstance; |
} |
_encoding = RESP_ENC_BINARY; |
if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO)) |
|
|
PEG_METHOD_EXIT(); |
|
return true; |
|
}; |
|
|
|
bool CIMInstanceResponseData::setXmlCimInstance(CIMBuffer& in) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++) |
"CIMInstanceResponseData::setXmlCimInstance"); |
|
|
|
if (!in.getSint8A(_instanceData)) |
|
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
SCMOInstance & scmoInst=_scmoInstances[j]; |
"Failed to get XML instance data!"); |
if (0 == scmoInst.getNameSpace()) |
PEG_METHOD_EXIT(); |
|
return false; |
|
} |
|
|
|
if (!in.getSint8A(_referenceData)) |
|
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
scmoInst.setNameSpace_l(ns,len); |
"Failed to get XML instance data (reference)!"); |
} |
PEG_METHOD_EXIT(); |
|
return false; |
|
} | } |
|
|
if (!in.getString(_hostData)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML instance data (host)!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} | } |
|
|
if (!in.getNamespaceName(_nameSpaceData)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML instance data (namespace)!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} | } |
| |
_resolveCallback = _resolveXMLInstance; |
|
_encoding = RESP_ENC_XML; |
|
|
|
PEG_METHOD_EXIT(); |
|
return true; |
|
}; |
|
| |
//------------------------------------------------------------------------------ |
void CIMResponseData::completeHostNameAndNamespace( |
// Encodes the CIMInstance representation contained in the current |
const String & hn, |
// CIMResponseData object in binary response message format. |
const CIMNamespaceName & ns) |
// 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, |
// Only perform this operation when we have instantiated data. |
"CIMInstanceResponseData::encodeBinaryResponse"); |
// Do nothing for binary and internal xml data. |
| |
if (_resolveCallback && (_encoding == RESP_ENC_BINARY)) |
if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)) |
{ | { |
const Array<Uint8>& data = _binaryData; |
switch (_dataType) |
out.putBytes(data.getData(), data.size()); |
{ |
|
case RESP_OBJECTS: |
|
{ |
|
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); |
} | } |
else |
if (p.getNameSpace().isNull()) |
{ | { |
out.putInstance(_cimInstance, false, false); |
p.setNameSpace(ns); |
} | } |
PEG_METHOD_EXIT(); |
|
} | } |
|
break; |
//------------------------------------------------------------------------------ |
} |
// Encodes the CIMInstanc representation contained in the current |
case RESP_OBJECTPATHS: |
// 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) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
for (Uint32 j = 0, n = _instanceNames.size(); j < n; j++) |
"CIMInstanceResponseData::encodeXmlResponse"); |
|
|
|
if (_resolveCallback && (_encoding == RESP_ENC_XML)) |
|
{ | { |
out.append( (char*)_instanceData.getData(),_instanceData.size()-1); |
CIMObjectPath& p = _instanceNames[j]; |
|
if (p.getHost().size() == 0) |
|
p.setHost(hn); |
|
if (p.getNameSpace().isNull()) |
|
p.setNameSpace(ns); |
} | } |
else |
break; |
|
} |
|
default: |
{ | { |
_resolve(); |
PEGASUS_DEBUG_ASSERT(false); |
XmlWriter::appendInstanceElement(out, _cimInstance); |
|
//SCMOXmlWriter::appendValueSCMOInstanceElement(out, _cimInstance); |
|
} | } |
PEG_METHOD_EXIT(); |
|
} | } |
|
} |
//------------------------------------------------------------------------------ |
if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO)) |
// Instantiates a CIMInstance from a binary representation created by |
|
// the CIMBinMessageSerializer. |
|
// Returns true on success. |
|
//------------------------------------------------------------------------------ |
|
Boolean CIMInstanceResponseData::_resolveBinaryInstance( |
|
CIMInstanceResponseData* data, |
|
CIMInstance& instance) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
CString hnCString=hn.getCString(); |
"CIMInstanceResponseData::_resolveBinaryInstance"); |
const char* hnChars = hnCString; |
|
Uint32 hnLen = strlen(hnChars); |
CIMBuffer in((char*)data->_binaryData.getData(), data->_binaryData.size()); |
CString nsCString=ns.getString().getCString(); |
|
const char* nsChars=nsCString; |
if (!in.getInstance(instance)) |
Uint32 nsLen = strlen(nsChars); |
|
switch (_dataType) |
{ | { |
instance = CIMInstance(); |
case RESP_OBJECTS: |
in.release(); |
case RESP_OBJECTPATHS: |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to resolve binary instance!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} |
|
|
|
in.release(); |
|
PEG_METHOD_EXIT(); |
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// Instantiates a CIMInstance from a SCMOInstance |
|
// Returns true on success. |
|
//------------------------------------------------------------------------------ |
|
Boolean CIMInstanceResponseData::_resolveSCMOInstance( |
|
CIMInstanceResponseData* data, |
|
CIMInstance& instance) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++) |
"CIMInstanceResponseData::_resolveSCMOInstance"); |
|
|
|
//--rk-->TBD: Do the actual coding here |
|
|
|
fprintf(stderr,"CIMInstanceResponseData::_resolveSCMOInstance() " |
|
"Poorly implemented!!!\n"); |
|
try |
|
{ | { |
/*SCMODump dmp; |
SCMOInstance & scmoInst=_scmoInstances[j]; |
dmp.dumpSCMOInstanceKeyBindings(data->_scmoInstances[0]); |
if (0 == scmoInst.getHostName()) |
dmp.dumpInstanceProperties(data->_scmoInstances[0]);*/ |
|
data->_scmoInstances[0].getCIMInstance(instance); |
|
} |
|
catch (CIMException& ex) |
|
{ | { |
fprintf(stderr,"CIMInstanceResponseData::_resolveSCMOInstance() " |
scmoInst.setHostName_l(hnChars,hnLen); |
"Exception:\n%s\n",(const char*)ex.getMessage().getCString()); |
|
} | } |
catch (Exception& ex) |
if (0 == scmoInst.getNameSpace()) |
{ | { |
fprintf(stderr,"CIMInstanceResponseData::_resolveSCMOInstance() " |
scmoInst.setNameSpace_l(nsChars,nsLen); |
"Exception:\n%s\n",(const char*)ex.getMessage().getCString()); |
|
} | } |
catch (exception& ex) |
|
{ |
|
fprintf(stderr,"CIMInstanceResponseData::_resolveSCMOInstance() " |
|
"exception:\n%s\n",(const char*)ex.what()); |
|
} | } |
catch (...) |
break; |
|
} |
|
default: |
{ | { |
fprintf(stderr,"CIMInstancesResponseData::_resolveSCMOInstances() " |
PEGASUS_DEBUG_ASSERT(false); |
"Exception: UNKNOWN\n"); |
} |
|
} |
} | } |
data->_resolveCallback = 0; |
|
|
|
PEG_METHOD_EXIT(); |
|
return true; |
|
} | } |
| |
//------------------------------------------------------------------------------ |
void CIMResponseData::encodeXmlResponse(Buffer& out) |
// 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, |
PEG_TRACE((TRC_XML, Tracer::LEVEL3, |
"CIMInstanceResponseData::_resolveXMLInstance"); |
"CIMResponseData::encodeXmlResponse(encoding=%X,content=%X)\n", |
|
_encoding, |
|
_dataType)); |
| |
// Deserialize instance: |
// already existing Internal XML does not need to be encoded further |
|
// binary input is not actually impossible here, but we have an established |
|
// fallback |
|
if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY)) |
{ | { |
XmlParser parser((char*)data->_instanceData.getData()); |
_resolveBinary(); |
|
} |
| |
if (!XmlReader::getInstanceElement(parser, cimInstance)) |
if (RESP_ENC_XML == (_encoding & RESP_ENC_XML)) |
{ | { |
cimInstance = CIMInstance(); |
switch (_dataType) |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
{ |
"Failed to resolve XML instance, parser error!"); |
case RESP_INSTANCE: |
PEG_METHOD_EXIT(); |
{ |
return false; |
const Array<ArraySint8>& a = _instanceData; |
} |
out.append((char*)a[0].getData(), a[0].size() - 1); |
|
break; |
} | } |
|
case RESP_INSTANCES: |
// Deserialize path: |
|
{ | { |
XmlParser parser((char*)data->_referenceData.getData()); |
const Array<ArraySint8>& a = _instanceData; |
CIMObjectPath cimObjectPath; |
const Array<ArraySint8>& b = _referencesData; |
| |
if (XmlReader::getValueReferenceElement(parser, cimObjectPath)) |
for (Uint32 i = 0, n = a.size(); i < n; i++) |
{ | { |
if (data->_hostData.size()) |
out << STRLIT("<VALUE.NAMEDINSTANCE>\n"); |
cimObjectPath.setHost(data->_hostData); |
out.append((char*)b[i].getData(), b[i].size() - 1); |
|
out.append((char*)a[i].getData(), a[i].size() - 1); |
if (!data->_nameSpaceData.isNull()) |
out << STRLIT("</VALUE.NAMEDINSTANCE>\n"); |
cimObjectPath.setNameSpace(data->_nameSpaceData); |
|
|
|
cimInstance.setPath(cimObjectPath); |
|
} | } |
|
break; |
} | } |
|
case RESP_OBJECTS: |
PEG_METHOD_EXIT(); |
|
return true; |
|
} |
|
|
|
|
|
|
|
//----------------------------------------------------------------------------- |
|
// |
|
// 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, |
const Array<ArraySint8>& a = _instanceData; |
"CIMInstancesResponseData::setBinaryCimInstances"); |
const Array<ArraySint8>& b = _referencesData; |
| |
if (hasLen) |
for (Uint32 i = 0, n = a.size(); i < n; i++) |
{ |
|
if (!in.getUint8A(_binaryData)) |
|
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
out << STRLIT("<VALUE.OBJECTWITHPATH>\n"); |
"Failed to get binary instance data!"); |
out.append((char*)b[i].getData(), b[i].size() - 1); |
PEG_METHOD_EXIT(); |
out.append((char*)a[i].getData(), a[i].size() - 1); |
return false; |
out << STRLIT("</VALUE.OBJECTWITHPATH>\n"); |
} | } |
|
break; |
} | } |
else |
// internal xml encoding of instance names and object paths not |
|
// done today |
|
case RESP_INSTNAMES: |
|
case RESP_OBJECTPATHS: |
|
default: |
{ | { |
size_t remainingDataLength = in.capacity() - in.size(); |
PEGASUS_DEBUG_ASSERT(false); |
_binaryData.append((Uint8*)in.getPtr(), remainingDataLength); |
} |
|
} |
} | } |
| |
_resolveCallback = _resolveBinaryInstances; |
if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)) |
_encoding = RESP_ENC_BINARY; |
|
|
|
PEG_METHOD_EXIT(); |
|
return true; |
|
}; |
|
|
|
bool CIMInstancesResponseData::setXmlCimInstances(CIMBuffer& in) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
switch (_dataType) |
"CIMInstancesResponseData::setXmlCimInstances"); |
|
|
|
Uint32 count; |
|
|
|
if (!in.getUint32(count)) |
|
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
case RESP_INSTNAMES: |
"Failed to get XML instance data (number of instance)!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} |
|
|
|
for (Uint32 i = 0; i < count; i++) |
|
{ | { |
Array<Sint8> inst; |
for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++) |
Array<Sint8> ref; |
|
CIMNamespaceName ns; |
|
String host; |
|
|
|
if (!in.getSint8A(inst)) |
|
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
XmlWriter::appendInstanceNameElement(out,_instanceNames[i]); |
"Failed to get XML instance data (instances)!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} | } |
|
break; |
if (!in.getSint8A(ref)) |
} |
|
case RESP_INSTANCE: |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
if (_instances.size() > 0) |
"Failed to get XML instance data (references)!"); |
{ |
PEG_METHOD_EXIT(); |
XmlWriter::appendInstanceElement(out, _instances[0]); |
return false; |
|
} | } |
|
break; |
if (!in.getString(host)) |
} |
|
case RESP_INSTANCES: |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
for (Uint32 i = 0, n = _instances.size(); i < n; i++) |
"Failed to get XML instance data (host)!"); |
{ |
PEG_METHOD_EXIT(); |
XmlWriter::appendValueNamedInstanceElement( |
return false; |
out, _instances[i]); |
} | } |
|
break; |
if (!in.getNamespaceName(ns)) |
} |
|
case RESP_OBJECTS: |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
for (Uint32 i = 0; i < _objects.size(); i++) |
"Failed to get XML instance data (namespace)!"); |
{ |
PEG_METHOD_EXIT(); |
XmlWriter::appendValueObjectWithPathElement( |
return false; |
out, |
|
_objects[i]); |
} | } |
|
break; |
_instancesData.append(inst); |
|
_referencesData.append(ref); |
|
_hostsData.append(host); |
|
_nameSpacesData.append(ns); |
|
} | } |
|
case RESP_OBJECTPATHS: |
_resolveCallback = _resolveXMLInstances; |
|
_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, |
for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++) |
"CIMInstancesResponseData::encodeBinaryResponse"); |
|
|
|
if (_resolveCallback && (_encoding == RESP_ENC_BINARY)) |
|
{ | { |
const Array<Uint8>& data = _binaryData; |
out << "<OBJECTPATH>\n"; |
out.putBytes(data.getData(), data.size()); |
XmlWriter::appendValueReferenceElement( |
|
out, |
|
_instanceNames[i], |
|
false); |
|
out << "</OBJECTPATH>\n"; |
} | } |
else |
break; |
|
} |
|
default: |
{ | { |
_resolve(); |
PEGASUS_DEBUG_ASSERT(false); |
out.putInstanceA(_namedInstances, false); |
|
} | } |
PEG_METHOD_EXIT(); |
|
} | } |
|
} |
//------------------------------------------------------------------------------ |
if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO)) |
// 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, |
switch (_dataType) |
"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"); |
case RESP_INSTNAMES: |
out.append((char*)b[i].getData(), b[i].size() - 1); |
{ |
out.append((char*)a[i].getData(), a[i].size() - 1); |
for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++) |
out << STRLIT("</VALUE.NAMEDINSTANCE>\n"); |
{ |
|
SCMOXmlWriter::appendInstanceNameElement( |
|
out, |
|
_scmoInstances[i]); |
} | } |
|
break; |
} | } |
else |
case RESP_INSTANCE: |
{ | { |
// DO NOT RESOLVE, use the SCMOXmlWriter to encode |
if (_scmoInstances.size() > 0) |
// _resolve(); |
|
for (Uint32 i = 0, n = _namedInstances.size(); i < n; i++) |
|
{ | { |
XmlWriter::appendValueNamedInstanceElement( |
SCMOXmlWriter::appendInstanceElement(out,_scmoInstances[0]); |
out, _namedInstances[i]); |
|
} | } |
|
break; |
|
} |
|
case RESP_INSTANCES: |
|
{ |
for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++) | for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++) |
{ | { |
/*SCMODump dmp; |
|
dmp.dumpSCMOInstanceKeyBindings(_scmoInstances[i]); |
|
dmp.dumpInstanceProperties(_scmoInstances[i]);*/ |
|
|
|
SCMOXmlWriter::appendValueSCMOInstanceElement( | SCMOXmlWriter::appendValueSCMOInstanceElement( |
out, _scmoInstances[i]); |
out, |
|
_scmoInstances[i]); |
/* fprintf( |
|
stderr, |
|
"After appendValueNamedInstanceElement()\n%s", |
|
out.getData()); |
|
fflush(stderr);*/ |
|
|
|
} | } |
|
break; |
} | } |
PEG_METHOD_EXIT(); |
case RESP_OBJECTS: |
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// Instantiates an array of CIMInstances from a binary representation created by |
|
// the CIMBinMessageSerializer. |
|
// Returns true on success. |
|
//------------------------------------------------------------------------------ |
|
Boolean CIMInstancesResponseData::_resolveBinaryInstances( |
|
CIMInstancesResponseData* data, |
|
Array<CIMInstance>& instances) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
for (Uint32 i = 0; i < _scmoInstances.size(); i++) |
"CIMInstancesResponseData::_resolveBinaryInstances"); |
|
|
|
instances.clear(); |
|
|
|
CIMBuffer in((char*)data->_binaryData.getData(), data->_binaryData.size()); |
|
|
|
while (in.more()) |
|
{ | { |
if (!in.getInstanceA(instances)) |
SCMOXmlWriter::appendValueObjectWithPathElement( |
{ |
out, |
in.release(); |
_scmoInstances[i]); |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to remove binary instance!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} | } |
|
break; |
} | } |
|
case RESP_OBJECTPATHS: |
in.release(); |
|
PEG_METHOD_EXIT(); |
|
return true; |
|
} |
|
|
|
|
|
|
|
//------------------------------------------------------------------------------ |
|
// 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, |
for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++) |
"CIMInstancesResponseData::_resolveXMLInstances"); |
|
|
|
instances.clear(); |
|
|
|
for (Uint32 i = 0; i < data->_instancesData.size(); i++) |
|
{ |
|
CIMInstance cimInstance; |
|
|
|
// Deserialize instance: |
|
{ | { |
XmlParser parser((char*)data->_instancesData[i].getData()); |
out << "<OBJECTPATH>\n"; |
|
SCMOXmlWriter::appendValueReferenceElement( |
if (!XmlReader::getInstanceElement(parser, cimInstance)) |
out, |
|
_scmoInstances[i], |
|
false); |
|
out << "</OBJECTPATH>\n"; |
|
} |
|
break; |
|
} |
|
default: |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
PEGASUS_DEBUG_ASSERT(false); |
"Failed to resolve XML instance. Creating empty instance!"); |
} |
cimInstance = CIMInstance(); |
} |
} | } |
} | } |
| |
// Deserialize path: |
// contrary to encodeXmlResponse this function encodes the Xml in a format |
|
// not usable by clients |
|
void CIMResponseData::encodeInternalXmlResponse(CIMBuffer& out) |
{ | { |
XmlParser parser((char*)data->_referencesData[i].getData()); |
PEG_TRACE((TRC_XML, Tracer::LEVEL3, |
CIMObjectPath cimObjectPath; |
"CIMResponseData::encodeInternalXmlResponse(encoding=%X,content=%X)\n", |
|
_encoding, |
|
_dataType)); |
| |
if (XmlReader::getInstanceNameElement(parser, cimObjectPath)) |
// already existing Internal XML does not need to be encoded further |
|
// binary input is not actually impossible here, but we have an established |
|
// fallback |
|
if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY)) |
{ | { |
if (!data->_nameSpacesData[i].isNull()) |
_resolveBinary(); |
cimObjectPath.setNameSpace(data->_nameSpacesData[i]); |
|
|
|
if (data->_hostsData[i].size()) |
|
cimObjectPath.setHost(data->_hostsData[i]); |
|
|
|
cimInstance.setPath(cimObjectPath); |
|
} | } |
|
if ((0 == _encoding) || |
|
(RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))) |
|
{ |
|
switch (_dataType) |
|
{ |
|
case RESP_INSTANCE: |
|
{ |
|
if (0 == _instances.size()) |
|
{ |
|
_instances.append(CIMInstance()); |
} | } |
|
CIMInternalXmlEncoder::_putXMLInstance(out, _instances[0]); |
instances.append(cimInstance); |
break; |
} | } |
|
case RESP_INSTANCES: |
PEG_METHOD_EXIT(); |
{ |
return true; |
Uint32 n = _instances.size(); |
|
out.putUint32(n); |
|
for (Uint32 i = 0; i < n; i++) |
|
{ |
|
CIMInternalXmlEncoder::_putXMLNamedInstance( |
|
out, |
|
_instances[i]); |
} | } |
|
break; |
//------------------------------------------------------------------------------ |
} |
// Instantiates an array of CIMInstances from an array of SCMOInstances |
case RESP_OBJECTS: |
// Returns true on success. |
|
//------------------------------------------------------------------------------ |
|
Boolean CIMInstancesResponseData::_resolveSCMOInstances( |
|
CIMInstancesResponseData* data, |
|
Array<CIMInstance>& instances) |
|
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, |
Uint32 n = _objects.size(); |
"CIMInstancesResponseData::_resolveSCMOInstances"); |
out.putUint32(n); |
|
for (Uint32 i = 0; i < n; i++) |
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++) |
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: |
{ | { |
/*SCMODump dmp; |
PEGASUS_DEBUG_ASSERT(false); |
dmp.dumpSCMOInstanceKeyBindings(data->_scmoInstances[x]); |
} |
dmp.dumpInstanceProperties(data->_scmoInstances[x]);*/ |
|
CIMInstance newInstance; |
|
data->_scmoInstances[x].getCIMInstance(newInstance); |
|
instances.append(newInstance); |
|
} | } |
} | } |
catch (CIMException& ex) |
if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO)) |
|
{ |
|
switch (_dataType) |
|
{ |
|
case RESP_INSTANCE: |
{ | { |
fprintf(stderr,"CIMInstancesResponseData::_resolveSCMOInstances() " |
if (0 == _scmoInstances.size()) |
"Exception:\n%s\n",(const char*)ex.getMessage().getCString()); |
{ |
|
_scmoInstances.append(SCMOInstance()); |
|
} |
|
SCMOInternalXmlEncoder::_putXMLInstance(out, _scmoInstances[0]); |
|
break; |
} | } |
catch (Exception& ex) |
case RESP_INSTANCES: |
{ | { |
fprintf(stderr,"CIMInstancesResponseData::_resolveSCMOInstances() " |
Uint32 n = _scmoInstances.size(); |
"Exception:\n%s\n",(const char*)ex.getMessage().getCString()); |
out.putUint32(n); |
|
for (Uint32 i = 0; i < n; i++) |
|
{ |
|
SCMOInternalXmlEncoder::_putXMLNamedInstance( |
|
out, |
|
_scmoInstances[i]); |
|
} |
|
break; |
} | } |
catch (exception& ex) |
case RESP_OBJECTS: |
{ | { |
fprintf(stderr,"CIMInstancesResponseData::_resolveSCMOInstances() " |
Uint32 n = _scmoInstances.size(); |
"exception:\n%s\n",(const char*)ex.what()); |
out.putUint32(n); |
|
for (Uint32 i = 0; i < n; i++) |
|
{ |
|
SCMOInternalXmlEncoder::_putXMLObject( |
|
out, |
|
_scmoInstances[i]); |
|
} |
|
break; |
} | } |
catch (...) |
// 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: UNKNOWN\n"); |
} |
|
} |
} | } |
data->_resolveCallback = 0; |
|
|
|
PEG_METHOD_EXIT(); |
|
return true; |
|
} | } |
| |
|
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)) |
// |
{ |
// CIMObjectsResponseData |
_resolveXmlToCIM(); |
// |
} |
//----------------------------------------------------------------------------- |
if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY)) |
|
{ |
|
_resolveBinary(); |
|
} |
|
if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO)) |
|
{ |
|
_resolveSCMOToCIM(); |
|
} |
| |
|
PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_CIM || _encoding == 0); |
|
} |
| |
//------------------------------------------------------------------------------ |
void CIMResponseData::_resolveToSCMO() |
// 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) |
{ | { |
|
// TODO: Decide what to decode based on marker |
|
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); |
case RESP_OBJECTS: |
_hostsData.append(host); |
{ |
_nameSpacesData.append(ns); |
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(); |
|
return; |
|
} |
|
break; |
|
} |
|
default: |
|
{ |
|
PEGASUS_DEBUG_ASSERT(false); |
|
} |
|
} // switch |
|
_encoding |= RESP_ENC_CIM; |
|
} // else SCMO |
} | } |
| |
_resolveCallback = _resolveXMLObjects; |
_encoding &=(~RESP_ENC_BINARY); |
_binaryEncoding = false; |
|
| |
|
in.release(); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return true; |
|
} | } |
| |
//------------------------------------------------------------------------------ |
void CIMResponseData::_resolveXmlToCIM() |
// Encodes the array of CIMObject representation contained in the current |
|
// 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, |
switch (_dataType) |
"CIMObjectsResponseData::encodeBinaryResponse"); |
{ |
|
// same encoding for instance names and object paths |
|
case RESP_OBJECTPATHS: |
|
case RESP_INSTNAMES: |
|
{ |
|
for (Uint32 i = 0; i < _referencesData.size(); i++) |
|
{ |
|
CIMObjectPath cop; |
|
// Deserialize path: |
|
{ |
|
XmlParser parser((char*)_referencesData[i].getData()); |
| |
if (_resolveCallback && _binaryEncoding) |
if (XmlReader::getInstanceNameElement(parser, cop)) |
{ | { |
const Array<Uint8>& data = _binaryData; |
if (!_nameSpacesData[i].isNull()) |
out.putBytes(data.getData(), data.size()); |
cop.setNameSpace(_nameSpacesData[i]); |
|
|
|
if (_hostsData[i].size()) |
|
cop.setHost(_hostsData[i]); |
} | } |
else |
|
{ |
|
out.putObjectA(_cimObjects); |
|
} | } |
PEG_METHOD_EXIT(); |
_instanceNames.append(cop); |
} | } |
|
break; |
//------------------------------------------------------------------------------ |
} |
// Encodes the array of CIMObject representation contained in the current |
case RESP_INSTANCE: |
// 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, |
CIMInstance cimInstance; |
"CIMObjectsResponseData::encodeXmlResponse"); |
// Deserialize instance: |
|
|
if (_resolveCallback && !_binaryEncoding) |
|
{ | { |
const Array<ArraySint8>& a = _cimObjectsData; |
XmlParser parser((char*)_instanceData[0].getData()); |
const Array<ArraySint8>& b = _referencesData; |
|
| |
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: |
{ | { |
for (Uint32 i = 0; i < _cimObjects.size(); i++) |
XmlParser parser((char*)_referencesData[0].getData()); |
|
CIMObjectPath cimObjectPath; |
|
|
|
if (XmlReader::getValueReferenceElement(parser, cimObjectPath)) |
|
{ |
|
if (_hostsData.size()) |
{ | { |
XmlWriter::appendValueObjectWithPathElement(out, _cimObjects[i]); |
cimObjectPath.setHost(_hostsData[0]); |
} | } |
|
if (!_nameSpacesData[0].isNull()) |
|
{ |
|
cimObjectPath.setNameSpace(_nameSpacesData[0]); |
} | } |
PEG_METHOD_EXIT(); |
cimInstance.setPath(cimObjectPath); |
|
// only if everything works we add the CIMInstance to the |
|
// array |
|
_instances.append(cimInstance); |
} | } |
|
} |
//------------------------------------------------------------------------------ |
break; |
// Instantiates an array of CIMObjects from a binary representation created by |
} |
// the CIMBinMessageSerializer. |
case RESP_INSTANCES: |
// 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]); |
| |
cimObjects.clear(); |
if (_hostsData[i].size()) |
|
cimObjectPath.setHost(_hostsData[i]); |
| |
for (Uint32 i=0, n=data->_cimObjectsData.size(); i<n; i++) |
cimInstance.setPath(cimObjectPath); |
|
} |
|
} |
|
|
|
_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() |
|
{ |
|
switch (_dataType) |
|
{ |
|
case RESP_INSTNAMES: |
|
{ |
|
for (Uint32 i=0,n=_instanceNames.size();i<n;i++) |
|
{ |
|
SCMOInstance addme( |
|
_instanceNames[i], |
|
_defaultNamespace, |
|
_defaultNamespaceLen); |
|
_scmoInstances.append(addme); |
|
} |
|
_instanceNames.clear(); |
|
break; |
|
} |
|
case RESP_INSTANCE: |
|
{ |
|
if (_instances.size() > 0) |
|
{ |
|
SCMOInstance addme( |
|
_instances[0], |
|
_defaultNamespace, |
|
_defaultNamespaceLen); |
|
_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], |
|
_defaultNamespace, |
|
_defaultNamespaceLen); |
|
_scmoInstances.append(addme); |
|
} |
|
_instances.clear(); |
|
break; |
|
} |
|
case RESP_OBJECTS: |
|
{ |
|
for (Uint32 i=0,n=_objects.size();i<n;i++) |
|
{ |
|
SCMOInstance addme( |
|
_objects[i], |
|
_defaultNamespace, |
|
_defaultNamespaceLen); |
|
_scmoInstances.append(addme); |
|
} |
|
_objects.clear(); |
|
break; |
|
} |
|
case RESP_OBJECTPATHS: |
|
{ |
|
for (Uint32 i=0,n=_instanceNames.size();i<n;i++) |
|
{ |
|
SCMOInstance addme( |
|
_instanceNames[i], |
|
_defaultNamespace, |
|
_defaultNamespaceLen); |
|
// 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 |