version 1.138.4.1, 2006/06/30 22:37:52
|
version 1.156, 2008/03/05 21:31:45
|
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Mike Brasher (mbrasher@bmc.com) |
|
// |
|
// Modified By: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) |
|
// Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com) |
|
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// Carol Ann Krug Graves, Hewlett-Packard Company |
|
// (carolann_graves@hp.com) |
|
// Amit K Arora, IBM (amita@in.ibm.com) for PEP#101 |
|
// Brian G. Campbell, EMC (campbell_brian@emc.com) - PEP140/phase1 |
|
// Willis White (whiwill@us.ibm.com) PEP 127 and 128 |
|
// Brian G. Campbell, EMC (campbell_brian@emc.com) - PEP140/phase2 |
|
// Dave Sudlik, IBM (dsudlik@us.ibm.com) |
|
// David Dillard, Symantec Corp. (david_dillard@symantec.com) |
|
// Vijay Eli, vijayeli@in.ibm.com, fix for #2571 |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
|
|
#include "StrLit.h" | #include "StrLit.h" |
#include "LanguageParser.h" | #include "LanguageParser.h" |
#include "IDFactory.h" | #include "IDFactory.h" |
|
#include "StringConversion.h" |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
struct SpecialChar | struct SpecialChar |
{ | { |
const char* str; | const char* str; |
size_t size; |
Uint32 size; |
}; | }; |
| |
// Defines encodings of special characters. Just use a 7-bit ASCII character | // Defines encodings of special characters. Just use a 7-bit ASCII character |
|
|
return out; | return out; |
} | } |
| |
Buffer& operator<<(Buffer& out, const Indentor& x) |
|
{ |
|
XmlWriter::append(out, x); |
|
return out; |
|
} |
|
|
|
Buffer& operator<<(Buffer& out, const Buffer& x) | Buffer& operator<<(Buffer& out, const Buffer& x) |
{ | { |
out.append(x.getData(), x.size()); | out.append(x.getData(), x.size()); |
|
|
} | } |
| |
| |
// l10n |
|
Buffer& operator<<(Buffer& out, const AcceptLanguageList& al) | Buffer& operator<<(Buffer& out, const AcceptLanguageList& al) |
{ | { |
XmlWriter::append(out, LanguageParser::buildAcceptLanguageHeader(al)); | XmlWriter::append(out, LanguageParser::buildAcceptLanguageHeader(al)); |
return out; | return out; |
} | } |
| |
// l10n |
|
Buffer& operator<<(Buffer& out, const ContentLanguageList& cl) | Buffer& operator<<(Buffer& out, const ContentLanguageList& cl) |
{ | { |
XmlWriter::append(out, LanguageParser::buildContentLanguageHeader(cl)); | XmlWriter::append(out, LanguageParser::buildContentLanguageHeader(cl)); |
|
|
Uint8 *strtgt = (Uint8 *)str; | Uint8 *strtgt = (Uint8 *)str; |
Uint8 *endtgt = (Uint8 *)&str[5]; | Uint8 *endtgt = (Uint8 *)&str[5]; |
| |
UTF16toUTF8(&strsrc, |
UTF16toUTF8( |
|
&strsrc, |
endsrc, | endsrc, |
&strtgt, | &strtgt, |
endtgt); | endtgt); |
|
|
{ | { |
if ( ((c < 0x20) && (c >= 0)) || (c == 0x7f) ) | if ( ((c < 0x20) && (c >= 0)) || (c == 0x7f) ) |
{ | { |
char charref[7]; |
char scratchBuffer[22]; |
sprintf(charref, "&#%u;", static_cast<Uint8>(c)); |
Uint32 outputLength; |
os << charref; |
const char * output = Uint8ToString(scratchBuffer, |
|
static_cast<Uint8>(c), |
|
outputLength); |
|
os << "&#" << output << ";"; |
} | } |
else | else |
{ | { |
|
|
Uint8 *strtgt = (Uint8 *)str; | Uint8 *strtgt = (Uint8 *)str; |
Uint8 *endtgt = (Uint8 *)&str[5]; | Uint8 *endtgt = (Uint8 *)&str[5]; |
| |
UTF16toUTF8(&strsrc, |
UTF16toUTF8( |
|
&strsrc, |
endsrc, | endsrc, |
&strtgt, | &strtgt, |
endtgt); | endtgt); |
|
|
_xmlWritter_appendSpecialChar(os, *str++); | _xmlWritter_appendSpecialChar(os, *str++); |
} | } |
| |
|
// On windows sprintf outputs 3 digit precision exponent prepending |
|
// zeros. Make it 2 digit precision if first digit is zero in the exponent. |
|
#ifdef PEGASUS_OS_TYPE_WINDOWS |
|
inline void _xmlWriter_normalizeRealValueString(char *str) |
|
{ |
|
// skip initial sign value... |
|
if (*str == '-' || *str == '+') |
|
{ |
|
++str; |
|
} |
|
while (*str && *str != '+' && *str != '-') |
|
{ |
|
++str; |
|
} |
|
if (*str && * ++str == '0') |
|
{ |
|
*str = *(str+1); |
|
*(str+1) = *(str+2); |
|
*(str+2) = 0; |
|
} |
|
} |
|
#endif |
|
|
void XmlWriter::append(Buffer& out, const Char16& x) | void XmlWriter::append(Buffer& out, const Char16& x) |
{ | { |
_xmlWritter_appendChar(out, x); | _xmlWritter_appendChar(out, x); |
|
|
| |
void XmlWriter::append(Buffer& out, Boolean x) | void XmlWriter::append(Buffer& out, Boolean x) |
{ | { |
append(out, (x ? "TRUE" : "FALSE")); |
if (x) |
|
out.append(STRLIT_ARGS("TRUE")); |
|
else |
|
out.append(STRLIT_ARGS("FALSE")); |
} | } |
| |
void XmlWriter::append(Buffer& out, Uint32 x) | void XmlWriter::append(Buffer& out, Uint32 x) |
{ | { |
char buffer[32]; |
Uint32 outputLength=0; |
sprintf(buffer, "%u", x); |
char buffer[22]; |
append(out, buffer); |
const char * output = Uint32ToString(buffer, x, outputLength); |
|
out.append(output, outputLength); |
} | } |
| |
void XmlWriter::append(Buffer& out, Sint32 x) | void XmlWriter::append(Buffer& out, Sint32 x) |
{ | { |
char buffer[32]; |
Uint32 outputLength=0; |
sprintf(buffer, "%d", x); |
char buffer[22]; |
append(out, buffer); |
const char * output = Sint32ToString(buffer, x, outputLength); |
|
out.append(output, outputLength); |
} | } |
| |
void XmlWriter::append(Buffer& out, Uint64 x) | void XmlWriter::append(Buffer& out, Uint64 x) |
{ | { |
char buffer[32]; // Should need 21 chars max |
Uint32 outputLength=0; |
sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", x); |
char buffer[22]; |
append(out, buffer); |
const char * output = Uint64ToString(buffer, x, outputLength); |
|
out.append(output, outputLength); |
} | } |
| |
void XmlWriter::append(Buffer& out, Sint64 x) | void XmlWriter::append(Buffer& out, Sint64 x) |
{ | { |
char buffer[32]; // Should need 21 chars max |
Uint32 outputLength=0; |
sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "d", x); |
char buffer[22]; |
append(out, buffer); |
const char * output = Sint64ToString(buffer, x, outputLength); |
|
out.append(output, outputLength); |
} | } |
| |
void XmlWriter::append(Buffer& out, Real32 x) | void XmlWriter::append(Buffer& out, Real32 x) |
|
|
// given in the CIM/XML spec, and the precision required by the CIM 2.2 spec | // given in the CIM/XML spec, and the precision required by the CIM 2.2 spec |
// (4 byte IEEE floating point) | // (4 byte IEEE floating point) |
sprintf(buffer, "%.7e", x); | sprintf(buffer, "%.7e", x); |
|
#ifdef PEGASUS_OS_TYPE_WINDOWS |
|
_xmlWriter_normalizeRealValueString(buffer); |
|
#endif |
append(out, buffer); | append(out, buffer); |
} | } |
| |
void XmlWriter::append(Buffer& out, Real64 x) | void XmlWriter::append(Buffer& out, Real64 x) |
{ | { |
char buffer[128]; | char buffer[128]; |
// %.16e gives '[-]m.dddddddddddddddde+/-xx', which seems compatible with the format |
// %.16e gives '[-]m.dddddddddddddddde+/-xx', which seems compatible |
// given in the CIM/XML spec, and the precision required by the CIM 2.2 spec |
// with the format given in the CIM/XML spec, and the precision required |
// (8 byte IEEE floating point) |
// by the CIM 2.2 spec (8 byte IEEE floating point) |
sprintf(buffer, "%.16e", x); | sprintf(buffer, "%.16e", x); |
|
#ifdef PEGASUS_OS_TYPE_WINDOWS |
|
_xmlWriter_normalizeRealValueString(buffer); |
|
#endif |
append(out, buffer); | append(out, buffer); |
} | } |
| |
|
|
continue; | continue; |
} | } |
| |
// Hanlde UTF8 case (if reached). |
// Handle UTF8 case (if reached). |
| |
if(((c >= FIRST_HIGH_SURROGATE) && (c <= LAST_HIGH_SURROGATE)) || | if(((c >= FIRST_HIGH_SURROGATE) && (c <= LAST_HIGH_SURROGATE)) || |
((c >= FIRST_LOW_SURROGATE) && (c <= LAST_LOW_SURROGATE))) | ((c >= FIRST_LOW_SURROGATE) && (c <= LAST_LOW_SURROGATE))) |
|
|
} | } |
} | } |
| |
void XmlWriter::append(Buffer& out, const Indentor& x) |
|
{ |
|
for (Uint32 i = 0; i < 4 * x.getLevel(); i++) |
|
out.append(' '); |
|
} |
|
|
|
void XmlWriter::appendSpecial(Buffer& out, const Char16& x) | void XmlWriter::appendSpecial(Buffer& out, const Char16& x) |
{ | { |
_xmlWritter_appendSpecialChar(out, x); | _xmlWritter_appendSpecialChar(out, x); |
|
|
Char16 highSurrogate = uriString[i]; | Char16 highSurrogate = uriString[i]; |
Char16 lowSurrogate = uriString[++i]; | Char16 lowSurrogate = uriString[++i]; |
| |
_xmlWritter_appendSurrogatePair(utf8, Uint16(highSurrogate),Uint16(lowSurrogate)); |
_xmlWritter_appendSurrogatePair( |
|
utf8, Uint16(highSurrogate),Uint16(lowSurrogate)); |
} | } |
else | else |
{ | { |
|
|
| |
char* nameSpaceCopy = strdup(nameSpace.getString().getCString()); | char* nameSpaceCopy = strdup(nameSpace.getString().getCString()); |
| |
#if !defined(PEGASUS_COMPILER_MSVC) |
#if !defined(PEGASUS_COMPILER_MSVC) && !defined(PEGASUS_OS_ZOS) |
char *last; | char *last; |
for (const char* p = strtok_r(nameSpaceCopy, "/", &last); p; | for (const char* p = strtok_r(nameSpaceCopy, "/", &last); p; |
p = strtok_r(NULL, "/", &last)) | p = strtok_r(NULL, "/", &last)) |
|
|
CIMObjectPath ref = keyBindings[i].getValue(); | CIMObjectPath ref = keyBindings[i].getValue(); |
appendValueReferenceElement(out, ref, true); | appendValueReferenceElement(out, ref, true); |
} | } |
else { |
else |
|
{ |
out << STRLIT("<KEYVALUE VALUETYPE=\""); | out << STRLIT("<KEYVALUE VALUETYPE=\""); |
out << keyBindingTypeToString(keyBindings[i].getType()); | out << keyBindingTypeToString(keyBindings[i].getType()); |
out << STRLIT("\">"); | out << STRLIT("\">"); |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendValueElement(tmp, value); | appendValueElement(tmp, value); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendValueReferenceElement(tmp, reference, true); | appendValueReferenceElement(tmp, reference, true); |
tmp.append('\0'); |
|
indentedPrint(os, tmp.getData()); | indentedPrint(os, tmp.getData()); |
} | } |
| |
|
|
| |
void XmlWriter::appendClassElement( | void XmlWriter::appendClassElement( |
Buffer& out, | Buffer& out, |
const CIMConstClass& cimclass) |
const CIMConstClass& cimClass) |
|
{ |
|
CheckRep(cimClass._rep); |
|
const CIMClassRep* rep = cimClass._rep; |
|
|
|
// Class opening element: |
|
|
|
out << STRLIT("<CLASS NAME=\"") |
|
<< rep->getClassName() |
|
<< STRLIT("\" "); |
|
|
|
if (!rep->getSuperClassName().isNull()) |
{ | { |
cimclass._checkRep(); |
out << STRLIT(" SUPERCLASS=\"") |
cimclass._rep->toXml(out); |
<< rep->getSuperClassName() |
|
<< STRLIT("\" "); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
|
|
// Append Class Qualifiers: |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
// Append Property definitions: |
|
|
|
for (Uint32 i = 0, n = rep->getPropertyCount(); i < n; i++) |
|
XmlWriter::appendPropertyElement(out, rep->getProperty(i)); |
|
|
|
// Append Method definitions: |
|
|
|
for (Uint32 i = 0, n = rep->getMethodCount(); i < n; i++) |
|
XmlWriter::appendMethodElement(out, rep->getMethod(i)); |
|
|
|
// Class closing element: |
|
|
|
out << STRLIT("</CLASS>\n"); |
} | } |
| |
void XmlWriter::printClassElement( | void XmlWriter::printClassElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendClassElement(tmp, cimclass); | appendClassElement(tmp, cimclass); |
tmp.append('\0'); |
|
indentedPrint(os, tmp.getData(), 4); | indentedPrint(os, tmp.getData(), 4); |
} | } |
| |
|
|
Buffer& out, | Buffer& out, |
const CIMConstInstance& instance) | const CIMConstInstance& instance) |
{ | { |
instance._checkRep(); |
CheckRep(instance._rep); |
instance._rep->toXml(out); |
const CIMInstanceRep* rep = instance._rep; |
|
|
|
// Class opening element: |
|
|
|
out << STRLIT("<INSTANCE CLASSNAME=\"") |
|
<< rep->getClassName() |
|
<< STRLIT("\" >\n"); |
|
|
|
// Append Instance Qualifiers: |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
// Append Properties: |
|
|
|
for (Uint32 i = 0, n = rep->getPropertyCount(); i < n; i++) |
|
XmlWriter::appendPropertyElement(out, rep->getProperty(i)); |
|
|
|
// Instance closing element: |
|
|
|
out << STRLIT("</INSTANCE>\n"); |
} | } |
| |
void XmlWriter::printInstanceElement( | void XmlWriter::printInstanceElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendInstanceElement(tmp, instance); | appendInstanceElement(tmp, instance); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
Buffer& out, | Buffer& out, |
const CIMConstProperty& property) | const CIMConstProperty& property) |
{ | { |
property._checkRep(); |
CheckRep(property._rep); |
property._rep->toXml(out); |
const CIMPropertyRep* rep = property._rep; |
|
|
|
if (rep->getValue().isArray()) |
|
{ |
|
out << STRLIT("<PROPERTY.ARRAY NAME=\"") |
|
<< rep->getName() |
|
<< STRLIT("\" "); |
|
|
|
if (rep->getValue().getType() == CIMTYPE_OBJECT) |
|
{ |
|
// If the property array type is CIMObject, then |
|
// encode the property in CIM-XML as a string array with the |
|
// EmbeddedObject attribute (there is not currently a CIM-XML |
|
// "object" datatype) |
|
|
|
Array<CIMObject> a; |
|
rep->getValue().get(a); |
|
out << STRLIT(" TYPE=\"string\""); |
|
// If the Embedded Object is an instance, always add the |
|
// EmbeddedObject attribute. |
|
if (a.size() > 0 && a[0].isInstance()) |
|
{ |
|
out << STRLIT(" EmbeddedObject=\"object\""); |
|
out << STRLIT(" EMBEDDEDOBJECT=\"object\""); |
|
} |
|
#ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY |
|
else |
|
#endif |
|
{ |
|
// Else the Embedded Object is a class, always add the |
|
// EmbeddedObject qualifier. Note that if the macro |
|
// PEGASUS_SNIA_INTEROP_COMPATIBILITY is defined, then |
|
// the EmbeddedObject qualifier will always be added, |
|
// whether it's a class or an instance. |
|
if (rep->findQualifier(CIMName("EmbeddedObject")) == |
|
PEG_NOT_FOUND) |
|
{ |
|
// Note that addQualifiers() cannot be called on a const |
|
// CIMQualifierRep. In this case we really do want to add |
|
// the EmbeddedObject qualifier, so we cast away the |
|
// constness. |
|
CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep); |
|
tmpRep->addQualifier( |
|
CIMQualifier(CIMName("EmbeddedObject"), true)); |
|
} |
|
} |
|
} |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
else if (rep->getValue().getType() == CIMTYPE_INSTANCE) |
|
{ |
|
// If the property array type is CIMInstance, then |
|
// encode the property in CIM-XML as a string array with the |
|
// EmbeddedObject attribute (there is not currently a CIM-XML |
|
// "instance" datatype) |
|
|
|
Array<CIMInstance> a; |
|
rep->getValue().get(a); |
|
out << STRLIT(" TYPE=\"string\""); |
|
|
|
// add the EmbeddedObject attribute |
|
if (a.size() > 0) |
|
{ |
|
out << STRLIT(" EmbeddedObject=\"instance\""); |
|
out << STRLIT(" EMBEDDEDOBJECT=\"instance\""); |
|
|
|
// Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY is |
|
// defined, then the EmbeddedInstance qualifier will be added |
|
# ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY |
|
if (rep->findQualifier(CIMName("EmbeddedInstance")) == |
|
PEG_NOT_FOUND) |
|
{ |
|
// Note that addQualifiers() cannot be called on a const |
|
// CIMQualifierRep. In this case we really do want to add |
|
// the EmbeddedInstance qualifier, so we cast away the |
|
// constness. |
|
|
|
// For now, we assume that all the embedded instances in |
|
// the array are of the same type |
|
CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep); |
|
tmpRep->addQualifier(CIMQualifier( |
|
CIMName("EmbeddedInstance"), |
|
a[0].getClassName().getString())); |
|
} |
|
# endif |
|
} |
|
} |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
else |
|
{ |
|
out << STRLIT(" TYPE=\"") |
|
<< cimTypeToString(rep->getValue().getType()); |
|
out.append('"'); |
|
} |
|
|
|
if (rep->getArraySize()) |
|
{ |
|
char buffer[32]; |
|
sprintf(buffer, "%d", rep->getArraySize()); |
|
out << STRLIT(" ARRAYSIZE=\"") << buffer; |
|
out.append('"'); |
|
} |
|
|
|
if (!rep->getClassOrigin().isNull()) |
|
{ |
|
out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin(); |
|
out.append('"'); |
|
} |
|
|
|
if (rep->getPropagated()) |
|
{ |
|
out << STRLIT(" PROPAGATED=\"true\""); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
XmlWriter::appendValueElement(out, rep->getValue()); |
|
|
|
out << STRLIT("</PROPERTY.ARRAY>\n"); |
|
} |
|
else if (rep->getValue().getType() == CIMTYPE_REFERENCE) |
|
{ |
|
out << STRLIT("<PROPERTY.REFERENCE"); |
|
|
|
out << STRLIT(" NAME=\"") << rep->getName() << STRLIT("\" "); |
|
|
|
if (!rep->getReferenceClassName().isNull()) |
|
{ |
|
out << STRLIT(" REFERENCECLASS=\"") << rep->getReferenceClassName(); |
|
out.append('"'); |
|
} |
|
|
|
if (!rep->getClassOrigin().isNull()) |
|
{ |
|
out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin(); |
|
out.append('"'); |
|
} |
|
|
|
if (rep->getPropagated()) |
|
{ |
|
out << STRLIT(" PROPAGATED=\"true\""); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
XmlWriter::appendValueElement(out, rep->getValue()); |
|
|
|
out << STRLIT("</PROPERTY.REFERENCE>\n"); |
|
} |
|
else |
|
{ |
|
out << STRLIT("<PROPERTY NAME=\"") << rep->getName() << STRLIT("\" "); |
|
|
|
if (!rep->getClassOrigin().isNull()) |
|
{ |
|
out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin(); |
|
out.append('"'); |
|
} |
|
|
|
if (rep->getPropagated()) |
|
{ |
|
out << STRLIT(" PROPAGATED=\"true\""); |
|
} |
|
|
|
if (rep->getValue().getType() == CIMTYPE_OBJECT) |
|
{ |
|
// If the property type is CIMObject, then |
|
// encode the property in CIM-XML as a string with the |
|
// EmbeddedObject attribute (there is not currently a CIM-XML |
|
// "object" datatype) |
|
|
|
CIMObject a; |
|
rep->getValue().get(a); |
|
out << STRLIT(" TYPE=\"string\""); |
|
|
|
// If the Embedded Object is an instance, always add the |
|
// EmbeddedObject attribute. |
|
if (a.isInstance()) |
|
{ |
|
out << STRLIT(" EmbeddedObject=\"object\""); |
|
out << STRLIT(" EMBEDDEDOBJECT=\"object\""); |
|
} |
|
// Else the Embedded Object is a class, always add the |
|
// EmbeddedObject qualifier. |
|
#ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY |
|
else |
|
#endif |
|
{ |
|
// Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY |
|
// is defined, then the EmbeddedObject qualifier will always |
|
// be added, whether it's a class or an instance. |
|
if (rep->findQualifier(CIMName("EmbeddedObject")) == |
|
PEG_NOT_FOUND) |
|
{ |
|
// Note that addQualifiers() cannot be called on a const |
|
// CIMQualifierRep. In this case we really do want to add |
|
// the EmbeddedObject qualifier, so we cast away the |
|
// constness. |
|
CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep); |
|
tmpRep->addQualifier( |
|
CIMQualifier(CIMName("EmbeddedObject"), true)); |
|
} |
|
} |
|
} |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
else if (rep->getValue().getType() == CIMTYPE_INSTANCE) |
|
{ |
|
CIMInstance a; |
|
rep->getValue().get(a); |
|
out << " TYPE=\"string\""; |
|
out << " EmbeddedObject=\"instance\""; |
|
out << " EMBEDDEDOBJECT=\"instance\""; |
|
|
|
# ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY |
|
if (rep->findQualifier(CIMName("EmbeddedObject")) == PEG_NOT_FOUND) |
|
{ |
|
// Note that addQualifiers() cannot be called on a const |
|
// CIMQualifierRep. In this case we really do want to add |
|
// the EmbeddedInstance qualifier, so we cast away the |
|
// constness. |
|
CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep); |
|
tmpRep->addQualifier(CIMQualifier( |
|
CIMName("EmbeddedInstance"), |
|
a.getClassName().getString())); |
|
} |
|
# endif |
|
} |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
else |
|
{ |
|
out << STRLIT(" TYPE=\"") |
|
<< cimTypeToString(rep->getValue().getType()); |
|
out.append('"'); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
XmlWriter::appendValueElement(out, rep->getValue()); |
|
|
|
out << STRLIT("</PROPERTY>\n"); |
|
} |
} | } |
| |
void XmlWriter::printPropertyElement( | void XmlWriter::printPropertyElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendPropertyElement(tmp, property); | appendPropertyElement(tmp, property); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
Buffer& out, | Buffer& out, |
const CIMConstMethod& method) | const CIMConstMethod& method) |
{ | { |
method._checkRep(); |
CheckRep(method._rep); |
method._rep->toXml(out); |
const CIMMethodRep* rep = method._rep; |
|
|
|
out << STRLIT("<METHOD NAME=\"") << rep->getName(); |
|
out.append('"'); |
|
|
|
out << STRLIT(" TYPE=\"") << cimTypeToString(rep->getType()); |
|
out.append('"'); |
|
|
|
if (!rep->getClassOrigin().isNull()) |
|
{ |
|
out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin(); |
|
out.append('"'); |
|
} |
|
|
|
if (rep->getPropagated()) |
|
{ |
|
out << STRLIT(" PROPAGATED=\"true\""); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
for (Uint32 i = 0, n = rep->getParameterCount(); i < n; i++) |
|
XmlWriter::appendParameterElement(out, rep->getParameter(i)); |
|
|
|
out << STRLIT("</METHOD>\n"); |
} | } |
| |
void XmlWriter::printMethodElement( | void XmlWriter::printMethodElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendMethodElement(tmp, method); | appendMethodElement(tmp, method); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
Buffer& out, | Buffer& out, |
const CIMConstParameter& parameter) | const CIMConstParameter& parameter) |
{ | { |
parameter._checkRep(); |
CheckRep(parameter._rep); |
parameter._rep->toXml(out); |
const CIMParameterRep* rep = parameter._rep; |
|
|
|
if (rep->isArray()) |
|
{ |
|
if (rep->getType() == CIMTYPE_REFERENCE) |
|
{ |
|
out << STRLIT("<PARAMETER.REFARRAY NAME=\"") << rep->getName(); |
|
out.append('"'); |
|
|
|
if (!rep->getReferenceClassName().isNull()) |
|
{ |
|
out << STRLIT(" REFERENCECLASS=\""); |
|
out << rep->getReferenceClassName().getString(); |
|
out.append('"'); |
|
} |
|
|
|
if (rep->getArraySize()) |
|
{ |
|
char buffer[32]; |
|
int n = sprintf(buffer, "%d", rep->getArraySize()); |
|
out << STRLIT(" ARRAYSIZE=\""); |
|
out.append(buffer, n); |
|
out.append('"'); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
out << STRLIT("</PARAMETER.REFARRAY>\n"); |
|
} |
|
else |
|
{ |
|
out << STRLIT("<PARAMETER.ARRAY"); |
|
out << STRLIT(" NAME=\"") << rep->getName(); |
|
out << STRLIT("\" "); |
|
out << STRLIT(" TYPE=\"") << cimTypeToString(rep->getType()); |
|
out.append('"'); |
|
|
|
if (rep->getArraySize()) |
|
{ |
|
char buffer[32]; |
|
sprintf(buffer, "%d", rep->getArraySize()); |
|
out << STRLIT(" ARRAYSIZE=\"") << buffer; |
|
out.append('"'); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
out << STRLIT("</PARAMETER.ARRAY>\n"); |
|
} |
|
} |
|
else if (rep->getType() == CIMTYPE_REFERENCE) |
|
{ |
|
out << STRLIT("<PARAMETER.REFERENCE"); |
|
out << STRLIT(" NAME=\"") << rep->getName(); |
|
out.append('"'); |
|
|
|
if (!rep->getReferenceClassName().isNull()) |
|
{ |
|
out << STRLIT(" REFERENCECLASS=\""); |
|
out << rep->getReferenceClassName().getString(); |
|
out.append('"'); |
|
} |
|
out << STRLIT(">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
out << STRLIT("</PARAMETER.REFERENCE>\n"); |
|
} |
|
else |
|
{ |
|
out << STRLIT("<PARAMETER"); |
|
out << STRLIT(" NAME=\"") << rep->getName(); |
|
out << STRLIT("\" "); |
|
out << STRLIT(" TYPE=\"") << cimTypeToString(rep->getType()); |
|
out << STRLIT("\">\n"); |
|
|
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
|
|
out << STRLIT("</PARAMETER>\n"); |
|
} |
} | } |
| |
void XmlWriter::printParameterElement( | void XmlWriter::printParameterElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendParameterElement(tmp, parameter); | appendParameterElement(tmp, parameter); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
// | // |
// <!ELEMENT PARAMVALUE (VALUE|VALUE.REFERENCE|VALUE.ARRAY|VALUE.REFARRAY)?> | // <!ELEMENT PARAMVALUE (VALUE|VALUE.REFERENCE|VALUE.ARRAY|VALUE.REFARRAY)?> |
// <!ATTLIST PARAMVALUE | // <!ATTLIST PARAMVALUE |
// %CIMName;> |
// %CIMName; |
|
// %EmbeddedObject; #IMPLIED |
|
// %ParamType;> |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
|
|
Buffer& out, | Buffer& out, |
const CIMParamValue& paramValue) | const CIMParamValue& paramValue) |
{ | { |
paramValue._checkRep(); |
CheckRep(paramValue._rep); |
paramValue._rep->toXml(out); |
const CIMParamValueRep* rep = paramValue._rep; |
|
|
|
out << STRLIT("<PARAMVALUE NAME=\"") << rep->getParameterName(); |
|
out.append('"'); |
|
|
|
CIMType type = rep->getValue().getType(); |
|
|
|
if (rep->isTyped()) |
|
{ |
|
XmlWriter::appendParamTypeAndEmbeddedObjAttrib(out, type); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
XmlWriter::appendValueElement(out, rep->getValue()); |
|
|
|
out << STRLIT("</PARAMVALUE>\n"); |
} | } |
| |
void XmlWriter::printParamValueElement( | void XmlWriter::printParamValueElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendParamValueElement(tmp, paramValue); | appendParamValueElement(tmp, paramValue); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
Buffer& out, | Buffer& out, |
const CIMConstQualifier& qualifier) | const CIMConstQualifier& qualifier) |
{ | { |
qualifier._checkRep(); |
CheckRep(qualifier._rep); |
qualifier._rep->toXml(out); |
const CIMQualifierRep* rep = qualifier._rep; |
|
|
|
out << STRLIT("<QUALIFIER NAME=\"") << rep->getName(); |
|
out.append('"'); |
|
out << STRLIT(" TYPE=\"") << cimTypeToString(rep->getValue().getType()); |
|
out.append('"'); |
|
|
|
if (rep->getPropagated()) |
|
{ |
|
out << STRLIT(" PROPAGATED=\"true\""); |
|
} |
|
|
|
XmlWriter::appendQualifierFlavorEntity(out, rep->getFlavor()); |
|
|
|
out << STRLIT(">\n"); |
|
|
|
XmlWriter::appendValueElement(out, rep->getValue()); |
|
|
|
out << STRLIT("</QUALIFIER>\n"); |
} | } |
| |
void XmlWriter::printQualifierElement( | void XmlWriter::printQualifierElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendQualifierElement(tmp, qualifier); | appendQualifierElement(tmp, qualifier); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
Buffer& out, | Buffer& out, |
const CIMConstQualifierDecl& qualifierDecl) | const CIMConstQualifierDecl& qualifierDecl) |
{ | { |
qualifierDecl._checkRep(); |
CheckRep(qualifierDecl._rep); |
qualifierDecl._rep->toXml(out); |
const CIMQualifierDeclRep* rep = qualifierDecl._rep; |
|
|
|
out << STRLIT("<QUALIFIER.DECLARATION NAME=\"") << rep->getName(); |
|
out.append('"'); |
|
out << STRLIT(" TYPE=\"") << cimTypeToString(rep->getValue().getType()); |
|
out.append('"'); |
|
|
|
if (rep->getValue().isArray()) |
|
{ |
|
out << STRLIT(" ISARRAY=\"true\""); |
|
|
|
if (rep->getArraySize()) |
|
{ |
|
char buffer[64]; |
|
int n = sprintf(buffer, " ARRAYSIZE=\"%d\"", rep->getArraySize()); |
|
out.append(buffer, n); |
|
} |
|
} |
|
|
|
XmlWriter::appendQualifierFlavorEntity(out, rep->getFlavor()); |
|
|
|
out << STRLIT(">\n"); |
|
|
|
XmlWriter::appendScopeElement(out, rep->getScope()); |
|
XmlWriter::appendValueElement(out, rep->getValue()); |
|
|
|
out << STRLIT("</QUALIFIER.DECLARATION>\n"); |
} | } |
| |
void XmlWriter::printQualifierDeclElement( | void XmlWriter::printQualifierDeclElement( |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendQualifierDeclElement(tmp, qualifierDecl); | appendQualifierDeclElement(tmp, qualifierDecl); |
tmp.append('\0'); |
|
os << tmp.getData() << PEGASUS_STD(endl); | os << tmp.getData() << PEGASUS_STD(endl); |
} | } |
| |
|
|
} | } |
if (contentLanguages.size() > 0) | if (contentLanguages.size() > 0) |
{ | { |
out << STRLIT("Content-Language: ") << contentLanguages << STRLIT("\r\n"); |
out << STRLIT("Content-Language: ") << contentLanguages << |
|
STRLIT("\r\n"); |
} | } |
| |
#ifdef PEGASUS_DEBUG | #ifdef PEGASUS_DEBUG |
|
|
| |
static const char *clientTransferEncodingOff = | static const char *clientTransferEncodingOff = |
getenv("PEGASUS_HTTP_TRANSFER_ENCODING_REQUEST"); | getenv("PEGASUS_HTTP_TRANSFER_ENCODING_REQUEST"); |
|
|
if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0') | if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0') |
#endif | #endif |
| |
|
|
else | else |
{ | { |
out << STRLIT("CIMOperation: MethodCall\r\n"); | out << STRLIT("CIMOperation: MethodCall\r\n"); |
out << STRLIT("CIMMethod: ") << encodeURICharacters(cimMethod.getString()) |
out << STRLIT("CIMMethod: ") |
|
<< encodeURICharacters(cimMethod.getString()) |
<< STRLIT("\r\n"); | << STRLIT("\r\n"); |
out << STRLIT("CIMObject: ") << encodeURICharacters(cimObject) | out << STRLIT("CIMObject: ") << encodeURICharacters(cimObject) |
<< STRLIT("\r\n"); | << STRLIT("\r\n"); |
|
|
{ | { |
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; | char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n"); | out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n"); |
STAT_SERVERTIME |
|
|
#ifndef PEGASUS_DISABLE_PERFINST |
|
if (StatisticalData::current()->copyGSD) |
|
{ |
|
out << STRLIT("WBEMServerResponseTime: ") << |
|
CIMValue(serverResponseTime).toString() << STRLIT("\r\n"); |
|
} |
|
#endif |
|
|
out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n"); | out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n"); |
OUTPUT_CONTENTLENGTH; | OUTPUT_CONTENTLENGTH; |
| |
if (contentLanguages.size() > 0) | if (contentLanguages.size() > 0) |
{ | { |
out << STRLIT("Content-Language: ") << contentLanguages << STRLIT("\r\n"); |
out << STRLIT("Content-Language: ") << contentLanguages << |
|
STRLIT("\r\n"); |
} | } |
if (httpMethod == HTTP_METHOD_M_POST) | if (httpMethod == HTTP_METHOD_M_POST) |
{ | { |
|
|
const String& content) | const String& content) |
{ | { |
out << STRLIT("HTTP/1.1 " HTTP_STATUS_UNAUTHORIZED "\r\n"); | out << STRLIT("HTTP/1.1 " HTTP_STATUS_UNAUTHORIZED "\r\n"); |
|
Uint32 contentLength = 0; |
|
OUTPUT_CONTENTLENGTH; |
out << content << STRLIT("\r\n"); | out << content << STRLIT("\r\n"); |
out << STRLIT("\r\n"); | out << STRLIT("\r\n"); |
| |
|
|
out << STRLIT("<ERROR"); | out << STRLIT("<ERROR"); |
out << STRLIT(" CODE=\"") << Uint32(cimException.getCode()); | out << STRLIT(" CODE=\"") << Uint32(cimException.getCode()); |
out.append('"'); | out.append('"'); |
|
|
String description = TraceableCIMException(cimException).getDescription(); | String description = TraceableCIMException(cimException).getDescription(); |
|
|
if (description != String::EMPTY) | if (description != String::EMPTY) |
{ | { |
out << STRLIT(" DESCRIPTION=\""); | out << STRLIT(" DESCRIPTION=\""); |
appendSpecial(out, description); | appendSpecial(out, description); |
out.append('"'); | out.append('"'); |
} | } |
|
|
|
if (cimException.getErrorCount()) |
|
{ |
|
out << STRLIT(">"); |
|
|
|
for (Uint32 i = 0, n = cimException.getErrorCount(); i < n; i++) |
|
appendInstanceElement(out, cimException.getError(i)); |
|
|
|
out << STRLIT("</ERROR>"); |
|
} |
|
else |
out << STRLIT("/>"); | out << STRLIT("/>"); |
} | } |
| |
//------------------------------------------------------------------------------ |
//---------------------------------------------------------------------- |
// |
|
// appendReturnValueElement() |
|
// | // |
// <!ELEMENT RETURNVALUE (VALUE|VALUE.REFERENCE)> |
// appendParmType |
// <!ATTLIST RETURNVALUE |
// Appends the Param type and EmbeddedObject Info |
|
// to the buffer |
// %EmbeddedObject; #IMPLIED | // %EmbeddedObject; #IMPLIED |
// %ParamType;> | // %ParamType;> |
// | // |
//------------------------------------------------------------------------------ |
//--------------------------------------------------------------------- |
|
void XmlWriter::appendParamTypeAndEmbeddedObjAttrib( |
void XmlWriter::appendReturnValueElement( |
|
Buffer& out, | Buffer& out, |
const CIMValue& value) |
const CIMType& type) |
{ | { |
out << STRLIT("<RETURNVALUE"); |
|
| |
CIMType type = value.getType(); |
|
// If the property type is CIMObject, then | // If the property type is CIMObject, then |
// encode the property in CIM-XML as a string with the EMBEDDEDOBJECT attribute |
// encode the property in CIM-XML as a string with the EmbeddedObject |
// (there is not currently a CIM-XML "object" datatype) |
// attribute (there is not currently a CIM-XML "object" |
|
// datatype). |
|
// Because of an error in Pegasus we were earlier outputting |
|
// upper case "EMBEDDEDOBJECT" as the attribute name. The |
|
// spec calls for mixed case "EmbeddedObject. Fixed in |
|
// bug 7131 to output EmbeddedObject attribute in upper |
|
// case and mixed case. Receiver will ignore one or the |
|
// other. |
// else | // else |
// output the real type | // output the real type |
if (type == CIMTYPE_OBJECT) | if (type == CIMTYPE_OBJECT) |
{ | { |
|
|
out << STRLIT(" PARAMTYPE=\"string\""); | out << STRLIT(" PARAMTYPE=\"string\""); |
|
out << STRLIT(" EmbeddedObject=\"object\""); |
out << STRLIT(" EMBEDDEDOBJECT=\"object\""); | out << STRLIT(" EMBEDDEDOBJECT=\"object\""); |
} | } |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT | #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
else if (type == CIMTYPE_INSTANCE) | else if (type == CIMTYPE_INSTANCE) |
{ | { |
out << STRLIT(" PARAMTYPE=\"string\""); | out << STRLIT(" PARAMTYPE=\"string\""); |
|
out << STRLIT(" EmbeddedObject=\"instance\""); |
out << STRLIT(" EMBEDDEDOBJECT=\"instance\""); | out << STRLIT(" EMBEDDEDOBJECT=\"instance\""); |
} | } |
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT | #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
|
out << STRLIT(" PARAMTYPE=\"") << cimTypeToString (type); | out << STRLIT(" PARAMTYPE=\"") << cimTypeToString (type); |
out.append('"'); | out.append('"'); |
} | } |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// appendReturnValueElement() |
|
// |
|
// <!ELEMENT RETURNVALUE (VALUE|VALUE.REFERENCE)> |
|
// <!ATTLIST RETURNVALUE |
|
// %EmbeddedObject; #IMPLIED |
|
// %ParamType;> |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
|
|
void XmlWriter::appendReturnValueElement( |
|
Buffer& out, |
|
const CIMValue& value) |
|
{ |
|
out << STRLIT("<RETURNVALUE"); |
|
|
|
CIMType type = value.getType(); |
|
|
|
appendParamTypeAndEmbeddedObjAttrib(out, type); |
| |
out << STRLIT(">\n"); | out << STRLIT(">\n"); |
| |
|
|
{ | { |
// NOTE: temporarily put zero for content length. the http code | // NOTE: temporarily put zero for content length. the http code |
// will later decide to fill in the length or remove it altogether | // will later decide to fill in the length or remove it altogether |
appendMethodResponseHeader(out, httpMethod, httpContentLanguages, 0, |
appendMethodResponseHeader( |
serverResponseTime); |
out, httpMethod, httpContentLanguages, 0, serverResponseTime); |
_appendMessageElementBegin(out, messageId); | _appendMessageElementBegin(out, messageId); |
_appendSimpleRspElementBegin(out); | _appendSimpleRspElementBegin(out); |
_appendMethodResponseElementBegin(out, methodName); | _appendMethodResponseElementBegin(out, methodName); |
|
|
} | } |
| |
| |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
// XmlWriter::formatSimpleMethodErrorRspMessage() | // XmlWriter::formatSimpleMethodErrorRspMessage() |
|
|
_appendSimpleRspElementEnd(out); | _appendSimpleRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
// l10n |
appendMethodResponseHeader( |
appendMethodResponseHeader(tmp, |
tmp, |
httpMethod, | httpMethod, |
cimException.getContentLanguages(), | cimException.getContentLanguages(), |
out.size()); | out.size()); |
|
|
{ | { |
// NOTE: temporarily put zero for content length. the http code | // NOTE: temporarily put zero for content length. the http code |
// will later decide to fill in the length or remove it altogether | // will later decide to fill in the length or remove it altogether |
appendMethodResponseHeader(out, httpMethod, httpContentLanguages, 0, |
appendMethodResponseHeader( |
serverResponseTime); |
out, httpMethod, httpContentLanguages, 0, serverResponseTime); |
_appendMessageElementBegin(out, messageId); | _appendMessageElementBegin(out, messageId); |
_appendSimpleRspElementBegin(out); | _appendSimpleRspElementBegin(out); |
_appendIMethodResponseElementBegin(out, iMethodName); | _appendIMethodResponseElementBegin(out, iMethodName); |
| |
// output the start of the return tag. Test if there is response data by: |
// output the start of the return tag. Test if there is response data |
|
// by: |
// 1. there is data on the first chunk OR | // 1. there is data on the first chunk OR |
// 2. there is no data on the first chunk but isLast is false implying | // 2. there is no data on the first chunk but isLast is false implying |
// there is more non-empty data to come. If all subsequent chunks | // there is more non-empty data to come. If all subsequent chunks |
|
|
_appendSimpleRspElementEnd(out); | _appendSimpleRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
// l10n |
|
appendMethodResponseHeader(tmp, | appendMethodResponseHeader(tmp, |
httpMethod, | httpMethod, |
cimException.getContentLanguages(), | cimException.getContentLanguages(), |
|
|
} | } |
if (contentLanguages.size() > 0) | if (contentLanguages.size() > 0) |
{ | { |
out << STRLIT("Content-Language: ") << contentLanguages << STRLIT("\r\n"); |
out << STRLIT("Content-Language: ") << contentLanguages << |
|
STRLIT("\r\n"); |
} | } |
| |
#ifdef PEGASUS_DEBUG | #ifdef PEGASUS_DEBUG |
|
|
out << STRLIT("Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="); | out << STRLIT("Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="); |
out << nn << STRLIT("\r\n"); | out << nn << STRLIT("\r\n"); |
out << nn << STRLIT("-CIMExport: MethodRequest\r\n"); | out << nn << STRLIT("-CIMExport: MethodRequest\r\n"); |
out << nn << STRLIT("-CIMExportMethod: ") << cimMethod << STRLIT("\r\n"); |
out << nn << STRLIT("-CIMExportMethod: ") << cimMethod << |
|
STRLIT("\r\n"); |
} | } |
else | else |
{ | { |
|
|
| |
if (contentLanguages.size() > 0) | if (contentLanguages.size() > 0) |
{ | { |
out << STRLIT("Content-Language: ") << contentLanguages << STRLIT("\r\n"); |
out << STRLIT("Content-Language: ") << contentLanguages << |
|
STRLIT("\r\n"); |
} | } |
if (httpMethod == HTTP_METHOD_M_POST) | if (httpMethod == HTTP_METHOD_M_POST) |
{ | { |
|
|
_appendSimpleExportRspElementEnd(out); | _appendSimpleExportRspElementEnd(out); |
_appendMessageElementEnd(out); | _appendMessageElementEnd(out); |
| |
// l10n |
appendEMethodResponseHeader( |
appendEMethodResponseHeader(tmp, |
tmp, |
httpMethod, | httpMethod, |
cimException.getContentLanguages(), | cimException.getContentLanguages(), |
out.size()); | out.size()); |
|
|
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
void _xmlWritter_indent(PEGASUS_STD(ostream)& os, Uint32 level, Uint32 indentChars) |
void _xmlWritter_indent( |
|
PEGASUS_STD(ostream)& os, |
|
Uint32 level, |
|
Uint32 indentChars) |
{ | { |
Uint32 n = level * indentChars; | Uint32 n = level * indentChars; |
| |
|
|
_xmlWritter_indent(os, stack.size(), indentChars); | _xmlWritter_indent(os, stack.size(), indentChars); |
| |
os << "<?" << entry.text << " "; | os << "<?" << entry.text << " "; |
_xmlWritter_printAttributes(os, entry.attributes, entry.attributeCount); |
_xmlWritter_printAttributes( |
|
os, entry.attributes, entry.attributeCount); |
os << "?>"; | os << "?>"; |
break; | break; |
} | } |
|
|
if (entry.attributeCount) | if (entry.attributeCount) |
os << ' '; | os << ' '; |
| |
_xmlWritter_printAttributes(os, entry.attributes, entry.attributeCount); |
_xmlWritter_printAttributes( |
|
os, entry.attributes, entry.attributeCount); |
os << ">"; | os << ">"; |
stack.push(entry.text); | stack.push(entry.text); |
break; | break; |
|
|
_xmlWritter_indent(os, stack.size(), indentChars); | _xmlWritter_indent(os, stack.size(), indentChars); |
| |
os << "<" << entry.text << " "; | os << "<" << entry.text << " "; |
_xmlWritter_printAttributes(os, entry.attributes, entry.attributeCount); |
_xmlWritter_printAttributes( |
|
os, entry.attributes, entry.attributeCount); |
os << "/>"; | os << "/>"; |
break; | break; |
} | } |
|
|
| |
case XmlEntry::COMMENT: | case XmlEntry::COMMENT: |
{ | { |
|
|
_xmlWritter_indent(os, stack.size(), indentChars); | _xmlWritter_indent(os, stack.size(), indentChars); |
os << "<!--"; | os << "<!--"; |
_xmlWritter_appendSpecial(os, entry.text); | _xmlWritter_appendSpecial(os, entry.text); |
|
|
| |
os << PEGASUS_STD(endl); | os << PEGASUS_STD(endl); |
} | } |
|
|
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
| |
String XmlWriter::getNextMessageId() | String XmlWriter::getNextMessageId() |
{ | { |
char buffer[16]; |
char scratchBuffer[22]; |
sprintf(buffer, "%u", _messageIDFactory.getID()); |
Uint32 n; |
return buffer; |
const char * startP = Uint32ToString(scratchBuffer, |
|
_messageIDFactory.getID(), |
|
n); |
|
return String(startP, n); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |