version 1.117, 2006/03/03 20:31:25
|
version 1.121, 2006/10/30 13:02:53
|
|
|
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
|
#include <errno.h> |
#include <cctype> | #include <cctype> |
#include <cstdio> | #include <cstdio> |
#include <cstdlib> | #include <cstdlib> |
|
|
#include "System.h" | #include "System.h" |
#include "XmlConstants.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> |
|
|
// Pegasus internal representation of an embedded object. However, this case is | // Pegasus internal representation of an embedded object. However, this case is |
// used when decoding string representations of embedded objects. | // used when decoding string representations of embedded objects. |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
case CIMTYPE_INSTANCE: |
|
#endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
{ | { |
CIMObject x; | CIMObject x; |
| |
if (*valueString == '\0') | if (*valueString == '\0') |
{ | { |
return CIMValue(CIMTYPE_OBJECT, false, 0); |
return CIMValue(type, false, 0); |
} | } |
else | else |
{ | { |
|
|
| |
if (XmlReader::getInstanceElement(tmp_parser, cimInstance)) | 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); | x = CIMObject(cimInstance); |
} | } |
else if (XmlReader::getClassElement(tmp_parser, cimClass)) | else if (XmlReader::getClassElement(tmp_parser, cimClass)) |
|
|
| |
// throw XmlValidationError(parser.getLine(), | // throw XmlValidationError(parser.getLine(), |
// "Expected INSTANCE or CLASS element"); | // "Expected INSTANCE or CLASS element"); |
|
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
|
if(type == CIMTYPE_OBJECT) |
|
{ |
MessageLoaderParms mlParms("Common.XmlReader.EXPECTED_INSTANCE_OR_CLASS_ELEMENT", | MessageLoaderParms mlParms("Common.XmlReader.EXPECTED_INSTANCE_OR_CLASS_ELEMENT", |
"Expected INSTANCE or CLASS element"); // change "element" to "embedded object" | "Expected INSTANCE or CLASS element"); // change "element" to "embedded object" |
| |
throw XmlValidationError(lineNumber, mlParms); | 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. | // Ok, now we can delete the storage for the temporary XmlParser. |
tmp_buffer.reset(); | tmp_buffer.reset(); |
|
|
// used when decoding string representations of embedded objects. | // used when decoding string representations of embedded objects. |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
return StringArrayToValueAux(lineNumber, array, type, (CIMObject*)0); | 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; |
|
|
{ | { |
property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue); | 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" | // If the EMBEDDEDOBJECT attribute is present with value "object" |
// or the EmbeddedObject qualifier exists on this property with value "true" | // or the EmbeddedObject qualifier exists on this property with value "true" |
// then | // then |
// Convert the EmbeddedObject-encoded string into a CIMObject | // Convert the EmbeddedObject-encoded string into a CIMObject |
if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue) |
#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 | // The EMBEDDEDOBJECT attribute is only valid on Properties of type string |
if (type == CIMTYPE_STRING) | if (type == CIMTYPE_STRING) |
{ | { |
|
if(isEmbeddedObject) |
type = CIMTYPE_OBJECT; | type = CIMTYPE_OBJECT; |
|
else |
|
type = CIMTYPE_INSTANCE; |
CIMValue new_value(type, false); | CIMValue new_value(type, false); |
CIMProperty new_property = CIMProperty(name, new_value, 0, CIMName(), classOrigin, propagated); | CIMProperty new_property = CIMProperty(name, new_value, 0, CIMName(), classOrigin, propagated); |
| |
|
|
throw XmlValidationError(parser.getLine(), mlParms); | 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)); |
|
} |
|
|
|
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. | // Continue on to get property value, if not empty. |
if (!empty) | if (!empty) |
{ | { |
|
|
{ | { |
property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue); | 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" | // If the EMBEDDEDOBJECT attribute is present with value "object" |
// or the EmbeddedObject qualifier exists on this property with value "true" | // or the EmbeddedObject qualifier exists on this property with value "true" |
// then | // then |
// Convert the EmbeddedObject-encoded string into a CIMObject | // Convert the EmbeddedObject-encoded string into a CIMObject |
if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue) |
#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 | // The EMBEDDEDOBJECT attribute is only valid on Properties of type string |
if (type == CIMTYPE_STRING) | if (type == CIMTYPE_STRING) |
{ | { |
|
if(isEmbeddedObject) |
type = CIMTYPE_OBJECT; | type = CIMTYPE_OBJECT; |
|
else |
|
type = CIMTYPE_INSTANCE; |
CIMValue new_value(type, true, arraySize); | CIMValue new_value(type, true, arraySize); |
CIMProperty new_property = CIMProperty(name, new_value, arraySize, CIMName(), classOrigin, propagated); | CIMProperty new_property = CIMProperty(name, new_value, arraySize, CIMName(), classOrigin, propagated); |
| |
|
|
throw XmlValidationError(parser.getLine(), mlParms); | 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. | // Continue on to get property array value, if not empty. |
// Else not an embedded object, if not empty, get the property array value. | // Else not an embedded object, if not empty, get the property array value. |
if (!empty) | if (!empty) |
|
|
| |
entry.getAttributeValue("DESCRIPTION", tmpDescription); | entry.getAttributeValue("DESCRIPTION", tmpDescription); |
| |
|
cimException = |
|
PEGASUS_CIM_EXCEPTION(CIMStatusCode(tmpCode), tmpDescription); |
|
|
if (!empty) | if (!empty) |
{ | { |
while (testStartTagOrEmptyTag(parser, entry)) |
CIMInstance instance; |
|
|
|
while (getInstanceElement(parser, instance)) |
{ | { |
skipElement(parser, entry); |
cimException.addError(instance); |
} | } |
| |
expectEndTag(parser, "ERROR"); | expectEndTag(parser, "ERROR"); |
} | } |
| |
cimException = PEGASUS_CIM_EXCEPTION(CIMStatusCode(tmpCode), tmpDescription); |
|
return true; | return true; |
} | } |
| |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// getValueObjectElement() | // getValueObjectElement() |
// | // |
|
|
// If the EMBEDDEDOBJECT attribute is present with value "object" | // If the EMBEDDEDOBJECT attribute is present with value "object" |
// then | // then |
// Convert the EmbeddedObject-encoded string into a CIMObject | // 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")) | if (String::equal(embeddedObject, "object")) |
{ | { |
// The EMBEDDEDOBJECT attribute is only valid on Parameters of type string | // The EMBEDDEDOBJECT attribute is only valid on Parameters of type string |
|
|
throw XmlValidationError(parser.getLine(), mlParms); | 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) ) |
|
|
// 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 (String::equal(embeddedObject, "object")) |
{ | { |
if (gotType && (type == CIMTYPE_STRING)) | if (gotType && (type == CIMTYPE_STRING)) |
|
|
throw XmlValidationError(parser.getLine(), mlParms); | 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 |
|
|