version 1.107, 2005/02/06 21:13:14
|
version 1.111, 2005/03/15 05:41:45
|
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// 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 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: |
|
{ |
|
CIMObject x; |
|
|
|
if (*valueString == '\0') |
|
{ |
|
x = CIMObject(); |
|
} |
|
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. |
|
char* tmp_buffer = new char[strlen(valueString) + 1]; |
|
strcpy(tmp_buffer, valueString); |
|
XmlParser tmp_parser(tmp_buffer); |
|
|
|
// 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)) |
|
{ |
|
x = CIMObject(cimInstance); |
|
} |
|
else if (XmlReader::getClassElement(tmp_parser, cimClass)) |
|
{ |
|
x = CIMObject(cimClass); |
|
} |
|
else |
|
{ |
|
// l10n |
|
|
|
// throw XmlValidationError(parser.getLine(), |
|
// "Expected INSTANCE or CLASS element"); |
|
|
|
MessageLoaderParms mlParms("Common.XmlReader.EXPECTED_INSTANCE_OR_CLASS_ELEMENT", |
|
"Expected INSTANCE or CLASS element"); // change "element" to "embedded object" |
|
|
|
throw XmlValidationError(lineNumber, mlParms); |
|
|
|
} |
|
// Ok, now we can delete the storage for the temporary XmlParser. |
|
delete [] tmp_buffer; |
|
} |
|
return CIMValue(x); |
|
} |
|
|
default: | default: |
break; | break; |
} | } |
|
|
| |
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"); |
} | } |
|
|
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); |
|
|
default: | default: |
break; | break; |
} | } |
|
|
// %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); |
|
} |
|
|
|
// 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 |
|
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); |
| |
// Get value: Insert value if getValueElement exists (returns True) |
// 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); |
|
} |
|
} |
|
|
|
// 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); |
|
} |
|
|
|
// 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 |
|
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); |
|
} |
|
} |
|
|
|
// 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"); |
} | } |
| |
|
|
| |
} | } |
| |
return false; |
PEGASUS_UNREACHABLE( return false; ) |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
// <!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;> |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
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: |
| |
|
|
effectiveType = type; | effectiveType = type; |
} | } |
| |
|
// If the EMBEDDEDOBJECT attribute is present with value "object" |
|
// then |
|
// Convert the EmbeddedObject-encoded string into a CIMObject |
|
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)) |
|
{ |
|
type = CIMTYPE_OBJECT; // Used below by getValueElement() or getValueArrayElement() |
|
} |
|
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); |
|
} |
|
} |
|
|
if ( !XmlReader::getValueArrayElement(parser, effectiveType, value) && | if ( !XmlReader::getValueArrayElement(parser, effectiveType, value) && |
!XmlReader::getValueElement(parser, effectiveType, value) ) | !XmlReader::getValueElement(parser, effectiveType, value) ) |
{ | { |
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) |
| |
|
|
type = CIMTYPE_STRING; | type = CIMTYPE_STRING; |
} | } |
| |
|
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); |
|
} |
|
} |
|
|
if ( !XmlReader::getValueElement(parser, type, returnValue) ) | if ( !XmlReader::getValueElement(parser, type, returnValue) ) |
{ | { |
| |