version 1.1, 2009/06/30 10:31:30
|
version 1.2.2.1, 2009/08/17 13:47:46
|
|
|
| |
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- |
// | // |
|
// CIMInstanceNamesResponseData |
|
// |
|
//----------------------------------------------------------------------------- |
|
|
|
//------------------------------------------------------------------------------ |
|
// Takes a binary stream of object paths from a CIMBuffer and stores it in the |
|
// responsedata. |
|
// @param hasLen Indicates if the binary object path stream is prepended with an |
|
// Uint32 value indicating the number of paths in the stream. |
|
//------------------------------------------------------------------------------ |
|
bool CIMInstanceNamesResponseData::setBinaryCimInstanceNames( |
|
CIMBuffer& in, bool hasLen) |
|
{ |
|
PEG_METHOD_ENTER(TRC_DISPATCHER, |
|
"CIMInstanceNamesResponseData::setBinaryCimInstanceNames"); |
|
|
|
if (hasLen) |
|
{ |
|
if (!in.getUint8A(_binaryData)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get binary object path data!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} |
|
} |
|
else |
|
{ |
|
size_t remainingDataLength = in.capacity() - in.size(); |
|
_binaryData.append((Uint8*)in.getPtr(), remainingDataLength); |
|
} |
|
|
|
_resolveCallback = _resolveBinaryInstanceNames; |
|
_encoding = RESP_ENC_BINARY; |
|
|
|
PEG_METHOD_EXIT(); |
|
return true; |
|
}; |
|
|
|
bool CIMInstanceNamesResponseData::setXmlCimInstanceNames(CIMBuffer& in) |
|
{ |
|
PEG_METHOD_ENTER(TRC_DISPATCHER, |
|
"CIMInstanceNamesResponseData::setXmlCimInstanceNames"); |
|
|
|
Uint32 count; |
|
|
|
if (!in.getUint32(count)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML objectpath data (number of paths)!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} |
|
|
|
for (Uint32 i = 0; i < count; i++) |
|
{ |
|
Array<Sint8> ref; |
|
CIMNamespaceName ns; |
|
String host; |
|
|
|
if (!in.getSint8A(ref)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML objectpath data (references)!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} |
|
|
|
if (!in.getString(host)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML instance data (host)!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} |
|
|
|
if (!in.getNamespaceName(ns)) |
|
{ |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to get XML instance data (namespace)!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} |
|
|
|
_referencesData.append(ref); |
|
_hostsData.append(host); |
|
_nameSpacesData.append(ns); |
|
} |
|
|
|
_resolveCallback = _resolveXMLInstanceNames; |
|
_encoding = RESP_ENC_XML; |
|
|
|
PEG_METHOD_EXIT(); |
|
return true; |
|
}; |
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------ |
|
// Encodes the array of CIMObjectPath representation contained in the current |
|
// 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, |
|
"CIMInstanceNamesResponseData::encodeBinaryResponse"); |
|
|
|
if (_resolveCallback && (_encoding == RESP_ENC_BINARY)) |
|
{ |
|
const Array<Uint8>& data = _binaryData; |
|
out.putBytes(data.getData(), data.size()); |
|
} |
|
else |
|
{ |
|
_resolve(); |
|
out.putObjectPathA(_instanceNames, false); |
|
} |
|
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, |
|
"CIMInstanceNamesResponseData::encodeXmlResponse"); |
|
|
|
if (_resolveCallback && (_encoding == RESP_ENC_XML)) |
|
{ |
|
const Array<ArraySint8>& a = _referencesData; |
|
|
|
for (Uint32 i = 0, n = a.size(); i < n; i++) |
|
{ |
|
out.append((char*)a[i].getData(), a[i].size() - 1); |
|
} |
|
} |
|
else |
|
{ |
|
_resolve(); |
|
for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++) |
|
XmlWriter::appendInstanceNameElement(out,_instanceNames[i]); |
|
} |
|
PEG_METHOD_EXIT(); |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// 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, |
|
"CIMInstanceNamesResponseData::_resolveBinaryInstanceNames"); |
|
|
|
cops.clear(); |
|
|
|
CIMBuffer in((char*)data->_binaryData.getData(), data->_binaryData.size()); |
|
|
|
while (in.more()) |
|
{ |
|
if (!in.getObjectPathA(cops)) |
|
{ |
|
in.release(); |
|
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
"Failed to resolve binary objectpath!"); |
|
PEG_METHOD_EXIT(); |
|
return false; |
|
} |
|
} |
|
|
|
in.release(); |
|
PEG_METHOD_EXIT(); |
|
return true; |
|
} |
|
|
|
|
|
|
|
//------------------------------------------------------------------------------ |
|
// 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, |
|
"CIMInstanceNamesResponseData::_resolveXMLInstanceNames"); |
|
|
|
cops.clear(); |
|
|
|
for (Uint32 i = 0; i < data->_referencesData.size(); i++) |
|
{ |
|
CIMObjectPath cop; |
|
|
|
// Deserialize path: |
|
{ |
|
XmlParser parser((char*)data->_referencesData[i].getData()); |
|
|
|
if (XmlReader::getInstanceNameElement(parser, cop)) |
|
{ |
|
if (!data->_nameSpacesData[i].isNull()) |
|
cop.setNameSpace(data->_nameSpacesData[i]); |
|
|
|
if (data->_hostsData[i].size()) |
|
cop.setHost(data->_hostsData[i]); |
|
} |
|
} |
|
|
|
cops.append(cop); |
|
} |
|
|
|
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, |
|
"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++) |
|
{ |
|
/*SCMODump dmp; |
|
dmp.dumpSCMOInstanceKeyBindings(data->_scmoInstanceNames[x]);*/ |
|
CIMObjectPath cop; |
|
data->_scmoInstanceNames[x].getCIMObjectPath(cop); |
|
cops.append(cop); |
|
} |
|
} |
|
catch (CIMException& ex) |
|
{ |
|
fprintf(stderr, |
|
"CIMInstanceNamesResponseData::_resolveSCMOInstanceNames() " |
|
"Exception:\n%s\n",(const char*)ex.getMessage().getCString()); |
|
} |
|
catch (Exception& ex) |
|
{ |
|
fprintf(stderr, |
|
"CIMInstanceNamesResponseData::_resolveSCMOInstanceNames() " |
|
"Exception:\n%s\n",(const char*)ex.getMessage().getCString()); |
|
} |
|
catch (exception& ex) |
|
{ |
|
fprintf(stderr, |
|
"CIMInstanceNamesResponseData::_resolveSCMOInstanceNames() " |
|
"exception:\n%s\n",(const char*)ex.what()); |
|
} |
|
catch (...) |
|
{ |
|
fprintf(stderr, |
|
"CIMInstanceNamesResponseData::_resolveSCMOInstanceNames() " |
|
"Exception: UNKNOWN\n"); |
|
} |
|
data->_resolveCallback = 0; |
|
|
|
PEG_METHOD_EXIT(); |
|
return true; |
|
} |
|
|
|
|
|
//----------------------------------------------------------------------------- |
|
// |
// CIMInstanceResponseData | // CIMInstanceResponseData |
// | // |
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- |
| |
bool CIMInstanceResponseData::setBinaryCimInstance(CIMBuffer& in) |
//------------------------------------------------------------------------------ |
|
// 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, | PEG_METHOD_ENTER(TRC_DISPATCHER, |
"CIMInstanceResponseData::setBinaryCimInstance"); | "CIMInstanceResponseData::setBinaryCimInstance"); |
| |
|
if (hasLen) |
|
{ |
if (!in.getUint8A(_binaryData)) | if (!in.getUint8A(_binaryData)) |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, | PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return false; | return false; |
} | } |
|
} |
|
else |
|
{ |
|
size_t remainingDataLength = in.capacity() - in.size(); |
|
|
|
_binaryData.append((Uint8*)in.getPtr(), remainingDataLength); |
|
} |
| |
_resolveCallback = _resolveBinaryInstance; | _resolveCallback = _resolveBinaryInstance; |
_binaryEncoding = true; | _binaryEncoding = true; |
|
|
} | } |
| |
_resolveCallback = _resolveXMLInstance; | _resolveCallback = _resolveXMLInstance; |
_binaryEncoding = false; |
|
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return true; | return true; |
|
|
} | } |
| |
| |
|
|
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- |
// | // |
// CIMInstancesResponseData | // CIMInstancesResponseData |
|
|
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// Reverts a binary instance array representation back into an array of |
// Takes a binary stream of instances from a CIMBuffer and stores it in the |
// CIMInstance |
// 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 CIMInstancesResponseData::setBinaryCimInstances(CIMBuffer& in, bool hasLen) |
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, | PEG_METHOD_ENTER(TRC_DISPATCHER, |
"CIMInstancesResponseData::setBinaryCimInstances"); | "CIMInstancesResponseData::setBinaryCimInstances"); |
| |
|
if (hasLen) |
|
{ |
if (!in.getUint8A(_binaryData)) | if (!in.getUint8A(_binaryData)) |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, | PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return false; | return false; |
} | } |
|
} |
|
else |
|
{ |
|
size_t remainingDataLength = in.capacity() - in.size(); |
|
_binaryData.append((Uint8*)in.getPtr(), remainingDataLength); |
|
} |
| |
_resolveCallback = _resolveBinaryInstances; | _resolveCallback = _resolveBinaryInstances; |
_binaryEncoding = true; |
_encoding = RESP_ENC_BINARY; |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return true; | return true; |
|
|
} | } |
| |
_resolveCallback = _resolveXMLInstances; | _resolveCallback = _resolveXMLInstances; |
_binaryEncoding = false; |
_encoding = RESP_ENC_XML; |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return true; | return true; |
|
|
// revert a binary instance array representation back into an array of | // revert a binary instance array representation back into an array of |
// CIMInstance | // CIMInstance |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
void CIMInstancesResponseData::encodeBinaryResponse(CIMBuffer& out) const |
void CIMInstancesResponseData::encodeBinaryResponse(CIMBuffer& out) |
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, | PEG_METHOD_ENTER(TRC_DISPATCHER, |
"CIMInstancesResponseData::encodeBinaryResponse"); | "CIMInstancesResponseData::encodeBinaryResponse"); |
| |
if (_resolveCallback && _binaryEncoding) |
if (_resolveCallback && (_encoding == RESP_ENC_BINARY)) |
{ | { |
const Array<Uint8>& data = _binaryData; | const Array<Uint8>& data = _binaryData; |
out.putBytes(data.getData(), data.size()); | out.putBytes(data.getData(), data.size()); |
} | } |
else | else |
{ | { |
|
_resolve(); |
out.putInstanceA(_namedInstances, false); | out.putInstanceA(_namedInstances, false); |
} | } |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
|
|
// revert a CIM-XML object array representation back into an array of | // revert a CIM-XML object array representation back into an array of |
// CIMInstance. | // CIMInstance. |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
void CIMInstancesResponseData::encodeXmlResponse(Buffer& out) const |
void CIMInstancesResponseData::encodeXmlResponse(Buffer& out) |
{ | { |
PEG_METHOD_ENTER(TRC_DISPATCHER, | PEG_METHOD_ENTER(TRC_DISPATCHER, |
"CIMInstancesResponseData::encodeXmlResponse"); | "CIMInstancesResponseData::encodeXmlResponse"); |
| |
if (_resolveCallback && !_binaryEncoding) |
if (_resolveCallback && (_encoding == RESP_ENC_XML)) |
{ | { |
const Array<ArraySint8>& a = _instancesData; | const Array<ArraySint8>& a = _instancesData; |
const Array<ArraySint8>& b = _referencesData; | const Array<ArraySint8>& b = _referencesData; |
|
|
} | } |
else | else |
{ | { |
|
_resolve(); |
for (Uint32 i = 0, n = _namedInstances.size(); i < n; i++) | for (Uint32 i = 0, n = _namedInstances.size(); i < n; i++) |
XmlWriter::appendValueNamedInstanceElement( | XmlWriter::appendValueNamedInstanceElement( |
out, _namedInstances[i]); | out, _namedInstances[i]); |
|
|
| |
CIMBuffer in((char*)data->_binaryData.getData(), data->_binaryData.size()); | CIMBuffer in((char*)data->_binaryData.getData(), data->_binaryData.size()); |
| |
|
while (in.more()) |
|
{ |
if (!in.getInstanceA(instances)) | if (!in.getInstanceA(instances)) |
{ | { |
in.release(); | in.release(); |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return false; | return false; |
} | } |
|
} |
| |
in.release(); | in.release(); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
|
|
return true; | return true; |
} | } |
| |
|
//------------------------------------------------------------------------------ |
|
// 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, |
|
"CIMInstancesResponseData::_resolveSCMOInstances"); |
|
|
|
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++) |
|
{ |
|
/*SCMODump dmp; |
|
dmp.dumpSCMOInstanceKeyBindings(data->_scmoInstances[x]); |
|
dmp.dumpInstanceProperties(data->_scmoInstances[x]);*/ |
|
CIMInstance newInstance; |
|
data->_scmoInstances[x].getCIMInstance(newInstance); |
|
instances.append(newInstance); |
|
} |
|
} |
|
catch (CIMException& ex) |
|
{ |
|
fprintf(stderr,"CIMInstancesResponseData::_resolveSCMOInstances() " |
|
"Exception:\n%s\n",(const char*)ex.getMessage().getCString()); |
|
} |
|
catch (Exception& ex) |
|
{ |
|
fprintf(stderr,"CIMInstancesResponseData::_resolveSCMOInstances() " |
|
"Exception:\n%s\n",(const char*)ex.getMessage().getCString()); |
|
} |
|
catch (exception& ex) |
|
{ |
|
fprintf(stderr,"CIMInstancesResponseData::_resolveSCMOInstances() " |
|
"exception:\n%s\n",(const char*)ex.what()); |
|
} |
|
catch (...) |
|
{ |
|
fprintf(stderr,"CIMInstancesResponseData::_resolveSCMOInstances() " |
|
"Exception: UNKNOWN\n"); |
|
} |
|
data->_resolveCallback = 0; |
|
|
|
PEG_METHOD_EXIT(); |
|
return true; |
|
} |
|
|
| |
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- |
// | // |
|
|
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- |
| |
| |
bool CIMObjectsResponseData::setBinaryCimObjects(CIMBuffer& in) |
//------------------------------------------------------------------------------ |
|
// 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_METHOD_ENTER(TRC_DISPATCHER, |
"CIMObjectsResponseData::setBinaryCimObjects"); | "CIMObjectsResponseData::setBinaryCimObjects"); |
| |
|
if (hasLen) |
|
{ |
if (!in.getUint8A(_binaryData)) | if (!in.getUint8A(_binaryData)) |
{ | { |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, | PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1, |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return false; | return false; |
} | } |
|
} |
|
else |
|
{ |
|
size_t remainingDataLength = in.capacity() - in.size(); |
|
_binaryData.append((Uint8*)in.getPtr(), remainingDataLength); |
|
} |
| |
_resolveCallback = _resolveBinaryObjects; | _resolveCallback = _resolveBinaryObjects; |
_binaryEncoding = true; | _binaryEncoding = true; |
|
|
| |
CIMBuffer in((char*)data->_binaryData.getData(), data->_binaryData.size()); | CIMBuffer in((char*)data->_binaryData.getData(), data->_binaryData.size()); |
| |
|
while (in.more()) |
|
{ |
if (!in.getObjectA(cimObjects)) | if (!in.getObjectA(cimObjects)) |
{ | { |
in.release(); | in.release(); |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return false; | return false; |
} | } |
|
} |
| |
in.release(); | in.release(); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |