version 1.61, 2002/05/30 15:55:21
|
version 1.80, 2002/09/13 21:40:42
|
|
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// The Open Group, Tivoli Systems | // The Open Group, Tivoli Systems |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
|
|
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); |
} | } |
|
|
| |
void XmlWriter::append(Array<Sint8>& out, const String& str) | void XmlWriter::append(Array<Sint8>& out, const String& str) |
{ | { |
const Char16* tmp = str.getData(); |
for (Uint32 i = 0; i < str.size(); i++) |
|
{ |
while (*tmp) |
_appendChar(out, str[i]); |
_appendChar(out, *tmp++); |
} |
} | } |
| |
void XmlWriter::append(Array<Sint8>& out, const Indentor& x) | void XmlWriter::append(Array<Sint8>& out, const Indentor& 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); |
} | } |
|
|
| |
void XmlWriter::appendSpecial(Array<Sint8>& out, const String& str) | void XmlWriter::appendSpecial(Array<Sint8>& out, const String& str) |
{ | { |
const Char16* tmp = str.getData(); |
for (Uint32 i = 0; i < str.size(); i++) |
|
{ |
while (*tmp) |
_appendSpecialChar(out, str[i]); |
_appendSpecialChar(out, *tmp++); |
} |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
| |
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); |
} | } |
else { | else { |
out << "<KEYVALUE VALUETYPE=\""; | out << "<KEYVALUE VALUETYPE=\""; |
out << KeyBinding::typeToString(keyBindings[i].getType()); |
out << keyBindingTypeToString(keyBindings[i].getType()); |
out << "\">"; | out << "\">"; |
| |
// fixed the special character problem - Markus | // fixed the special character problem - Markus |
|
|
Array<Sint8>& out, | Array<Sint8>& out, |
const CIMObjectPath& objectPath) | const CIMObjectPath& objectPath) |
{ | { |
if (objectPath.isInstanceName()) |
// |
|
// ATTN-CAKG-P2-20020726: The following condition does not correctly |
|
// distinguish instanceNames from classNames in every case |
|
// The instanceName of a singleton instance of a keyless class has no |
|
// key bindings |
|
// |
|
if (objectPath.getKeyBindings ().size () != 0) |
{ | { |
appendLocalInstancePathElement(out, objectPath); | appendLocalInstancePathElement(out, objectPath); |
} | } |
|
|
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) |
|
|
{ | { |
switch (value.getType()) | switch (value.getType()) |
{ | { |
case CIMType::BOOLEAN: |
case CIMTYPE_BOOLEAN: |
{ | { |
Array<Boolean> a; | Array<Boolean> a; |
value.get(a); | value.get(a); |
|
|
break; | break; |
} | } |
| |
case CIMType::UINT8: |
case CIMTYPE_UINT8: |
{ | { |
Array<Uint8> a; | Array<Uint8> a; |
value.get(a); | value.get(a); |
|
|
break; | break; |
} | } |
| |
case CIMType::SINT8: |
case CIMTYPE_SINT8: |
{ | { |
Array<Sint8> a; | Array<Sint8> a; |
value.get(a); | value.get(a); |
|
|
break; | break; |
} | } |
| |
case CIMType::UINT16: |
case CIMTYPE_UINT16: |
{ | { |
Array<Uint16> a; | Array<Uint16> a; |
value.get(a); | value.get(a); |
|
|
break; | break; |
} | } |
| |
case CIMType::SINT16: |
case CIMTYPE_SINT16: |
{ | { |
Array<Sint16> a; | Array<Sint16> a; |
value.get(a); | value.get(a); |
|
|
break; | break; |
} | } |
| |
case CIMType::UINT32: |
case CIMTYPE_UINT32: |
{ | { |
Array<Uint32> a; | Array<Uint32> a; |
value.get(a); | value.get(a); |
|
|
break; | break; |
} | } |
| |
case CIMType::SINT32: |
case CIMTYPE_SINT32: |
{ | { |
Array<Sint32> a; | Array<Sint32> a; |
value.get(a); | value.get(a); |
|
|
break; | break; |
} | } |
| |
case CIMType::UINT64: |
case CIMTYPE_UINT64: |
{ | { |
Array<Uint64> a; | Array<Uint64> a; |
value.get(a); | value.get(a); |
|
|
break; | break; |
} | } |
| |
case CIMType::SINT64: |
case CIMTYPE_SINT64: |
{ | { |
Array<Sint64> a; | Array<Sint64> a; |
value.get(a); | value.get(a); |
|
|
break; | break; |
} | } |
| |
case CIMType::REAL32: |
case CIMTYPE_REAL32: |
{ | { |
Array<Real32> a; | Array<Real32> a; |
value.get(a); | value.get(a); |
|
|
break; | break; |
} | } |
| |
case CIMType::REAL64: |
case CIMTYPE_REAL64: |
{ | { |
Array<Real64> a; | Array<Real64> a; |
value.get(a); | value.get(a); |
|
|
break; | break; |
} | } |
| |
case CIMType::CHAR16: |
case CIMTYPE_CHAR16: |
{ | { |
Array<Char16> a; | Array<Char16> a; |
value.get(a); | value.get(a); |
|
|
break; | break; |
} | } |
| |
case CIMType::STRING: |
case CIMTYPE_STRING: |
{ | { |
Array<String> a; | Array<String> a; |
value.get(a); | value.get(a); |
|
|
break; | break; |
} | } |
| |
case CIMType::DATETIME: |
case CIMTYPE_DATETIME: |
{ | { |
Array<CIMDateTime> a; | Array<CIMDateTime> a; |
value.get(a); | value.get(a); |
|
|
break; | break; |
} | } |
| |
case CIMType::REFERENCE: |
case CIMTYPE_REFERENCE: |
{ | { |
Array<CIMObjectPath> a; | Array<CIMObjectPath> a; |
value.get(a); | value.get(a); |
|
|
} | } |
| |
default: | default: |
throw CIMValueInvalidType(); |
PEGASUS_ASSERT(false); |
} | } |
} | } |
else if (value.getType() == CIMType::REFERENCE) |
else if (value.getType() == CIMTYPE_REFERENCE) |
{ | { |
// Has to be separate because it uses VALUE.REFERENCE tag | // Has to be separate because it uses VALUE.REFERENCE tag |
CIMObjectPath v; | CIMObjectPath v; |
|
|
| |
switch (value.getType()) | switch (value.getType()) |
{ | { |
case CIMType::BOOLEAN: |
case CIMTYPE_BOOLEAN: |
{ | { |
Boolean v; | Boolean v; |
value.get(v); | value.get(v); |
|
|
break; | break; |
} | } |
| |
case CIMType::UINT8: |
case CIMTYPE_UINT8: |
{ | { |
Uint8 v; | Uint8 v; |
value.get(v); | value.get(v); |
|
|
break; | break; |
} | } |
| |
case CIMType::SINT8: |
case CIMTYPE_SINT8: |
{ | { |
Sint8 v; | Sint8 v; |
value.get(v); | value.get(v); |
|
|
break; | break; |
} | } |
| |
case CIMType::UINT16: |
case CIMTYPE_UINT16: |
{ | { |
Uint16 v; | Uint16 v; |
value.get(v); | value.get(v); |
|
|
break; | break; |
} | } |
| |
case CIMType::SINT16: |
case CIMTYPE_SINT16: |
{ | { |
Sint16 v; | Sint16 v; |
value.get(v); | value.get(v); |
|
|
break; | break; |
} | } |
| |
case CIMType::UINT32: |
case CIMTYPE_UINT32: |
{ | { |
Uint32 v; | Uint32 v; |
value.get(v); | value.get(v); |
|
|
break; | break; |
} | } |
| |
case CIMType::SINT32: |
case CIMTYPE_SINT32: |
{ | { |
Sint32 v; | Sint32 v; |
value.get(v); | value.get(v); |
|
|
break; | break; |
} | } |
| |
case CIMType::UINT64: |
case CIMTYPE_UINT64: |
{ | { |
Uint64 v; | Uint64 v; |
value.get(v); | value.get(v); |
|
|
break; | break; |
} | } |
| |
case CIMType::SINT64: |
case CIMTYPE_SINT64: |
{ | { |
Sint64 v; | Sint64 v; |
value.get(v); | value.get(v); |
|
|
break; | break; |
} | } |
| |
case CIMType::REAL32: |
case CIMTYPE_REAL32: |
{ | { |
Real32 v; | Real32 v; |
value.get(v); | value.get(v); |
|
|
break; | break; |
} | } |
| |
case CIMType::REAL64: |
case CIMTYPE_REAL64: |
{ | { |
Real64 v; | Real64 v; |
value.get(v); | value.get(v); |
|
|
break; | break; |
} | } |
| |
case CIMType::CHAR16: |
case CIMTYPE_CHAR16: |
{ | { |
Char16 v; | Char16 v; |
value.get(v); | value.get(v); |
|
|
break; | break; |
} | } |
| |
case CIMType::STRING: |
case CIMTYPE_STRING: |
{ | { |
String v; | String v; |
value.get(v); | value.get(v); |
|
|
break; | break; |
} | } |
| |
case CIMType::DATETIME: |
case CIMTYPE_DATETIME: |
{ | { |
CIMDateTime v; | CIMDateTime v; |
value.get(v); | value.get(v); |
|
|
} | } |
| |
default: | default: |
throw CIMValueInvalidType(); |
PEGASUS_ASSERT(false); |
} | } |
| |
out << "</VALUE>\n"; | out << "</VALUE>\n"; |
|
|
| |
void XmlWriter::appendValueObjectWithPathElement( | void XmlWriter::appendValueObjectWithPathElement( |
Array<Sint8>& out, | Array<Sint8>& out, |
const CIMObjectWithPath& objectWithPath) |
const CIMObject& objectWithPath) |
{ | { |
out << "<VALUE.OBJECTWITHPATH>\n"; | out << "<VALUE.OBJECTWITHPATH>\n"; |
| |
appendValueReferenceElement(out, objectWithPath.getReference(), false); |
appendValueReferenceElement(out, objectWithPath.getPath (), false); |
appendObjectElement(out, objectWithPath.getObject()); |
appendObjectElement(out, objectWithPath); |
| |
out << "</VALUE.OBJECTWITHPATH>\n"; | out << "</VALUE.OBJECTWITHPATH>\n"; |
} | } |
|
|
| |
// See if it is a class or instance reference (instance references have | // See if it is a class or instance reference (instance references have |
// key-bindings; class references do not). | // key-bindings; class references do not). |
|
// |
|
// ATTN-CAKG-P2-20020726: The following condition does not correctly |
|
// distinguish instanceNames from classNames in every case |
|
// The instanceName of a singleton instance of a keyless class has no |
|
// key bindings |
|
// |
| |
//KeyBindingArray kbs = reference.getKeyBindingArray(); |
Array<CIMKeyBinding> kbs = reference.getKeyBindings(); |
KeyBindingArray kbs = reference.getKeyBindings(); |
|
| |
if (kbs.size()) | if (kbs.size()) |
{ | { |
|
|
{ | { |
appendInstancePathElement(out, reference); | appendInstancePathElement(out, reference); |
} | } |
else if (reference.getNameSpace().size()) |
else if (!reference.getNameSpace().isNull()) |
{ | { |
appendLocalInstancePathElement(out, reference); | appendLocalInstancePathElement(out, reference); |
} | } |
|
|
{ | { |
appendClassPathElement(out, reference); | appendClassPathElement(out, reference); |
} | } |
else if (reference.getNameSpace().size()) |
else if (!reference.getNameSpace().isNull()) |
{ | { |
appendLocalClassPathElement(out, reference); | appendLocalClassPathElement(out, reference); |
} | } |
|
|
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, |
Uint32 contentLength) | Uint32 contentLength) |
|
|
| |
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=\"" << type.toString() << "\""; |
|
} |
|
| |
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); |
appendClassNameElement(out, className); | appendClassNameElement(out, className); |
|
|
const char* name, | const char* name, |
const CIMObjectPath& objectName) | const CIMObjectPath& objectName) |
{ | { |
if (objectName.isClassName()) |
// |
|
// ATTN-CAKG-P2-20020726: The following condition does not correctly |
|
// distinguish instanceNames from classNames in every case |
|
// The instanceName of a singleton instance of a keyless class also |
|
// has no key bindings |
|
// |
|
if (objectName.getKeyBindings ().size () == 0) |
{ | { |
XmlWriter::appendClassNameIParameter( | XmlWriter::appendClassNameIParameter( |
out, name, objectName.getClassName()); | out, name, objectName.getClassName()); |
|
|
//========================================================== | //========================================================== |
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"; |
|
|
_appendIParamValueElementBegin(out, "PropertyList"); | _appendIParamValueElementBegin(out, "PropertyList"); |
| |
out << "<VALUE.ARRAY>\n"; | out << "<VALUE.ARRAY>\n"; |
for (Uint32 i = 0; i < propertyList.getNumProperties(); i++) |
for (Uint32 i = 0; i < propertyList.size(); i++) |
{ | { |
out << "<VALUE>" << propertyList.getPropertyName(i) << "</VALUE>\n"; |
out << "<VALUE>" << propertyList[i] << "</VALUE>\n"; |
} | } |
out << "</VALUE.ARRAY>\n"; | out << "</VALUE.ARRAY>\n"; |
| |
|
|
// 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, |
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, |
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, |
const Array<Sint8>& body) | const Array<Sint8>& body) |
{ | { |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Array<Sint8> XmlWriter::formatSimpleMethodErrorRspMessage( | Array<Sint8> XmlWriter::formatSimpleMethodErrorRspMessage( |
const String& methodName, |
const CIMName& methodName, |
const String& messageId, | const String& messageId, |
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); |
|
|
| |
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, |
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, |
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, |
const Array<Sint8>& body) | const Array<Sint8>& body) |
{ | { |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Array<Sint8> XmlWriter::formatSimpleIMethodErrorRspMessage( | Array<Sint8> XmlWriter::formatSimpleIMethodErrorRspMessage( |
const String& iMethodName, |
const CIMName& iMethodName, |
const String& messageId, | const String& messageId, |
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); |
|
|
Array<Sint8>& out, | Array<Sint8>& out, |
const char* requestUri, | const char* requestUri, |
const char* host, | const char* host, |
const char* cimMethod, |
const CIMName& cimMethod, |
const String& authenticationHeader, | const String& authenticationHeader, |
Uint32 contentLength) | Uint32 contentLength) |
{ | { |
|
|
| |
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"; |
} | } |
|
|
| |
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, |
const String& authenticationHeader, | const String& authenticationHeader, |
const Array<Sint8>& body) | const Array<Sint8>& body) |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Array<Sint8> XmlWriter::formatSimpleEMethodRspMessage( | Array<Sint8> XmlWriter::formatSimpleEMethodRspMessage( |
const char* eMethodName, |
const CIMName& eMethodName, |
const String& messageId, | const String& messageId, |
const Array<Sint8>& body) | const Array<Sint8>& body) |
{ | { |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Array<Sint8> XmlWriter::formatSimpleEMethodErrorRspMessage( | Array<Sint8> XmlWriter::formatSimpleEMethodErrorRspMessage( |
const String& eMethodName, |
const CIMName& eMethodName, |
const String& messageId, | const String& messageId, |
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); |
|
|
return buffer; | return buffer; |
} | } |
| |
|
//------------------------------------------------------------------------------ |
|
// |
|
// XmlWriter::keyBindingTypeToString |
|
// |
|
//------------------------------------------------------------------------------ |
|
const char* XmlWriter::keyBindingTypeToString (CIMKeyBinding::Type type) |
|
{ |
|
switch (type) |
|
{ |
|
case CIMKeyBinding::BOOLEAN: |
|
return "boolean"; |
|
|
|
case CIMKeyBinding::STRING: |
|
return "string"; |
|
|
|
case CIMKeyBinding::NUMERIC: |
|
return "numeric"; |
|
|
|
case CIMKeyBinding::REFERENCE: |
|
default: |
|
PEGASUS_ASSERT(false); |
|
} |
|
|
|
return "unknown"; |
|
} |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |