version 1.68, 2002/07/31 15:45:25
|
version 1.86, 2003/03/13 17:37:34
|
|
|
return out; | return out; |
} | } |
| |
Array<Sint8>& operator<<(Array<Sint8>& out, Char16 x) |
Array<Sint8>& operator<<(Array<Sint8>& out, const Char16& x) |
{ | { |
XmlWriter::append(out, x); | XmlWriter::append(out, x); |
return out; | return out; |
|
|
return out; | return out; |
} | } |
| |
inline void _appendChar(Array<Sint8>& out, Char16 c) |
Array<Sint8>& operator<<(Array<Sint8>& out, const CIMName& name) |
|
{ |
|
XmlWriter::append(out, name.getString ()); |
|
return out; |
|
} |
|
|
|
PEGASUS_STD(ostream)& operator<<(PEGASUS_STD(ostream)& os, const CIMDateTime& x) |
|
{ |
|
return os << x.toString(); |
|
} |
|
|
|
PEGASUS_STD(ostream)& operator<<(PEGASUS_STD(ostream)& os, const CIMName& name) |
|
{ |
|
os << name.getString(); |
|
return os; |
|
} |
|
|
|
PEGASUS_STD(ostream)& operator<<(PEGASUS_STD(ostream)& os, |
|
const CIMNamespaceName& name) |
|
{ |
|
os << name.getString(); |
|
return os; |
|
} |
|
|
|
inline void _appendChar(Array<Sint8>& out, const Char16& c) |
{ | { |
out.append(Sint8(c)); | out.append(Sint8(c)); |
} | } |
| |
inline void _appendSpecialChar(Array<Sint8>& out, Char16 c) |
inline void _appendSpecialChar(Array<Sint8>& out, const Char16& c) |
{ | { |
// ATTN-B: Only UTF-8 handled for now. | // ATTN-B: Only UTF-8 handled for now. |
| |
|
|
_appendSpecialChar(os, *str++); | _appendSpecialChar(os, *str++); |
} | } |
| |
void XmlWriter::append(Array<Sint8>& out, Char16 x) |
void XmlWriter::append(Array<Sint8>& out, const Char16& x) |
{ | { |
_appendChar(out, x); | _appendChar(out, x); |
} | } |
|
|
out.append(' '); | out.append(' '); |
} | } |
| |
void XmlWriter::appendSpecial(Array<Sint8>& out, Char16 x) |
void XmlWriter::appendSpecial(Array<Sint8>& out, const Char16& x) |
{ | { |
_appendSpecialChar(out, x); | _appendSpecialChar(out, x); |
} | } |
|
|
} | } |
} | } |
| |
|
// See http://www.ietf.org/rfc/rfc2396.txt section 2 |
|
// Reserved characters = ';' '/' '?' ':' '@' '&' '=' '+' '$' ',' |
|
// Excluded characters: |
|
// Control characters = 0x00-0x1f, 0x7f |
|
// Space character = 0x20 |
|
// Delimiters = '<' '>' '#' '%' '"' |
|
// Unwise = '{' '}' '|' '\\' '^' '[' ']' '`' |
|
inline void _encodeURIChar(String& outString, Char16 char16) |
|
{ |
|
// ATTN: Handle non-UTF-8 character sets |
|
char c = char16 & 0x007f; |
|
|
|
#ifndef PEGASUS_DO_NOT_IMPLEMENT_URI_ENCODING |
|
if ( (c <= 0x20) || // Control characters + space char |
|
( (c >= 0x22) && (c <= 0x26) ) || // '"' '#' '$' '%' '&' |
|
(c == 0x2b) || // '+' |
|
(c == 0x2c) || // ',' |
|
(c == 0x2f) || // '/' |
|
( (c >= 0x3a) && (c <= 0x40) ) || // ':' ';' '<' '=' '>' '?' '@' |
|
( (c >= 0x5b) && (c <= 0x5e) ) || // '[' '\\' ']' '^' |
|
(c == 0x60) || // '`' |
|
( (c >= 0x7b) && (c <= 0x7d) ) || // '{' '|' '}' |
|
(c == 0x7f) ) // Control character |
|
{ |
|
char hexencoding[4]; |
|
|
|
sprintf(hexencoding, "%%%X%X", c/16, c%16); |
|
outString.append(hexencoding); |
|
} |
|
else |
|
#endif |
|
{ |
|
outString.append(c); |
|
} |
|
} |
|
|
|
String XmlWriter::encodeURICharacters(Array<Sint8> uriString) |
|
{ |
|
String encodedString; |
|
|
|
for (Uint32 i=0; i<uriString.size(); i++) |
|
{ |
|
_encodeURIChar(encodedString, Char16(uriString[i])); |
|
} |
|
|
|
return encodedString; |
|
} |
|
|
|
String XmlWriter::encodeURICharacters(String uriString) |
|
{ |
|
String encodedString; |
|
|
|
for (Uint32 i=0; i<uriString.size(); i++) |
|
{ |
|
_encodeURIChar(encodedString, uriString[i]); |
|
} |
|
|
|
return encodedString; |
|
} |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
// appendLocalNameSpacePathElement() | // appendLocalNameSpacePathElement() |
|
|
| |
void XmlWriter::appendLocalNameSpacePathElement( | void XmlWriter::appendLocalNameSpacePathElement( |
Array<Sint8>& out, | Array<Sint8>& out, |
const String& nameSpace) |
const CIMNamespaceName& nameSpace) |
{ | { |
out << "<LOCALNAMESPACEPATH>\n"; | out << "<LOCALNAMESPACEPATH>\n"; |
| |
char* tmp = nameSpace.allocateCString(); |
char* nameSpaceCopy = strdup(nameSpace.getString().getCString()); |
|
for (const char* p = strtok(nameSpaceCopy, "/"); p; p = strtok(NULL, "/")) |
for (char* p = strtok(tmp, "/"); p; p = strtok(NULL, "/")) |
|
{ | { |
out << "<NAMESPACE NAME=\"" << p << "\"/>\n"; | out << "<NAMESPACE NAME=\"" << p << "\"/>\n"; |
} | } |
|
delete nameSpaceCopy; |
delete [] tmp; |
|
| |
out << "</LOCALNAMESPACEPATH>\n"; | out << "</LOCALNAMESPACEPATH>\n"; |
} | } |
|
|
void XmlWriter::appendNameSpacePathElement( | void XmlWriter::appendNameSpacePathElement( |
Array<Sint8>& out, | Array<Sint8>& out, |
const String& host, | const String& host, |
const String& nameSpace) |
const CIMNamespaceName& nameSpace) |
{ | { |
out << "<NAMESPACEPATH>\n"; | out << "<NAMESPACEPATH>\n"; |
out << "<HOST>" << host << "</HOST>\n"; | out << "<HOST>" << host << "</HOST>\n"; |
|
|
| |
void XmlWriter::appendClassNameElement( | void XmlWriter::appendClassNameElement( |
Array<Sint8>& out, | Array<Sint8>& out, |
const String& className) |
const CIMName& className) |
{ | { |
out << "<CLASSNAME NAME=\"" << className << "\"/>\n"; | out << "<CLASSNAME NAME=\"" << className << "\"/>\n"; |
} | } |
|
|
{ | { |
out << "<INSTANCENAME CLASSNAME=\"" << instanceName.getClassName() << "\">\n"; | out << "<INSTANCENAME CLASSNAME=\"" << instanceName.getClassName() << "\">\n"; |
| |
Array<KeyBinding> keyBindings = instanceName.getKeyBindings(); |
Array<CIMKeyBinding> keyBindings = instanceName.getKeyBindings(); |
for (Uint32 i = 0, n = keyBindings.size(); i < n; i++) | for (Uint32 i = 0, n = keyBindings.size(); i < n; i++) |
{ | { |
out << "<KEYBINDING NAME=\"" << keyBindings[i].getName() << "\">\n"; | out << "<KEYBINDING NAME=\"" << keyBindings[i].getName() << "\">\n"; |
| |
if (keyBindings[i].getType() == KeyBinding::REFERENCE) |
if (keyBindings[i].getType() == CIMKeyBinding::REFERENCE) |
{ | { |
CIMObjectPath ref = keyBindings[i].getValue(); | CIMObjectPath ref = keyBindings[i].getValue(); |
appendValueReferenceElement(out, ref, true); | appendValueReferenceElement(out, ref, true); |
|
|
XmlWriter::append(out, x); | XmlWriter::append(out, x); |
} | } |
| |
inline void _appendValue(Array<Sint8>& out, Char16 x) |
inline void _appendValue(Array<Sint8>& out, const Char16& x) |
{ | { |
XmlWriter::appendSpecial(out, x); | XmlWriter::appendSpecial(out, x); |
} | } |
|
|
| |
inline void _appendValue(Array<Sint8>& out, const CIMDateTime& x) | inline void _appendValue(Array<Sint8>& out, const CIMDateTime& x) |
{ | { |
out << x.getString(); //ATTN: append() method? |
out << x.toString(); //ATTN: append() method? |
} | } |
| |
inline void _appendValue(Array<Sint8>& out, const CIMObjectPath& x) | inline void _appendValue(Array<Sint8>& out, const CIMObjectPath& x) |
|
|
} | } |
| |
default: | default: |
throw CIMValueInvalidType(); |
PEGASUS_ASSERT(false); |
} | } |
} | } |
else if (value.getType() == CIMTYPE_REFERENCE) | else if (value.getType() == CIMTYPE_REFERENCE) |
|
|
} | } |
| |
default: | default: |
throw CIMValueInvalidType(); |
PEGASUS_ASSERT(false); |
} | } |
| |
out << "</VALUE>\n"; | out << "</VALUE>\n"; |
|
|
// key bindings | // key bindings |
// | // |
| |
KeyBindingArray kbs = reference.getKeyBindings(); |
Array<CIMKeyBinding> kbs = reference.getKeyBindings(); |
| |
if (kbs.size()) | if (kbs.size()) |
{ | { |
|
|
Array<Sint8>& out, | Array<Sint8>& out, |
const CIMConstObject& object) | const CIMConstObject& object) |
{ | { |
// ATTN-RK-P3-20020515: This could use some work |
if (object.isClass()) |
try |
|
{ | { |
CIMConstClass c(object); | CIMConstClass c(object); |
appendClassElement(out, c); | appendClassElement(out, c); |
} | } |
catch (DynamicCastFailed) |
else if (object.isInstance()) |
{ |
|
try |
|
{ | { |
CIMConstInstance i(object); | CIMConstInstance i(object); |
appendInstanceElement(out, i); | appendInstanceElement(out, i); |
} | } |
catch (DynamicCastFailed) |
// else PEGASUS_ASSERT(0); |
{ |
|
PEGASUS_ASSERT(0); |
|
} |
|
} |
|
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
| |
void XmlWriter::appendQualifierFlavorEntity( | void XmlWriter::appendQualifierFlavorEntity( |
Array<Sint8>& out, | Array<Sint8>& out, |
Uint32 flavor) |
const CIMFlavor & flavor) |
{ | { |
if (!(flavor & CIMFlavor::OVERRIDABLE)) |
if (!(flavor.hasFlavor (CIMFlavor::OVERRIDABLE))) |
out << " OVERRIDABLE=\"false\""; | out << " OVERRIDABLE=\"false\""; |
| |
if (!(flavor & CIMFlavor::TOSUBCLASS)) |
if (!(flavor.hasFlavor (CIMFlavor::TOSUBCLASS))) |
out << " TOSUBCLASS=\"false\""; | out << " TOSUBCLASS=\"false\""; |
| |
if (flavor & CIMFlavor::TOINSTANCE) |
if (flavor.hasFlavor (CIMFlavor::TOINSTANCE)) |
out << " TOINSTANCE=\"true\""; | out << " TOINSTANCE=\"true\""; |
| |
if (flavor & CIMFlavor::TRANSLATABLE) |
if (flavor.hasFlavor (CIMFlavor::TRANSLATABLE)) |
out << " TRANSLATABLE=\"true\""; | out << " TRANSLATABLE=\"true\""; |
} | } |
| |
|
|
| |
void XmlWriter::appendScopeElement( | void XmlWriter::appendScopeElement( |
Array<Sint8>& out, | Array<Sint8>& out, |
Uint32 scope) |
const CIMScope & scope) |
{ | { |
if (scope) |
if (!(scope.equal (CIMScope ()))) |
{ | { |
out << "<SCOPE"; | out << "<SCOPE"; |
| |
if (scope & CIMScope::CLASS) |
if (scope.hasScope (CIMScope::CLASS)) |
out << " CLASS=\"true\""; | out << " CLASS=\"true\""; |
| |
if (scope & CIMScope::ASSOCIATION) |
if (scope.hasScope (CIMScope::ASSOCIATION)) |
out << " ASSOCIATION=\"true\""; | out << " ASSOCIATION=\"true\""; |
| |
if (scope & CIMScope::REFERENCE) |
if (scope.hasScope (CIMScope::REFERENCE)) |
out << " REFERENCE=\"true\""; | out << " REFERENCE=\"true\""; |
| |
if (scope & CIMScope::PROPERTY) |
if (scope.hasScope (CIMScope::PROPERTY)) |
out << " PROPERTY=\"true\""; | out << " PROPERTY=\"true\""; |
| |
if (scope & CIMScope::METHOD) |
if (scope.hasScope (CIMScope::METHOD)) |
out << " METHOD=\"true\""; | out << " METHOD=\"true\""; |
| |
if (scope & CIMScope::PARAMETER) |
if (scope.hasScope (CIMScope::PARAMETER)) |
out << " PARAMETER=\"true\""; | out << " PARAMETER=\"true\""; |
| |
if (scope & CIMScope::INDICATION) |
if (scope.hasScope (CIMScope::INDICATION)) |
out << " INDICATION=\"true\""; | out << " INDICATION=\"true\""; |
| |
out << "/>"; | out << "/>"; |
|
|
void XmlWriter::appendMethodCallHeader( | void XmlWriter::appendMethodCallHeader( |
Array<Sint8>& out, | Array<Sint8>& out, |
const char* host, | const char* host, |
const char* cimMethod, |
const CIMName& cimMethod, |
const String& cimObject, | const String& cimObject, |
const String& authenticationHeader, | const String& authenticationHeader, |
|
HttpMethod httpMethod, |
Uint32 contentLength) | Uint32 contentLength) |
{ | { |
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; | char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
| |
|
// ATTN: KS 20020926 - Temporary change to issue only POST. This may |
|
// be changed in the DMTF CIM Operations standard in the future. |
|
// If we kept M-Post we would have to retry with Post. Does not |
|
// do that in client today. Permanent change is to retry until spec |
|
// updated. This change is temp to finish tests or until the retry |
|
// installed. Required because of change to wbemservices cimom |
|
#ifdef PEGASUS_SNIA_INTEROP_TEST |
|
out << "POST /cimom HTTP/1.1\r\n"; |
|
#else |
|
if (httpMethod == HTTP_METHOD_M_POST) |
|
{ |
out << "M-POST /cimom HTTP/1.1\r\n"; | out << "M-POST /cimom HTTP/1.1\r\n"; |
|
} |
|
else |
|
{ |
|
out << "POST /cimom HTTP/1.1\r\n"; |
|
} |
|
#endif |
out << "HOST: " << host << "\r\n"; | out << "HOST: " << host << "\r\n"; |
out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; | out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; |
out << "Content-Length: " << contentLength << "\r\n"; | out << "Content-Length: " << contentLength << "\r\n"; |
|
if (httpMethod == HTTP_METHOD_M_POST) |
|
{ |
out << "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="; | out << "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="; |
out << nn <<"\r\n"; | out << nn <<"\r\n"; |
out << nn << "-CIMOperation: MethodCall\r\n"; | out << nn << "-CIMOperation: MethodCall\r\n"; |
out << nn << "-CIMMethod: " << cimMethod << "\r\n"; |
out << nn << "-CIMMethod: " |
out << nn << "-CIMObject: " << cimObject << "\r\n"; |
<< encodeURICharacters(cimMethod.getString()) << "\r\n"; |
|
out << nn << "-CIMObject: " << encodeURICharacters(cimObject) << "\r\n"; |
|
} |
|
else |
|
{ |
|
out << "CIMOperation: MethodCall\r\n"; |
|
out << "CIMMethod: " << encodeURICharacters(cimMethod.getString()) |
|
<< "\r\n"; |
|
out << "CIMObject: " << encodeURICharacters(cimObject) << "\r\n"; |
|
} |
|
|
if (authenticationHeader.size()) | if (authenticationHeader.size()) |
{ | { |
out << authenticationHeader << "\r\n"; | out << authenticationHeader << "\r\n"; |
|
|
| |
void XmlWriter::appendMethodResponseHeader( | void XmlWriter::appendMethodResponseHeader( |
Array<Sint8>& out, | Array<Sint8>& out, |
|
HttpMethod httpMethod, |
Uint32 contentLength) | Uint32 contentLength) |
{ | { |
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; | char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
|
|
STAT_SERVERTIME | STAT_SERVERTIME |
out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; | out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; |
out << "Content-Length: " << contentLength << "\r\n"; | out << "Content-Length: " << contentLength << "\r\n"; |
|
if (httpMethod == HTTP_METHOD_M_POST) |
|
{ |
out << "Ext:\r\n"; | out << "Ext:\r\n"; |
out << "Cache-Control: no-cache\r\n"; | out << "Cache-Control: no-cache\r\n"; |
out << "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="; | out << "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="; |
out << nn <<"\r\n"; | out << nn <<"\r\n"; |
out << nn << "-CIMOperation: MethodResponse\r\n\r\n"; | out << nn << "-CIMOperation: MethodResponse\r\n\r\n"; |
} | } |
|
else |
|
{ |
|
out << "CIMOperation: MethodResponse\r\n\r\n"; |
|
} |
|
} |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
|
// ATTN-RK-P3-20020404: It is critical that this text not contain '\n' | // ATTN-RK-P3-20020404: It is critical that this text not contain '\n' |
// ATTN-RK-P3-20020404: Need to encode this value properly. (See | // ATTN-RK-P3-20020404: Need to encode this value properly. (See |
// CIM/HTTP Specification section 3.3.2 | // CIM/HTTP Specification section 3.3.2 |
out << PEGASUS_HTTPHEADERTAG_ERRORDETAIL ": " << errorDetail << "\r\n"; |
out << PEGASUS_HTTPHEADERTAG_ERRORDETAIL ": " |
|
<< encodeURICharacters(errorDetail) << "\r\n"; |
} | } |
out << "\r\n"; | out << "\r\n"; |
} | } |
|
|
| |
void XmlWriter::_appendMethodCallElementBegin( | void XmlWriter::_appendMethodCallElementBegin( |
Array<Sint8>& out, | Array<Sint8>& out, |
const char* name) |
const CIMName& name) |
{ | { |
out << "<METHODCALL NAME=\"" << name << "\">\n"; | out << "<METHODCALL NAME=\"" << name << "\">\n"; |
} | } |
|
|
| |
void XmlWriter::_appendIMethodCallElementBegin( | void XmlWriter::_appendIMethodCallElementBegin( |
Array<Sint8>& out, | Array<Sint8>& out, |
const char* name) |
const CIMName& name) |
{ | { |
out << "<IMETHODCALL NAME=\"" << name << "\">\n"; | out << "<IMETHODCALL NAME=\"" << name << "\">\n"; |
} | } |
|
|
| |
void XmlWriter::_appendMethodResponseElementBegin( | void XmlWriter::_appendMethodResponseElementBegin( |
Array<Sint8>& out, | Array<Sint8>& out, |
const char* name) |
const CIMName& name) |
{ | { |
out << "<METHODRESPONSE NAME=\"" << name << "\">\n"; | out << "<METHODRESPONSE NAME=\"" << name << "\">\n"; |
} | } |
|
|
| |
void XmlWriter::_appendIMethodResponseElementBegin( | void XmlWriter::_appendIMethodResponseElementBegin( |
Array<Sint8>& out, | Array<Sint8>& out, |
const char* name) |
const CIMName& name) |
{ | { |
out << "<IMETHODRESPONSE NAME=\"" << name << "\">\n"; | out << "<IMETHODRESPONSE NAME=\"" << name << "\">\n"; |
} | } |
|
|
Array<Sint8>& out, | Array<Sint8>& out, |
const CIMException& cimException) | const CIMException& cimException) |
{ | { |
PEG_TRACE_STRING(TRC_XML_WRITER, Tracer::LEVEL2, |
Tracer::traceCIMException(TRC_XML_WRITER, Tracer::LEVEL2, cimException); |
cimException.getTraceDescription()); |
|
| |
out << "<ERROR"; | out << "<ERROR"; |
out << " CODE=\"" << Uint32(cimException.getCode()) << "\""; | out << " CODE=\"" << Uint32(cimException.getCode()) << "\""; |
String description = cimException.getDescription(); |
String description = TraceableCIMException(cimException).getDescription(); |
if (description != String::EMPTY) | if (description != String::EMPTY) |
{ | { |
out << " DESCRIPTION=\""; | out << " DESCRIPTION=\""; |
|
|
out << "<RETURNVALUE"; | out << "<RETURNVALUE"; |
| |
CIMType type = value.getType(); | CIMType type = value.getType(); |
if (type != CIMTYPE_NONE) |
|
{ |
|
out << " PARAMTYPE=\"" << cimTypeToString (type) << "\""; | out << " PARAMTYPE=\"" << cimTypeToString (type) << "\""; |
} |
|
| |
out << ">\n"; | out << ">\n"; |
| |
|
|
void XmlWriter::appendClassNameIParameter( | void XmlWriter::appendClassNameIParameter( |
Array<Sint8>& out, | Array<Sint8>& out, |
const char* name, | const char* name, |
const String& className) |
const CIMName& className) |
{ | { |
_appendIParamValueElementBegin(out, name); | _appendIParamValueElementBegin(out, name); |
|
|
|
// |
|
// A NULL (unassigned) value for a parameter is specified by an |
|
// <IPARAMVALUE> element with no subelement |
|
// |
|
if (!className.isNull ()) |
|
{ |
appendClassNameElement(out, className); | appendClassNameElement(out, className); |
|
} |
|
|
_appendIParamValueElementEnd(out); | _appendIParamValueElementEnd(out); |
} | } |
| |
|
|
//========================================================== | //========================================================== |
void XmlWriter::appendPropertyNameIParameter( | void XmlWriter::appendPropertyNameIParameter( |
Array<Sint8>& out, | Array<Sint8>& out, |
const String& propertyName) |
const CIMName& propertyName) |
{ | { |
_appendIParamValueElementBegin(out, "PropertyName"); | _appendIParamValueElementBegin(out, "PropertyName"); |
out << "<VALUE>" << propertyName << "</VALUE>\n"; | out << "<VALUE>" << propertyName << "</VALUE>\n"; |
|
|
Array<Sint8>& out, | Array<Sint8>& out, |
const CIMPropertyList& propertyList) | const CIMPropertyList& propertyList) |
{ | { |
// ATTN: P3 KS 4 Mar 2002 - As check shouldn't we check for null property list |
|
_appendIParamValueElementBegin(out, "PropertyList"); | _appendIParamValueElementBegin(out, "PropertyList"); |
| |
|
// |
|
// A NULL (unassigned) value for a parameter is specified by an |
|
// <IPARAMVALUE> element with no subelement |
|
// |
|
if (!propertyList.isNull ()) |
|
{ |
out << "<VALUE.ARRAY>\n"; | out << "<VALUE.ARRAY>\n"; |
for (Uint32 i = 0; i < propertyList.size(); i++) | for (Uint32 i = 0; i < propertyList.size(); i++) |
{ | { |
out << "<VALUE>" << propertyList[i] << "</VALUE>\n"; | out << "<VALUE>" << propertyList[i] << "</VALUE>\n"; |
} | } |
out << "</VALUE.ARRAY>\n"; | out << "</VALUE.ARRAY>\n"; |
|
} |
| |
_appendIParamValueElementEnd(out); | _appendIParamValueElementEnd(out); |
} | } |
|
|
// ATTN-RK-P1-20020228: Need to complete copy elimination optimization | // ATTN-RK-P1-20020228: Need to complete copy elimination optimization |
Array<Sint8> XmlWriter::formatSimpleMethodReqMessage( | Array<Sint8> XmlWriter::formatSimpleMethodReqMessage( |
const char* host, | const char* host, |
const String& nameSpace, |
const CIMNamespaceName& nameSpace, |
const CIMObjectPath& path, | const CIMObjectPath& path, |
const char* methodName, |
const CIMName& methodName, |
const Array<CIMParamValue>& parameters, | const Array<CIMParamValue>& parameters, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const String& authenticationHeader) | const String& authenticationHeader) |
{ | { |
Array<Sint8> out; | Array<Sint8> out; |
Array<Sint8> tmp; | Array<Sint8> tmp; |
CIMObjectPath localObjectPath = path; | CIMObjectPath localObjectPath = path; |
localObjectPath.setNameSpace(nameSpace); |
localObjectPath.setNameSpace(nameSpace.getString()); |
|
localObjectPath.setHost(String::EMPTY); |
| |
_appendMessageElementBegin(out, messageId); | _appendMessageElementBegin(out, messageId); |
_appendSimpleReqElementBegin(out); | _appendSimpleReqElementBegin(out); |
|
|
tmp, | tmp, |
host, | host, |
methodName, | methodName, |
localObjectPath.toString(false), |
localObjectPath.toString(), |
authenticationHeader, | authenticationHeader, |
|
httpMethod, |
out.size()); | out.size()); |
tmp << out; | tmp << out; |
| |
|
|
} | } |
| |
Array<Sint8> XmlWriter::formatSimpleMethodRspMessage( | Array<Sint8> XmlWriter::formatSimpleMethodRspMessage( |
const char* methodName, |
const CIMName& methodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const Array<Sint8>& body) | const Array<Sint8>& body) |
{ | { |
Array<Sint8> out; | Array<Sint8> out; |
|
|
_appendSimpleRspElementEnd(out); | _appendSimpleRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
appendMethodResponseHeader(tmp, out.size()); |
appendMethodResponseHeader(tmp, httpMethod, out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Array<Sint8> XmlWriter::formatSimpleMethodErrorRspMessage( | Array<Sint8> XmlWriter::formatSimpleMethodErrorRspMessage( |
const String& methodName, |
const CIMName& methodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const CIMException& cimException) | const CIMException& cimException) |
{ | { |
ArrayDestroyer<char> tmp1(methodName.allocateCString()); |
|
Array<Sint8> out; | Array<Sint8> out; |
Array<Sint8> tmp; | Array<Sint8> tmp; |
| |
_appendMessageElementBegin(out, messageId); | _appendMessageElementBegin(out, messageId); |
_appendSimpleRspElementBegin(out); | _appendSimpleRspElementBegin(out); |
_appendMethodResponseElementBegin(out, tmp1.getPointer()); |
_appendMethodResponseElementBegin(out, methodName); |
_appendErrorElement(out, cimException); | _appendErrorElement(out, cimException); |
_appendMethodResponseElementEnd(out); | _appendMethodResponseElementEnd(out); |
_appendSimpleRspElementEnd(out); | _appendSimpleRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
appendMethodResponseHeader(tmp, out.size()); |
appendMethodResponseHeader(tmp, httpMethod, out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
| |
Array<Sint8> XmlWriter::formatSimpleIMethodReqMessage( | Array<Sint8> XmlWriter::formatSimpleIMethodReqMessage( |
const char* host, | const char* host, |
const String& nameSpace, |
const CIMNamespaceName& nameSpace, |
const char* iMethodName, |
const CIMName& iMethodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const String& authenticationHeader, | const String& authenticationHeader, |
const Array<Sint8>& body) | const Array<Sint8>& body) |
{ | { |
|
|
_appendMessageElementBegin(out, messageId); | _appendMessageElementBegin(out, messageId); |
_appendSimpleReqElementBegin(out); | _appendSimpleReqElementBegin(out); |
_appendIMethodCallElementBegin(out, iMethodName); | _appendIMethodCallElementBegin(out, iMethodName); |
appendLocalNameSpacePathElement(out, nameSpace); |
appendLocalNameSpacePathElement(out, nameSpace.getString()); |
out << body; | out << body; |
_appendIMethodCallElementEnd(out); | _appendIMethodCallElementEnd(out); |
_appendSimpleReqElementEnd(out); | _appendSimpleReqElementEnd(out); |
|
|
tmp, | tmp, |
host, | host, |
iMethodName, | iMethodName, |
nameSpace, |
nameSpace.getString(), |
authenticationHeader, | authenticationHeader, |
|
httpMethod, |
out.size()); | out.size()); |
tmp << out; | tmp << out; |
| |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Array<Sint8> XmlWriter::formatSimpleIMethodRspMessage( | Array<Sint8> XmlWriter::formatSimpleIMethodRspMessage( |
const char* iMethodName, |
const CIMName& iMethodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const Array<Sint8>& body) | const Array<Sint8>& body) |
{ | { |
Array<Sint8> out; | Array<Sint8> out; |
|
|
_appendSimpleRspElementEnd(out); | _appendSimpleRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
appendMethodResponseHeader(tmp, out.size()); |
appendMethodResponseHeader(tmp, httpMethod, out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Array<Sint8> XmlWriter::formatSimpleIMethodErrorRspMessage( | Array<Sint8> XmlWriter::formatSimpleIMethodErrorRspMessage( |
const String& iMethodName, |
const CIMName& iMethodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const CIMException& cimException) | const CIMException& cimException) |
{ | { |
ArrayDestroyer<char> tmp1(iMethodName.allocateCString()); |
|
Array<Sint8> out; | Array<Sint8> out; |
Array<Sint8> tmp; | Array<Sint8> tmp; |
| |
_appendMessageElementBegin(out, messageId); | _appendMessageElementBegin(out, messageId); |
_appendSimpleRspElementBegin(out); | _appendSimpleRspElementBegin(out); |
_appendIMethodResponseElementBegin(out, tmp1.getPointer()); |
_appendIMethodResponseElementBegin(out, iMethodName); |
_appendErrorElement(out, cimException); | _appendErrorElement(out, cimException); |
_appendIMethodResponseElementEnd(out); | _appendIMethodResponseElementEnd(out); |
_appendSimpleRspElementEnd(out); | _appendSimpleRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
appendMethodResponseHeader(tmp, out.size()); |
appendMethodResponseHeader(tmp, httpMethod, out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
Array<Sint8>& out, | Array<Sint8>& out, |
const char* requestUri, | const char* requestUri, |
const char* host, | const char* host, |
const char* cimMethod, |
const CIMName& cimMethod, |
|
HttpMethod httpMethod, |
const String& authenticationHeader, | const String& authenticationHeader, |
Uint32 contentLength) | Uint32 contentLength) |
{ | { |
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; | char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
| |
|
if (httpMethod == HTTP_METHOD_M_POST) |
|
{ |
out << "M-POST " << requestUri << " HTTP/1.1\r\n"; | out << "M-POST " << requestUri << " HTTP/1.1\r\n"; |
|
} |
|
else |
|
{ |
|
out << "POST " << requestUri << " HTTP/1.1\r\n"; |
|
} |
out << "HOST: " << host << "\r\n"; | out << "HOST: " << host << "\r\n"; |
out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; | out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; |
out << "Content-Length: " << contentLength << "\r\n"; | out << "Content-Length: " << contentLength << "\r\n"; |
|
if (httpMethod == HTTP_METHOD_M_POST) |
|
{ |
out << "Man: http://www.hp.com; ns="; | out << "Man: http://www.hp.com; ns="; |
out << nn <<"\r\n"; | out << nn <<"\r\n"; |
out << nn << "-CIMExport: MethodRequest\r\n"; | out << nn << "-CIMExport: MethodRequest\r\n"; |
out << nn << "-CIMExportMethod: " << cimMethod << "\r\n"; | out << nn << "-CIMExportMethod: " << cimMethod << "\r\n"; |
|
} |
|
else |
|
{ |
|
out << "CIMExport: MethodRequest\r\n"; |
|
out << "CIMExportMethod: " << cimMethod << "\r\n"; |
|
} |
|
|
if (authenticationHeader.size()) | if (authenticationHeader.size()) |
{ | { |
out << authenticationHeader << "\r\n"; | out << authenticationHeader << "\r\n"; |
|
|
| |
void XmlWriter::appendEMethodResponseHeader( | void XmlWriter::appendEMethodResponseHeader( |
Array<Sint8>& out, | Array<Sint8>& out, |
|
HttpMethod httpMethod, |
Uint32 contentLength) | Uint32 contentLength) |
{ | { |
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; | char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
|
|
out << "HTTP/1.1 " HTTP_STATUS_OK "\r\n"; | out << "HTTP/1.1 " HTTP_STATUS_OK "\r\n"; |
out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; | out << "Content-Type: application/xml; charset=\"utf-8\"\r\n"; |
out << "Content-Length: " << contentLength << "\r\n"; | out << "Content-Length: " << contentLength << "\r\n"; |
|
if (httpMethod == HTTP_METHOD_M_POST) |
|
{ |
out << "Ext:\r\n"; | out << "Ext:\r\n"; |
out << "Cache-Control: no-cache\r\n"; | out << "Cache-Control: no-cache\r\n"; |
out << "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="; | out << "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="; |
out << nn <<"\r\n"; | out << nn <<"\r\n"; |
out << nn << "-CIMExport: MethodResponse\r\n\r\n"; | out << nn << "-CIMExport: MethodResponse\r\n\r\n"; |
} | } |
|
else |
|
{ |
|
out << "CIMExport: MethodResponse\r\n\r\n"; |
|
} |
|
} |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
|
| |
void XmlWriter::_appendEMethodCallElementBegin( | void XmlWriter::_appendEMethodCallElementBegin( |
Array<Sint8>& out, | Array<Sint8>& out, |
const char* name) |
const CIMName& name) |
{ | { |
out << "<EXPMETHODCALL NAME=\"" << name << "\">\n"; | out << "<EXPMETHODCALL NAME=\"" << name << "\">\n"; |
} | } |
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// _appendEParamValueElementBegin() |
|
// _appendEParamValueElementEnd() |
|
// |
|
// <!ELEMENT EXPPARAMVALUE (INSTANCE)> |
|
// <!ATTLIST EXPPARAMVALUE |
|
// %CIMName;> |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
void XmlWriter::_appendEParamValueElementBegin( |
|
Array<Sint8>& out, |
|
const char* name) |
|
{ |
|
out << "<EXPPARAMVALUE NAME=\"" << name << "\">\n"; |
|
} |
|
|
|
void XmlWriter::_appendEParamValueElementEnd( |
|
Array<Sint8>& out) |
|
{ |
|
out << "</EXPPARAMVALUE>\n"; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// appendInstanceEParameter() |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
void XmlWriter::appendInstanceEParameter( |
|
Array<Sint8>& out, |
|
const char* name, |
|
const CIMInstance& instance) |
|
{ |
|
_appendEParamValueElementBegin(out, name); |
|
appendInstanceElement(out, instance); |
|
_appendEParamValueElementEnd(out); |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
// _appendSimpleExportRspElementBegin() | // _appendSimpleExportRspElementBegin() |
// _appendSimpleExportRspElementEnd() | // _appendSimpleExportRspElementEnd() |
// | // |
|
|
| |
void XmlWriter::_appendEMethodResponseElementBegin( | void XmlWriter::_appendEMethodResponseElementBegin( |
Array<Sint8>& out, | Array<Sint8>& out, |
const char* name) |
const CIMName& name) |
{ | { |
out << "<EXPMETHODRESPONSE NAME=\"" << name << "\">\n"; | out << "<EXPMETHODRESPONSE NAME=\"" << name << "\">\n"; |
} | } |
|
|
Array<Sint8> XmlWriter::formatSimpleEMethodReqMessage( | Array<Sint8> XmlWriter::formatSimpleEMethodReqMessage( |
const char* requestUri, | const char* requestUri, |
const char* host, | const char* host, |
const char* eMethodName, |
const CIMName& eMethodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const String& authenticationHeader, | const String& authenticationHeader, |
const Array<Sint8>& body) | const Array<Sint8>& body) |
{ | { |
|
|
requestUri, | requestUri, |
host, | host, |
eMethodName, | eMethodName, |
|
httpMethod, |
authenticationHeader, | authenticationHeader, |
out.size()); | out.size()); |
tmp << out; | tmp << out; |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Array<Sint8> XmlWriter::formatSimpleEMethodRspMessage( | Array<Sint8> XmlWriter::formatSimpleEMethodRspMessage( |
const char* eMethodName, |
const CIMName& eMethodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const Array<Sint8>& body) | const Array<Sint8>& body) |
{ | { |
Array<Sint8> out; | Array<Sint8> out; |
|
|
_appendSimpleExportRspElementEnd(out); | _appendSimpleExportRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
appendEMethodResponseHeader(tmp, out.size()); |
appendEMethodResponseHeader(tmp, httpMethod, out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Array<Sint8> XmlWriter::formatSimpleEMethodErrorRspMessage( | Array<Sint8> XmlWriter::formatSimpleEMethodErrorRspMessage( |
const String& eMethodName, |
const CIMName& eMethodName, |
const String& messageId, | const String& messageId, |
|
HttpMethod httpMethod, |
const CIMException& cimException) | const CIMException& cimException) |
{ | { |
ArrayDestroyer<char> tmp1(eMethodName.allocateCString()); |
|
Array<Sint8> out; | Array<Sint8> out; |
Array<Sint8> tmp; | Array<Sint8> tmp; |
| |
_appendMessageElementBegin(out, messageId); | _appendMessageElementBegin(out, messageId); |
_appendSimpleExportRspElementBegin(out); | _appendSimpleExportRspElementBegin(out); |
_appendEMethodResponseElementBegin(out, tmp1.getPointer()); |
_appendEMethodResponseElementBegin(out, eMethodName); |
_appendErrorElement(out, cimException); | _appendErrorElement(out, cimException); |
_appendEMethodResponseElementEnd(out); | _appendEMethodResponseElementEnd(out); |
_appendSimpleExportRspElementEnd(out); | _appendSimpleExportRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
appendEMethodResponseHeader(tmp, out.size()); |
appendEMethodResponseHeader(tmp, httpMethod, out.size()); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
// XmlWriter::keyBindingTypeToString | // XmlWriter::keyBindingTypeToString |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
const char* XmlWriter::keyBindingTypeToString (KeyBinding::Type type) |
const char* XmlWriter::keyBindingTypeToString (CIMKeyBinding::Type type) |
{ | { |
switch (type) | switch (type) |
{ | { |
case KeyBinding::BOOLEAN: |
case CIMKeyBinding::BOOLEAN: |
return "boolean"; | return "boolean"; |
| |
case KeyBinding::STRING: |
case CIMKeyBinding::STRING: |
return "string"; | return "string"; |
| |
case KeyBinding::NUMERIC: |
case CIMKeyBinding::NUMERIC: |
return "numeric"; | return "numeric"; |
| |
case KeyBinding::REFERENCE: |
case CIMKeyBinding::REFERENCE: |
default: | default: |
PEGASUS_ASSERT(false); | PEGASUS_ASSERT(false); |
} | } |