version 1.96, 2011/01/07 02:17:19
|
version 1.96.2.8, 2013/11/30 16:16:04
|
|
|
#include <Pegasus/Common/Exception.h> | #include <Pegasus/Common/Exception.h> |
#include <Pegasus/Common/BinaryCodec.h> | #include <Pegasus/Common/BinaryCodec.h> |
#include "CIMOperationResponseDecoder.h" | #include "CIMOperationResponseDecoder.h" |
|
#include "CIMClientRep.h" |
| |
#include <Pegasus/Common/MessageLoader.h> | #include <Pegasus/Common/MessageLoader.h> |
| |
|
|
CIMOperationResponseDecoder::CIMOperationResponseDecoder( | CIMOperationResponseDecoder::CIMOperationResponseDecoder( |
MessageQueue* outputQueue, | MessageQueue* outputQueue, |
MessageQueue* encoderQueue, | MessageQueue* encoderQueue, |
ClientAuthenticator* authenticator, |
ClientAuthenticator* authenticator) |
Uint32 showInput) |
|
: | : |
MessageQueue(PEGASUS_QUEUENAME_OPRESPDECODER), | MessageQueue(PEGASUS_QUEUENAME_OPRESPDECODER), |
_outputQueue(outputQueue), | _outputQueue(outputQueue), |
_encoderQueue(encoderQueue), | _encoderQueue(encoderQueue), |
_authenticator(authenticator), |
_authenticator(authenticator) |
_showInput(showInput) |
|
{ | { |
} | } |
| |
|
|
} | } |
| |
default: | default: |
PEGASUS_ASSERT(0); |
PEGASUS_UNREACHABLE(PEGASUS_ASSERT(0);) |
break; | break; |
} | } |
| |
|
|
return; | return; |
} | } |
| |
#ifdef PEGASUS_CLIENT_TRACE_ENABLE |
if (ClientTrace::displayOutput(ClientTrace::TRACE_CON)) { |
if (_showInput & 1) |
|
{ |
|
cout << "CIMOperatonResponseDecoder"; | cout << "CIMOperatonResponseDecoder"; |
httpMessage->printAll(cout); | httpMessage->printAll(cout); |
} | } |
if (_showInput & 2) |
if (ClientTrace::displayOutput(ClientTrace::TRACE_LOG)) |
{ | { |
Logger::put(Logger::STANDARD_LOG, | Logger::put(Logger::STANDARD_LOG, |
System::CIMSERVER, |
"CIMCLient", |
Logger::INFORMATION, | Logger::INFORMATION, |
"CIMOperationRequestDecoder::Response, XML content: $1", |
"CIMOperationRequestDecoder::Response, XML content: $0", |
httpMessage->message.getData()); | httpMessage->message.getData()); |
} | } |
#endif |
|
| |
try | try |
{ | { |
|
|
(((!String::equalNoCase(type, "application/xml") && | (((!String::equalNoCase(type, "application/xml") && |
!String::equalNoCase(type, "text/xml")) || | !String::equalNoCase(type, "text/xml")) || |
!String::equalNoCase(charset, "utf-8")) | !String::equalNoCase(charset, "utf-8")) |
#if defined(PEGASUS_ENABLE_PROTOCOL_BINARY) |
|
&& !(binaryResponse=String::equalNoCase( | && !(binaryResponse=String::equalNoCase( |
type, "application/x-openpegasus")) | type, "application/x-openpegasus")) |
#endif |
|
)) | )) |
{ | { |
CIMClientMalformedHTTPException* malformedHTTPException = new | CIMClientMalformedHTTPException* malformedHTTPException = new |
|
|
| |
// Calculate the beginning of the content from the message size and | // Calculate the beginning of the content from the message size and |
// the content length. | // the content length. |
|
if (binaryResponse) |
|
{ |
|
// binary the "Content" also contains a few padding '\0' to align |
|
// data structures to 8byte boundary |
|
// the padding '\0' are also part of the counted contentLength |
|
Uint32 headerEnd = httpMessage->message.size() - contentLength; |
|
Uint32 binContentStart = CIMBuffer::round(headerEnd); |
| |
|
contentLength = contentLength - (binContentStart - headerEnd); |
|
content = httpMessage->message.getData() + binContentStart; |
|
} |
|
else |
|
{ |
content = httpMessage->message.getData() + | content = httpMessage->message.getData() + |
httpMessage->message.size() - contentLength; | httpMessage->message.size() - contentLength; |
|
} |
| |
// | // |
// If it is a method response, then dispatch it to be handled: | // If it is a method response, then dispatch it to be handled: |
|
|
else if (System::strcasecmp(iMethodResponseName, "ExecQuery") == 0) | else if (System::strcasecmp(iMethodResponseName, "ExecQuery") == 0) |
response = _decodeExecQueryResponse( | response = _decodeExecQueryResponse( |
parser, messageId, isEmptyTag); | parser, messageId, isEmptyTag); |
|
// EXP_PULL_BEGIN |
|
else if (System::strcasecmp( |
|
iMethodResponseName, "OpenEnumerateInstances") == 0) |
|
{ |
|
response = _decodeOpenEnumerateInstancesResponse( |
|
parser, messageId, isEmptyTag); |
|
} |
|
else if (System::strcasecmp( |
|
iMethodResponseName, "OpenEnumerateInstancePaths") == 0) |
|
{ |
|
response = _decodeOpenEnumerateInstancePathsResponse( |
|
parser, messageId, isEmptyTag); |
|
} |
|
else if (System::strcasecmp( |
|
iMethodResponseName, "OpenReferenceInstances") == 0) |
|
{ |
|
response = _decodeOpenReferenceInstancesResponse( |
|
parser, messageId, isEmptyTag); |
|
} |
|
else if (System::strcasecmp( |
|
iMethodResponseName, "OpenReferenceInstancePaths") == 0) |
|
{ |
|
response = _decodeOpenReferenceInstancePathsResponse( |
|
parser, messageId, isEmptyTag); |
|
} |
|
else if (System::strcasecmp( |
|
iMethodResponseName, "OpenAssociatorInstances") == 0) |
|
{ |
|
response = _decodeOpenAssociatorInstancesResponse( |
|
parser, messageId, isEmptyTag); |
|
} |
|
else if (System::strcasecmp( |
|
iMethodResponseName, "OpenAssociatorInstancePaths") == 0) |
|
{ |
|
response = _decodeOpenAssociatorInstancePathsResponse( |
|
parser, messageId, isEmptyTag); |
|
} |
|
else if (System::strcasecmp( |
|
iMethodResponseName, "PullInstancesWithPath") == 0) |
|
{ |
|
response = _decodePullInstancesWithPathResponse( |
|
parser, messageId, isEmptyTag); |
|
} |
|
else if (System::strcasecmp( |
|
iMethodResponseName, "PullInstancePaths") == 0) |
|
{ |
|
response = _decodePullInstancePathsResponse( |
|
parser, messageId, isEmptyTag); |
|
} |
|
else if (System::strcasecmp( |
|
iMethodResponseName, "PullInstances") == 0) |
|
{ |
|
response = _decodePullInstancesWithPathResponse( |
|
parser, messageId, isEmptyTag); |
|
} |
|
else if (System::strcasecmp( |
|
iMethodResponseName, "CloseEnumeration") == 0) |
|
{ |
|
response = _decodeCloseEnumerationResponse( |
|
parser, messageId, isEmptyTag); |
|
} |
|
|
|
else if (System::strcasecmp( |
|
iMethodResponseName, "EnumerationCount") == 0) |
|
{ |
|
response = _decodeEnumerationCountResponse( |
|
parser, messageId, isEmptyTag); |
|
} |
|
//EXP_PULL_END |
else | else |
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
|
|
{ | { |
if (response) | if (response) |
{ | { |
//#ifdef PEGASUS_SNIA_INTEROP_TEST |
|
// httpMessage->printAll(cout); |
|
//#endif |
|
|
|
delete response; | delete response; |
} | } |
| |
|
|
methodName); | methodName); |
} | } |
| |
|
// EXP_PULL_BEGIN |
|
/************************************************************************** |
|
** |
|
** Common Functions to support the decode of Pull Operation Responses |
|
** |
|
***************************************************************************/ |
|
|
|
/* |
|
Decode the instancePath portion of all of the open an pull instancepaths |
|
operations. This function is common to all of the pull decode operations. |
|
*/ |
|
|
|
// KS_EXP_TBD - Can we combine what we do here with the function in |
|
// enumerateinstancenames that uses getInstanceNameElement???? |
|
void _decodeInstancePathElements( |
|
XmlParser& parser, |
|
Array<CIMObjectPath>& instancePaths) |
|
{ |
|
XmlEntry entry; |
|
if (XmlReader::testStartTagOrEmptyTag(parser, entry, "IRETURNVALUE")) |
|
{ |
|
if (entry.type != XmlEntry::EMPTY_TAG) |
|
{ |
|
CIMObjectPath instancePath; |
|
|
|
while (XmlReader::getInstancePathElement(parser, instancePath)) |
|
{ |
|
instancePaths.append(instancePath); |
|
} |
|
XmlReader::expectEndTag(parser, "IRETURNVALUE"); |
|
} |
|
} |
|
} |
|
|
|
/* |
|
decode returned instancesWithPathElement into an array |
|
of instances. This function is common to all of the Pull decoder |
|
operations. |
|
*/ |
|
void _decodeGetInstancesWithPathElement( |
|
XmlParser& parser, |
|
Array<CIMInstance>& namedInstances) |
|
{ |
|
XmlEntry entry; |
|
if (XmlReader::testStartTagOrEmptyTag(parser, entry, "IRETURNVALUE")) |
|
{ |
|
if (entry.type != XmlEntry::EMPTY_TAG) |
|
{ |
|
CIMInstance namedInstance; |
|
|
|
/// KS_TBD _QUESTION. Diff of this getNameInstances Function |
|
while (XmlReader::getInstanceWithPathElement( |
|
parser, namedInstance)) |
|
{ |
|
namedInstances.append(namedInstance); |
|
} |
|
|
|
XmlReader::expectEndTag(parser, "IRETURNVALUE"); |
|
} |
|
} |
|
} |
|
|
|
/* |
|
Decode returned instances Element into an array |
|
of instances. This function is only for pullInstances. |
|
*/ |
|
void _decodeGetInstancesElement( |
|
XmlParser& parser, |
|
Array<CIMInstance>& instances) |
|
{ |
|
XmlEntry entry; |
|
if (XmlReader::testStartTagOrEmptyTag(parser, entry, "IRETURNVALUE")) |
|
{ |
|
if (entry.type != XmlEntry::EMPTY_TAG) |
|
{ |
|
CIMInstance instance; |
|
|
|
while (XmlReader::getInstanceElement(parser, instance)) |
|
{ |
|
instances.append(instance); |
|
} |
|
|
|
XmlReader::expectEndTag(parser, "IRETURNVALUE"); |
|
} |
|
} |
|
} |
|
|
|
/* Common Function for Open, Pull Parm Value processing. |
|
Parse the output parameters from the responses that |
|
have two parameters (endOfSequence and enumerationContext). These |
|
parameters are common across all of the Open* operations and the |
|
pull operations. |
|
This function returns the parsed values of these parameters or, if |
|
there is an error, generates an exception. |
|
*/ |
|
void _decodeOpenResponseParamValues(XmlParser& parser, |
|
Boolean& endOfSequence, |
|
String& enumerationContext) |
|
{ |
|
Boolean duplicateParameter = false; |
|
Boolean gotEndOfSequence = false; |
|
Boolean gotEnumerationContext = false; |
|
|
|
Boolean emptyTag; |
|
for (const char* name; |
|
XmlReader::getParamValueTag(parser, name, emptyTag); ) |
|
{ |
|
if (System::strcasecmp(name, "EndOfSequence") == 0) |
|
{ |
|
XmlReader::rejectNullParamValue(parser, emptyTag, name); |
|
XmlReader::getBooleanValueElement(parser, endOfSequence, true); |
|
duplicateParameter = gotEndOfSequence; |
|
gotEndOfSequence = true; |
|
} |
|
|
|
else if (System::strcasecmp(name, "EnumerationContext") == 0) |
|
{ |
|
XmlReader::getStringValueElement(parser, enumerationContext, |
|
false); |
|
duplicateParameter = gotEnumerationContext; |
|
gotEnumerationContext = true; |
|
} |
|
else |
|
{ |
|
// Ignore this as an extra tag |
|
} |
|
if (!emptyTag) |
|
{ |
|
XmlReader::expectEndTag(parser, "PARAMVALUE"); |
|
} |
|
// Stop on the first duplicate found |
|
if (duplicateParameter) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION( |
|
CIM_ERR_INVALID_PARAMETER, |
|
"Duplicate EndOfSequence or EnumerationContext received"); |
|
} |
|
} |
|
|
|
// KS_TODO -Should the error be INVALID_PARAMETER or XmlValidation since |
|
// it is really MISSING but this is response so we have generally |
|
// used XmlValidationError. Not sure so ignore issue for now. Nov 2013, KS |
|
if (!gotEndOfSequence) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, |
|
"EndOfSequence is a Required Parameter"); |
|
} |
|
|
|
// EnumerationContext is required parameter |
|
if (!gotEnumerationContext) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, |
|
"EnumerationContext is a Required Parameter"); |
|
} |
|
// EnumerationContext must have value if not endOfSequence |
|
if ((!endOfSequence) && (enumerationContext.size() == 0)) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, |
|
"Valid EnumerationContext is a Required Parameter"); |
|
} |
|
} |
|
|
|
/****************************************************************************** |
|
** |
|
** Open and Pull Operation Response Decoders |
|
** |
|
******************************************************************************/ |
|
CIMOpenEnumerateInstancesResponseMessage* |
|
CIMOperationResponseDecoder::_decodeOpenEnumerateInstancesResponse( |
|
XmlParser& parser, |
|
const String& messageId, |
|
Boolean isEmptyImethodresponseTag) |
|
{ |
|
//XmlEntry entry; |
|
CIMException cimException; |
|
Array<CIMInstance> namedInstances; |
|
Boolean endOfSequence = true; |
|
String enumerationContext = String::EMPTY; |
|
|
|
if (XmlReader::getErrorElement(parser, cimException)) |
|
{ |
|
return new CIMOpenEnumerateInstancesResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
} |
|
// EXP_PULL should error out if response empty because either |
|
// enumerationContext or endOfSequence is required. Create |
|
// missing Parameter error here. |
|
if (isEmptyImethodresponseTag) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, |
|
"Return Parameters endOfSequence" |
|
"and/or enumerationContext required."); |
|
} |
|
|
|
_decodeGetInstancesWithPathElement(parser, namedInstances); |
|
|
|
// Get the OUT parameters (endOfSequence and enumerationContext) |
|
_decodeOpenResponseParamValues(parser, endOfSequence, enumerationContext); |
|
|
|
CIMOpenEnumerateInstancesResponseMessage* msg; |
|
|
|
msg = new CIMOpenEnumerateInstancesResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
|
|
msg->getResponseData().setInstances(namedInstances); |
|
return msg; |
|
} |
|
|
|
CIMOpenEnumerateInstancePathsResponseMessage* |
|
CIMOperationResponseDecoder::_decodeOpenEnumerateInstancePathsResponse( |
|
XmlParser& parser, |
|
const String& messageId, |
|
Boolean isEmptyImethodresponseTag) |
|
{ |
|
XmlEntry entry; |
|
CIMException cimException; |
|
Array<CIMObjectPath> instancePaths; |
|
|
|
Boolean endOfSequence = true; |
|
String enumerationContext = String::EMPTY; |
|
|
|
if (XmlReader::getErrorElement(parser, cimException)) |
|
{ |
|
return new CIMOpenEnumerateInstancePathsResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
} |
|
|
|
if (isEmptyImethodresponseTag) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, |
|
"Return Parameters endOfSequence" |
|
"and/or enumerationContext required."); |
|
|
|
} |
|
|
|
_decodeInstancePathElements(parser, instancePaths); |
|
|
|
// Get the OUT parameters (endOfSequence and enumerationContext) |
|
_decodeOpenResponseParamValues(parser, endOfSequence, enumerationContext); |
|
|
|
CIMOpenEnumerateInstancePathsResponseMessage* msg; |
|
|
|
msg = new CIMOpenEnumerateInstancePathsResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
|
|
msg->getResponseData().setInstanceNames(instancePaths); |
|
return msg; |
|
} |
|
|
|
|
|
CIMOpenReferenceInstancesResponseMessage* |
|
CIMOperationResponseDecoder::_decodeOpenReferenceInstancesResponse( |
|
XmlParser& parser, |
|
const String& messageId, |
|
Boolean isEmptyImethodresponseTag) |
|
{ |
|
XmlEntry entry; |
|
CIMException cimException; |
|
// KS_TODO KS_PULL _CHANGE NAME TO MATCH XML TAG |
|
Array<CIMInstance> namedInstances; |
|
Boolean endOfSequence = true; |
|
String enumerationContext = String::EMPTY; |
|
|
|
if (XmlReader::getErrorElement(parser, cimException)) |
|
{ |
|
return new CIMOpenReferenceInstancesResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
} |
|
|
|
if (isEmptyImethodresponseTag) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, |
|
"Return Parameters endOfSequence" |
|
"and/or enumerationContext required."); |
|
} |
|
|
|
_decodeGetInstancesWithPathElement(parser, namedInstances); |
|
|
|
// Get the OUT parameters (endOfSequence and enumerationContext) |
|
_decodeOpenResponseParamValues(parser, endOfSequence, enumerationContext); |
|
|
|
CIMOpenReferenceInstancesResponseMessage* msg; |
|
|
|
msg = new CIMOpenReferenceInstancesResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
|
|
// set response data type to Instances. The default for this |
|
// message is OBJECTS since that is what we use in the server. |
|
msg->getResponseData().setDataType(CIMResponseData::RESP_INSTANCES); |
|
msg->getResponseData().setInstances(namedInstances); |
|
|
|
return msg; |
|
} |
|
|
|
CIMOpenReferenceInstancePathsResponseMessage* |
|
CIMOperationResponseDecoder::_decodeOpenReferenceInstancePathsResponse( |
|
XmlParser& parser, |
|
const String& messageId, |
|
Boolean isEmptyImethodresponseTag) |
|
{ |
|
XmlEntry entry; |
|
CIMException cimException; |
|
Array<CIMObjectPath> instancePaths; |
|
Boolean endOfSequence = true; |
|
String enumerationContext = String::EMPTY; |
|
|
|
if (XmlReader::getErrorElement(parser, cimException)) |
|
{ |
|
return new CIMOpenReferenceInstancePathsResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
} |
|
if (isEmptyImethodresponseTag) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, |
|
"Return Parameters endOfSequence" |
|
"and/or enumerationContext required."); |
|
} |
|
|
|
_decodeInstancePathElements(parser, instancePaths); |
|
|
|
// Get the OUT parameters (endOfSequence and enumerationContext) |
|
_decodeOpenResponseParamValues(parser, endOfSequence, enumerationContext); |
|
|
|
CIMOpenReferenceInstancePathsResponseMessage* msg; |
|
|
|
msg = new CIMOpenReferenceInstancePathsResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
|
|
msg->getResponseData().setInstanceNames(instancePaths); |
|
|
|
return msg; |
|
} |
|
|
|
CIMOpenAssociatorInstancesResponseMessage* |
|
CIMOperationResponseDecoder::_decodeOpenAssociatorInstancesResponse( |
|
XmlParser& parser, |
|
const String& messageId, |
|
Boolean isEmptyImethodresponseTag) |
|
{ |
|
XmlEntry entry; |
|
CIMException cimException; |
|
Array<CIMInstance> namedInstances; |
|
Boolean endOfSequence = true; |
|
String enumerationContext = String::EMPTY; |
|
|
|
if (XmlReader::getErrorElement(parser, cimException)) |
|
{ |
|
return new CIMOpenAssociatorInstancesResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
} |
|
|
|
if (isEmptyImethodresponseTag) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, |
|
"Return Parameters endOfSequence" |
|
"and/or enumerationContext required."); |
|
} |
|
|
|
_decodeGetInstancesWithPathElement(parser, namedInstances); |
|
|
|
// Get the OUT parameters (endOfSequence and enumerationContext) |
|
_decodeOpenResponseParamValues(parser, endOfSequence, enumerationContext); |
|
|
|
CIMOpenAssociatorInstancesResponseMessage* msg; |
|
|
|
msg = new CIMOpenAssociatorInstancesResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
|
|
msg->getResponseData().setDataType(CIMResponseData::RESP_INSTANCES); |
|
msg->getResponseData().setInstances(namedInstances); |
|
|
|
return msg; |
|
} |
|
|
|
CIMOpenAssociatorInstancePathsResponseMessage* |
|
CIMOperationResponseDecoder::_decodeOpenAssociatorInstancePathsResponse( |
|
XmlParser& parser, |
|
const String& messageId, |
|
Boolean isEmptyImethodresponseTag) |
|
{ |
|
XmlEntry entry; |
|
CIMException cimException; |
|
Array<CIMObjectPath> instancePaths; |
|
Boolean endOfSequence = true; |
|
String enumerationContext = String::EMPTY; |
|
|
|
if (XmlReader::getErrorElement(parser, cimException)) |
|
{ |
|
return new CIMOpenAssociatorInstancePathsResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
} |
|
|
|
if (isEmptyImethodresponseTag) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, |
|
"Return Parameters endOfSequence" |
|
"and/or enumerationContext required."); |
|
} |
|
|
|
if (XmlReader::testStartTagOrEmptyTag(parser, entry, "IRETURNVALUE")) |
|
{ |
|
if (entry.type != XmlEntry::EMPTY_TAG) |
|
{ |
|
CIMObjectPath instancePath; |
|
|
|
while (XmlReader::getInstancePathElement(parser, instancePath)) |
|
instancePaths.append(instancePath); |
|
XmlReader::expectEndTag(parser, "IRETURNVALUE"); |
|
} |
|
} |
|
|
|
// Get the OUT parameters (endOfSequence and enumerationContext) |
|
// |
|
_decodeOpenResponseParamValues(parser, endOfSequence, enumerationContext); |
|
|
|
CIMOpenAssociatorInstancePathsResponseMessage* msg; |
|
|
|
msg = new CIMOpenAssociatorInstancePathsResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
|
|
msg->getResponseData().setInstanceNames(instancePaths); |
|
|
|
return msg; |
|
} |
|
|
|
CIMPullInstancesWithPathResponseMessage* |
|
CIMOperationResponseDecoder::_decodePullInstancesWithPathResponse( |
|
XmlParser& parser, |
|
const String& messageId, |
|
Boolean isEmptyImethodresponseTag) |
|
{ |
|
XmlEntry entry; |
|
CIMException cimException; |
|
Array<CIMInstance> namedInstances; |
|
Boolean endOfSequence = true; |
|
String enumerationContext = String::EMPTY; |
|
|
|
if (XmlReader::getErrorElement(parser, cimException)) |
|
{ |
|
return new CIMPullInstancesWithPathResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
} |
|
|
|
if (isEmptyImethodresponseTag) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, |
|
"Return Parameters endOfSequence" |
|
"and/or enumerationContext required."); |
|
} |
|
_decodeGetInstancesWithPathElement(parser, namedInstances); |
|
|
|
_decodeOpenResponseParamValues(parser, endOfSequence, enumerationContext); |
|
|
|
CIMPullInstancesWithPathResponseMessage* msg; |
|
|
|
msg = new CIMPullInstancesWithPathResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
|
|
msg->getResponseData().setInstances(namedInstances); |
|
return msg; |
|
} |
|
|
|
CIMPullInstancePathsResponseMessage* |
|
CIMOperationResponseDecoder::_decodePullInstancePathsResponse( |
|
XmlParser& parser, |
|
const String& messageId, |
|
Boolean isEmptyImethodresponseTag) |
|
{ |
|
XmlEntry entry; |
|
CIMException cimException; |
|
Array<CIMObjectPath> instancePaths; |
|
Boolean endOfSequence = true; |
|
String enumerationContext = String::EMPTY; |
|
|
|
//Boolean duplicateParameter = false; |
|
//Boolean gotEndOfSequence = false; |
|
//Boolean gotEnumerationContext = false; |
|
|
|
if (XmlReader::getErrorElement(parser, cimException)) |
|
{ |
|
return new CIMPullInstancePathsResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
} |
|
|
|
if (isEmptyImethodresponseTag) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, |
|
"Return Parameters endOfSequence" |
|
"and/or enumerationContext required."); |
|
} |
|
|
|
_decodeInstancePathElements(parser, instancePaths); |
|
|
|
_decodeOpenResponseParamValues(parser, endOfSequence, enumerationContext); |
|
|
|
CIMPullInstancePathsResponseMessage* msg; |
|
|
|
msg = new CIMPullInstancePathsResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
|
|
msg->getResponseData().setInstanceNames(instancePaths); |
|
return msg; |
|
} |
|
|
|
CIMPullInstancesResponseMessage* |
|
CIMOperationResponseDecoder::_decodePullInstancesResponse( |
|
XmlParser& parser, |
|
const String& messageId, |
|
Boolean isEmptyImethodresponseTag) |
|
{ |
|
XmlEntry entry; |
|
CIMException cimException; |
|
Array<CIMInstance> instances; |
|
Boolean endOfSequence = true; |
|
String enumerationContext = String::EMPTY; |
|
|
|
if (XmlReader::getErrorElement(parser, cimException)) |
|
{ |
|
return new CIMPullInstancesResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
} |
|
|
|
if (isEmptyImethodresponseTag) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, |
|
"Return Parameters endOfSequence" |
|
"and/or enumerationContext required."); |
|
} |
|
_decodeGetInstancesElement(parser, instances); |
|
|
|
_decodeOpenResponseParamValues(parser, endOfSequence, enumerationContext); |
|
|
|
CIMPullInstancesResponseMessage* msg; |
|
|
|
msg = new CIMPullInstancesResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
endOfSequence, |
|
enumerationContext); |
|
|
|
msg->getResponseData().setInstances(instances); |
|
return msg; |
|
} |
|
|
|
CIMCloseEnumerationResponseMessage* |
|
CIMOperationResponseDecoder::_decodeCloseEnumerationResponse( |
|
XmlParser& parser, |
|
const String& messageId, |
|
Boolean isEmptyImethodresponseTag) |
|
{ |
|
XmlEntry entry; |
|
CIMException cimException; |
|
Array<CIMObjectPath> instanceNames; |
|
String enumerationContext = String::EMPTY; |
|
|
|
if (XmlReader::getErrorElement(parser, cimException)) |
|
{ |
|
return new CIMCloseEnumerationResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack()); |
|
} |
|
|
|
return new CIMCloseEnumerationResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack()); |
|
} |
|
|
|
CIMEnumerationCountResponseMessage* |
|
CIMOperationResponseDecoder::_decodeEnumerationCountResponse( |
|
XmlParser& parser, |
|
const String& messageId, |
|
Boolean isEmptyImethodresponseTag) |
|
{ |
|
XmlEntry entry; |
|
CIMException cimException; |
|
Uint64Arg count; |
|
|
|
Boolean duplicateParameter = false; |
|
Boolean gotCount = false; |
|
|
|
if (XmlReader::getErrorElement(parser, cimException)) |
|
{ |
|
return new CIMEnumerationCountResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
0); |
|
} |
|
|
|
if (isEmptyImethodresponseTag) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, |
|
"Return Parameters endOfSequence" |
|
"and/or enumerationContext required."); |
|
} |
|
|
|
// Extract the parameter count from the message |
|
|
|
Boolean emptyTag; |
|
for (const char* name; |
|
XmlReader::getIReturnValueTag(parser, name, emptyTag); ) |
|
{ |
|
if (System::strcasecmp(name, "Count") == 0) |
|
{ |
|
XmlReader::getUint64ValueElement(parser, count, true); |
|
//duplicateParameter = gotCount; |
|
gotCount = true; |
|
} |
|
|
|
else |
|
{ |
|
/// EXP_PULL_TBD |
|
// We probably simply want to ignore this as an extra tag |
|
} |
|
if (!emptyTag) |
|
{ |
|
XmlReader::expectEndTag(parser, "IRETURNVALUE"); |
|
} |
|
|
|
if (duplicateParameter) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION( |
|
CIM_ERR_INVALID_PARAMETER, String::EMPTY); |
|
} |
|
|
|
// EXP_PULL_TBD add test here for the required parameters |
|
// NOT sure from the spec if the parameter is required or not. |
|
|
|
if (!gotCount) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, |
|
"Return value missing"); |
|
} |
|
} |
|
return new CIMEnumerationCountResponseMessage( |
|
messageId, |
|
cimException, |
|
QueueIdStack(), |
|
count); |
|
} |
|
|
|
CIMOpenQueryInstancesResponseMessage* |
|
CIMOperationResponseDecoder::_decodeOpenQueryInstancesResponse( |
|
XmlParser& parser, |
|
const String& messageId, |
|
Boolean isEmptyImethodresponseTag) |
|
{ |
|
CIMException cimException; |
|
Array<CIMInstance> instances; |
|
Boolean endOfSequence = true; |
|
String enumerationContext = String::EMPTY; |
|
|
|
if (XmlReader::getErrorElement(parser, cimException)) |
|
{ |
|
return new CIMOpenQueryInstancesResponseMessage( |
|
messageId, |
|
cimException, |
|
CIMClass(), |
|
endOfSequence, |
|
enumerationContext, |
|
QueueIdStack()); |
|
} |
|
|
|
if (isEmptyImethodresponseTag) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, |
|
"Return Parameters endOfSequence" |
|
"and/or enumerationContext required."); |
|
} |
|
|
|
//// KS_TODO this should be instance without path. We do not have |
|
//// function for that in XmlReader so we are not compliant. |
|
/// KS_TODO modify whole OpenQuery operation for instance w/o path |
|
//// NOTE that this impacts the pull also I think. |
|
_decodeGetInstancesWithPathElement(parser, instances); |
|
|
|
// Get the OUT parameters (endOfSequence and enumerationContext) |
|
_decodeOpenResponseParamValues(parser, endOfSequence, enumerationContext); |
|
|
|
CIMOpenQueryInstancesResponseMessage* msg; |
|
|
|
msg = new CIMOpenQueryInstancesResponseMessage( |
|
messageId, |
|
cimException, |
|
CIMClass(), // Note. KS_TODO not returning queryResultClass |
|
endOfSequence, |
|
enumerationContext, |
|
QueueIdStack()); |
|
|
|
msg->getResponseData().setInstances(instances); |
|
return msg; |
|
} |
|
//EXP_PULL_END |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |