version 1.153.2.3, 2008/02/28 00:21:08
|
version 1.170, 2011/01/25 11:24:24
|
|
|
//%2006//////////////////////////////////////////////////////////////////////// |
//%LICENSE//////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Licensed to The Open Group (TOG) under one or more contributor license |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
// agreements. Refer to the OpenPegasusNOTICE.txt file distributed with |
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
// this work for additional information regarding copyright ownership. |
// IBM Corp.; EMC Corporation, The Open Group. |
// Each contributor licenses this file to you under the OpenPegasus Open |
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
// Source License; you may not use this file except in compliance with the |
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
// License. |
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
// |
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
// Permission is hereby granted, free of charge, to any person obtaining a |
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
// copy of this software and associated documentation files (the "Software"), |
// EMC Corporation; Symantec Corporation; The Open Group. |
// to deal in the Software without restriction, including without limitation |
// |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
// and/or sell copies of the Software, and to permit persons to whom the |
// of this software and associated documentation files (the "Software"), to |
// Software is furnished to do so, subject to the following conditions: |
// deal in the Software without restriction, including without limitation the |
// |
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
// The above copyright notice and this permission notice shall be included |
// sell copies of the Software, and to permit persons to whom the Software is |
// in all copies or substantial portions of the Software. |
// furnished to do so, subject to the following conditions: |
// |
// |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
// | // |
//============================================================================== |
////////////////////////////////////////////////////////////////////////// |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
#include "CIMQualifierDeclRep.h" | #include "CIMQualifierDeclRep.h" |
#include "CIMValue.h" | #include "CIMValue.h" |
#include "XmlWriter.h" | #include "XmlWriter.h" |
#include "XmlParser.h" |
|
#include "Tracer.h" | #include "Tracer.h" |
#include <Pegasus/Common/StatisticalData.h> | #include <Pegasus/Common/StatisticalData.h> |
#include "CommonUTF.h" | #include "CommonUTF.h" |
#include "Buffer.h" | #include "Buffer.h" |
#include "StrLit.h" | #include "StrLit.h" |
#include "LanguageParser.h" |
|
#include "IDFactory.h" | #include "IDFactory.h" |
#include "StringConversion.h" | #include "StringConversion.h" |
|
|
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
// appendLocalNameSpacePathElement() | // appendLocalNameSpacePathElement() |
|
|
const String& host, | const String& host, |
const CIMNamespaceName& nameSpace) | const CIMNamespaceName& nameSpace) |
{ | { |
out << STRLIT("<NAMESPACEPATH>\n"); |
out << STRLIT("<NAMESPACEPATH>\n" |
out << STRLIT("<HOST>") << host << STRLIT("</HOST>\n"); |
"<HOST>") << host << STRLIT("</HOST>\n"); |
appendLocalNameSpacePathElement(out, nameSpace); | appendLocalNameSpacePathElement(out, nameSpace); |
out << STRLIT("</NAMESPACEPATH>\n"); | out << STRLIT("</NAMESPACEPATH>\n"); |
} | } |
|
|
_xmlWritter_appendValueArray(out, a.getData(), a.size()); | _xmlWritter_appendValueArray(out, a.getData(), a.size()); |
break; | break; |
} | } |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
{ | { |
Array<CIMInstance> a; | Array<CIMInstance> a; |
|
|
_xmlWritter_appendValueArray(out, a.getData(), a.size()); | _xmlWritter_appendValueArray(out, a.getData(), a.size()); |
break; | break; |
} | } |
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
default: | default: |
PEGASUS_ASSERT(false); | PEGASUS_ASSERT(false); |
} | } |
|
|
_xmlWritter_appendValue(out, v); | _xmlWritter_appendValue(out, v); |
break; | break; |
} | } |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
{ | { |
CIMInstance v; | CIMInstance v; |
|
|
_xmlWritter_appendValue(out, v); | _xmlWritter_appendValue(out, v); |
break; | break; |
} | } |
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
default: | default: |
PEGASUS_ASSERT(false); | PEGASUS_ASSERT(false); |
} | } |
|
|
| |
void XmlWriter::appendValueObjectWithPathElement( | void XmlWriter::appendValueObjectWithPathElement( |
Buffer& out, | Buffer& out, |
const CIMObject& objectWithPath) |
const CIMObject& objectWithPath, |
|
Boolean includeQualifiers, |
|
Boolean includeClassOrigin, |
|
const CIMPropertyList& propertyList) |
{ | { |
out << STRLIT("<VALUE.OBJECTWITHPATH>\n"); | out << STRLIT("<VALUE.OBJECTWITHPATH>\n"); |
| |
appendValueReferenceElement(out, objectWithPath.getPath (), false); | appendValueReferenceElement(out, objectWithPath.getPath (), false); |
appendObjectElement(out, objectWithPath); |
appendObjectElement( |
|
out, |
|
objectWithPath, |
|
includeQualifiers, |
|
includeClassOrigin, |
|
propertyList); |
| |
out << STRLIT("</VALUE.OBJECTWITHPATH>\n"); | out << STRLIT("</VALUE.OBJECTWITHPATH>\n"); |
} | } |
|
|
{ | { |
Buffer tmp; | Buffer tmp; |
appendValueReferenceElement(tmp, reference, true); | appendValueReferenceElement(tmp, reference, true); |
XmlUtils::indentedPrint(os, tmp.getData()); |
indentedPrint(os, tmp.getData()); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
| |
void XmlWriter::appendValueNamedInstanceElement( | void XmlWriter::appendValueNamedInstanceElement( |
Buffer& out, | Buffer& out, |
const CIMInstance& namedInstance) |
const CIMInstance& namedInstance, |
|
Boolean includeQualifiers, |
|
Boolean includeClassOrigin, |
|
const CIMPropertyList& propertyList) |
{ | { |
out << STRLIT("<VALUE.NAMEDINSTANCE>\n"); | out << STRLIT("<VALUE.NAMEDINSTANCE>\n"); |
| |
appendInstanceNameElement(out, namedInstance.getPath ()); | appendInstanceNameElement(out, namedInstance.getPath ()); |
appendInstanceElement(out, namedInstance); |
appendInstanceElement( |
|
out, |
|
namedInstance, |
|
includeQualifiers, |
|
includeClassOrigin, |
|
propertyList); |
| |
out << STRLIT("</VALUE.NAMEDINSTANCE>\n"); | out << STRLIT("</VALUE.NAMEDINSTANCE>\n"); |
} | } |
|
|
| |
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()) |
{ | { |
CheckRep(cimclass._rep); |
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); |
XmlUtils::indentedPrint(os, tmp.getData(), 4); |
indentedPrint(os, tmp.getData(), 4); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
| |
void XmlWriter::appendInstanceElement( | void XmlWriter::appendInstanceElement( |
Buffer& out, | Buffer& out, |
const CIMConstInstance& instance) |
const CIMConstInstance& instance, |
|
Boolean includeQualifiers, |
|
Boolean includeClassOrigin, |
|
const CIMPropertyList& propertyList) |
{ | { |
CheckRep(instance._rep); | 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: |
|
if(includeQualifiers) |
|
{ |
|
for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++) |
|
XmlWriter::appendQualifierElement(out, rep->getQualifier(i)); |
|
} |
|
if(propertyList.isNull()) |
|
{ |
|
for (Uint32 i = 0, n = rep->getPropertyCount(); i < n; i++) |
|
{ |
|
XmlWriter::appendPropertyElement( |
|
out, |
|
rep->getProperty(i), |
|
includeQualifiers,includeClassOrigin); |
|
} |
|
} |
|
else |
|
{ |
|
for (Uint32 i = 0, n = propertyList.size(); i < n; i++) |
|
{ |
|
CIMName name = propertyList[i]; |
|
Uint32 pos = rep->_properties.find( |
|
propertyList[i], |
|
propertyList.getCIMNameTag(i)); |
|
if(pos != PEG_NOT_FOUND) |
|
{ |
|
PEG_TRACE((TRC_XML,Tracer::LEVEL4, |
|
"XmlWriter::appendInstanceElement" |
|
" Filtering the property name:%s for the className:%s" |
|
"since it was not filtered by the provider.", |
|
(const char *)name.getString().getCString(), |
|
(const char *)instance.getClassName(). |
|
getString().getCString())); |
|
|
|
XmlWriter::appendPropertyElement( |
|
out, |
|
rep->getProperty(pos), |
|
includeQualifiers,includeClassOrigin); |
|
} |
|
} |
|
|
|
} |
|
|
|
// Instance closing element: |
|
|
|
out << STRLIT("</INSTANCE>\n"); |
} | } |
| |
void XmlWriter::printInstanceElement( | void XmlWriter::printInstanceElement( |
|
|
| |
void XmlWriter::appendObjectElement( | void XmlWriter::appendObjectElement( |
Buffer& out, | Buffer& out, |
const CIMConstObject& object) |
const CIMConstObject& object, |
|
Boolean includeQualifiers, |
|
Boolean includeClassOrigin, |
|
const CIMPropertyList& propertyList) |
{ | { |
if (object.isClass()) | if (object.isClass()) |
{ | { |
|
|
else if (object.isInstance()) | else if (object.isInstance()) |
{ | { |
CIMConstInstance i(object); | CIMConstInstance i(object); |
appendInstanceElement(out, i); |
appendInstanceElement( |
|
out, |
|
i, |
|
includeQualifiers, |
|
includeClassOrigin, |
|
propertyList); |
} | } |
// else PEGASUS_ASSERT(0); | // else PEGASUS_ASSERT(0); |
} | } |
|
|
| |
void XmlWriter::appendPropertyElement( | void XmlWriter::appendPropertyElement( |
Buffer& out, | Buffer& out, |
const CIMConstProperty& property) |
const CIMConstProperty& property, |
|
Boolean includeQualifiers, |
|
Boolean includeClassOrigin) |
{ | { |
CheckRep(property._rep); | 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\"" |
|
" 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(PEGASUS_QUALIFIERNAME_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(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT, |
|
true)); |
|
} |
|
} |
|
} |
|
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\"" |
|
" 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(PEGASUS_QUALIFIERNAME_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( |
|
PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE, |
|
a[0].getClassName().getString())); |
|
} |
|
# endif |
|
} |
|
} |
|
else |
|
{ |
|
out.append(' '); |
|
out << xmlWriterTypeStrings(rep->getValue().getType()); |
|
} |
|
|
|
if (rep->getArraySize()) |
|
{ |
|
char buffer[32]; |
|
sprintf(buffer, "%u", rep->getArraySize()); |
|
out << STRLIT(" ARRAYSIZE=\"") << buffer; |
|
out.append('"'); |
|
} |
|
|
|
if(includeClassOrigin && !rep->getClassOrigin().isNull()) |
|
{ |
|
out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin(); |
|
out.append('"'); |
|
} |
|
|
|
if (rep->getPropagated()) |
|
{ |
|
out << STRLIT(" PROPAGATED=\"true\""); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
if(includeQualifiers) |
|
{ |
|
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" |
|
" NAME=\"") << rep->getName() << STRLIT("\" "); |
|
|
|
if (!rep->getReferenceClassName().isNull()) |
|
{ |
|
out << STRLIT(" REFERENCECLASS=\"") << rep->getReferenceClassName(); |
|
out.append('"'); |
|
} |
|
if(includeClassOrigin && !rep->getClassOrigin().isNull()) |
|
{ |
|
out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin(); |
|
out.append('"'); |
|
} |
|
|
|
if (rep->getPropagated()) |
|
{ |
|
out << STRLIT(" PROPAGATED=\"true\""); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
if(includeQualifiers) |
|
{ |
|
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(includeClassOrigin && !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\"" |
|
" 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(PEGASUS_QUALIFIERNAME_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(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT, |
|
true)); |
|
} |
|
} |
|
} |
|
else if (rep->getValue().getType() == CIMTYPE_INSTANCE) |
|
{ |
|
CIMInstance a; |
|
rep->getValue().get(a); |
|
out << STRLIT(" TYPE=\"string\"" |
|
" EmbeddedObject=\"instance\"" |
|
" EMBEDDEDOBJECT=\"instance\""); |
|
|
|
# ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY |
|
if (rep->findQualifier(PEGASUS_QUALIFIERNAME_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( |
|
PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE, |
|
a.getClassName().getString())); |
|
} |
|
# endif |
|
} |
|
else |
|
{ |
|
out.append(' '); |
|
out << xmlWriterTypeStrings(rep->getValue().getType()); |
|
} |
|
|
|
out << STRLIT(">\n"); |
|
if(includeQualifiers) |
|
{ |
|
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( |
|
|
const CIMConstMethod& method) | const CIMConstMethod& method) |
{ | { |
CheckRep(method._rep); | CheckRep(method._rep); |
method._rep->toXml(out); |
const CIMMethodRep* rep = method._rep; |
|
|
|
out << STRLIT("<METHOD NAME=\"") << rep->getName(); |
|
out << STRLIT("\" "); |
|
|
|
out << xmlWriterTypeStrings(rep->getType()); |
|
|
|
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( |
|
|
const CIMConstParameter& parameter) | const CIMConstParameter& parameter) |
{ | { |
CheckRep(parameter._rep); | 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, "%u", 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" |
|
" NAME=\"") << rep->getName(); |
|
out << STRLIT("\" ") << xmlWriterTypeStrings(rep->getType()); |
|
|
|
if (rep->getArraySize()) |
|
{ |
|
char buffer[32]; |
|
sprintf(buffer, "%u", 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" |
|
" 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" |
|
" NAME=\"") << rep->getName(); |
|
out << STRLIT("\" ") << xmlWriterTypeStrings(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( |
|
|
// | // |
// <!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;> |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
|
|
const CIMParamValue& paramValue) | const CIMParamValue& paramValue) |
{ | { |
CheckRep(paramValue._rep); | 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( |
|
|
const CIMConstQualifier& qualifier) | const CIMConstQualifier& qualifier) |
{ | { |
CheckRep(qualifier._rep); | CheckRep(qualifier._rep); |
qualifier._rep->toXml(out); |
const CIMQualifierRep* rep = qualifier._rep; |
|
|
|
out << STRLIT("<QUALIFIER NAME=\"") << rep->getName(); |
|
out << STRLIT("\" ") << xmlWriterTypeStrings(rep->getValue().getType()); |
|
|
|
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( |
|
|
const CIMConstQualifierDecl& qualifierDecl) | const CIMConstQualifierDecl& qualifierDecl) |
{ | { |
CheckRep(qualifierDecl._rep); | CheckRep(qualifierDecl._rep); |
qualifierDecl._rep->toXml(out); |
const CIMQualifierDeclRep* rep = qualifierDecl._rep; |
|
|
|
out << STRLIT("<QUALIFIER.DECLARATION NAME=\"") << rep->getName(); |
|
out << STRLIT("\" ") << xmlWriterTypeStrings(rep->getValue().getType()); |
|
|
|
if (rep->getValue().isArray()) |
|
{ |
|
out << STRLIT(" ISARRAY=\"true\""); |
|
|
|
if (rep->getArraySize()) |
|
{ |
|
char buffer[64]; |
|
int n = sprintf(buffer, " ARRAYSIZE=\"%u\"", 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( |
|
|
// TOINSTANCE (true|false) 'false' | // TOINSTANCE (true|false) 'false' |
// TRANSLATABLE (true|false) 'false'"> | // TRANSLATABLE (true|false) 'false'"> |
// | // |
|
// DEPRECATION NOTE: The attribute TOINSTANCE is DEPRECATED and MAY be |
|
// removed from the QualifierFlavor entity in a future version of this |
|
// document. Use of this qualifier is discouraged. |
|
// |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
void XmlWriter::appendQualifierFlavorEntity( | void XmlWriter::appendQualifierFlavorEntity( |
|
|
if (!(flavor.hasFlavor (CIMFlavor::TOSUBCLASS))) | if (!(flavor.hasFlavor (CIMFlavor::TOSUBCLASS))) |
out << STRLIT(" TOSUBCLASS=\"false\""); | out << STRLIT(" TOSUBCLASS=\"false\""); |
| |
if (flavor.hasFlavor (CIMFlavor::TOINSTANCE)) |
//if (flavor.hasFlavor (CIMFlavor::TOINSTANCE)) |
out << STRLIT(" TOINSTANCE=\"true\""); |
// out << STRLIT(" TOINSTANCE=\"true\""); |
| |
if (flavor.hasFlavor (CIMFlavor::TRANSLATABLE)) | if (flavor.hasFlavor (CIMFlavor::TRANSLATABLE)) |
out << STRLIT(" TRANSLATABLE=\"true\""); | out << STRLIT(" TRANSLATABLE=\"true\""); |
|
|
HttpMethod httpMethod, | HttpMethod httpMethod, |
const AcceptLanguageList& acceptLanguages, | const AcceptLanguageList& acceptLanguages, |
const ContentLanguageList& contentLanguages, | const ContentLanguageList& contentLanguages, |
Uint32 contentLength) |
Uint32 contentLength, |
|
bool binaryRequest, |
|
bool binaryResponse) |
{ | { |
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; | char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
| |
|
|
out << STRLIT("POST /cimom HTTP/1.1\r\n"); | out << STRLIT("POST /cimom HTTP/1.1\r\n"); |
} | } |
out << STRLIT("HOST: ") << host << STRLIT("\r\n"); | out << STRLIT("HOST: ") << host << STRLIT("\r\n"); |
|
|
|
if (binaryRequest) |
|
{ |
|
// Tell the server that the payload is encoded in the OpenPegasus |
|
// binary protocol. |
|
out << STRLIT("Content-Type: application/x-openpegasus\r\n"); |
|
} |
|
else |
|
{ |
out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n"); | out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n"); |
OUTPUT_CONTENTLENGTH; |
} |
|
|
|
if (binaryResponse) |
|
{ |
|
// Tell the server that this client accepts the OpenPegasus binary |
|
// protocol. |
|
out << STRLIT("Accept: application/x-openpegasus\r\n"); |
|
} |
|
|
|
OUTPUT_CONTENTLENGTH(out, contentLength); |
if (acceptLanguages.size() > 0) | if (acceptLanguages.size() > 0) |
{ | { |
out << STRLIT("Accept-Language: ") << acceptLanguages << STRLIT("\r\n"); | out << STRLIT("Accept-Language: ") << acceptLanguages << STRLIT("\r\n"); |
|
|
if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0') | if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0') |
#endif | #endif |
| |
|
if (!binaryResponse) |
|
{ |
|
// The binary protocol does not allow chunking. |
out << STRLIT("TE: chunked, trailers\r\n"); | out << STRLIT("TE: chunked, trailers\r\n"); |
|
} |
| |
if (httpMethod == HTTP_METHOD_M_POST) | if (httpMethod == HTTP_METHOD_M_POST) |
{ | { |
|
|
out << nn << STRLIT("\r\n"); | out << nn << STRLIT("\r\n"); |
out << nn << STRLIT("-CIMOperation: MethodCall\r\n"); | out << nn << STRLIT("-CIMOperation: MethodCall\r\n"); |
out << nn << STRLIT("-CIMMethod: ") | out << nn << STRLIT("-CIMMethod: ") |
<< XmlUtils::encodeURICharacters(cimMethod.getString()) |
<< encodeURICharacters(cimMethod.getString()) << STRLIT("\r\n"); |
<< STRLIT("\r\n"); |
|
out << nn << STRLIT("-CIMObject: ") | out << nn << STRLIT("-CIMObject: ") |
<< XmlUtils::encodeURICharacters(cimObject) |
<< encodeURICharacters(cimObject) << STRLIT("\r\n"); |
<< STRLIT("\r\n"); |
|
} | } |
else | else |
{ | { |
out << STRLIT("CIMOperation: MethodCall\r\n"); | out << STRLIT("CIMOperation: MethodCall\r\n"); |
out << STRLIT("CIMMethod: ") | out << STRLIT("CIMMethod: ") |
<< XmlUtils::encodeURICharacters(cimMethod.getString()) |
<< encodeURICharacters(cimMethod.getString()) << STRLIT("\r\n"); |
<< STRLIT("\r\n"); |
out << STRLIT("CIMObject: ") << encodeURICharacters(cimObject) |
out << STRLIT("CIMObject: ") << XmlUtils::encodeURICharacters(cimObject) |
|
<< STRLIT("\r\n"); | << STRLIT("\r\n"); |
} | } |
| |
|
|
HttpMethod httpMethod, | HttpMethod httpMethod, |
const ContentLanguageList& contentLanguages, | const ContentLanguageList& contentLanguages, |
Uint32 contentLength, | Uint32 contentLength, |
Uint64 serverResponseTime) |
Uint64 serverResponseTime, |
|
bool binaryResponse) |
{ | { |
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
// Optimize the typical case for binary messages, circumventing the |
|
// more expensive logic below. |
|
if (binaryResponse && |
|
contentLength == 0 && |
|
httpMethod != HTTP_METHOD_M_POST && |
|
contentLanguages.size() == 0) |
|
{ |
|
static const char HEADERS[] = |
|
"HTTP/1.1 200 OK\r\n" |
|
"Content-Type: application/x-openpegasus\r\n" |
|
"content-length: 0000000000\r\n" |
|
"CIMOperation: MethodResponse\r\n" |
|
"\r\n"; |
|
|
|
// The HTTP processor fills in the content-length value later. |
|
// It searches for a field matching "content-length" (so the first |
|
// character must be lower case). |
|
out.append(HEADERS, sizeof(HEADERS) - 1); |
|
return; |
|
} |
|
|
out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n"); | out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n"); |
| |
#ifndef PEGASUS_DISABLE_PERFINST | #ifndef PEGASUS_DISABLE_PERFINST |
|
|
} | } |
#endif | #endif |
| |
|
if (binaryResponse) |
|
{ |
|
// According to MIME RFC, the "x-" prefix should be used for all |
|
// non-registered values. |
|
out << STRLIT("Content-Type: application/x-openpegasus\r\n"); |
|
} |
|
else |
|
{ |
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(out, contentLength); |
| |
if (contentLanguages.size() > 0) | if (contentLanguages.size() > 0) |
{ | { |
|
|
} | } |
if (httpMethod == HTTP_METHOD_M_POST) | if (httpMethod == HTTP_METHOD_M_POST) |
{ | { |
out << STRLIT("Ext:\r\n"); |
char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' }; |
out << STRLIT("Cache-Control: no-cache\r\n"); |
|
out << STRLIT("Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="); |
out << STRLIT("Ext:\r\n" |
|
"Cache-Control: no-cache\r\n" |
|
"Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="); |
out << nn << STRLIT("\r\n"); | out << nn << STRLIT("\r\n"); |
out << nn << STRLIT("-CIMOperation: MethodResponse\r\n\r\n"); | out << nn << STRLIT("-CIMOperation: MethodResponse\r\n\r\n"); |
} | } |
|
|
if (errorDetail != String::EMPTY) | if (errorDetail != String::EMPTY) |
{ | { |
out << STRLIT(PEGASUS_HTTPHEADERTAG_ERRORDETAIL ": ") | out << STRLIT(PEGASUS_HTTPHEADERTAG_ERRORDETAIL ": ") |
<< XmlUtils::encodeURICharacters(errorDetail) << STRLIT("\r\n"); |
<< encodeURICharacters(errorDetail) << STRLIT("\r\n"); |
} | } |
out << STRLIT("\r\n"); | out << STRLIT("\r\n"); |
} | } |
|
|
// Returns unauthorized message in the following format: | // Returns unauthorized message in the following format: |
// | // |
// HTTP/1.1 401 Unauthorized | // HTTP/1.1 401 Unauthorized |
// WWW-Authenticate: Basic "hostname:80" |
// WWW-Authenticate: Basic realm="HostName" |
// <HTML><HEAD> | // <HTML><HEAD> |
// <TITLE>401 Unauthorized</TITLE> | // <TITLE>401 Unauthorized</TITLE> |
// </HEAD><BODY BGCOLOR="#99cc99"> | // </HEAD><BODY BGCOLOR="#99cc99"> |
|
|
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, 0); |
OUTPUT_CONTENTLENGTH; |
out << content << STRLIT("\r\n\r\n"); |
out << content << STRLIT("\r\n"); |
|
out << STRLIT("\r\n"); |
|
| |
//ATTN: We may need to include the following line, so that the browsers | //ATTN: We may need to include the following line, so that the browsers |
// can display the error message. | // can display the error message. |
|
|
// is usually intended to have content. But, for Kerberos this | // is usually intended to have content. But, for Kerberos this |
// may not always be the case so we need to indicate that there | // may not always be the case so we need to indicate that there |
// is no content | // is no content |
Uint32 contentLength = 0; |
OUTPUT_CONTENTLENGTH(out, 0); |
OUTPUT_CONTENTLENGTH; |
out << content << STRLIT("\r\n\r\n"); |
out << content << STRLIT("\r\n"); |
|
out << STRLIT("\r\n"); |
|
| |
//ATTN: We may need to include the following line, so that the browsers | //ATTN: We may need to include the following line, so that the browsers |
// can display the error message. | // can display the error message. |
|
|
Buffer& out, | Buffer& out, |
const String& messageId) | const String& messageId) |
{ | { |
out << STRLIT("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
out << STRLIT("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" |
out << STRLIT("<CIM CIMVERSION=\"2.0\" DTDVERSION=\"2.0\">\n"); |
"<CIM CIMVERSION=\"2.0\" DTDVERSION=\"2.0\">\n" |
out << STRLIT("<MESSAGE ID=\"") << messageId; |
"<MESSAGE ID=\"") << messageId; |
out << STRLIT("\" PROTOCOLVERSION=\"1.0\">\n"); | out << STRLIT("\" PROTOCOLVERSION=\"1.0\">\n"); |
} | } |
| |
void XmlWriter::_appendMessageElementEnd( | void XmlWriter::_appendMessageElementEnd( |
Buffer& out) | Buffer& out) |
{ | { |
out << STRLIT("</MESSAGE>\n"); |
out << STRLIT("</MESSAGE>\n</CIM>\n"); |
out << STRLIT("</CIM>\n"); |
|
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
Buffer& out, | Buffer& out, |
const CIMException& cimException) | const CIMException& cimException) |
{ | { |
Tracer::traceCIMException(TRC_XML_WRITER, Tracer::LEVEL2, cimException); |
Tracer::traceCIMException(TRC_XML, Tracer::LEVEL2, cimException); |
| |
out << STRLIT("<ERROR"); |
out << STRLIT("<ERROR CODE=\"") << Uint32(cimException.getCode()); |
out << STRLIT(" CODE=\"") << Uint32(cimException.getCode()); |
|
out.append('"'); | out.append('"'); |
| |
String description = TraceableCIMException(cimException).getDescription(); | String description = TraceableCIMException(cimException).getDescription(); |
|
|
out << STRLIT("/>"); | out << STRLIT("/>"); |
} | } |
| |
//------------------------------------------------------------------------------ |
//---------------------------------------------------------------------- |
// |
|
// appendReturnValueElement() |
|
// | // |
// <!ELEMENT RETURNVALUE (VALUE|VALUE.REFERENCE)> |
// appendParamTypeAndEmbeddedObjAttrib |
// <!ATTLIST RETURNVALUE |
// Appends the Param type and EmbeddedObject Info to the buffer |
// %EmbeddedObject; #IMPLIED | // %EmbeddedObject; #IMPLIED |
// %ParamType;> | // %ParamType;> |
// | // |
//------------------------------------------------------------------------------ |
//--------------------------------------------------------------------- |
| |
void XmlWriter::appendReturnValueElement( |
void XmlWriter::appendParamTypeAndEmbeddedObjAttrib( |
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 |
// encode the property in CIM-XML as a string with the EmbeddedObject |
// attribute (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(" EMBEDDEDOBJECT=\"object\""); |
out << STRLIT(" PARAMTYPE=\"string\"" |
|
" EmbeddedObject=\"object\"" |
|
" EMBEDDEDOBJECT=\"object\""); |
} | } |
#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\""); |
" EmbeddedObject=\"instance\"" |
|
" EMBEDDEDOBJECT=\"instance\""); |
} | } |
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
else | else |
{ | { |
out << STRLIT(" PARAMTYPE=\"") << cimTypeToString (type); |
out << STRLIT(" PARAM") << xmlWriterTypeStrings(type); |
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"); |
| |
|
|
HttpMethod httpMethod, | HttpMethod httpMethod, |
const String& authenticationHeader, | const String& authenticationHeader, |
const AcceptLanguageList& httpAcceptLanguages, | const AcceptLanguageList& httpAcceptLanguages, |
const ContentLanguageList& httpContentLanguages) |
const ContentLanguageList& httpContentLanguages, |
|
bool binaryResponse) |
{ | { |
Buffer out; | Buffer out; |
Buffer tmp; | Buffer tmp; |
|
|
httpMethod, | httpMethod, |
httpAcceptLanguages, | httpAcceptLanguages, |
httpContentLanguages, | httpContentLanguages, |
out.size()); |
out.size(), |
|
false, |
|
binaryResponse); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
} | } |
| |
//PEP 128 adding serverRsponseTime to header |
|
Buffer XmlWriter::formatSimpleMethodRspMessage( | Buffer XmlWriter::formatSimpleMethodRspMessage( |
const CIMName& methodName, | const CIMName& methodName, |
const String& messageId, | const String& messageId, |
|
|
tmp, | tmp, |
httpMethod, | httpMethod, |
cimException.getContentLanguages(), | cimException.getContentLanguages(), |
out.size()); |
out.size(), |
|
false); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
const String& authenticationHeader, | const String& authenticationHeader, |
const AcceptLanguageList& httpAcceptLanguages, | const AcceptLanguageList& httpAcceptLanguages, |
const ContentLanguageList& httpContentLanguages, | const ContentLanguageList& httpContentLanguages, |
const Buffer& body) |
const Buffer& body, |
|
bool binaryResponse) |
{ | { |
Buffer out; | Buffer out; |
Buffer tmp; | Buffer tmp; |
|
|
httpMethod, | httpMethod, |
httpAcceptLanguages, | httpAcceptLanguages, |
httpContentLanguages, | httpContentLanguages, |
out.size()); |
out.size(), |
|
false, |
|
binaryResponse); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
appendMethodResponseHeader(tmp, | appendMethodResponseHeader(tmp, |
httpMethod, | httpMethod, |
cimException.getContentLanguages(), | cimException.getContentLanguages(), |
out.size()); |
out.size(), false); |
tmp << out; | tmp << out; |
| |
return tmp; | return tmp; |
|
|
{ | { |
out << STRLIT("POST ") << requestUri << STRLIT(" HTTP/1.1\r\n"); | out << STRLIT("POST ") << requestUri << STRLIT(" HTTP/1.1\r\n"); |
} | } |
out << STRLIT("HOST: ") << host << STRLIT("\r\n"); |
out << STRLIT("HOST: ") << host << STRLIT("\r\n" |
out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n"); |
"Content-Type: application/xml; charset=\"utf-8\"\r\n"); |
OUTPUT_CONTENTLENGTH; |
OUTPUT_CONTENTLENGTH(out, contentLength); |
| |
if (acceptLanguages.size() > 0) | if (acceptLanguages.size() > 0) |
{ | { |
|
|
} | } |
else | else |
{ | { |
out << STRLIT("CIMExport: MethodRequest\r\n"); |
out << STRLIT("CIMExport: MethodRequest\r\n" |
out << STRLIT("CIMExportMethod: ") << cimMethod << STRLIT("\r\n"); |
"CIMExportMethod: ") << cimMethod << STRLIT("\r\n"); |
} | } |
| |
if (authenticationHeader.size()) | if (authenticationHeader.size()) |
|
|
{ | { |
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" |
out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n"); |
"Content-Type: application/xml; charset=\"utf-8\"\r\n"); |
OUTPUT_CONTENTLENGTH; |
OUTPUT_CONTENTLENGTH(out, contentLength); |
| |
if (contentLanguages.size() > 0) | if (contentLanguages.size() > 0) |
{ | { |
|
|
} | } |
if (httpMethod == HTTP_METHOD_M_POST) | if (httpMethod == HTTP_METHOD_M_POST) |
{ | { |
out << STRLIT("Ext:\r\n"); |
out << STRLIT("Ext:\r\n" |
out << STRLIT("Cache-Control: no-cache\r\n"); |
"Cache-Control: no-cache\r\n" |
out << STRLIT("Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns="); |
"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: MethodResponse\r\n\r\n"); | out << nn << STRLIT("-CIMExport: MethodResponse\r\n\r\n"); |
} | } |
|
|
// XmlWriter::keyBindingTypeToString | // XmlWriter::keyBindingTypeToString |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
const char* XmlWriter::keyBindingTypeToString (CIMKeyBinding::Type type) |
const StrLit XmlWriter::keyBindingTypeToString (CIMKeyBinding::Type type) |
{ | { |
switch (type) | switch (type) |
{ | { |
case CIMKeyBinding::BOOLEAN: | case CIMKeyBinding::BOOLEAN: |
return "boolean"; |
return STRLIT("boolean"); |
| |
case CIMKeyBinding::STRING: | case CIMKeyBinding::STRING: |
return "string"; |
return STRLIT("string"); |
| |
case CIMKeyBinding::NUMERIC: | case CIMKeyBinding::NUMERIC: |
return "numeric"; |
return STRLIT("numeric"); |
| |
case CIMKeyBinding::REFERENCE: | case CIMKeyBinding::REFERENCE: |
default: | default: |
PEGASUS_ASSERT(false); | PEGASUS_ASSERT(false); |
} | } |
| |
return "unknown"; |
return STRLIT("unknown"); |
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |