version 1.19.6.1, 2003/07/29 15:08:29
|
version 1.19.6.2, 2003/08/13 19:39:51
|
|
|
#include <Pegasus/Common/Exception.h> | #include <Pegasus/Common/Exception.h> |
#include "CIMExportResponseDecoder.h" | #include "CIMExportResponseDecoder.h" |
| |
|
// l10n |
|
#include <Pegasus/Common/MessageLoader.h> |
|
|
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
|
|
| |
if (httpMessage->message.size() == 0) | if (httpMessage->message.size() == 0) |
{ | { |
|
|
|
// l10n |
|
|
|
// CIMClientMalformedHTTPException* malformedHTTPException = |
|
// new CIMClientMalformedHTTPException("Empty HTTP response message."); |
|
|
|
MessageLoaderParms mlParms("ExportClient.CIMExportResponseDecoder.EMPTY_RESPONSE", "Empty HTTP response message."); |
|
String mlString(MessageLoader::getMessage(mlParms)); |
|
|
CIMClientMalformedHTTPException* malformedHTTPException = | CIMClientMalformedHTTPException* malformedHTTPException = |
new CIMClientMalformedHTTPException("Empty HTTP response message.") |
new CIMClientMalformedHTTPException(mlString); |
; |
|
ClientExceptionMessage * response = | ClientExceptionMessage * response = |
new ClientExceptionMessage(malformedHTTPException); | new ClientExceptionMessage(malformedHTTPException); |
| |
|
|
startLine, httpVersion, statusCode, reasonPhrase); | startLine, httpVersion, statusCode, reasonPhrase); |
if (!parsableMessage) | if (!parsableMessage) |
{ | { |
|
|
|
// l10n |
|
|
|
// CIMClientMalformedHTTPException* malformedHTTPException = new |
|
// CIMClientMalformedHTTPException("Malformed HTTP response message."); |
|
|
|
MessageLoaderParms mlParms("ExportClient.CIMExportResponseDecoder.MALFORMED_RESPONSE", "Malformed HTTP response message."); |
|
String mlString(MessageLoader::getMessage(mlParms)); |
|
|
CIMClientMalformedHTTPException* malformedHTTPException = new | CIMClientMalformedHTTPException* malformedHTTPException = new |
CIMClientMalformedHTTPException("Malformed HTTP response message.") |
CIMClientMalformedHTTPException(mlString); |
; |
|
ClientExceptionMessage * response = | ClientExceptionMessage * response = |
new ClientExceptionMessage(malformedHTTPException); | new ClientExceptionMessage(malformedHTTPException); |
| |
|
|
// ATTN-SF-P3-20030115: Need to create a specific exception | // ATTN-SF-P3-20030115: Need to create a specific exception |
// to indicate Authentication failure. See JAGae53944. | // to indicate Authentication failure. See JAGae53944. |
| |
const String ERROR_MESSAGE = "Authentication failed."; |
// l10n |
|
// const String ERROR_MESSAGE = "Authentication failed."; |
|
|
|
MessageLoaderParms mlParms("ExportClient.CIMExportResponseDecoder.AUTHENTICATION_FAILED", "Authentication failed."); |
|
String ERROR_MESSAGE(MessageLoader::getMessage(mlParms)); |
|
|
CannotConnectException* cannotConnectException = | CannotConnectException* cannotConnectException = |
new CannotConnectException(ERROR_MESSAGE); | new CannotConnectException(ERROR_MESSAGE); |
ClientExceptionMessage * response = | ClientExceptionMessage * response = |
|
|
if (!HTTPMessage::lookupHeader( | if (!HTTPMessage::lookupHeader( |
headers, "CIMExport", cimOperation, true)) | headers, "CIMExport", cimOperation, true)) |
{ | { |
|
|
|
// l10n |
|
|
|
// CIMClientMalformedHTTPException* malformedHTTPException = new |
|
// CIMClientMalformedHTTPException("Missing CIMOperation HTTP header"); |
|
|
|
MessageLoaderParms mlParms("ExportClient.CIMExportResponseDecoder.MISSING_CIMOP_HEADER", "Missing $0 HTTP header", "CIMOperation"); |
|
String mlString(MessageLoader::getMessage(mlParms)); |
|
|
CIMClientMalformedHTTPException* malformedHTTPException = new | CIMClientMalformedHTTPException* malformedHTTPException = new |
CIMClientMalformedHTTPException("Missing CIMOperation HTTP header") |
CIMClientMalformedHTTPException(mlString); |
; |
|
|
ClientExceptionMessage * response = |
|
new ClientExceptionMessage(malformedHTTPException); |
|
|
|
_outputQueue->enqueue(response); |
|
return; |
|
} |
|
|
|
// |
|
// Search for "Content-Type" header: |
|
// |
|
|
|
String cimContentType; |
|
|
|
if (!HTTPMessage::lookupHeader( |
|
headers, "Content-Type", cimContentType, true)) |
|
{ |
|
CIMClientMalformedHTTPException* malformedHTTPException = new |
|
CIMClientMalformedHTTPException("Missing CIMContentType HTTP header"); |
ClientExceptionMessage * response = | ClientExceptionMessage * response = |
new ClientExceptionMessage(malformedHTTPException); | new ClientExceptionMessage(malformedHTTPException); |
| |
|
|
return; | return; |
} | } |
| |
|
|
// | // |
// Zero-terminate the message: | // Zero-terminate the message: |
// | // |
|
|
| |
if (!String::equalNoCase(cimOperation, "MethodResponse")) | if (!String::equalNoCase(cimOperation, "MethodResponse")) |
{ | { |
|
|
|
// l10n |
|
|
|
// CIMClientMalformedHTTPException* malformedHTTPException = |
|
// new CIMClientMalformedHTTPException( |
|
// String("Received CIMOperation HTTP header value \"") + |
|
// cimOperation + "\", expected \"MethodResponse\""); |
|
|
|
MessageLoaderParms mlParms("ExportClient.CIMExportResponseDecoder.EXPECTED_METHODRESPONSE", "Received $0 HTTP header value \"$1\", expected \"$2\"", "CIMOperation", cimOperation, "MethodResponse"); |
|
String mlString(MessageLoader::getMessage(mlParms)); |
|
|
CIMClientMalformedHTTPException* malformedHTTPException = | CIMClientMalformedHTTPException* malformedHTTPException = |
new CIMClientMalformedHTTPException( |
new CIMClientMalformedHTTPException(mlString); |
String("Received CIMOperation HTTP header value \"") + |
|
cimOperation + "\", expected \"MethodResponse\""); |
|
ClientExceptionMessage * response = | ClientExceptionMessage * response = |
new ClientExceptionMessage(malformedHTTPException); | new ClientExceptionMessage(malformedHTTPException); |
| |
|
|
String messageId; | String messageId; |
String protocolVersion; | String protocolVersion; |
| |
if (!XmlReader::getMessageStartTag(parser, messageId, protocolVersion)) |
if (!XmlReader::getMessageStartTag(parser, messageId, protocolVersion)) { |
throw XmlValidationError( |
|
parser.getLine(), "expected MESSAGE element"); |
// l10n |
|
|
|
// throw XmlValidationError( |
|
// parser.getLine(), "expected MESSAGE element"); |
|
|
|
MessageLoaderParms mlParms("ExportClient.CIMExportResponseDecoder.EXPECTED_ELEMENT", "expected $0 element", "MESSAGE"); |
|
String mlString(MessageLoader::getMessage(mlParms)); |
|
|
|
throw XmlValidationError(parser.getLine(), mlString); |
|
|
|
} |
| |
if (!String::equalNoCase(protocolVersion, "1.0")) | if (!String::equalNoCase(protocolVersion, "1.0")) |
{ | { |
|
|
|
// l10n |
|
|
|
// CIMClientResponseException* responseException = |
|
// new CIMClientResponseException( |
|
// String("Received unsupported protocol version \"") + |
|
// protocolVersion + "\", expected \"1.0\""); |
|
|
|
MessageLoaderParms mlParms("ExportClient.CIMExportResponseDecoder.UNSUPPORTED_PROTOCOL", "Received unsupported protocol version \"$0\", expected \"1.0\"", protocolVersion); |
|
String mlString(MessageLoader::getMessage(mlParms)); |
|
|
CIMClientResponseException* responseException = | CIMClientResponseException* responseException = |
new CIMClientResponseException( |
new CIMClientResponseException(mlString); |
String("Received unsupported protocol version \"") + |
|
protocolVersion + "\", expected \"1.0\""); |
|
ClientExceptionMessage * response = | ClientExceptionMessage * response = |
new ClientExceptionMessage(responseException); | new ClientExceptionMessage(responseException); |
| |
|
|
else | else |
{ | { |
// Unrecognized IMethodResponse name attribute | // Unrecognized IMethodResponse name attribute |
throw XmlValidationError(parser.getLine(), |
|
String("Unrecognized IMethodResponse name \"") + |
// l10n |
iMethodResponseName + "\""); |
|
|
// throw XmlValidationError(parser.getLine(), |
|
// String("Unrecognized IMethodResponse name \"") + |
|
// iMethodResponseName + "\""); |
|
|
|
MessageLoaderParms mlParms("ExportClient.CIMExportResponseDecoder.UNRECOGNIZED_IMETH", "Unrecognized $0 name \"$1\"", "IMethodResponse", iMethodResponseName); |
|
String mlString(MessageLoader::getMessage(mlParms)); |
|
|
|
throw XmlValidationError(parser.getLine(), mlString); |
} | } |
| |
// | // |
|
|
} | } |
else | else |
{ | { |
throw XmlValidationError(parser.getLine(), |
|
"expected METHODRESPONSE or IMETHODRESPONSE element"); |
// l10n |
|
|
|
// throw XmlValidationError(parser.getLine(), |
|
// "expected METHODRESPONSE or IMETHODRESPONSE element"); |
|
|
|
MessageLoaderParms mlParms("ExportClient.CIMExportResponseDecoder.EXPECTED_ELEMENT_OR", "expected $0 or $1 element", "METHODRESPONSE", "IMETHODRESPONSE"); |
|
String mlString(MessageLoader::getMessage(mlParms)); |
|
|
|
throw XmlValidationError(parser.getLine(), mlString); |
} | } |
| |
// | // |