version 1.87, 2003/08/22 14:54:39
|
version 1.118.6.1, 2006/07/30 19:26:30
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// The Open Group, Tivoli Systems |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; Symantec Corporation; The Open Group. |
// | // |
// 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 |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// (carolann_graves@hp.com) | // (carolann_graves@hp.com) |
// Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) | // Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) |
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) | // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com) |
|
// Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for Bug#3103 |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <cctype> | #include <cctype> |
#include <cstdio> | #include <cstdio> |
#include <cstdlib> | #include <cstdlib> |
#if defined(PEGASUS_OS_TYPE_UNIX) |
#if defined(PEGASUS_OS_TYPE_UNIX) || defined(PEGASUS_OS_VMS) |
#include <errno.h> | #include <errno.h> |
#endif | #endif |
#include "CIMName.h" | #include "CIMName.h" |
|
|
#include "CIMObject.h" | #include "CIMObject.h" |
#include "CIMParamValue.h" | #include "CIMParamValue.h" |
#include "System.h" | #include "System.h" |
|
#include "XmlConstants.h" |
#ifdef PEGASUS_PLATFORM_OS400_ISERIES_IBM | #ifdef PEGASUS_PLATFORM_OS400_ISERIES_IBM |
#include "OS400ConvertChar.h" |
#include "EBCDIC_OS400.h" |
#endif | #endif |
// l10n | // l10n |
#include <Pegasus/Common/MessageLoader.h> | #include <Pegasus/Common/MessageLoader.h> |
|
#include <Pegasus/Common/AutoPtr.h> |
|
#include "CIMNameUnchecked.h" |
| |
#define PEGASUS_SINT64_MIN (PEGASUS_SINT64_LITERAL(0x8000000000000000)) | #define PEGASUS_SINT64_MIN (PEGASUS_SINT64_LITERAL(0x8000000000000000)) |
#define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL(0xFFFFFFFFFFFFFFFF) | #define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL(0xFFFFFFFFFFFFFFFF) |
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// testStartTagOrEmptyTag() |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::testStartTagOrEmptyTag( |
|
XmlParser& parser, |
|
XmlEntry& entry) |
|
{ |
|
if (!parser.next(entry) || |
|
(entry.type != XmlEntry::START_TAG && |
|
entry.type != XmlEntry::EMPTY_TAG)) |
|
{ |
|
parser.putBack(entry); |
|
return false; |
|
} |
|
|
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
// testContentOrCData() | // testContentOrCData() |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
| |
#endif | #endif |
} | } |
return CIMName (name); |
return CIMNameUnchecked(name); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
if (!entry.getAttributeValue("CLASSORIGIN", name)) | if (!entry.getAttributeValue("CLASSORIGIN", name)) |
return CIMName(); | return CIMName(); |
| |
// KS 200209 This may be temp but we are adding test for form |
|
// CLASSNAME = "" for Wbemservices interoperability. Returns same |
|
// as if attribute did not exist. |
|
if (name.size() == 0) |
|
return CIMName(); |
|
|
|
if (!CIMName::legal(name)) | if (!CIMName::legal(name)) |
{ | { |
// l10n | // l10n |
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// getEmbeddedObjectAttribute() |
|
// |
|
// <!ENTITY % EmbeddedObject "EMBEDDEDOBJECT (object | instance) #IMPLIED"> |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
String XmlReader::getEmbeddedObjectAttribute( |
|
Uint32 lineNumber, |
|
const XmlEntry& entry, |
|
const char* elementName) |
|
{ |
|
String embeddedObject; |
|
|
|
if (!entry.getAttributeValue("EMBEDDEDOBJECT", embeddedObject)) |
|
return String(); |
|
|
|
// The embeddedObject attribute, if present, must have the string |
|
// value "object" or "instance". |
|
if (!(String::equal(embeddedObject, "object") || |
|
String::equal(embeddedObject, "instance") |
|
) |
|
) |
|
{ |
|
// l10n |
|
|
|
// char buffer[MESSAGE_SIZE]; |
|
// sprintf(buffer, |
|
// "Illegal value for %s.EMBEDDEDOBJECT attribute", elementName); |
|
// throw XmlSemanticError(lineNumber, buffer); |
|
|
|
char buffer[MESSAGE_SIZE]; |
|
sprintf(buffer, "%s.EMBEDDEDOBJECT", elementName); |
|
|
|
MessageLoaderParms mlParms("Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE", |
|
"Illegal value for $0 attribute", |
|
buffer); |
|
|
|
throw XmlSemanticError(lineNumber, mlParms); |
|
|
|
} |
|
|
|
return embeddedObject; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
// getReferenceClassAttribute() | // getReferenceClassAttribute() |
// | // |
// <!ENTITY % ReferenceClass "REFERENCECLASS CDATA #IMPLIED"> | // <!ENTITY % ReferenceClass "REFERENCECLASS CDATA #IMPLIED"> |
|
|
type = CIMTYPE_REAL64; | type = CIMTYPE_REAL64; |
else if (strcmp(typeName, "reference") == 0) | else if (strcmp(typeName, "reference") == 0) |
type = CIMTYPE_REFERENCE; | type = CIMTYPE_REFERENCE; |
|
// PEP 194: |
|
// Note that "object" (ie. CIMTYPE_OBJECT) is not a real CIM datatype, just a |
|
// Pegasus internal representation of an embedded object, so it won't be found here. |
else unrecognizedType = true; | else unrecognizedType = true; |
| |
if (unrecognizedType || | if (unrecognizedType || |
|
|
return true; | return true; |
} | } |
| |
inline Uint8 _hexCharToNumeric(const char c) |
inline Uint8 _xmlReader_hexCharToNumeric(const char c) |
{ | { |
Uint8 n; | Uint8 n; |
| |
|
|
} | } |
| |
// See http://www.ietf.org/rfc/rfc2396.txt section 2 | // See http://www.ietf.org/rfc/rfc2396.txt section 2 |
|
// |
|
// Also see the "CIM Operations over HTTP" spec, section 3.3.2 and |
|
// 3.3.3, for the treatment of non US-ASCII chars (UTF-8) |
String XmlReader::decodeURICharacters(String uriString) | String XmlReader::decodeURICharacters(String uriString) |
{ | { |
String decodedString; |
|
Uint32 i; | Uint32 i; |
| |
|
Array<Uint8> utf8Chars; |
|
|
for (i=0; i<uriString.size(); i++) | for (i=0; i<uriString.size(); i++) |
{ | { |
if (uriString[i] == '%') | if (uriString[i] == '%') |
|
|
| |
} | } |
| |
Uint8 digit1 = _hexCharToNumeric(char(uriString[++i])); |
Uint8 digit1 = _xmlReader_hexCharToNumeric(char(uriString[++i])); |
Uint8 digit2 = _hexCharToNumeric(char(uriString[++i])); |
Uint8 digit2 = _xmlReader_hexCharToNumeric(char(uriString[++i])); |
if ( (digit1 > 15) || (digit2 > 15) ) | if ( (digit1 > 15) || (digit2 > 15) ) |
{ | { |
// l10n | // l10n |
|
|
throw ParseError(MessageLoader::getMessage(mlParms)); | throw ParseError(MessageLoader::getMessage(mlParms)); |
} | } |
| |
// ATTN: Handle non-UTF-8 character sets |
|
Uint16 decodedChar = Uint16(digit1<<4) + Uint16(digit2); | Uint16 decodedChar = Uint16(digit1<<4) + Uint16(digit2); |
decodedString.append(Char16(decodedChar)); |
utf8Chars.append((Uint8)decodedChar); |
} | } |
else | else |
{ | { |
decodedString.append(uriString[i]); |
utf8Chars.append((Uint8)uriString[i]); |
} | } |
} | } |
| |
return decodedString; |
// If there was a string to decode... |
|
if (uriString.size() > 0) |
|
{ |
|
// Convert UTF-8 to UTF-16 and return the String |
|
utf8Chars.append('\0'); |
|
return String((char *)utf8Chars.getData()); |
|
} |
|
else |
|
{ |
|
return String(); |
|
} |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
x = x << 4; | x = x << 4; |
| |
// Make sure we don't overflow when we add the next digit | // Make sure we don't overflow when we add the next digit |
Sint64 newDigit = Sint64(_hexCharToNumeric(*p++)); |
Sint64 newDigit = Sint64(_xmlReader_hexCharToNumeric(*p++)); |
if (PEGASUS_SINT64_MIN - x > -newDigit) | if (PEGASUS_SINT64_MIN - x > -newDigit) |
{ | { |
return false; | return false; |
|
|
x = x << 4; | x = x << 4; |
| |
// We can't overflow when we add the next digit | // We can't overflow when we add the next digit |
Uint64 newDigit = Uint64(_hexCharToNumeric(*p++)); |
Uint64 newDigit = Uint64(_xmlReader_hexCharToNumeric(*p++)); |
if (PEGASUS_UINT64_MAX - x < newDigit) | if (PEGASUS_UINT64_MAX - x < newDigit) |
{ | { |
return false; | return false; |
|
|
| |
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
return CIMValue(String(valueString, STRING_FLAG_UTF8)); |
return CIMValue(String(valueString)); |
} | } |
| |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
{ | { |
|
|
|
// remove this test, utf-8 can be up to 6 bytes per char |
|
/* |
if (strlen(valueString) != 1) { | if (strlen(valueString) != 1) { |
|
// l10n |
| |
|
// throw XmlSemanticError(lineNumber, "Invalid char16 value"); |
|
|
|
MessageLoaderParms mlParms("Common.XmlReader.INVALID_CHAR16_VALUE", |
|
"Invalid char16 value"); |
|
|
|
throw XmlSemanticError(lineNumber, mlParms); |
|
} |
|
*/ |
|
// Converts UTF-8 to UTF-16 |
|
String tmp(valueString); |
|
if (tmp.size() != 1) |
|
{ |
// l10n | // l10n |
| |
// throw XmlSemanticError(lineNumber, "Invalid char16 value"); | // throw XmlSemanticError(lineNumber, "Invalid char16 value"); |
|
|
throw XmlSemanticError(lineNumber, mlParms); | throw XmlSemanticError(lineNumber, mlParms); |
} | } |
| |
return CIMValue(Char16(valueString[0])); |
return CIMValue(tmp[0]); |
} | } |
| |
case CIMTYPE_UINT8: | case CIMTYPE_UINT8: |
|
|
return CIMValue(x); | return CIMValue(x); |
} | } |
| |
|
// PEP 194: |
|
// Note that "object" (ie. CIMTYPE_OBJECT) is not a real CIM datatype, but just a |
|
// Pegasus internal representation of an embedded object. However, this case is |
|
// used when decoding string representations of embedded objects. |
|
case CIMTYPE_OBJECT: |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
case CIMTYPE_INSTANCE: |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
{ |
|
CIMObject x; |
|
|
|
if (*valueString == '\0') |
|
{ |
|
return CIMValue(type, false, 0); |
|
} |
|
else |
|
{ |
|
// Convert the non-NULL string to a CIMObject (containing either a |
|
// CIMInstance or a CIMClass). |
|
|
|
// First we need to create a new "temporary" XmlParser that is |
|
// just the value of the Embedded Object in String representation. |
|
AutoArrayPtr<char> tmp_buffer(new char[strlen(valueString) + 1]); |
|
strcpy(tmp_buffer.get(), valueString); |
|
XmlParser tmp_parser(tmp_buffer.get()); |
|
|
|
// The next bit of logic constructs a CIMObject from the Embedded Object String. |
|
// It is similar to the method XmlReader::getValueObjectElement(). |
|
CIMInstance cimInstance; |
|
CIMClass cimClass; |
|
|
|
if (XmlReader::getInstanceElement(tmp_parser, cimInstance)) |
|
{ |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
if(type == CIMTYPE_INSTANCE) |
|
return CIMValue(cimInstance); |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
x = CIMObject(cimInstance); |
|
} |
|
else if (XmlReader::getClassElement(tmp_parser, cimClass)) |
|
{ |
|
x = CIMObject(cimClass); |
|
} |
|
else |
|
{ |
|
// l10n |
|
|
|
// throw XmlValidationError(parser.getLine(), |
|
// "Expected INSTANCE or CLASS element"); |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
if(type == CIMTYPE_OBJECT) |
|
{ |
|
MessageLoaderParms mlParms("Common.XmlReader.EXPECTED_INSTANCE_OR_CLASS_ELEMENT", |
|
"Expected INSTANCE or CLASS element"); // change "element" to "embedded object" |
|
|
|
throw XmlValidationError(lineNumber, mlParms); |
|
} |
|
else |
|
{ |
|
MessageLoaderParms mlParms("Common.XmlReader.EXPECTED_INSTANCE_ELEMENT", |
|
"Expected INSTANCE element"); // change "element" to "embedded object" |
|
throw XmlValidationError(lineNumber, mlParms); |
|
} |
|
#else |
|
MessageLoaderParms mlParms("Common.XmlReader.EXPECTED_INSTANCE_OR_CLASS_ELEMENT", |
|
"Expected INSTANCE or CLASS element"); // change "element" to "embedded object" |
|
throw XmlValidationError(lineNumber, mlParms); |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
} |
|
// Ok, now we can delete the storage for the temporary XmlParser. |
|
tmp_buffer.reset(); |
|
} |
|
return CIMValue(x); |
|
} |
|
|
default: | default: |
break; | break; |
} | } |
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// skipElement() |
|
// |
|
//------------------------------------------------------------------------------ |
|
void XmlReader::skipElement( |
|
XmlParser& parser, |
|
XmlEntry& entry) |
|
{ |
|
const char * tag_name = entry.text; |
|
|
|
if (entry.type == XmlEntry::EMPTY_TAG) |
|
{ |
|
return; |
|
} |
|
|
|
while (testStartTagOrEmptyTag(parser, entry)) |
|
{ |
|
skipElement(parser, entry); |
|
} |
|
|
|
if (testContentOrCData(parser, entry)) |
|
{ |
|
; // skip |
|
} |
|
|
|
expectEndTag(parser, tag_name); |
|
return; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
// getValueElement() | // getValueElement() |
// | // |
// <!ELEMENT VALUE (#PCDATA)> | // <!ELEMENT VALUE (#PCDATA)> |
|
|
| |
XmlEntry entry; | XmlEntry entry; |
if (!testStartTagOrEmptyTag(parser, entry, "VALUE")) | if (!testStartTagOrEmptyTag(parser, entry, "VALUE")) |
|
{ |
return false; | return false; |
|
} |
| |
Boolean empty = entry.type == XmlEntry::EMPTY_TAG; | Boolean empty = entry.type == XmlEntry::EMPTY_TAG; |
| |
|
|
if (!empty) | if (!empty) |
{ | { |
if (testContentOrCData(parser, entry)) | if (testContentOrCData(parser, entry)) |
|
{ |
valueString = entry.text; | valueString = entry.text; |
|
} |
| |
expectEndTag(parser, "VALUE"); | expectEndTag(parser, "VALUE"); |
} | } |
|
|
expectEndTag(parser, "VALUE"); | expectEndTag(parser, "VALUE"); |
} | } |
| |
str = String(valueString,STRING_FLAG_UTF8); |
str = String(valueString); |
return true; | return true; |
} | } |
| |
|
|
case CIMTYPE_REAL64: | case CIMTYPE_REAL64: |
return StringArrayToValueAux(lineNumber, array, type, (Real64*)0); | return StringArrayToValueAux(lineNumber, array, type, (Real64*)0); |
| |
|
// PEP 194: |
|
// Note that "object" (ie. CIMTYPE_OBJECT) is not a real CIM datatype, but just a |
|
// Pegasus internal representation of an embedded object. However, this case is |
|
// used when decoding string representations of embedded objects. |
|
case CIMTYPE_OBJECT: |
|
return StringArrayToValueAux(lineNumber, array, type, (CIMObject*)0); |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
case CIMTYPE_INSTANCE: |
|
return StringArrayToValueAux(lineNumber, array, type, (CIMInstance*)0); |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
|
default: | default: |
break; | break; |
} | } |
|
|
// Get QUALIFIER element: | // Get QUALIFIER element: |
| |
XmlEntry entry; | XmlEntry entry; |
if (!testStartTag(parser, entry, "QUALIFIER")) |
if (!testStartTagOrEmptyTag(parser, entry, "QUALIFIER")) |
return false; | return false; |
| |
|
Boolean empty = entry.type == XmlEntry::EMPTY_TAG; |
|
|
// Get QUALIFIER.NAME attribute: | // Get QUALIFIER.NAME attribute: |
| |
CIMName name = getCimNameAttribute(parser.getLine(), entry, "QUALIFIER"); | CIMName name = getCimNameAttribute(parser.getLine(), entry, "QUALIFIER"); |
|
|
| |
CIMValue value; | CIMValue value; |
| |
|
if (empty) |
|
{ |
|
value.setNullValue(type, false); |
|
} |
|
else |
|
{ |
if (!getValueElement(parser, type, value) && | if (!getValueElement(parser, type, value) && |
!getValueArrayElement(parser, type, value)) | !getValueArrayElement(parser, type, value)) |
{ | { |
|
|
// Expect </QUALIFIER>: | // Expect </QUALIFIER>: |
| |
expectEndTag(parser, "QUALIFIER"); | expectEndTag(parser, "QUALIFIER"); |
|
} |
| |
// Build qualifier: | // Build qualifier: |
| |
|
|
// %CIMName; | // %CIMName; |
// %ClassOrigin; | // %ClassOrigin; |
// %Propagated; | // %Propagated; |
|
// %EmbeddedObject; #IMPLIED |
// %CIMType; #REQUIRED> | // %CIMType; #REQUIRED> |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
Boolean propagated = getCimBooleanAttribute( | Boolean propagated = getCimBooleanAttribute( |
parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false); | parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false); |
| |
|
// Get PROPERTY.EMBEDDEDOBJECT attribute: |
|
|
|
String embeddedObject = getEmbeddedObjectAttribute( |
|
parser.getLine(), entry, "PROPERTY"); |
|
|
// Get PROPERTY.TYPE attribute: | // Get PROPERTY.TYPE attribute: |
| |
CIMType type; | CIMType type; |
|
|
| |
if (!empty) | if (!empty) |
{ | { |
// Get qualifiers: |
// Get qualifiers. We need to do this before checking for the property as an |
|
// embedded object, because we need to also check for the EmbeddedObject qualifier. |
getQualifierElements(parser, property); | getQualifierElements(parser, property); |
|
} |
|
|
|
Boolean embeddedObjectQualifierValue = false; |
|
Uint32 ix = property.findQualifier(CIMName("EmbeddedObject")); |
|
if (ix != PEG_NOT_FOUND) |
|
{ |
|
property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue); |
|
} |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
String embeddedInstanceQualifierValue; |
|
ix = property.findQualifier(CIMName("EmbeddedInstance")); |
|
if (ix != PEG_NOT_FOUND) |
|
{ |
|
property.getQualifier(ix).getValue().get(embeddedInstanceQualifierValue); |
|
} |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
// If the EMBEDDEDOBJECT attribute is present with value "object" |
|
// or the EmbeddedObject qualifier exists on this property with value "true" |
|
// then |
|
// Convert the EmbeddedObject-encoded string into a CIMObject |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
Boolean isEmbeddedObject = String::equal(embeddedObject, "object") || |
|
embeddedObjectQualifierValue; |
|
Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance") || |
|
embeddedInstanceQualifierValue.size() > 0; |
|
if (isEmbeddedObject || isEmbeddedInstance) |
|
{ |
|
// The EMBEDDEDOBJECT attribute is only valid on Properties of type string |
|
if (type == CIMTYPE_STRING) |
|
{ |
|
if(isEmbeddedObject) |
|
type = CIMTYPE_OBJECT; |
|
else |
|
type = CIMTYPE_INSTANCE; |
|
CIMValue new_value(type, false); |
|
CIMProperty new_property = CIMProperty(name, new_value, 0, CIMName(), classOrigin, propagated); |
|
|
|
// Copy the qualifiers from the String property to the CIMObject property. |
|
for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix) |
|
{ |
|
// All properties are copied, including the EmbeddedObject qualifier. |
|
// This way we don't have to keep track to know that the EmbeddedObject |
|
// qualifier needs to be added back during the encode step. |
|
new_property.addQualifier(property.getQualifier(ix)); |
|
} |
|
|
|
value = new_value; |
|
property = new_property; |
|
} |
|
else |
|
{ |
|
// Error -- throw exception |
|
// (the EmbeddedObject attribute may be applied only to entities that have the type String) |
|
|
|
// l10n |
|
|
|
// throw XmlValidationError(parser.getLine(), |
|
// "expected string type"); |
|
|
|
MessageLoaderParms mlParms("Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
|
"The EMBEDDEDOBJECT attribute is only valid on string types."); |
|
|
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
} |
|
#else |
|
if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue) |
|
{ |
|
// The EMBEDDEDOBJECT attribute is only valid on Properties of type string |
|
if (type == CIMTYPE_STRING) |
|
{ |
|
type = CIMTYPE_OBJECT; |
|
CIMValue new_value(type, false); |
|
CIMProperty new_property = CIMProperty(name, new_value, 0, CIMName(), classOrigin, propagated); |
|
|
|
// Copy the qualifiers from the String property to the CIMObject property. |
|
for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix) |
|
{ |
|
// All properties are copied, including the EmbeddedObject qualifier. |
|
// This way we don't have to keep track to know that the EmbeddedObject |
|
// qualifier needs to be added back during the encode step. |
|
new_property.addQualifier(property.getQualifier(ix)); |
|
} |
| |
// Get value: Insert value if getValueElement exists (returns True) |
value = new_value; |
|
property = new_property; |
|
} |
|
else |
|
{ |
|
// Error -- throw exception |
|
// (the EmbeddedObject attribute may be applied only to entities that have the type String) |
| |
|
// l10n |
|
|
|
// throw XmlValidationError(parser.getLine(), |
|
// "expected string type"); |
|
|
|
MessageLoaderParms mlParms("Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
|
"The EMBEDDEDOBJECT attribute is only valid on string types."); |
|
|
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
} |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
// Continue on to get property value, if not empty. |
|
if (!empty) |
|
{ |
if (getValueElement(parser, type, value)) | if (getValueElement(parser, type, value)) |
property.setValue(value); | property.setValue(value); |
|
|
expectEndTag(parser, "PROPERTY"); | expectEndTag(parser, "PROPERTY"); |
} | } |
| |
|
|
// %CIMType; #REQUIRED | // %CIMType; #REQUIRED |
// %ArraySize; | // %ArraySize; |
// %ClassOrigin; | // %ClassOrigin; |
// %Propagated;> |
// %Propagated; |
|
// %EmbeddedObject; #IMPLIED> |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
|
|
| |
// Get PROPERTY.CLASSORIGIN attribute: | // Get PROPERTY.CLASSORIGIN attribute: |
| |
CIMName classOrigin |
CIMName classOrigin = getClassOriginAttribute(parser.getLine(), entry, "PROPERTY.ARRAY"); |
= getClassOriginAttribute(parser.getLine(), entry, "PROPERTY.ARRAY"); |
|
| |
// Get PROPERTY.ARRAY.PROPAGATED | // Get PROPERTY.ARRAY.PROPAGATED |
| |
Boolean propagated = getCimBooleanAttribute( |
Boolean propagated = getCimBooleanAttribute(parser.getLine() |
parser.getLine(), entry, "PROPERTY.ARRAY", "PROPAGATED", false, false); |
,entry |
|
,"PROPERTY.ARRAY" |
|
,"PROPAGATED" |
|
,false |
|
,false); |
|
|
|
// Get PROPERTY.EMBEDDEDOBJECT attribute: |
|
|
|
String embeddedObject = getEmbeddedObjectAttribute(parser.getLine() |
|
,entry |
|
,"PROPERTY.ARRAY"); |
| |
// Create property: | // Create property: |
| |
CIMValue value(type, true, arraySize); | CIMValue value(type, true, arraySize); |
property = CIMProperty( |
property = CIMProperty(name, value, arraySize, CIMName(), classOrigin, propagated); |
name, value, arraySize, CIMName(), classOrigin, propagated); |
|
| |
if (!empty) | if (!empty) |
{ | { |
// Get qualifiers: | // Get qualifiers: |
|
|
getQualifierElements(parser, property); | getQualifierElements(parser, property); |
|
} |
| |
// Get value: |
Boolean embeddedObjectQualifierValue = false; |
|
Uint32 ix = property.findQualifier(CIMName("EmbeddedObject")); |
|
if (ix != PEG_NOT_FOUND) |
|
{ |
|
property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue); |
|
} |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
String embeddedInstanceQualifierValue; |
|
ix = property.findQualifier(CIMName("EmbeddedInstance")); |
|
if (ix != PEG_NOT_FOUND) |
|
{ |
|
property.getQualifier(ix).getValue().get(embeddedInstanceQualifierValue); |
|
} |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
// If the EMBEDDEDOBJECT attribute is present with value "object" |
|
// or the EmbeddedObject qualifier exists on this property with value "true" |
|
// then |
|
// Convert the EmbeddedObject-encoded string into a CIMObject |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
Boolean isEmbeddedObject = String::equal(embeddedObject, "object") || |
|
embeddedObjectQualifierValue; |
|
Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance") || |
|
embeddedInstanceQualifierValue.size() > 0; |
|
if (isEmbeddedObject || isEmbeddedInstance) |
|
{ |
|
// The EMBEDDEDOBJECT attribute is only valid on Properties of type string |
|
if (type == CIMTYPE_STRING) |
|
{ |
|
if(isEmbeddedObject) |
|
type = CIMTYPE_OBJECT; |
|
else |
|
type = CIMTYPE_INSTANCE; |
|
CIMValue new_value(type, true, arraySize); |
|
CIMProperty new_property = CIMProperty(name, new_value, arraySize, CIMName(), classOrigin, propagated); |
|
|
|
// Copy the qualifiers from the String property to the CIMObject property. |
|
for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix) |
|
{ |
|
// All properties are copied, including the EmbeddedObject qualifier. |
|
// This way we don't have to keep track to know that the EmbeddedObject |
|
// qualifier needs to be added back during the encode step. |
|
new_property.addQualifier(property.getQualifier(ix)); |
|
} |
|
|
|
value = new_value; |
|
property = new_property; |
|
} |
|
else |
|
{ |
|
// Error -- throw exception |
|
// (the EmbeddedObject attribute may be applied only to entities that have the type String) |
|
|
|
// l10n |
|
|
|
// throw XmlValidationError(parser.getLine(), |
|
// "expected string type"); |
|
|
|
MessageLoaderParms mlParms("Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
|
"The EMBEDDEDOBJECT attribute is only valid on string types."); |
|
|
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
} |
|
#else |
|
if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue) |
|
{ |
|
// The EMBEDDEDOBJECT attribute is only valid on Properties of type string |
|
if (type == CIMTYPE_STRING) |
|
{ |
|
type = CIMTYPE_OBJECT; |
|
CIMValue new_value(type, true, arraySize); |
|
CIMProperty new_property = CIMProperty(name, new_value, arraySize, CIMName(), classOrigin, propagated); |
| |
|
// Copy the qualifiers from the String property to the CIMObject property. |
|
for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix) |
|
{ |
|
// All properties are copied, including the EmbeddedObject qualifier. |
|
// This way we don't have to keep track to know that the EmbeddedObject |
|
// qualifier needs to be added back during the encode step. |
|
new_property.addQualifier(property.getQualifier(ix)); |
|
} |
|
|
|
value = new_value; |
|
property = new_property; |
|
} |
|
else |
|
{ |
|
// Error -- throw exception |
|
// (the EmbeddedObject attribute may be applied only to entities that have the type String) |
|
|
|
// l10n |
|
|
|
// throw XmlValidationError(parser.getLine(), |
|
// "expected string type"); |
|
|
|
MessageLoaderParms mlParms("Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
|
"The EMBEDDEDOBJECT attribute is only valid on string types."); |
|
|
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
} |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
// Continue on to get property array value, if not empty. |
|
// Else not an embedded object, if not empty, get the property array value. |
|
if (!empty) |
|
{ |
if (getValueArrayElement(parser, type, value)) | if (getValueArrayElement(parser, type, value)) |
{ | { |
if (arraySize && arraySize != value.getArraySize()) | if (arraySize && arraySize != value.getArraySize()) |
|
|
| |
property.setValue(value); | property.setValue(value); |
} | } |
|
|
expectEndTag(parser, "PROPERTY.ARRAY"); | expectEndTag(parser, "PROPERTY.ARRAY"); |
} | } |
| |
|
|
throw XmlException(XmlException::UNCLOSED_TAGS, parser.getLine()); | throw XmlException(XmlException::UNCLOSED_TAGS, parser.getLine()); |
| |
if (entry.type == XmlEntry::CONTENT) | if (entry.type == XmlEntry::CONTENT) |
host = String(entry.text,STRING_FLAG_UTF8); |
host = String(entry.text); |
else | else |
{ | { |
parser.putBack(entry); | parser.putBack(entry); |
|
|
| |
} | } |
| |
host = String(entry.text,STRING_FLAG_UTF8); |
host = String(entry.text); |
#endif | #endif |
expectEndTag(parser, "HOST"); | expectEndTag(parser, "HOST"); |
return true; | return true; |
|
|
throw XmlException(XmlException::UNCLOSED_TAGS, parser.getLine()); | throw XmlException(XmlException::UNCLOSED_TAGS, parser.getLine()); |
| |
if (entry.type == XmlEntry::CONTENT) | if (entry.type == XmlEntry::CONTENT) |
value = String(entry.text,STRING_FLAG_UTF8); |
value = String(entry.text); |
else | else |
parser.putBack(entry); | parser.putBack(entry); |
| |
|
|
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
if (!testStartTag(parser, entry, "CLASS")) |
if (!testStartTagOrEmptyTag(parser, entry, "CLASS")) |
return false; | return false; |
| |
CIMName name = getCimNameAttribute(parser.getLine(), entry, "CLASS"); | CIMName name = getCimNameAttribute(parser.getLine(), entry, "CLASS"); |
|
|
| |
cimClass = CIMClass(name, superClass); | cimClass = CIMClass(name, superClass); |
| |
|
if(entry.type != XmlEntry::EMPTY_TAG) |
|
{ |
|
|
// Get QUALIFIER elements: | // Get QUALIFIER elements: |
| |
getQualifierElements(parser, cimClass); | getQualifierElements(parser, cimClass); |
|
|
// Get CLASS end tag: | // Get CLASS end tag: |
| |
expectEndTag(parser, "CLASS"); | expectEndTag(parser, "CLASS"); |
|
} |
| |
return true; | return true; |
} | } |
|
|
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
if (!testStartTag(parser, entry, "INSTANCE")) |
if (!testStartTagOrEmptyTag(parser, entry, "INSTANCE")) |
return false; | return false; |
| |
|
Boolean empty = entry.type == XmlEntry::EMPTY_TAG; |
|
|
String className = getClassNameAttribute( | String className = getClassNameAttribute( |
parser.getLine(), entry, "INSTANCE"); | parser.getLine(), entry, "INSTANCE"); |
| |
cimInstance = CIMInstance(className); | cimInstance = CIMInstance(className); |
| |
|
if (!empty) |
|
{ |
// Get QUALIFIER elements: | // Get QUALIFIER elements: |
|
|
getQualifierElements(parser, cimInstance); | getQualifierElements(parser, cimInstance); |
| |
// Get PROPERTY elements: | // Get PROPERTY elements: |
|
|
GetPropertyElements(parser, cimInstance); | GetPropertyElements(parser, cimInstance); |
| |
// Get INSTANCE end tag: | // Get INSTANCE end tag: |
|
|
expectEndTag(parser, "INSTANCE"); | expectEndTag(parser, "INSTANCE"); |
|
} |
| |
return true; | return true; |
} | } |
|
|
| |
Boolean XmlReader::getIMethodResponseStartTag( | Boolean XmlReader::getIMethodResponseStartTag( |
XmlParser& parser, | XmlParser& parser, |
const char*& name) |
const char*& name, |
|
Boolean& isEmptyTag) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
if (!testStartTag(parser, entry, "IMETHODRESPONSE")) |
if (!testStartTagOrEmptyTag(parser, entry, "IMETHODRESPONSE")) |
return false; | return false; |
| |
|
isEmptyTag = (entry.type == XmlEntry::EMPTY_TAG); |
|
|
// Get IMETHODRESPONSE.NAME attribute: | // Get IMETHODRESPONSE.NAME attribute: |
| |
if (!entry.getAttributeValue("NAME", name)) { | if (!entry.getAttributeValue("NAME", name)) { |
|
|
| |
Boolean XmlReader::getIParamValueTag( | Boolean XmlReader::getIParamValueTag( |
XmlParser& parser, | XmlParser& parser, |
const char*& name) |
const char*& name, |
|
Boolean& isEmptyTag) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
if (!testStartTag(parser, entry, "IPARAMVALUE")) |
if (!testStartTagOrEmptyTag(parser, entry, "IPARAMVALUE")) |
return false; | return false; |
| |
|
isEmptyTag = (entry.type == XmlEntry::EMPTY_TAG); |
|
|
// Get IPARAMVALUE.NAME attribute: | // Get IPARAMVALUE.NAME attribute: |
| |
if (!entry.getAttributeValue("NAME", name)) { | if (!entry.getAttributeValue("NAME", name)) { |
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// rejectNullIParamValue() |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
void XmlReader::rejectNullIParamValue( |
|
XmlParser& parser, |
|
Boolean isEmptyTag, |
|
const char* paramName) |
|
{ |
|
if (isEmptyTag) |
|
{ |
|
MessageLoaderParms mlParms("Common.XmlReader.INVALID_NULL_IPARAMVALUE", |
|
"A null value is not valid for IPARAMVALUE \"$0\".", |
|
paramName); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
// getBooleanValueElement() | // getBooleanValueElement() |
// | // |
// Get an elements like: "<VALUE>FALSE</VALUE>" | // Get an elements like: "<VALUE>FALSE</VALUE>" |
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
// getErrorElement() |
// DMTF CR Pending |
// | // |
// <!ELEMENT ERROR EMPTY> |
// <!ELEMENT ERROR (INSTANCE*)> |
// <!ATTLIST ERROR | // <!ATTLIST ERROR |
// CODE CDATA #REQUIRED | // CODE CDATA #REQUIRED |
// DESCRIPTION CDATA #IMPLIED> | // DESCRIPTION CDATA #IMPLIED> |
|
|
entry.getAttributeValue("DESCRIPTION", tmpDescription); | entry.getAttributeValue("DESCRIPTION", tmpDescription); |
| |
if (!empty) | if (!empty) |
|
{ |
|
while (testStartTagOrEmptyTag(parser, entry)) |
|
{ |
|
skipElement(parser, entry); |
|
} |
|
|
expectEndTag(parser, "ERROR"); | expectEndTag(parser, "ERROR"); |
|
} |
| |
cimException = PEGASUS_CIM_EXCEPTION(CIMStatusCode(tmpCode), tmpDescription); | cimException = PEGASUS_CIM_EXCEPTION(CIMStatusCode(tmpCode), tmpDescription); |
return true; | return true; |
|
|
{ | { |
object = CIMObject(cimInstance); | object = CIMObject(cimInstance); |
} | } |
else if (!XmlReader::getClassElement(parser, cimClass)) |
else if (XmlReader::getClassElement(parser, cimClass)) |
{ | { |
object = CIMObject(cimClass); | object = CIMObject(cimClass); |
} | } |
|
|
else if (!XmlReader::getClassPathElement(parser, reference)) | else if (!XmlReader::getClassPathElement(parser, reference)) |
{ | { |
| |
// l10n |
// l10n 485 |
| |
// throw XmlValidationError(parser.getLine(), | // throw XmlValidationError(parser.getLine(), |
// "Expected INSTANCEPATH or CLASSPATH element"); | // "Expected INSTANCEPATH or CLASSPATH element"); |
| |
MessageLoaderParms mlParms("Common.XmlReader.EXPECTED_INSTANCEPATH_OR_CLASSPATH_ELEMENT", | MessageLoaderParms mlParms("Common.XmlReader.EXPECTED_INSTANCEPATH_OR_CLASSPATH_ELEMENT", |
"Expected INSTANCEPATH or CLASSPATH element", "INSTANCEPATH", "CLASSPATH"); |
"Expected INSTANCEPATH or CLASSPATH element"); |
| |
throw XmlValidationError(parser.getLine(), mlParms); | throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
|
|
// throw XmlValidationError(parser.getLine(), | // throw XmlValidationError(parser.getLine(), |
// "Expected LOCALINSTANCEPATH or LOCALCLASSPATH element"); | // "Expected LOCALINSTANCEPATH or LOCALCLASSPATH element"); |
| |
MessageLoaderParms mlParms("Common.XmlReader.EXPECTED_LOCALINSTANCEPATH_OR_LOCALCLASSPATH_ELEMENT", |
//l10n updated |
"Expected LOCALINSTANCEPATH or LOCALCLASSPATH element"); |
MessageLoaderParms mlParms("Common.XmlConstants.MISSING_ELEMENT_LOCALPATH", |
|
MISSING_ELEMENT_LOCALPATH); |
| |
throw XmlValidationError(parser.getLine(), mlParms); | throw XmlValidationError(parser.getLine(), mlParms); |
| |
|
|
| |
} | } |
| |
return false; |
PEGASUS_UNREACHABLE( return false; ) |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
| |
Boolean XmlReader::getEMethodResponseStartTag( | Boolean XmlReader::getEMethodResponseStartTag( |
XmlParser& parser, | XmlParser& parser, |
const char*& name) |
const char*& name, |
|
Boolean& isEmptyTag) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
if (!testStartTag(parser, entry, "EXPMETHODRESPONSE")) |
if (!testStartTagOrEmptyTag(parser, entry, "EXPMETHODRESPONSE")) |
return false; | return false; |
| |
|
isEmptyTag = (entry.type == XmlEntry::EMPTY_TAG); |
|
|
// Get EXPMETHODRESPONSE.NAME attribute: | // Get EXPMETHODRESPONSE.NAME attribute: |
| |
| |
|
|
| |
Boolean XmlReader::getMethodResponseStartTag( | Boolean XmlReader::getMethodResponseStartTag( |
XmlParser& parser, | XmlParser& parser, |
const char*& name) |
const char*& name, |
|
Boolean& isEmptyTag) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
if (!testStartTag(parser, entry, "METHODRESPONSE")) |
if (!testStartTagOrEmptyTag(parser, entry, "METHODRESPONSE")) |
return false; | return false; |
| |
|
isEmptyTag = (entry.type == XmlEntry::EMPTY_TAG); |
|
|
// Get METHODRESPONSE.NAME attribute: | // Get METHODRESPONSE.NAME attribute: |
| |
| |
|
|
// <!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;> | // %ParamType;> |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
{ | { |
XmlEntry entry; | XmlEntry entry; |
const char* name; | const char* name; |
CIMType type; |
CIMType type=CIMTYPE_BOOLEAN; |
CIMValue value; | CIMValue value; |
| |
if (!testStartTagOrEmptyTag(parser, entry, "PARAMVALUE")) | if (!testStartTagOrEmptyTag(parser, entry, "PARAMVALUE")) |
|
|
throw XmlValidationError(parser.getLine(), mlParms); | throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
|
// Get PROPERTY.EMBEDDEDOBJECT |
|
|
|
String embeddedObject = getEmbeddedObjectAttribute( |
|
parser.getLine(), entry, "PARAMVALUE"); |
| |
// Get PARAMVALUE.PARAMTYPE attribute: | // Get PARAMVALUE.PARAMTYPE attribute: |
| |
Boolean gotType = getCimTypeAttribute(parser.getLine(), entry, type, | Boolean gotType = getCimTypeAttribute(parser.getLine(), entry, type, |
"PARAMVALUE", "PARAMTYPE", false); | "PARAMVALUE", "PARAMTYPE", false); |
| |
if (!empty) |
if (empty) |
|
{ |
|
gotType = false; // Can't distinguish array and non-array types |
|
} |
|
else |
{ | { |
// Parse VALUE.REFERENCE and VALUE.REFARRAY type | // Parse VALUE.REFERENCE and VALUE.REFARRAY type |
if ( (type == CIMTYPE_REFERENCE) || !gotType ) | if ( (type == CIMTYPE_REFERENCE) || !gotType ) |
|
|
effectiveType = type; | effectiveType = type; |
} | } |
| |
|
// If the EMBEDDEDOBJECT attribute is present with value "object" |
|
// then |
|
// Convert the EmbeddedObject-encoded string into a CIMObject |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
Boolean isEmbeddedObject = String::equal(embeddedObject, "object"); |
|
Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance"); |
|
if(isEmbeddedObject || isEmbeddedInstance) |
|
{ |
|
// The EMBEDDEDOBJECT attribute is only valid on Parameters of type string |
|
// The type must have been specified. |
|
if (gotType && (type == CIMTYPE_STRING)) |
|
{ |
|
if(isEmbeddedObject) |
|
effectiveType = CIMTYPE_OBJECT; // Used below by getValueElement() or getValueArrayElement() |
|
else |
|
effectiveType = CIMTYPE_INSTANCE; |
|
} |
|
else |
|
{ |
|
// Error -- throw exception |
|
// (the EmbeddedObject attribute may be applied only to entities that have the type String) |
|
|
|
// l10n |
|
|
|
// throw XmlValidationError(parser.getLine(), |
|
// "expected string type"); |
|
|
|
MessageLoaderParms mlParms("Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
|
"The EMBEDDEDOBJECT attribute is only valid on string types."); |
|
|
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
} |
|
#else |
|
if (String::equal(embeddedObject, "object")) |
|
{ |
|
// The EMBEDDEDOBJECT attribute is only valid on Parameters of type string |
|
// The type must have been specified. |
|
if (gotType && (type == CIMTYPE_STRING)) |
|
{ |
|
// Used below by getValueElement() or getValueArrayElement() |
|
effectiveType = CIMTYPE_OBJECT; |
|
} |
|
else |
|
{ |
|
// Error -- throw exception |
|
// (the EmbeddedObject attribute may be applied only to entities that have the type String) |
|
|
|
// l10n |
|
|
|
// throw XmlValidationError(parser.getLine(), |
|
// "expected string type"); |
|
|
|
MessageLoaderParms mlParms("Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
|
"The EMBEDDEDOBJECT attribute is only valid on string types."); |
|
|
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
} |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
|
if ( !XmlReader::getValueArrayElement(parser, effectiveType, value) && | if ( !XmlReader::getValueArrayElement(parser, effectiveType, value) && |
!XmlReader::getValueElement(parser, effectiveType, value) ) | !XmlReader::getValueElement(parser, effectiveType, value) ) |
{ | { |
|
gotType = false; // Can't distinguish array and non-array types |
value.clear(); // Isn't necessary; should already be cleared | value.clear(); // Isn't necessary; should already be cleared |
} | } |
|
|
} | } |
| |
expectEndTag(parser, "PARAMVALUE"); | expectEndTag(parser, "PARAMVALUE"); |
} | } |
| |
|
|
paramValue = CIMParamValue(name, value, gotType); | paramValue = CIMParamValue(name, value, gotType); |
| |
return true; | return true; |
|
|
// | // |
// <!ELEMENT RETURNVALUE (VALUE|VALUE.REFERENCE)> | // <!ELEMENT RETURNVALUE (VALUE|VALUE.REFERENCE)> |
// <!ATTLIST RETURNVALUE | // <!ATTLIST RETURNVALUE |
|
// %EmbeddedObject; #IMPLIED |
// %ParamType;> | // %ParamType;> |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
if (!testStartTag(parser, entry, "RETURNVALUE")) | if (!testStartTag(parser, entry, "RETURNVALUE")) |
return false; | return false; |
| |
|
// Get PROPERTY.EMBEDDEDOBJECT |
|
|
|
String embeddedObject = getEmbeddedObjectAttribute( |
|
parser.getLine(), entry, "RETURNVALUE"); |
|
|
// Get RETURNVALUE.PARAMTYPE attribute: | // Get RETURNVALUE.PARAMTYPE attribute: |
// NOTE: Array type return values are not allowed (2/20/02) | // NOTE: Array type return values are not allowed (2/20/02) |
| |
|
|
// If we don't know what type the value is, read it as a String | // If we don't know what type the value is, read it as a String |
type = CIMTYPE_STRING; | type = CIMTYPE_STRING; |
} | } |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
Boolean isEmbeddedObject = String::equal(embeddedObject, "object"); |
|
Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance"); |
|
if(isEmbeddedObject || isEmbeddedInstance) |
|
{ |
|
if (gotType && (type == CIMTYPE_STRING)) |
|
{ |
|
if(isEmbeddedObject) |
|
type = CIMTYPE_OBJECT; // Used below by getValueElement() or getValueArrayElement() |
|
else |
|
type = CIMTYPE_INSTANCE; |
|
} |
|
else |
|
{ |
|
// Error -- throw exception |
|
// (the EmbeddedObject attribute may be applied only to entities that have the type String) |
| |
|
// l10n |
|
|
|
// throw XmlValidationError(parser.getLine(), |
|
// "expected string type"); |
|
|
|
MessageLoaderParms mlParms("Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
|
"The EMBEDDEDOBJECT attribute is only valid on string types."); |
|
|
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
} |
|
#else |
|
if (String::equal(embeddedObject, "object")) |
|
{ |
|
if (gotType && (type == CIMTYPE_STRING)) |
|
{ |
|
type = CIMTYPE_OBJECT; // Used below by getValueElement() |
|
} |
|
else |
|
{ |
|
// Error -- throw exception |
|
// (the EmbeddedObject attribute may be applied only to entities that have the type String) |
|
|
|
// l10n |
|
|
|
// throw XmlValidationError(parser.getLine(), |
|
// "expected string type"); |
|
|
|
MessageLoaderParms mlParms("Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE", |
|
"The EMBEDDEDOBJECT attribute is only valid on string types."); |
|
|
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
} |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
if ( !XmlReader::getValueElement(parser, type, returnValue) ) | if ( !XmlReader::getValueElement(parser, type, returnValue) ) |
{ | { |
| |
|
|
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
|
|