version 1.127.4.3, 2009/03/23 15:11:15
|
version 1.131, 2008/08/12 19:36:13
|
|
|
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
|
#include <Pegasus/Common/Constants.h> |
#include <errno.h> | #include <errno.h> |
#include <cctype> | #include <cctype> |
#include <cstdio> | #include <cstdio> |
|
|
if (!entry.getAttributeValue("CLASSORIGIN", name)) | if (!entry.getAttributeValue("CLASSORIGIN", name)) |
return CIMName(); | return CIMName(); |
| |
/* Interoperability hack to make the C++ client of OpenPegasus able |
|
to deal with the wbemservices CIMOM delivered with Sun Solaris. |
|
The issue is that the wbemservices delivers Xml responses with |
|
CLASSORIGIN="" |
|
Originally this had been reported with Bug#537. |
|
*/ |
|
if (name.size()==0) |
|
{ |
|
return CIMName(); |
|
} |
|
|
|
if (!CIMName::legal(name)) | if (!CIMName::legal(name)) |
{ | { |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
|
|
buffer); | buffer); |
throw XmlSemanticError(lineNumber, mlParms); | throw XmlSemanticError(lineNumber, mlParms); |
} | } |
|
// The CIMName was already checked with legal() + String() |
return name; |
return CIMNameUnchecked(name); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
// | // |
// <!ENTITY % EmbeddedObject "EmbeddedObject (object | instance) #IMPLIED"> | // <!ENTITY % EmbeddedObject "EmbeddedObject (object | instance) #IMPLIED"> |
// | // |
|
// EmbeddedObjectAttributeType: |
|
// NO_EMBEDDED_OBJECT = 0, |
|
// EMBEDDED_OBJECT_ATTR = 1, |
|
// EMBEDDED_INSTANCE_ATTR = 2 |
|
// |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
String XmlReader::getEmbeddedObjectAttribute( |
XmlReader::EmbeddedObjectAttributeType XmlReader::getEmbeddedObjectAttribute( |
Uint32 lineNumber, | Uint32 lineNumber, |
const XmlEntry& entry, | const XmlEntry& entry, |
const char* elementName) |
const char* tagName) |
{ | { |
String embeddedObject; |
const char* embeddedObject; |
| |
// Check for both upper case and mixed case "EmbeddedObject" | // Check for both upper case and mixed case "EmbeddedObject" |
// because of an error in an earlier pegasus version where we | // because of an error in an earlier pegasus version where we |
|
|
// whereas the DMTF spec calls for mixed case. | // whereas the DMTF spec calls for mixed case. |
if (!entry.getAttributeValue("EmbeddedObject", embeddedObject) && | if (!entry.getAttributeValue("EmbeddedObject", embeddedObject) && |
!entry.getAttributeValue("EMBEDDEDOBJECT", embeddedObject)) | !entry.getAttributeValue("EMBEDDEDOBJECT", embeddedObject)) |
return String(); |
return NO_EMBEDDED_OBJECT; |
| |
// The embeddedObject attribute, if present, must have the string | // The embeddedObject attribute, if present, must have the string |
// value "object" or "instance". | // value "object" or "instance". |
if (!(String::equal(embeddedObject, "object") || |
if (strcmp(embeddedObject, "object") == 0) |
String::equal(embeddedObject, "instance"))) |
{ |
|
return EMBEDDED_OBJECT_ATTR; |
|
} |
|
|
|
if (strcmp(embeddedObject, "instance") == 0) |
{ | { |
|
return EMBEDDED_INSTANCE_ATTR; |
|
} |
|
|
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
sprintf(buffer, "%s.EmbeddedObject", elementName); |
sprintf(buffer, "%s.EmbeddedObject", tagName); |
| |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
"Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE", | "Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE", |
"Illegal value for $0 attribute", | "Illegal value for $0 attribute", |
buffer); | buffer); |
throw XmlSemanticError(lineNumber, mlParms); | throw XmlSemanticError(lineNumber, mlParms); |
} |
|
| |
return embeddedObject; |
return NO_EMBEDDED_OBJECT; |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
buffer); | buffer); |
throw XmlSemanticError(lineNumber, mlParms); | throw XmlSemanticError(lineNumber, mlParms); |
} | } |
|
// The CIMName was already checked with legal() + String() |
return name; |
return CIMNameUnchecked(name); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
buffer); | buffer); |
throw XmlSemanticError(lineNumber, mlParms); | throw XmlSemanticError(lineNumber, mlParms); |
} | } |
|
// The CIMName was already checked with legal() + String() |
return superClass; |
return CIMNameUnchecked(superClass); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
| |
// Get PROPERTY.EmbeddedObject attribute: | // Get PROPERTY.EmbeddedObject attribute: |
| |
String embeddedObject = getEmbeddedObjectAttribute( |
EmbeddedObjectAttributeType embeddedObject = |
parser.getLine(), entry, "PROPERTY"); |
getEmbeddedObjectAttribute(parser.getLine(), entry, "PROPERTY"); |
| |
// Get PROPERTY.TYPE attribute: | // Get PROPERTY.TYPE attribute: |
| |
|
|
} | } |
| |
Boolean embeddedObjectQualifierValue = false; | Boolean embeddedObjectQualifierValue = false; |
Uint32 ix = property.findQualifier(CIMName("EmbeddedObject")); |
Uint32 ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT); |
if (ix != PEG_NOT_FOUND) | if (ix != PEG_NOT_FOUND) |
{ | { |
property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue); | property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue); |
} | } |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT | #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
String embeddedInstanceQualifierValue; | String embeddedInstanceQualifierValue; |
ix = property.findQualifier(CIMName("EmbeddedInstance")); |
ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE); |
if (ix != PEG_NOT_FOUND) | if (ix != PEG_NOT_FOUND) |
{ | { |
property.getQualifier(ix).getValue().get( | property.getQualifier(ix).getValue().get( |
|
|
// or the EmbeddedObject qualifier exists on this property with value "true" | // or the EmbeddedObject qualifier exists on this property with value "true" |
// then convert the EmbeddedObject-encoded string into a CIMObject | // then convert the EmbeddedObject-encoded string into a CIMObject |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT | #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
Boolean isEmbeddedObject = String::equal(embeddedObject, "object") || |
Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) || |
embeddedObjectQualifierValue; | embeddedObjectQualifierValue; |
Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance") || |
Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) || |
embeddedInstanceQualifierValue.size() > 0; | embeddedInstanceQualifierValue.size() > 0; |
if (isEmbeddedObject || isEmbeddedInstance) | if (isEmbeddedObject || isEmbeddedInstance) |
{ | { |
|
|
| |
// Copy the qualifiers from the String property to the CIMObject | // Copy the qualifiers from the String property to the CIMObject |
// property. | // property. |
for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix) |
for (Uint32 i = 0; i < property.getQualifierCount(); ++i) |
{ | { |
// All properties are copied, including the EmbeddedObject | // All properties are copied, including the EmbeddedObject |
// qualifier. This way we don't have to keep track to know | // qualifier. This way we don't have to keep track to know |
// that the EmbeddedObject qualifier needs to be added back | // that the EmbeddedObject qualifier needs to be added back |
// during the encode step. | // during the encode step. |
new_property.addQualifier(property.getQualifier(ix)); |
new_property.addQualifier(property.getQualifier(i)); |
} | } |
| |
value = new_value; | value = new_value; |
|
|
} | } |
} | } |
#else | #else |
if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue) |
if ((embeddedObject == EMBEDDED_OBJECT_ATTR)|| embeddedObjectQualifierValue) |
{ | { |
// The EmbeddedObject attribute is only valid on Properties of type | // The EmbeddedObject attribute is only valid on Properties of type |
// string | // string |
|
|
| |
// Copy the qualifiers from the String property to the CIMObject | // Copy the qualifiers from the String property to the CIMObject |
// property. | // property. |
for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix) |
for (Uint32 i = 0; i < property.getQualifierCount(); ++i) |
{ | { |
// All properties are copied, including the EmbeddedObject | // All properties are copied, including the EmbeddedObject |
// qualifier. This way we don't have to keep track to know | // qualifier. This way we don't have to keep track to know |
// that the EmbeddedObject qualifier needs to be added back | // that the EmbeddedObject qualifier needs to be added back |
// during the encode step. | // during the encode step. |
new_property.addQualifier(property.getQualifier(ix)); |
new_property.addQualifier(property.getQualifier(i)); |
} | } |
| |
value = new_value; | value = new_value; |
|
|
| |
// Get PROPERTY.EmbeddedObject attribute: | // Get PROPERTY.EmbeddedObject attribute: |
| |
String embeddedObject = getEmbeddedObjectAttribute( |
EmbeddedObjectAttributeType embeddedObject = getEmbeddedObjectAttribute( |
parser.getLine(), entry, "PROPERTY.ARRAY"); | parser.getLine(), entry, "PROPERTY.ARRAY"); |
| |
// Create property: | // Create property: |
|
|
} | } |
| |
Boolean embeddedObjectQualifierValue = false; | Boolean embeddedObjectQualifierValue = false; |
Uint32 ix = property.findQualifier(CIMName("EmbeddedObject")); |
Uint32 ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT); |
if (ix != PEG_NOT_FOUND) | if (ix != PEG_NOT_FOUND) |
{ | { |
property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue); | property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue); |
} | } |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT | #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
String embeddedInstanceQualifierValue; | String embeddedInstanceQualifierValue; |
ix = property.findQualifier(CIMName("EmbeddedInstance")); |
ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE); |
if (ix != PEG_NOT_FOUND) | if (ix != PEG_NOT_FOUND) |
{ | { |
property.getQualifier(ix).getValue().get( | property.getQualifier(ix).getValue().get( |
|
|
// then | // then |
// Convert the EmbeddedObject-encoded string into a CIMObject | // Convert the EmbeddedObject-encoded string into a CIMObject |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT | #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
Boolean isEmbeddedObject = String::equal(embeddedObject, "object") || |
Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) || |
embeddedObjectQualifierValue; | embeddedObjectQualifierValue; |
Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance") || |
Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) || |
embeddedInstanceQualifierValue.size() > 0; | embeddedInstanceQualifierValue.size() > 0; |
if (isEmbeddedObject || isEmbeddedInstance) | if (isEmbeddedObject || isEmbeddedInstance) |
{ | { |
|
|
| |
// Copy the qualifiers from the String property to the CIMObject | // Copy the qualifiers from the String property to the CIMObject |
// property. | // property. |
for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix) |
for (Uint32 i = 0; i < property.getQualifierCount(); ++i) |
{ | { |
// All properties are copied, including the EmbeddedObject | // All properties are copied, including the EmbeddedObject |
// qualifier. This way we don't have to keep track to know | // qualifier. This way we don't have to keep track to know |
// that the EmbeddedObject qualifier needs to be added back | // that the EmbeddedObject qualifier needs to be added back |
// during the encode step. | // during the encode step. |
new_property.addQualifier(property.getQualifier(ix)); |
new_property.addQualifier(property.getQualifier(i)); |
} | } |
| |
value = new_value; | value = new_value; |
|
|
} | } |
} | } |
#else | #else |
if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue) |
if ((embeddedObject == EMBEDDED_OBJECT_ATTR)||embeddedObjectQualifierValue) |
{ | { |
// The EmbeddedObject attribute is only valid on Properties of type | // The EmbeddedObject attribute is only valid on Properties of type |
// string | // string |
|
|
| |
// Copy the qualifiers from the String property to the CIMObject | // Copy the qualifiers from the String property to the CIMObject |
// property. | // property. |
for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix) |
for (Uint32 i = 0; i < property.getQualifierCount(); ++i) |
{ | { |
// All properties are copied, including the EmbeddedObject | // All properties are copied, including the EmbeddedObject |
// qualifier. This way we don't have to keep track to know | // qualifier. This way we don't have to keep track to know |
// that the EmbeddedObject qualifier needs to be added back | // that the EmbeddedObject qualifier needs to be added back |
// during the encode step. | // during the encode step. |
new_property.addQualifier(property.getQualifier(ix)); |
new_property.addQualifier(property.getQualifier(i)); |
} | } |
| |
value = new_value; | value = new_value; |
|
|
const XmlEntry& entry, | const XmlEntry& entry, |
const char* elementName) | const char* elementName) |
{ | { |
String tmp; |
const char* tmp; |
| |
if (!entry.getAttributeValue("VALUETYPE", tmp)) | if (!entry.getAttributeValue("VALUETYPE", tmp)) |
return CIMKeyBinding::STRING; | return CIMKeyBinding::STRING; |
| |
if (String::equal(tmp, "string")) |
if (strcmp(tmp, "string") == 0) |
return CIMKeyBinding::STRING; | return CIMKeyBinding::STRING; |
else if (String::equal(tmp, "boolean")) |
else if (strcmp(tmp, "boolean") == 0) |
return CIMKeyBinding::BOOLEAN; | return CIMKeyBinding::BOOLEAN; |
else if (String::equal(tmp, "numeric")) |
else if (strcmp(tmp, "numeric") == 0) |
return CIMKeyBinding::NUMERIC; | return CIMKeyBinding::NUMERIC; |
| |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
|
|
| |
// Get PROPERTY.EmbeddedObject | // Get PROPERTY.EmbeddedObject |
| |
String embeddedObject = getEmbeddedObjectAttribute( |
EmbeddedObjectAttributeType embeddedObject = getEmbeddedObjectAttribute( |
parser.getLine(), entry, "PARAMVALUE"); | parser.getLine(), entry, "PARAMVALUE"); |
| |
// Get PARAMVALUE.PARAMTYPE attribute: | // Get PARAMVALUE.PARAMTYPE attribute: |
|
|
// then | // then |
// Convert the EmbeddedObject-encoded string into a CIMObject | // Convert the EmbeddedObject-encoded string into a CIMObject |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT | #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
Boolean isEmbeddedObject = String::equal(embeddedObject, "object"); |
if (embeddedObject != NO_EMBEDDED_OBJECT) |
Boolean isEmbeddedInstance = |
|
String::equal(embeddedObject, "instance"); |
|
if (isEmbeddedObject || isEmbeddedInstance) |
|
{ | { |
// The EmbeddedObject attribute is only valid on Parameters | // The EmbeddedObject attribute is only valid on Parameters |
// of type string | // of type string |
// The type must have been specified. | // The type must have been specified. |
if (gotType && (type == CIMTYPE_STRING)) | if (gotType && (type == CIMTYPE_STRING)) |
{ | { |
if (isEmbeddedObject) |
if (embeddedObject == EMBEDDED_OBJECT_ATTR) |
// Used below by getValueElement() or | // Used below by getValueElement() or |
// getValueArrayElement() | // getValueArrayElement() |
effectiveType = CIMTYPE_OBJECT; | effectiveType = CIMTYPE_OBJECT; |
|
|
} | } |
} | } |
#else | #else |
if (String::equal(embeddedObject, "object")) |
if (embeddedObject == EMBEDDED_OBJECT_ATTR) |
{ | { |
// The EmbeddedObject attribute is only valid on Parameters | // The EmbeddedObject attribute is only valid on Parameters |
// of type string | // of type string |
|
|
| |
// Get PROPERTY.EmbeddedObject | // Get PROPERTY.EmbeddedObject |
| |
String embeddedObject = getEmbeddedObjectAttribute( |
EmbeddedObjectAttributeType embeddedObject = getEmbeddedObjectAttribute( |
parser.getLine(), entry, "RETURNVALUE"); | parser.getLine(), entry, "RETURNVALUE"); |
| |
// Get RETURNVALUE.PARAMTYPE attribute: | // Get RETURNVALUE.PARAMTYPE attribute: |
|
|
type = CIMTYPE_STRING; | type = CIMTYPE_STRING; |
} | } |
#ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT | #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT |
Boolean isEmbeddedObject = String::equal(embeddedObject, "object"); |
if (embeddedObject != NO_EMBEDDED_OBJECT) |
Boolean isEmbeddedInstance = String::equal(embeddedObject, "instance"); |
|
if (isEmbeddedObject || isEmbeddedInstance) |
|
{ | { |
if (gotType && (type == CIMTYPE_STRING)) | if (gotType && (type == CIMTYPE_STRING)) |
{ | { |
if (isEmbeddedObject) |
if (embeddedObject == EMBEDDED_OBJECT_ATTR) |
// Used below by getValueElement() or getValueArrayElement() | // Used below by getValueElement() or getValueArrayElement() |
type = CIMTYPE_OBJECT; | type = CIMTYPE_OBJECT; |
else | else |
|
|
} | } |
} | } |
#else | #else |
if (String::equal(embeddedObject, "object")) |
if (embeddedObject == EMBEDDED_OBJECT_ATTR) |
{ | { |
if (gotType && (type == CIMTYPE_STRING)) | if (gotType && (type == CIMTYPE_STRING)) |
{ | { |