version 1.144.4.3, 2012/02/21 17:22:10
|
version 1.144.4.4, 2013/06/03 22:35:14
|
|
|
| |
if (!CIMName::legal(name)) | if (!CIMName::legal(name)) |
{ | { |
#ifdef PEGASUS_SNIA_INTEROP_TEST |
|
// In testing, replace illegal CIMName with this value to avoid the |
|
// exception and let xml parsing continue. THIS IS TEMP. |
|
name = "BADNAMESUBSTITUTEDBYPEGASUSCLIENT"; |
|
#else |
|
|
|
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
sprintf(buffer, "%s.NAME", elementName); | sprintf(buffer, "%s.NAME", elementName); |
| |
|
|
buffer); | buffer); |
| |
throw XmlSemanticError(lineNumber, mlParms); | throw XmlSemanticError(lineNumber, mlParms); |
|
|
#endif |
|
} | } |
| |
return CIMNameCast(name); | return CIMNameCast(name); |
|
|
| |
if (!CIMName::legal(name)) | if (!CIMName::legal(name)) |
{ | { |
#ifdef PEGASUS_SNIA_INTEROP_TEST |
|
name = "PEGASUS_SUBSTITUED_THIS_FOR_BAD_NAME"; |
|
return name; |
|
#endif |
|
|
|
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
sprintf(buffer, "%s.REFERENCECLASS", elementName); | sprintf(buffer, "%s.REFERENCECLASS", elementName); |
| |
|
|
| |
try | try |
{ | { |
// KS 20021002 - Exception if no datetime value. Test for |
|
// zero length and leave the NULL value in the variable |
|
// Bugzilla 137 Adds the following if line. |
|
// Expect this to become permanent but test only for now |
|
#ifdef PEGASUS_SNIA_INTEROP_TEST |
|
if (valueStringLen != 0) | if (valueStringLen != 0) |
#endif |
{ |
tmp.set(valueString); | tmp.set(valueString); |
} | } |
|
} |
catch (InvalidDateTimeFormatException&) | catch (InvalidDateTimeFormatException&) |
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
|
|
| |
expectEndTag(parser, "VALUE"); | expectEndTag(parser, "VALUE"); |
} | } |
#ifdef PEGASUS_SNIA_INTEROP_TEST |
value = stringToValue(parser.getLine(),valueString,valueStringLen,type); |
// KS 20021004 - tries to put value in even if empty. |
|
// Think this is general problem with empty value |
|
// Need to check meaning of (#PCDATA) - Does it allow empty. |
|
// Bugzilla tbd |
|
if (!empty) |
|
#endif |
|
value = stringToValue( |
|
parser.getLine(), |
|
valueString, |
|
valueStringLen, |
|
type); |
|
| |
return true; | return true; |
} | } |
|
|
// EXP_PULL_BEGIN | // EXP_PULL_BEGIN |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
// getUint32ValueElement() |
// getUint32ArgValueElement() |
// | // |
// <!ELEMENT VALUE (#PCDATA)> | // <!ELEMENT VALUE (#PCDATA)> |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
Boolean XmlReader::getUint32ValueElement( |
Boolean XmlReader::getUint32ArgValueElement( |
XmlParser& parser, | XmlParser& parser, |
Uint32Arg& val, | Uint32Arg& val, |
Boolean required) | Boolean required) |
|
|
} | } |
| |
Uint64 x; | Uint64 x; |
// EXP_PULL clean this up |
// EXP_PULL clean this up KS_TODO |
if (!StringConversion::stringToUnsignedInteger(valueString, x)) | if (!StringConversion::stringToUnsignedInteger(valueString, x)) |
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
|
|
| |
return true; | return true; |
} | } |
|
|
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// getUint32ValueElement() |
|
// |
|
// <!ELEMENT VALUE (#PCDATA)> |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::getUint32ValueElement( |
|
XmlParser& parser, |
|
Uint32& val, |
|
Boolean required) |
|
{ |
|
XmlEntry entry; |
|
|
|
if (!testStartTagOrEmptyTag(parser, entry, "VALUE")) |
|
{ |
|
if (required) |
|
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_VALUE_ELEMENT", |
|
"Expected VALUE element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
return false; |
|
} |
|
|
|
Boolean empty = entry.type == XmlEntry::EMPTY_TAG; |
|
|
|
const char* valueString = ""; |
|
|
|
if (!empty) |
|
{ |
|
if (testContentOrCData(parser, entry)) |
|
valueString = entry.text; |
|
|
|
expectEndTag(parser, "VALUE"); |
|
} |
|
else |
|
{ |
|
// leave the existing value |
|
return true; |
|
} |
|
|
|
//convert to Uint32. Note error if overflow. |
|
|
|
Uint64 x; |
|
if (!StringConversion::stringToUnsignedInteger(valueString, x)) |
|
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.INVALID_UI_VALUE", |
|
"Invalid unsigned integer value"); |
|
throw XmlSemanticError(parser.getLine(), mlParms); |
|
} |
|
|
|
if (!StringConversion::checkUintBounds(x, CIMTYPE_UINT32)) |
|
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.U32_VALUE_OUT_OF_RANGE", |
|
"Uint32 value out of range"); |
|
throw XmlSemanticError(parser.getLine(), mlParms); |
|
} |
|
// create the arg object with the value in it. |
|
val = x; |
|
|
|
return true; |
|
} |
//EXP_PULL_END | //EXP_PULL_END |
| |
//---------------------------------------------------------------------------- | //---------------------------------------------------------------------------- |
|
|
| |
if (!testStartTag(parser, entry, "HOST")) | if (!testStartTag(parser, entry, "HOST")) |
return false; | return false; |
#ifdef PEGASUS_SNIA_INTEROP_TEST |
|
// Temp code to allow empty HOST field. |
|
// SNIA CIMOMs return empty field particularly on enumerateinstance. |
|
// Simply substitute a string for the empty. |
|
if (!parser.next(entry)) |
|
throw XmlException(XmlException::UNCLOSED_TAGS, parser.getLine()); |
|
|
|
if (entry.type == XmlEntry::CONTENT) |
|
host = String(entry.text); |
|
else |
|
{ |
|
parser.putBack(entry); |
|
host = "HOSTNAMEINSERTEDBYPEGASUSCLIENT"; |
|
} |
|
|
|
#else |
|
| |
if (!parser.next(entry) || entry.type != XmlEntry::CONTENT) | if (!parser.next(entry) || entry.type != XmlEntry::CONTENT) |
{ | { |
|
|
} | } |
| |
host = String(entry.text); | host = String(entry.text); |
#endif |
|
expectEndTag(parser, "HOST"); | expectEndTag(parser, "HOST"); |
return true; | return true; |
} | } |
|
|
else | else |
{ | { |
while (getKeyBindingElement(parser, name, value, type)) | while (getKeyBindingElement(parser, name, value, type)) |
|
{ |
keyBindings.append(CIMKeyBinding(name, value, type)); | keyBindings.append(CIMKeyBinding(name, value, type)); |
|
if (keyBindings.size() > PEGASUS_MAXELEMENTS_NUM) |
|
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.TOO_MANY_KEYBINDINGS", |
|
"More than $0 key-value pairs per object path" |
|
" are not supported.", |
|
PEGASUS_MAXELEMENTS_NUM); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
} |
} | } |
| |
expectEndTag(parser, "INSTANCENAME"); | expectEndTag(parser, "INSTANCENAME"); |
|
|
// | // |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
// |
|
// Parses the input to a CIMObjectPath. Note that today the differences |
|
// between ClassPath and InstancePath are lost in this mapping because |
|
// Pegasus uses the existence of keys as separator . See BUG_3302 |
Boolean XmlReader::getValueReferenceElement( | Boolean XmlReader::getValueReferenceElement( |
XmlParser& parser, | XmlParser& parser, |
CIMObjectPath& reference) | CIMObjectPath& reference) |
|
|
// Get ARRAYSIZE attribute: | // Get ARRAYSIZE attribute: |
| |
Uint32 arraySize = 0; | Uint32 arraySize = 0; |
Boolean gotArraySize = getArraySizeAttribute(parser.getLine(), |
getArraySizeAttribute(parser.getLine(), |
entry, "QUALIFIER.DECLARATION", arraySize); | entry, "QUALIFIER.DECLARATION", arraySize); |
| |
// Get flavor oriented attributes: | // Get flavor oriented attributes: |
|
|
CIMObjectPath instanceName; | CIMObjectPath instanceName; |
| |
// Get INSTANCENAME elements: | // Get INSTANCENAME elements: |
//EXP_PULL_ISSUE Should we have new getInstancePathElement??? |
//EXP_PULL_ISSUE Should we have new getInstancePathElement??? KS_TODO |
if (!getInstancePathElement(parser, instanceName)) | if (!getInstancePathElement(parser, instanceName)) |
{ | { |
MessageLoaderParms mlParms( | MessageLoaderParms mlParms( |
|
|
// getIReturnValueTag() | // getIReturnValueTag() |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
////EXP_PULL Think we can get rid of this TBD |
////EXP_PULL Think we can get rid of this KS_TODO |
Boolean XmlReader::getIReturnValueTag( | Boolean XmlReader::getIReturnValueTag( |
XmlParser& parser, | XmlParser& parser, |
const char*& name, | const char*& name, |
|
|
"Missing IRETURNVALUE.NAME attribute"); | "Missing IRETURNVALUE.NAME attribute"); |
throw XmlValidationError(parser.getLine(), mlParms); | throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
// EXP_PULL_TBD Add new msg above to msg bundle. |
// EXP_PULL_TBD Add new msg above to msg bundle. KS_TODO |
return true; | return true; |
} | } |
| |
|
|
throw XmlValidationError(parser.getLine(), mlParms); | throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
} | } |
// EXP_PULL_TODO_TBD add above message to bundle |
// EXP_PULL_TODO_TBD add above message to bundle KS_TODO |
// EXP_PULL_END | // EXP_PULL_END |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
|
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
|
// Returns true if ClassNameElement or false if InstanceNameElement |
|
// Parse errors always throw exception |
Boolean XmlReader::getObjectNameElement( | Boolean XmlReader::getObjectNameElement( |
XmlParser& parser, | XmlParser& parser, |
CIMObjectPath& objectName) | CIMObjectPath& objectName) |
|
|
if (getClassNameElement(parser, className, false)) | if (getClassNameElement(parser, className, false)) |
{ | { |
objectName.set(String(), CIMNamespaceName(), className); | objectName.set(String(), CIMNamespaceName(), className); |
|
|
|
// Return flag indicating this is ClassNameElement |
return true; | return true; |
} | } |
| |
|
|
throw XmlValidationError(parser.getLine(), mlParms); | throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
return true; |
// Return flag indicating this is InstanceNameElement |
|
return false; |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |