version 1.70, 2002/08/25 06:43:56
|
version 1.146, 2012/08/30 14:49:11
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%LICENSE//////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// Licensed to The Open Group (TOG) under one or more contributor license |
// The Open Group, Tivoli Systems |
// agreements. Refer to the OpenPegasusNOTICE.txt file distributed with |
|
// this work for additional information regarding copyright ownership. |
|
// Each contributor licenses this file to you under the OpenPegasus Open |
|
// Source License; you may not use this file except in compliance with the |
|
// License. |
|
// |
|
// Permission is hereby granted, free of charge, to any person obtaining a |
|
// copy of this software and associated documentation files (the "Software"), |
|
// to deal in the Software without restriction, including without limitation |
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
// and/or sell copies of the Software, and to permit persons to whom the |
|
// Software is furnished to do so, subject to the following conditions: |
|
// |
|
// The above copyright notice and this permission notice shall be included |
|
// in all copies or substantial portions of the Software. |
|
// |
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
////////////////////////////////////////////////////////////////////////// |
// of this software and associated documentation files (the "Software"), to |
|
// deal in the Software without restriction, including without limitation the |
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
|
// sell copies of the Software, and to permit persons to whom the Software is |
|
// furnished to do so, subject to the following conditions: |
|
// |
|
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN |
|
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED |
|
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
|
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
|
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
// |
|
//============================================================================== |
|
// |
|
// Author: Mike Brasher (mbrasher@bmc.com) |
|
// |
|
// Modified By: Carol Ann Krug Graves, Hewlett-Packard Company |
|
// (carolann_graves@hp.com) |
|
// Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) |
|
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
|
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
|
#include <Pegasus/Common/Constants.h> |
|
#include <errno.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 "CIMNameCast.h" |
#include "XmlReader.h" | #include "XmlReader.h" |
#include "XmlWriter.h" | #include "XmlWriter.h" |
#include "CIMQualifier.h" | #include "CIMQualifier.h" |
|
|
#include "CIMInstance.h" | #include "CIMInstance.h" |
#include "CIMObject.h" | #include "CIMObject.h" |
#include "CIMParamValue.h" | #include "CIMParamValue.h" |
|
#include "System.h" |
|
#include "XmlConstants.h" |
| |
//#define PEGASUS_SINT64_MIN (-PEGASUS_SINT64_LITERAL(9223372036854775808)) |
#include <Pegasus/Common/MessageLoader.h> |
//#define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL(18446744073709551615) |
#include <Pegasus/Common/StringConversion.h> |
#define PEGASUS_SINT64_MIN (-PEGASUS_SINT64_LITERAL((Sint64) 0x8000000000000000)) |
#include <Pegasus/Common/AutoPtr.h> |
#define PEGASUS_UINT64_MAX PEGASUS_UINT64_LITERAL((Uint64) 0xFFFFFFFFFFFFFFFF) |
|
| |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
|
|
entry.type != XmlEntry::XML_DECLARATION || | entry.type != XmlEntry::XML_DECLARATION || |
strcmp(entry.text, "xml") != 0) | strcmp(entry.text, "xml") != 0) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_XML_STYLE", |
"Expected <?xml ... ?> style declaration"); | "Expected <?xml ... ?> style declaration"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
if (!entry.getAttributeValue("version", xmlVersion)) | if (!entry.getAttributeValue("version", xmlVersion)) |
throw XmlValidationError( |
{ |
parser.getLine(), "missing xml.version attribute"); |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_XML_ATTRIBUTE", |
|
"missing xml.version attribute"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
| |
if (!entry.getAttributeValue("encoding", xmlEncoding)) | if (!entry.getAttributeValue("encoding", xmlEncoding)) |
{ | { |
|
|
entry.type != XmlEntry::START_TAG || | entry.type != XmlEntry::START_TAG || |
strcmp(entry.text, tagName) != 0) | strcmp(entry.text, tagName) != 0) |
{ | { |
char message[MESSAGE_SIZE]; |
MessageLoaderParms mlParms( |
sprintf(message, "Expected open of %s element", tagName); |
"Common.XmlReader.EXPECTED_OPEN", |
throw XmlValidationError(parser.getLine(), message); |
"Expected open of $0 element", |
|
tagName); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
} | } |
| |
|
|
entry.type != XmlEntry::END_TAG || | entry.type != XmlEntry::END_TAG || |
strcmp(entry.text, tagName) != 0) | strcmp(entry.text, tagName) != 0) |
{ | { |
char message[MESSAGE_SIZE]; |
MessageLoaderParms mlParms( |
sprintf(message, "Expected close of %s element, got %s instead", |
"Common.XmlReader.EXPECTED_CLOSE", |
|
"Expected close of $0 element, got $1 instead", |
tagName,entry.text); | tagName,entry.text); |
throw XmlValidationError(parser.getLine(), message); |
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
} | } |
| |
|
|
entry.type != XmlEntry::EMPTY_TAG) || | entry.type != XmlEntry::EMPTY_TAG) || |
strcmp(entry.text, tagName) != 0) | strcmp(entry.text, tagName) != 0) |
{ | { |
char message[MESSAGE_SIZE]; |
MessageLoaderParms mlParms( |
sprintf(message, |
"Common.XmlReader.EXPECTED_OPENCLOSE", |
"Expected either open or open/close %s element", tagName); |
"Expected either open or open/close $0 element", |
throw XmlValidationError(parser.getLine(), message); |
tagName); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
} | } |
| |
|
|
(entry.type != XmlEntry::CONTENT && | (entry.type != XmlEntry::CONTENT && |
entry.type != XmlEntry::CDATA)) | entry.type != XmlEntry::CDATA)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
"Expected content of CDATA"); |
"Common.XmlReader.EXPECTED_CDATA", |
|
"Expected content or CDATA"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
return true; | return true; |
|
|
XmlEntry& entry, | XmlEntry& entry, |
const char* tagName) | const char* tagName) |
{ | { |
if (!parser.next(entry) || |
if (!parser.next(entry)) |
(entry.type != XmlEntry::START_TAG && |
{ |
|
return false; |
|
} |
|
if ((entry.type != XmlEntry::START_TAG && |
entry.type != XmlEntry::EMPTY_TAG) || | entry.type != XmlEntry::EMPTY_TAG) || |
strcmp(entry.text, tagName) != 0) | strcmp(entry.text, tagName) != 0) |
{ | { |
|
|
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// 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() |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
XmlReader::expectStartTag(parser, entry, "CIM"); | XmlReader::expectStartTag(parser, entry, "CIM"); |
| |
if (!entry.getAttributeValue("CIMVERSION", cimVersion)) | if (!entry.getAttributeValue("CIMVERSION", cimVersion)) |
throw XmlValidationError( |
{ |
parser.getLine(), "missing CIM.CIMVERSION attribute"); |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_CIMVERSION_ATTRIBUTE", |
|
"missing CIM.CIMVERSION attribute"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
| |
if (!entry.getAttributeValue("DTDVERSION", dtdVersion)) | if (!entry.getAttributeValue("DTDVERSION", dtdVersion)) |
throw XmlValidationError( |
{ |
parser.getLine(), "missing CIM.DTDVERSION attribute"); |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_DTDVERSION_ATTRIBUTE", |
|
"missing CIM.DTDVERSION attribute"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
String XmlReader::getCimNameAttribute( |
CIMName XmlReader::getCimNameAttribute( |
Uint32 lineNumber, | Uint32 lineNumber, |
const XmlEntry& entry, | const XmlEntry& entry, |
const char* elementName, | const char* elementName, |
Boolean acceptNull) | Boolean acceptNull) |
{ | { |
String name; |
const char* name; |
| |
if (!entry.getAttributeValue("NAME", name)) | if (!entry.getAttributeValue("NAME", name)) |
{ | { |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
sprintf(buffer, "missing %s.NAME attribute", elementName); |
sprintf(buffer, "%s.NAME", elementName); |
throw XmlValidationError(lineNumber, buffer); |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_ATTRIBUTE", |
|
"missing $0 attribute", |
|
buffer); |
|
|
|
throw XmlValidationError(lineNumber, mlParms); |
} | } |
| |
if (acceptNull && name.size() == 0) |
if (acceptNull && *name == '\0') |
return name; |
return CIMName(); |
|
|
|
Uint32 size = CIMNameLegalASCII(name); |
|
|
|
if (size) |
|
{ |
|
String tmp(name, size); |
|
return CIMName(CIMNameCast(tmp)); |
|
} |
| |
if (!CIMName::legal(name)) | if (!CIMName::legal(name)) |
{ | { |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
sprintf(buffer, "Illegal value for %s.NAME attribute", elementName); |
sprintf(buffer, "%s.NAME", elementName); |
throw XmlSemanticError(lineNumber, buffer); |
|
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE", |
|
"Illegal value for $0 attribute", |
|
buffer); |
|
|
|
throw XmlSemanticError(lineNumber, mlParms); |
} | } |
| |
return name; |
return CIMNameCast(name); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
if (!entry.getAttributeValue("CLASSNAME", name)) | if (!entry.getAttributeValue("CLASSNAME", name)) |
{ | { |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
sprintf(buffer, "missing %s.CLASSNAME attribute", elementName); |
sprintf(buffer, "%s.CLASSNAME", elementName); |
throw XmlValidationError(lineNumber, buffer); |
|
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_ATTRIBUTE", |
|
"missing $0 attribute", |
|
buffer); |
|
|
|
throw XmlValidationError(lineNumber, mlParms); |
} | } |
| |
if (!CIMName::legal(name)) | if (!CIMName::legal(name)) |
{ | { |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
sprintf(buffer, |
sprintf(buffer, "%s.CLASSNAME", elementName); |
"Illegal value for %s.CLASSNAME attribute", elementName); |
|
throw XmlSemanticError(lineNumber, buffer); |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE", |
|
"Illegal value for $0 attribute", |
|
buffer); |
|
throw XmlSemanticError(lineNumber, mlParms); |
} | } |
| |
return name; | return name; |
|
|
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]; |
sprintf(buffer, |
sprintf(buffer, "%s.CLASSORIGIN", tagName); |
"Illegal value for %s.CLASSORIGIN attribute", tagName); |
|
throw XmlSemanticError(lineNumber, buffer); |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE", |
|
"Illegal value for $0 attribute", |
|
buffer); |
|
throw XmlSemanticError(lineNumber, mlParms); |
|
} |
|
// The CIMName was already checked with legal() + String() |
|
return CIMNameCast(name); |
} | } |
| |
return name; |
//------------------------------------------------------------------------------ |
|
// |
|
// getEmbeddedObjectAttribute() |
|
// |
|
// <!ENTITY % EmbeddedObject "EmbeddedObject (object | instance) #IMPLIED"> |
|
// |
|
// EmbeddedObjectAttributeType: |
|
// NO_EMBEDDED_OBJECT = 0, |
|
// EMBEDDED_OBJECT_ATTR = 1, |
|
// EMBEDDED_INSTANCE_ATTR = 2 |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
XmlReader::EmbeddedObjectAttributeType XmlReader::getEmbeddedObjectAttribute( |
|
Uint32 lineNumber, |
|
const XmlEntry& entry, |
|
const char* tagName) |
|
{ |
|
const char* embeddedObject; |
|
|
|
// Check for both upper case and mixed case "EmbeddedObject" |
|
// because of an error in an earlier pegasus version where we |
|
// used upper case in the generation of the attribute name |
|
// whereas the DMTF spec calls for mixed case. |
|
if (!entry.getAttributeValue("EmbeddedObject", embeddedObject) && |
|
!entry.getAttributeValue("EMBEDDEDOBJECT", embeddedObject)) |
|
return NO_EMBEDDED_OBJECT; |
|
|
|
// The embeddedObject attribute, if present, must have the string |
|
// value "object" or "instance". |
|
if (strcmp(embeddedObject, "object") == 0) |
|
{ |
|
return EMBEDDED_OBJECT_ATTR; |
|
} |
|
|
|
if (strcmp(embeddedObject, "instance") == 0) |
|
{ |
|
return EMBEDDED_INSTANCE_ATTR; |
|
} |
|
|
|
char buffer[MESSAGE_SIZE]; |
|
sprintf(buffer, "%s.EmbeddedObject", tagName); |
|
|
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE", |
|
"Illegal value for $0 attribute", |
|
buffer); |
|
throw XmlSemanticError(lineNumber, mlParms); |
|
|
|
return NO_EMBEDDED_OBJECT; |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
if (!CIMName::legal(name)) | if (!CIMName::legal(name)) |
{ | { |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
sprintf(buffer, |
sprintf(buffer, "%s.REFERENCECLASS", elementName); |
"Illegal value for %s.REFERENCECLASS attribute", elementName); |
|
throw XmlSemanticError(lineNumber, buffer); |
|
} |
|
| |
return name; |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE", |
|
"Illegal value for $0 attribute", |
|
buffer); |
|
throw XmlSemanticError(lineNumber, mlParms); |
|
} |
|
// The CIMName was already checked with legal() + String() |
|
return CIMNameCast(name); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
if (!CIMName::legal(superClass)) | if (!CIMName::legal(superClass)) |
{ | { |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
sprintf( |
sprintf(buffer, "%s.SUPERCLASS", tagName); |
buffer, "Illegal value for %s.SUPERCLASS attribute", tagName); |
|
throw XmlSemanticError(lineNumber, buffer); |
|
} |
|
| |
return superClass; |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE", |
|
"Illegal value for $0 attribute", |
|
buffer); |
|
throw XmlSemanticError(lineNumber, mlParms); |
|
} |
|
// The CIMName was already checked with legal() + String() |
|
return CIMNameCast(superClass); |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
if (required) | if (required) |
{ | { |
char message[MESSAGE_SIZE]; | char message[MESSAGE_SIZE]; |
sprintf(message, "missing %s.%s attribute", tagName, attributeName); |
sprintf(message, "%s.%s", tagName, attributeName); |
throw XmlValidationError(lineNumber, message); |
|
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_ATTRIBUTE", |
|
"missing $0 attribute", |
|
message); |
|
throw XmlValidationError(lineNumber, mlParms); |
} | } |
else | else |
{ | { |
|
|
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 || |
((type == CIMTYPE_REFERENCE) && | ((type == CIMTYPE_REFERENCE) && |
(strcmp(attributeName, "PARAMTYPE") != 0))) | (strcmp(attributeName, "PARAMTYPE") != 0))) |
{ | { |
char message[MESSAGE_SIZE]; |
char buffer[MESSAGE_SIZE]; |
sprintf(message, "Illegal value for %s.%s attribute", tagName, |
sprintf(buffer, "%s.%s", tagName, attributeName); |
attributeName); |
|
throw XmlSemanticError(lineNumber, message); |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE", |
|
"Illegal value for $0 attribute", |
|
buffer); |
|
|
|
throw XmlSemanticError(lineNumber, mlParms); |
} | } |
| |
cimType = type; | cimType = type; |
|
|
if (!required) | if (!required) |
return defaultValue; | return defaultValue; |
| |
char buffer[62]; |
char buffer[MESSAGE_SIZE]; |
sprintf(buffer, "missing required %s.%s attribute", |
sprintf(buffer, "%s.%s", attributeName, tagName); |
attributeName, tagName); |
|
| |
throw XmlValidationError(lineNumber, buffer); |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_REQUIRED_ATTRIBUTE", |
|
"missing required $0 attribute", |
|
buffer); |
|
throw XmlValidationError(lineNumber, mlParms); |
} | } |
| |
if (strcmp(tmp, "true") == 0) | if (strcmp(tmp, "true") == 0) |
|
|
else if (strcmp(tmp, "false") == 0) | else if (strcmp(tmp, "false") == 0) |
return false; | return false; |
| |
char buffer[62]; |
char buffer[MESSAGE_SIZE]; |
sprintf(buffer, "Invalid %s.%s attribute value", attributeName, tagName); |
sprintf(buffer, "%s.%s", attributeName, tagName); |
throw XmlSemanticError(lineNumber, buffer); |
|
return false; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// SringToReal() |
|
// |
|
// [ "+" | "-" ] *decimalDigit "." 1*decimalDigit |
|
// [ ( "e" | "E" ) [ "+" | "-" ] 1*decimalDigit ] |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::stringToReal(const char* stringValue, Real64& x) |
|
{ |
|
// |
|
// Check the string against the DMTF-defined grammar |
|
// |
|
const char* p = stringValue; |
|
|
|
if (!*p) |
|
return false; |
|
|
|
// Skip optional sign: |
|
|
|
if (*p == '+' || *p == '-') |
|
p++; |
|
|
|
// Skip optional first set of digits: |
|
|
|
while (isdigit(*p)) |
|
p++; |
|
|
|
// Test required dot: |
|
|
|
if (*p++ != '.') |
|
return false; |
|
|
|
// One or more digits required: |
|
|
|
if (!isdigit(*p++)) |
|
return false; |
|
|
|
while (isdigit(*p)) |
|
p++; |
|
|
|
// If there is an exponent now: |
|
|
|
if (*p) |
|
{ |
|
// Test exponent: |
|
|
|
if (*p != 'e' && *p != 'E') |
|
return false; |
|
|
|
p++; |
|
|
|
// Skip optional sign: |
|
| |
if (*p == '+' || *p == '-') |
MessageLoaderParms mlParms( |
p++; |
"Common.XmlReader.INVALID_ATTRIBUTE", |
|
"Invalid $0 attribute value", |
|
buffer); |
| |
// One or more digits required: |
throw XmlSemanticError(lineNumber, mlParms); |
| |
if (!isdigit(*p++)) |
|
return false; | return false; |
|
|
while (isdigit(*p)) |
|
p++; |
|
} | } |
| |
if (*p) |
// See http://www.ietf.org/rfc/rfc2396.txt section 2 |
return false; |
|
|
|
// |
|
// Do the conversion |
|
// | // |
char* end; |
// Also see the "CIM Operations over HTTP" spec, section 3.3.2 and |
errno = 0; |
// 3.3.3, for the treatment of non US-ASCII chars (UTF-8) |
x = strtod(stringValue, &end); |
String XmlReader::decodeURICharacters(String uriString) |
if (*end || (errno == ERANGE)) |
|
{ | { |
return false; |
Uint32 i; |
} |
|
| |
return true; |
Buffer utf8Chars; |
} |
|
| |
inline Uint8 _hexCharToNumeric(const char c) |
for (i=0; i<uriString.size(); i++) |
{ | { |
Uint8 n; |
if (uriString[i] == '%') |
|
|
if (isdigit(c)) |
|
n = (c - '0'); |
|
else if (isupper(c)) |
|
n = (c - 'A' + 10); |
|
else // if (islower(c)) |
|
n = (c - 'a' + 10); |
|
|
|
return n; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// stringToSignedInteger |
|
// |
|
// [ "+" | "-" ] ( positiveDecimalDigit *decimalDigit | "0" ) |
|
// or |
|
// [ "+" | "-" ] ( "0x" | "0X" ) 1*hexDigit |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::stringToSignedInteger( |
|
const char* stringValue, |
|
Sint64& x) |
|
{ | { |
x = 0; |
if (i+2 >= uriString.size()) |
const char* p = stringValue; |
|
|
|
if (!p || !*p) |
|
return false; |
|
|
|
// Skip optional sign: |
|
|
|
Boolean negative = *p == '-'; |
|
|
|
if (negative || *p == '+') |
|
p++; |
|
|
|
if (*p == '0') |
|
{ |
|
if ( (p[1] == 'x') || (p[1] == 'X') ) |
|
{ |
|
// Convert a hexadecimal string |
|
|
|
// Skip over the "0x" |
|
p+=2; |
|
|
|
// At least one hexadecimal digit is required |
|
if (!isxdigit(*p)) |
|
return false; |
|
|
|
// Build the Sint64 as a negative number, regardless of the |
|
// eventual sign (negative numbers can be bigger than positive ones) |
|
|
|
// Add on each digit, checking for overflow errors |
|
while (isxdigit(*p)) |
|
{ |
|
// Make sure we won't overflow when we multiply by 16 |
|
if (x < PEGASUS_SINT64_MIN/16) |
|
{ | { |
return false; |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.INVALID_URI_ENCODING", |
|
"Invalid URI encoding"); |
|
throw ParseError(MessageLoader::getMessage(mlParms)); |
} | } |
x = x << 4; |
|
| |
// Make sure we don't overflow when we add the next digit |
Uint8 digit1 = |
Sint64 newDigit = Sint64(_hexCharToNumeric(*p++)); |
StringConversion::hexCharToNumeric(char(uriString[++i])); |
if (PEGASUS_SINT64_MIN - x > -newDigit) |
Uint8 digit2 = |
|
StringConversion::hexCharToNumeric(char(uriString[++i])); |
|
if ( (digit1 > 15) || (digit2 > 15) ) |
{ | { |
return false; |
MessageLoaderParms mlParms( |
} |
"Common.XmlReader.INVALID_URI_ENCODING", |
x = x - newDigit; |
"Invalid URI encoding"); |
|
throw ParseError(MessageLoader::getMessage(mlParms)); |
} | } |
| |
// If we found a non-hexadecimal digit, report an error |
Uint16 decodedChar = Uint16(digit1<<4) + Uint16(digit2); |
if (*p) |
utf8Chars.append((char)decodedChar); |
return false; |
|
|
|
// Return the integer to positive, if necessary, checking for an |
|
// overflow error |
|
if (!negative) |
|
{ |
|
if (x == PEGASUS_SINT64_MIN) |
|
{ |
|
return false; |
|
} |
|
x = -x; |
|
} |
|
return true; |
|
} | } |
else | else |
{ | { |
// A decimal string that starts with '0' must be exactly "0". |
utf8Chars.append((char)uriString[i]); |
return p[1] == '\0'; |
|
} | } |
} | } |
| |
// Expect a positive decimal digit: |
// If there was a string to decode... |
|
if (uriString.size() > 0) |
// At least one decimal digit is required |
|
if (!isdigit(*p)) |
|
return false; |
|
|
|
// Build the Sint64 as a negative number, regardless of the |
|
// eventual sign (negative numbers can be bigger than positive ones) |
|
|
|
// Add on each digit, checking for overflow errors |
|
while (isdigit(*p)) |
|
{ |
|
// Make sure we won't overflow when we multiply by 10 |
|
if (x < PEGASUS_SINT64_MIN/10) |
|
{ |
|
return false; |
|
} |
|
x = 10 * x; |
|
|
|
// Make sure we won't overflow when we add the next digit |
|
Sint64 newDigit = (*p++ - '0'); |
|
if (PEGASUS_SINT64_MIN - x > -newDigit) |
|
{ |
|
return false; |
|
} |
|
x = x - newDigit; |
|
} |
|
|
|
// If we found a non-decimal digit, report an error |
|
if (*p) |
|
return false; |
|
|
|
// Return the integer to positive, if necessary, checking for an |
|
// overflow error |
|
if (!negative) |
|
{ |
|
if (x == PEGASUS_SINT64_MIN) |
|
{ |
|
return false; |
|
} |
|
x = -x; |
|
} |
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// stringToUnsignedInteger |
|
// |
|
// ( positiveDecimalDigit *decimalDigit | "0" ) |
|
// or |
|
// ( "0x" | "0X" ) 1*hexDigit |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::stringToUnsignedInteger( |
|
const char* stringValue, |
|
Uint64& x) |
|
{ |
|
x = 0; |
|
const char* p = stringValue; |
|
|
|
if (!p || !*p) |
|
return false; |
|
|
|
if (*p == '0') |
|
{ |
|
if ( (p[1] == 'x') || (p[1] == 'X') ) |
|
{ |
|
// Convert a hexadecimal string |
|
|
|
// Skip over the "0x" |
|
p+=2; |
|
|
|
// At least one hexadecimal digit is required |
|
if (!*p) |
|
return false; |
|
|
|
// Add on each digit, checking for overflow errors |
|
while (isxdigit(*p)) |
|
{ |
|
// Make sure we won't overflow when we multiply by 16 |
|
if (x > PEGASUS_UINT64_MAX/16) |
|
{ |
|
return false; |
|
} |
|
x = x << 4; |
|
|
|
// We can't overflow when we add the next digit |
|
Uint64 newDigit = Uint64(_hexCharToNumeric(*p++)); |
|
if (PEGASUS_UINT64_MAX - x < newDigit) |
|
{ | { |
return false; |
// Convert UTF-8 to UTF-16 and return the String |
} |
return String(utf8Chars.getData(), utf8Chars.size()); |
x = x + newDigit; |
|
} |
|
|
|
// If we found a non-hexadecimal digit, report an error |
|
if (*p) |
|
return false; |
|
|
|
return true; |
|
} | } |
else | else |
{ | { |
// A decimal string that starts with '0' must be exactly "0". |
return String(); |
return p[1] == '\0'; |
|
} | } |
} | } |
| |
// Expect a positive decimal digit: |
|
|
|
// Add on each digit, checking for overflow errors |
|
while (isdigit(*p)) |
|
{ |
|
// Make sure we won't overflow when we multiply by 10 |
|
if (x > PEGASUS_UINT64_MAX/10) |
|
{ |
|
return false; |
|
} |
|
x = 10 * x; |
|
|
|
// Make sure we won't overflow when we add the next digit |
|
Uint64 newDigit = (*p++ - '0'); |
|
if (PEGASUS_UINT64_MAX - x < newDigit) |
|
{ |
|
return false; |
|
} |
|
x = x + newDigit; |
|
} |
|
|
|
// If we found a non-decimal digit, report an error |
|
if (*p) |
|
return false; |
|
|
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
// stringToValue() | // stringToValue() |
|
|
const char* valueString, | const char* valueString, |
CIMType type) | CIMType type) |
{ | { |
|
return stringToValue(lineNumber, valueString, strlen(valueString), type); |
|
} |
|
|
|
CIMValue XmlReader::stringToValue( |
|
Uint32 lineNumber, |
|
const char* valueString, |
|
Uint32 valueStringLen, |
|
CIMType type) |
|
{ |
// ATTN-B: accepting only UTF-8 for now! (affects string and char16): | // ATTN-B: accepting only UTF-8 for now! (affects string and char16): |
| |
|
// Char string must have been null terminated. |
|
PEGASUS_ASSERT (!valueString[valueStringLen]); |
|
|
// Create value per type | // Create value per type |
switch (type) | switch (type) |
{ | { |
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
{ | { |
if (CompareNoCase(valueString, "TRUE") == 0) |
if (System::strcasecmp(valueString, "TRUE") == 0) |
return CIMValue(true); | return CIMValue(true); |
else if (CompareNoCase(valueString, "FALSE") == 0) |
else if (System::strcasecmp(valueString, "FALSE") == 0) |
return CIMValue(false); | return CIMValue(false); |
else | else |
throw XmlSemanticError( |
{ |
lineNumber, "Invalid boolean value"); |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.INVALID_BOOLEAN_VALUE", |
|
"Invalid boolean value"); |
|
throw XmlSemanticError(lineNumber, mlParms); |
|
} |
} | } |
| |
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
return CIMValue(String(valueString)); |
return CIMValue(String(valueString, valueStringLen)); |
} | } |
| |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
{ | { |
if (strlen(valueString) != 1) |
// Converts UTF-8 to UTF-16 |
throw XmlSemanticError(lineNumber, "Invalid char16 value"); |
String tmp(valueString, valueStringLen); |
|
if (tmp.size() != 1) |
|
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.INVALID_CHAR16_VALUE", |
|
"Invalid char16 value"); |
|
throw XmlSemanticError(lineNumber, mlParms); |
|
} |
| |
return CIMValue(Char16(valueString[0])); |
return CIMValue(tmp[0]); |
} | } |
| |
case CIMTYPE_UINT8: | case CIMTYPE_UINT8: |
|
|
{ | { |
Uint64 x; | Uint64 x; |
| |
if (!stringToUnsignedInteger(valueString, x)) |
if (!StringConversion::stringToUnsignedInteger(valueString, x)) |
{ | { |
throw XmlSemanticError( |
MessageLoaderParms mlParms( |
lineNumber, "Invalid unsigned integer value"); |
"Common.XmlReader.INVALID_UI_VALUE", |
|
"Invalid unsigned integer value"); |
|
throw XmlSemanticError(lineNumber, mlParms); |
} | } |
| |
switch (type) | switch (type) |
{ | { |
case CIMTYPE_UINT8: | case CIMTYPE_UINT8: |
{ | { |
if (x >= (Uint64(1)<<8)) |
if (!StringConversion::checkUintBounds(x, type)) |
{ | { |
throw XmlSemanticError( |
MessageLoaderParms mlParms( |
lineNumber, "Uint8 value out of range"); |
"Common.XmlReader.U8_VALUE_OUT_OF_RANGE", |
|
"Uint8 value out of range"); |
|
throw XmlSemanticError(lineNumber, mlParms); |
} | } |
return CIMValue(Uint8(x)); | return CIMValue(Uint8(x)); |
} | } |
case CIMTYPE_UINT16: | case CIMTYPE_UINT16: |
{ | { |
if (x >= (Uint64(1)<<16)) |
if (!StringConversion::checkUintBounds(x, type)) |
{ | { |
throw XmlSemanticError( |
MessageLoaderParms mlParms( |
lineNumber, "Uint16 value out of range"); |
"Common.XmlReader.U16_VALUE_OUT_OF_RANGE", |
|
"Uint16 value out of range"); |
|
throw XmlSemanticError(lineNumber, mlParms); |
} | } |
return CIMValue(Uint16(x)); | return CIMValue(Uint16(x)); |
} | } |
case CIMTYPE_UINT32: | case CIMTYPE_UINT32: |
{ | { |
if (x >= (Uint64(1)<<32)) |
if (!StringConversion::checkUintBounds(x, type)) |
{ | { |
throw XmlSemanticError( |
MessageLoaderParms mlParms( |
lineNumber, "Uint32 value out of range"); |
"Common.XmlReader.U32_VALUE_OUT_OF_RANGE", |
|
"Uint32 value out of range"); |
|
throw XmlSemanticError(lineNumber, mlParms); |
} | } |
return CIMValue(Uint32(x)); | return CIMValue(Uint32(x)); |
} | } |
|
|
{ | { |
Sint64 x; | Sint64 x; |
| |
if (!stringToSignedInteger(valueString, x)) |
if (!StringConversion::stringToSignedInteger(valueString, x)) |
{ | { |
throw XmlSemanticError( |
MessageLoaderParms mlParms( |
lineNumber, "Invalid signed integer value"); |
"Common.XmlReader.INVALID_SI_VALUE", |
|
"Invalid signed integer value"); |
|
throw XmlSemanticError(lineNumber, mlParms); |
} | } |
| |
switch (type) | switch (type) |
{ | { |
case CIMTYPE_SINT8: | case CIMTYPE_SINT8: |
{ | { |
if( (x >= (Sint64(1)<<7)) || (x < (-(Sint64(1)<<7))) ) |
if (!StringConversion::checkSintBounds(x, type)) |
{ | { |
throw XmlSemanticError( |
MessageLoaderParms mlParms( |
lineNumber, "Sint8 value out of range"); |
"Common.XmlReader.S8_VALUE_OUT_OF_RANGE", |
|
"Sint8 value out of range"); |
|
throw XmlSemanticError(lineNumber, mlParms); |
} | } |
return CIMValue(Sint8(x)); | return CIMValue(Sint8(x)); |
} | } |
case CIMTYPE_SINT16: | case CIMTYPE_SINT16: |
{ | { |
if( (x >= (Sint64(1)<<15)) || (x < (-(Sint64(1)<<15))) ) |
if (!StringConversion::checkSintBounds(x, type)) |
{ | { |
throw XmlSemanticError( |
MessageLoaderParms mlParms( |
lineNumber, "Sint16 value out of range"); |
"Common.XmlReader.S16_VALUE_OUT_OF_RANGE", |
|
"Sint16 value out of range"); |
|
throw XmlSemanticError(lineNumber, mlParms); |
} | } |
return CIMValue(Sint16(x)); | return CIMValue(Sint16(x)); |
} | } |
case CIMTYPE_SINT32: | case CIMTYPE_SINT32: |
{ | { |
if( (x >= (Sint64(1)<<31)) || (x < (-(Sint64(1)<<31))) ) |
if (!StringConversion::checkSintBounds(x, type)) |
{ | { |
throw XmlSemanticError( |
MessageLoaderParms mlParms( |
lineNumber, "Sint32 value out of range"); |
"Common.XmlReader.S32_VALUE_OUT_OF_RANGE", |
|
"Sint32 value out of range"); |
|
throw XmlSemanticError(lineNumber, mlParms); |
} | } |
return CIMValue(Sint32(x)); | return CIMValue(Sint32(x)); |
} | } |
|
|
| |
try | try |
{ | { |
|
if (valueStringLen != 0) |
|
{ |
tmp.set(valueString); | tmp.set(valueString); |
} | } |
|
} |
catch (InvalidDateTimeFormatException&) | catch (InvalidDateTimeFormatException&) |
{ | { |
throw XmlSemanticError(lineNumber, "Invalid datetime value"); |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.INVALID_DATETIME_VALUE", |
|
"Invalid datetime value"); |
|
throw XmlSemanticError(lineNumber, mlParms); |
} | } |
| |
return CIMValue(tmp); | return CIMValue(tmp); |
|
|
{ | { |
Real64 x; | Real64 x; |
| |
if (!stringToReal(valueString, x)) |
if (!StringConversion::stringToReal64(valueString, x)) |
throw XmlSemanticError(lineNumber, "Invalid real number value"); |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.INVALID_RN_VALUE", |
|
"Invalid real number value"); |
|
throw XmlSemanticError(lineNumber, mlParms); |
|
} |
return CIMValue(Real32(x)); | return CIMValue(Real32(x)); |
} | } |
| |
|
|
{ | { |
Real64 x; | Real64 x; |
| |
if (!stringToReal(valueString, x)) |
if (!StringConversion::stringToReal64(valueString, x)) |
throw XmlSemanticError(lineNumber, "Invalid real number value"); |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.INVALID_RN_VALUE", |
|
"Invalid real number value"); |
|
throw XmlSemanticError(lineNumber, mlParms); |
|
} |
|
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: |
|
case CIMTYPE_INSTANCE: |
|
{ |
|
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[valueStringLen + 1]); |
|
memcpy(tmp_buffer.get(), valueString, valueStringLen + 1); |
|
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)) |
|
{ |
|
if (type == CIMTYPE_INSTANCE) |
|
return CIMValue(cimInstance); |
|
x = CIMObject(cimInstance); |
|
} |
|
else if (XmlReader::getClassElement(tmp_parser, cimClass)) |
|
{ |
|
x = CIMObject(cimClass); |
|
} |
|
else |
|
{ |
|
if (type == CIMTYPE_OBJECT) |
|
{ |
|
// change "element" to "embedded object" |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader." |
|
"EXPECTED_INSTANCE_OR_CLASS_ELEMENT", |
|
"Expected INSTANCE or CLASS element"); |
|
throw XmlValidationError(lineNumber, mlParms); |
|
} |
|
else |
|
{ |
|
// change "element" to "embedded object" |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_INSTANCE_ELEMENT", |
|
"Expected INSTANCE element"); |
|
throw XmlValidationError(lineNumber, mlParms); |
|
} |
|
} |
|
// Ok, now we can delete the storage for the temporary |
|
// XmlParser. |
|
tmp_buffer.reset(); |
|
} |
return CIMValue(x); | return CIMValue(x); |
} | } |
| |
|
|
break; | break; |
} | } |
| |
throw XmlSemanticError(lineNumber, "malformed XML"); |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MALFORMED_XML", |
|
"malformed XML"); |
|
throw XmlSemanticError(lineNumber, mlParms); |
|
|
return false; | return false; |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// 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; |
| |
const char* valueString = ""; | const char* valueString = ""; |
|
Uint32 valueStringLen = 0; |
if (!empty) | if (!empty) |
{ | { |
if (testContentOrCData(parser, entry)) | if (testContentOrCData(parser, entry)) |
|
{ |
valueString = entry.text; | valueString = entry.text; |
|
valueStringLen = entry.textLen; |
|
} |
| |
expectEndTag(parser, "VALUE"); | expectEndTag(parser, "VALUE"); |
} | } |
|
value = stringToValue(parser.getLine(),valueString,valueStringLen,type); |
value = stringToValue(parser.getLine(), valueString,type); |
|
| |
return true; | return true; |
} | } |
|
|
if (!testStartTagOrEmptyTag(parser, entry, "VALUE")) | if (!testStartTagOrEmptyTag(parser, entry, "VALUE")) |
{ | { |
if (required) | if (required) |
throw XmlValidationError(parser.getLine(),"Expected VALUE element"); |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_VALUE_ELEMENT", |
|
"Expected VALUE element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
return false; | return false; |
} | } |
| |
Boolean empty = entry.type == XmlEntry::EMPTY_TAG; | Boolean empty = entry.type == XmlEntry::EMPTY_TAG; |
| |
const char* valueString = ""; | const char* valueString = ""; |
|
Uint32 valueStringLen = 0; |
| |
if (!empty) | if (!empty) |
{ | { |
if (testContentOrCData(parser, entry)) | if (testContentOrCData(parser, entry)) |
|
{ |
valueString = entry.text; | valueString = entry.text; |
|
valueStringLen = entry.textLen; |
|
} |
| |
expectEndTag(parser, "VALUE"); | expectEndTag(parser, "VALUE"); |
} | } |
| |
str = valueString; |
str = String(valueString, valueStringLen); |
return true; | return true; |
} | } |
| |
|
|
template<class T> | template<class T> |
CIMValue StringArrayToValueAux( | CIMValue StringArrayToValueAux( |
Uint32 lineNumber, | Uint32 lineNumber, |
const Array<const char*>& stringArray, |
const Array<CharString>& stringArray, |
CIMType type, | CIMType type, |
T*) | T*) |
{ | { |
|
|
for (Uint32 i = 0, n = stringArray.size(); i < n; i++) | for (Uint32 i = 0, n = stringArray.size(); i < n; i++) |
{ | { |
CIMValue value = XmlReader::stringToValue( | CIMValue value = XmlReader::stringToValue( |
lineNumber, stringArray[i], type); |
lineNumber, |
|
stringArray[i].value, |
|
stringArray[i].length, |
|
type); |
| |
T x; | T x; |
value.get(x); | value.get(x); |
|
|
const Array<const char*>& array, | const Array<const char*>& array, |
CIMType type) | CIMType type) |
{ | { |
|
Array<CharString> strArray; |
|
|
|
for (Uint32 i = 0, n = array.size() ; i < n ; ++i) |
|
{ |
|
strArray.append(CharString(array[i], strlen(array[i]))); |
|
} |
|
|
|
return _stringArrayToValue(lineNumber, strArray, type); |
|
} |
|
|
|
CIMValue XmlReader::_stringArrayToValue( |
|
Uint32 lineNumber, |
|
const Array<CharString> &array, |
|
CIMType type) |
|
{ |
switch (type) | switch (type) |
{ | { |
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
|
|
return StringArrayToValueAux(lineNumber, array, type, (Sint64*)0); | return StringArrayToValueAux(lineNumber, array, type, (Sint64*)0); |
| |
case CIMTYPE_DATETIME: | case CIMTYPE_DATETIME: |
return StringArrayToValueAux(lineNumber, array, type, (CIMDateTime*)0); |
return StringArrayToValueAux( |
|
lineNumber, array, type, (CIMDateTime*)0); |
| |
case CIMTYPE_REAL32: | case CIMTYPE_REAL32: |
return StringArrayToValueAux(lineNumber, array, type, (Real32*)0); | return StringArrayToValueAux(lineNumber, array, type, (Real32*)0); |
|
|
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); |
|
case CIMTYPE_INSTANCE: |
|
return StringArrayToValueAux( |
|
lineNumber, array, type, (CIMInstance*)0); |
default: | default: |
break; | break; |
} | } |
|
|
// Get VALUE.ARRAY open tag: | // Get VALUE.ARRAY open tag: |
| |
XmlEntry entry; | XmlEntry entry; |
Array<const char*> stringArray; |
Array<CharString> stringArray; |
| |
// If no VALUE.ARRAY start tag, return false | // If no VALUE.ARRAY start tag, return false |
if (!testStartTagOrEmptyTag(parser, entry, "VALUE.ARRAY")) | if (!testStartTagOrEmptyTag(parser, entry, "VALUE.ARRAY")) |
|
|
| |
while (testStartTagOrEmptyTag(parser, entry, "VALUE")) | while (testStartTagOrEmptyTag(parser, entry, "VALUE")) |
{ | { |
|
// ATTN: NULL values in array will have VALUE.NULL subelement |
|
// See DSP0201 Version 2.3.0, Section 5.2.3.2 |
if (entry.type == XmlEntry::EMPTY_TAG) | if (entry.type == XmlEntry::EMPTY_TAG) |
{ | { |
stringArray.append(""); |
stringArray.append(CharString("", 0)); |
continue; | continue; |
} | } |
| |
if (testContentOrCData(parser, entry)) | if (testContentOrCData(parser, entry)) |
stringArray.append(entry.text); |
{ |
|
stringArray.append(CharString(entry.text, entry.textLen)); |
|
} |
else | else |
stringArray.append(""); |
{ |
|
stringArray.append(CharString("", 0)); |
|
} |
expectEndTag(parser, "VALUE"); | expectEndTag(parser, "VALUE"); |
} | } |
| |
expectEndTag(parser, "VALUE.ARRAY"); | expectEndTag(parser, "VALUE.ARRAY"); |
} | } |
| |
value = stringArrayToValue(parser.getLine(), stringArray, type); |
value = _stringArrayToValue(parser.getLine(), stringArray, type); |
return true; | return true; |
} | } |
| |
|
|
// 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: |
| |
String name = getCimNameAttribute(parser.getLine(), entry, "QUALIFIER"); |
CIMName name = getCimNameAttribute(parser.getLine(), entry, "QUALIFIER"); |
| |
// Get QUALIFIER.TYPE attribute: | // Get QUALIFIER.TYPE attribute: |
| |
|
|
| |
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: |
| |
|
|
} | } |
catch (AlreadyExistsException&) | catch (AlreadyExistsException&) |
{ | { |
throw XmlSemanticError(parser.getLine(), "duplicate qualifier"); |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.DUPLICATE_QUALIFIER", |
|
"duplicate qualifier"); |
|
throw XmlSemanticError(parser.getLine(), mlParms); |
} | } |
} | } |
} | } |
|
|
// %CIMName; | // %CIMName; |
// %ClassOrigin; | // %ClassOrigin; |
// %Propagated; | // %Propagated; |
|
// %EmbeddedObject; #IMPLIED |
// %CIMType; #REQUIRED> | // %CIMType; #REQUIRED> |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
| |
// Get PROPERTY.NAME attribute: | // Get PROPERTY.NAME attribute: |
| |
String name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY"); |
CIMName name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY"); |
| |
// Get PROPERTY.CLASSORIGIN attribute: | // Get PROPERTY.CLASSORIGIN attribute: |
| |
|
|
Boolean propagated = getCimBooleanAttribute( | Boolean propagated = getCimBooleanAttribute( |
parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false); | parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false); |
| |
|
// Get PROPERTY.EmbeddedObject attribute: |
|
|
|
EmbeddedObjectAttributeType 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); |
|
} |
| |
// Get value: Insert value if getValueElement exists (returns True) |
Boolean embeddedObjectQualifierValue = false; |
|
Uint32 ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT); |
|
if (ix != PEG_NOT_FOUND) |
|
{ |
|
property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue); |
|
} |
|
String embeddedInstanceQualifierValue; |
|
ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE); |
|
if (ix != PEG_NOT_FOUND) |
|
{ |
|
property.getQualifier(ix).getValue().get( |
|
embeddedInstanceQualifierValue); |
|
} |
|
// 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 |
|
Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) || |
|
embeddedObjectQualifierValue; |
|
Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) || |
|
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 i = 0; i < property.getQualifierCount(); ++i) |
|
{ |
|
// 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(i)); |
|
} |
| |
|
value = new_value; |
|
property = new_property; |
|
} |
|
else |
|
{ |
|
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"); |
} | } |
| |
|
|
| |
Uint64 arraySize; | Uint64 arraySize; |
| |
if (!stringToUnsignedInteger(tmp, arraySize) || arraySize == 0) |
if (!StringConversion::stringToUnsignedInteger(tmp, arraySize) || |
|
(arraySize == 0) || |
|
!StringConversion::checkUintBounds(arraySize, CIMTYPE_UINT32)) |
{ | { |
char message[128]; | char message[128]; |
sprintf(message, "Illegal value for %s.%s", tagName, "ARRAYSIZE"); |
sprintf(message, "%s.%s", tagName, "ARRAYSIZE"); |
throw XmlSemanticError(lineNumber, message); |
|
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.ILLEGAL_VALUE", |
|
"Illegal value for $0", |
|
message); |
|
throw XmlSemanticError(lineNumber, mlParms); |
} | } |
| |
value = Uint32(arraySize); | value = Uint32(arraySize); |
|
|
// %CIMType; #REQUIRED | // %CIMType; #REQUIRED |
// %ArraySize; | // %ArraySize; |
// %ClassOrigin; | // %ClassOrigin; |
// %Propagated;> |
// %Propagated; |
|
// %EmbeddedObject; #IMPLIED> |
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
|
|
| |
// Get PROPERTY.NAME attribute: | // Get PROPERTY.NAME attribute: |
| |
String name = |
CIMName name = |
getCimNameAttribute(parser.getLine(), entry, "PROPERTY.ARRAY"); | getCimNameAttribute(parser.getLine(), entry, "PROPERTY.ARRAY"); |
| |
// Get PROPERTY.TYPE attribute: | // Get PROPERTY.TYPE attribute: |
|
|
| |
// 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(), entry, "PROPERTY.ARRAY", "PROPAGATED", false, false); |
parser.getLine(), |
|
entry, |
|
"PROPERTY.ARRAY", |
|
"PROPAGATED", |
|
false, |
|
false); |
|
|
|
// Get PROPERTY.EmbeddedObject attribute: |
|
|
|
EmbeddedObjectAttributeType embeddedObject = getEmbeddedObjectAttribute( |
|
parser.getLine(), entry, "PROPERTY.ARRAY"); |
| |
// Create property: | // Create property: |
| |
|
|
if (!empty) | if (!empty) |
{ | { |
// Get qualifiers: | // Get qualifiers: |
|
|
getQualifierElements(parser, property); | getQualifierElements(parser, property); |
|
} |
| |
// Get value: |
Boolean embeddedObjectQualifierValue = false; |
|
Uint32 ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT); |
|
if (ix != PEG_NOT_FOUND) |
|
{ |
|
property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue); |
|
} |
|
String embeddedInstanceQualifierValue; |
|
ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE); |
|
if (ix != PEG_NOT_FOUND) |
|
{ |
|
property.getQualifier(ix).getValue().get( |
|
embeddedInstanceQualifierValue); |
|
} |
|
// 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 |
|
Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) || |
|
embeddedObjectQualifierValue; |
|
Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) || |
|
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 i = 0; i < property.getQualifierCount(); ++i) |
|
{ |
|
// 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(i)); |
|
} |
| |
|
value = new_value; |
|
property = new_property; |
|
} |
|
else |
|
{ |
|
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()) |
{ | { |
throw XmlSemanticError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.ARRAY_SIZE_DIFFERENT", |
"ARRAYSIZE attribute and value-array size are different"); | "ARRAYSIZE attribute and value-array size are different"); |
|
throw XmlSemanticError(parser.getLine(), mlParms); |
} | } |
| |
property.setValue(value); | property.setValue(value); |
} | } |
|
|
expectEndTag(parser, "PROPERTY.ARRAY"); | expectEndTag(parser, "PROPERTY.ARRAY"); |
} | } |
| |
|
|
| |
if (!parser.next(entry) || entry.type != XmlEntry::CONTENT) | if (!parser.next(entry) || entry.type != XmlEntry::CONTENT) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_CONTENT_ELEMENT", |
"expected content of HOST element"); | "expected content of HOST element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
host = entry.text; |
host = String(entry.text); |
|
|
expectEndTag(parser, "HOST"); | expectEndTag(parser, "HOST"); |
return true; | return true; |
} | } |
|
|
| |
Boolean XmlReader::getNameSpaceElement( | Boolean XmlReader::getNameSpaceElement( |
XmlParser& parser, | XmlParser& parser, |
String& nameSpaceComponent) |
CIMName& nameSpaceComponent) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
if (!testStartTag(parser, entry, "LOCALNAMESPACEPATH")) | if (!testStartTag(parser, entry, "LOCALNAMESPACEPATH")) |
return false; | return false; |
| |
String nameSpaceComponent; |
CIMName nameSpaceComponent; |
| |
while (getNameSpaceElement(parser, nameSpaceComponent)) | while (getNameSpaceElement(parser, nameSpaceComponent)) |
{ | { |
if (nameSpace.size()) | if (nameSpace.size()) |
nameSpace += '/'; |
nameSpace.append('/'); |
| |
nameSpace += nameSpaceComponent; |
nameSpace.append(nameSpaceComponent.getString()); |
} | } |
| |
if (!nameSpace.size()) | if (!nameSpace.size()) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_NAMESPACE_ELEMENTS", |
"Expected one or more NAMESPACE elements within " | "Expected one or more NAMESPACE elements within " |
"LOCALNAMESPACEPATH element"); | "LOCALNAMESPACEPATH element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
expectEndTag(parser, "LOCALNAMESPACEPATH"); | expectEndTag(parser, "LOCALNAMESPACEPATH"); |
|
|
return false; | return false; |
| |
if (!getHostElement(parser, host)) | if (!getHostElement(parser, host)) |
throw XmlValidationError(parser.getLine(), "expected HOST element"); |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_HOST_ELEMENT", |
|
"expected HOST element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
| |
if (!getLocalNameSpacePathElement(parser, nameSpace)) | if (!getLocalNameSpacePathElement(parser, nameSpace)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_LOCALNAMESPACEPATH_ELEMENT", |
"expected LOCALNAMESPACEPATH element"); | "expected LOCALNAMESPACEPATH element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
expectEndTag(parser, "NAMESPACEPATH"); | expectEndTag(parser, "NAMESPACEPATH"); |
|
|
| |
Boolean XmlReader::getClassNameElement( | Boolean XmlReader::getClassNameElement( |
XmlParser& parser, | XmlParser& parser, |
String& className, |
CIMName& className, |
Boolean required) | Boolean required) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
|
|
{ | { |
if (required) | if (required) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_CLASSNAME_ELEMENT", |
"expected CLASSNAME element"); | "expected CLASSNAME element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
else | else |
return false; | return false; |
} | } |
|
|
Boolean empty = entry.type == XmlEntry::EMPTY_TAG; | Boolean empty = entry.type == XmlEntry::EMPTY_TAG; |
| |
className = getCimNameAttribute( | className = getCimNameAttribute( |
parser.getLine(), entry, "CLASSNAME", true); |
parser.getLine(), entry, "CLASSNAME", false); |
| |
if (!empty) | if (!empty) |
expectEndTag(parser, "CLASSNAME"); | expectEndTag(parser, "CLASSNAME"); |
|
|
// | // |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
| |
KeyBinding::Type XmlReader::getValueTypeAttribute( |
CIMKeyBinding::Type XmlReader::getValueTypeAttribute( |
Uint32 lineNumber, | Uint32 lineNumber, |
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 KeyBinding::STRING; |
return CIMKeyBinding::STRING; |
| |
if (String::equal(tmp, "string")) |
if (strcmp(tmp, "string") == 0) |
return KeyBinding::STRING; |
return CIMKeyBinding::STRING; |
else if (String::equal(tmp, "boolean")) |
else if (strcmp(tmp, "boolean") == 0) |
return KeyBinding::BOOLEAN; |
return CIMKeyBinding::BOOLEAN; |
else if (String::equal(tmp, "numeric")) |
else if (strcmp(tmp, "numeric") == 0) |
return KeyBinding::NUMERIC; |
return CIMKeyBinding::NUMERIC; |
| |
char buffer[MESSAGE_SIZE]; | char buffer[MESSAGE_SIZE]; |
|
sprintf(buffer, "%s.VALUETYPE", elementName); |
| |
sprintf(buffer, |
MessageLoaderParms mlParms( |
"Illegal value for %s.VALUETYPE attribute; " |
"Common.XmlReader.ILLEGAL_VALUE_FOR_CIMVALUE_ATTRIBUTE", |
"CIMValue must be one of \"string\", \"boolean\", or \"numeric\"", |
"Illegal value for $0 attribute; CIMValue must be one of \"string\", " |
elementName); |
"\"boolean\", or \"numeric\"", |
|
buffer); |
|
throw XmlSemanticError(lineNumber, mlParms); |
| |
throw XmlSemanticError(lineNumber, buffer); |
return CIMKeyBinding::BOOLEAN; |
return KeyBinding::BOOLEAN; |
|
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
| |
Boolean XmlReader::getKeyValueElement( | Boolean XmlReader::getKeyValueElement( |
XmlParser& parser, | XmlParser& parser, |
KeyBinding::Type& type, |
CIMKeyBinding::Type& type, |
String& value) | String& value) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
|
|
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 = entry.text; |
value = String(entry.text); |
else | else |
parser.putBack(entry); | parser.putBack(entry); |
| |
|
|
| |
Boolean XmlReader::getKeyBindingElement( | Boolean XmlReader::getKeyBindingElement( |
XmlParser& parser, | XmlParser& parser, |
String& name, |
CIMName& name, |
String& value, | String& value, |
KeyBinding::Type& type) |
CIMKeyBinding::Type& type) |
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
|
|
| |
if (!getValueReferenceElement(parser, reference)) | if (!getValueReferenceElement(parser, reference)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_KEYVALUE_OR_REFERENCE_ELEMENT", |
"Expected KEYVALUE or VALUE.REFERENCE element"); | "Expected KEYVALUE or VALUE.REFERENCE element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
type = KeyBinding::REFERENCE; |
type = CIMKeyBinding::REFERENCE; |
value = reference.toString(); | value = reference.toString(); |
} | } |
| |
|
|
Boolean XmlReader::getInstanceNameElement( | Boolean XmlReader::getInstanceNameElement( |
XmlParser& parser, | XmlParser& parser, |
String& className, | String& className, |
Array<KeyBinding>& keyBindings) |
Array<CIMKeyBinding>& keyBindings) |
{ | { |
className.clear(); | className.clear(); |
keyBindings.clear(); | keyBindings.clear(); |
|
|
return true; | return true; |
} | } |
| |
String name; |
CIMName name; |
KeyBinding::Type type; |
CIMKeyBinding::Type type; |
String value; | String value; |
CIMObjectPath reference; | CIMObjectPath reference; |
| |
if (getKeyValueElement(parser, type, value)) | if (getKeyValueElement(parser, type, value)) |
{ | { |
// Use empty key name because none was specified | // Use empty key name because none was specified |
keyBindings.append(KeyBinding(name, value, type)); |
keyBindings.append(CIMKeyBinding(name, value, type)); |
} | } |
else if (getValueReferenceElement(parser, reference)) | else if (getValueReferenceElement(parser, reference)) |
{ | { |
// Use empty key name because none was specified | // Use empty key name because none was specified |
type = KeyBinding::REFERENCE; |
type = CIMKeyBinding::REFERENCE; |
value = reference.toString(); | value = reference.toString(); |
keyBindings.append(KeyBinding(name, value, type)); |
keyBindings.append(CIMKeyBinding(name, value, type)); |
} | } |
else | else |
{ | { |
while (getKeyBindingElement(parser, name, value, type)) | while (getKeyBindingElement(parser, name, value, type)) |
keyBindings.append(KeyBinding(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"); |
|
|
CIMObjectPath& instanceName) | CIMObjectPath& instanceName) |
{ | { |
String className; | String className; |
Array<KeyBinding> keyBindings; |
Array<CIMKeyBinding> keyBindings; |
| |
if (!XmlReader::getInstanceNameElement(parser, className, keyBindings)) | if (!XmlReader::getInstanceNameElement(parser, className, keyBindings)) |
return false; | return false; |
|
|
| |
if (!getNameSpacePathElement(parser, host, nameSpace)) | if (!getNameSpacePathElement(parser, host, nameSpace)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_NAMESPACEPATH_ELEMENT", |
"expected NAMESPACEPATH element"); | "expected NAMESPACEPATH element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
String className; | String className; |
Array<KeyBinding> keyBindings; |
Array<CIMKeyBinding> keyBindings; |
| |
if (!getInstanceNameElement(parser, className, keyBindings)) | if (!getInstanceNameElement(parser, className, keyBindings)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_INSTANCENAME_ELEMENT", |
"expected INSTANCENAME element"); | "expected INSTANCENAME element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
reference.set(host, nameSpace, className, keyBindings); | reference.set(host, nameSpace, className, keyBindings); |
|
|
| |
if (!getLocalNameSpacePathElement(parser, nameSpace)) | if (!getLocalNameSpacePathElement(parser, nameSpace)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_LOCALNAMESPACEPATH_ELEMENT", |
"expected LOCALNAMESPACEPATH element"); | "expected LOCALNAMESPACEPATH element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
String className; | String className; |
Array<KeyBinding> keyBindings; |
Array<CIMKeyBinding> keyBindings; |
| |
if (!getInstanceNameElement(parser, className, keyBindings)) | if (!getInstanceNameElement(parser, className, keyBindings)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_INSTANCENAME_ELEMENT", |
"expected INSTANCENAME element"); | "expected INSTANCENAME element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
reference.set(String(), nameSpace, className, keyBindings); | reference.set(String(), nameSpace, className, keyBindings); |
|
|
| |
if (!getNameSpacePathElement(parser, host, nameSpace)) | if (!getNameSpacePathElement(parser, host, nameSpace)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_NAMESPACEPATH_ELEMENT", |
"expected NAMESPACEPATH element"); | "expected NAMESPACEPATH element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
String className; |
CIMName className; |
| |
if (!getClassNameElement(parser, className)) | if (!getClassNameElement(parser, className)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_CLASSNAME_ELEMENT", |
"expected CLASSNAME element"); | "expected CLASSNAME element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
reference.set(host, nameSpace, className); | reference.set(host, nameSpace, className); |
|
|
| |
if (!getLocalNameSpacePathElement(parser, nameSpace)) | if (!getLocalNameSpacePathElement(parser, nameSpace)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_LOCALNAMESPACEPATH_ELEMENT", |
"expected LOCALNAMESPACEPATH element"); | "expected LOCALNAMESPACEPATH element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
String className; |
CIMName className; |
| |
if (!getClassNameElement(parser, className)) | if (!getClassNameElement(parser, className)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_CLASSNAME_ELEMENT", |
"expected CLASSNAME element"); | "expected CLASSNAME element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
reference.set(String(), nameSpace, className); | reference.set(String(), nameSpace, className); |
|
|
if (entry.type != XmlEntry::START_TAG && | if (entry.type != XmlEntry::START_TAG && |
entry.type != XmlEntry::EMPTY_TAG) | entry.type != XmlEntry::EMPTY_TAG) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
"Expected one of the following start tags: " |
"Common.XmlReader.EXPECTED_START_TAGS", |
"CLASSPATH, LOCALCLASSPATH, CLASSNAME, INSTANCEPATH, " |
"Expected one of the following start tags: CLASSPATH, " |
"LOCALINSTANCEPATH, INSTANCENAME"); |
"LOCALCLASSPATH, CLASSNAME, INSTANCEPATH, LOCALINSTANCEPATH, " |
|
"INSTANCENAME"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
if (strcmp(entry.text, "CLASSPATH") == 0) | if (strcmp(entry.text, "CLASSPATH") == 0) |
|
|
else if (strcmp(entry.text, "CLASSNAME") == 0) | else if (strcmp(entry.text, "CLASSNAME") == 0) |
{ | { |
parser.putBack(entry); | parser.putBack(entry); |
String className; |
CIMName className; |
getClassNameElement(parser, className); | getClassNameElement(parser, className); |
reference.set(String(), CIMNamespaceName(), className); | reference.set(String(), CIMNamespaceName(), className); |
} | } |
|
|
{ | { |
parser.putBack(entry); | parser.putBack(entry); |
String className; | String className; |
Array<KeyBinding> keyBindings; |
Array<CIMKeyBinding> keyBindings; |
getInstanceNameElement(parser, className, keyBindings); | getInstanceNameElement(parser, className, keyBindings); |
reference.set(String(), CIMNamespaceName(), className, keyBindings); | reference.set(String(), CIMNamespaceName(), className, keyBindings); |
} | } |
|
|
| |
// Get PROPERTY.NAME attribute: | // Get PROPERTY.NAME attribute: |
| |
String name = getCimNameAttribute( |
CIMName name = getCimNameAttribute( |
parser.getLine(), entry, "PROPERTY.REFERENCE"); | parser.getLine(), entry, "PROPERTY.REFERENCE"); |
| |
// Get PROPERTY.REFERENCECLASS attribute: | // Get PROPERTY.REFERENCECLASS attribute: |
|
|
} | } |
catch (AlreadyExistsException&) | catch (AlreadyExistsException&) |
{ | { |
throw XmlSemanticError(parser.getLine(), "duplicate property"); |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.DUPLICATE_PROPERTY", |
|
"duplicate property"); |
|
throw XmlSemanticError(parser.getLine(), mlParms); |
} | } |
} | } |
} | } |
|
|
| |
// Get PARAMETER.NAME attribute: | // Get PARAMETER.NAME attribute: |
| |
String name = getCimNameAttribute(parser.getLine(), entry, "PARAMETER"); |
CIMName name = getCimNameAttribute(parser.getLine(), entry, "PARAMETER"); |
| |
// Get PARAMETER.TYPE attribute: | // Get PARAMETER.TYPE attribute: |
| |
|
|
| |
// Get PARAMETER.ARRAY.NAME attribute: | // Get PARAMETER.ARRAY.NAME attribute: |
| |
String name = getCimNameAttribute( |
CIMName name = getCimNameAttribute( |
parser.getLine(), entry, "PARAMETER.ARRAY"); | parser.getLine(), entry, "PARAMETER.ARRAY"); |
| |
// Get PARAMETER.ARRAY.TYPE attribute: | // Get PARAMETER.ARRAY.TYPE attribute: |
|
|
| |
// Get PARAMETER.NAME attribute: | // Get PARAMETER.NAME attribute: |
| |
String name = getCimNameAttribute( |
CIMName name = getCimNameAttribute( |
parser.getLine(), entry, "PARAMETER.REFERENCE"); | parser.getLine(), entry, "PARAMETER.REFERENCE"); |
| |
// Get PARAMETER.REFERENCECLASS attribute: | // Get PARAMETER.REFERENCECLASS attribute: |
|
|
| |
// Get PARAMETER.NAME attribute: | // Get PARAMETER.NAME attribute: |
| |
String name = getCimNameAttribute( |
CIMName name = getCimNameAttribute( |
parser.getLine(), entry, "PARAMETER.REFARRAY"); | parser.getLine(), entry, "PARAMETER.REFARRAY"); |
| |
// Get PARAMETER.REFERENCECLASS attribute: | // Get PARAMETER.REFERENCECLASS attribute: |
|
|
// Get PARAMETER.ARRAYSIZE attribute: | // Get PARAMETER.ARRAYSIZE attribute: |
| |
Uint32 arraySize = 0; | Uint32 arraySize = 0; |
getArraySizeAttribute(parser.getLine(), entry, "PARAMETER.REFARRAY", |
getArraySizeAttribute( |
arraySize); |
parser.getLine(), entry, "PARAMETER.REFARRAY", arraySize); |
| |
// Create parameter: | // Create parameter: |
| |
parameter = CIMParameter(name, CIMTYPE_REFERENCE, true, arraySize, |
parameter = CIMParameter( |
referenceClass); |
name, CIMTYPE_REFERENCE, true, arraySize, referenceClass); |
| |
if (!empty) | if (!empty) |
{ | { |
|
|
} | } |
catch (AlreadyExistsException&) | catch (AlreadyExistsException&) |
{ | { |
throw XmlSemanticError(parser.getLine(), "duplicate parameter"); |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.DUPLICATE_PARAMETER", |
|
"duplicate parameter"); |
|
throw XmlSemanticError(parser.getLine(), mlParms); |
} | } |
} | } |
} | } |
|
|
| |
// Get NAME attribute: | // Get NAME attribute: |
| |
String name = getCimNameAttribute( |
CIMName name = getCimNameAttribute( |
parser.getLine(), entry, "QUALIFIER.DECLARATION"); | parser.getLine(), entry, "QUALIFIER.DECLARATION"); |
| |
// Get TYPE attribute: | // Get TYPE attribute: |
|
|
{ | { |
if (!isArray) | if (!isArray) |
{ | { |
throw XmlSemanticError(parser.getLine(), |
MessageLoaderParms mlParms( |
"VALUE.ARRAY element encountered without " |
"Common.XmlReader.ARRAY_WITHOUT_ISARRAY", |
"ISARRAY attribute"); |
"VALUE.ARRAY element encountered without ISARRAY " |
|
"attribute"); |
|
throw XmlSemanticError(parser.getLine(), mlParms); |
} | } |
| |
if (arraySize && arraySize != value.getArraySize()) | if (arraySize && arraySize != value.getArraySize()) |
{ | { |
throw XmlSemanticError(parser.getLine(), |
MessageLoaderParms mlParms( |
"VALUE.ARRAY size is not the same as " |
"Common.XmlReader.ARRAY_SIZE_NOT_SAME", |
"ARRAYSIZE attribute"); |
"VALUE.ARRAY size is not the same as ARRAYSIZE attribute"); |
|
throw XmlSemanticError(parser.getLine(), mlParms); |
} | } |
| |
gotValue = true; | gotValue = true; |
|
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
throw XmlSemanticError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.ARRAY_ATTRIBUTE_DIFFERENT", |
"ISARRAY attribute used but VALUE element encountered"); | "ISARRAY attribute used but VALUE element encountered"); |
|
throw XmlSemanticError(parser.getLine(), mlParms); |
} | } |
| |
gotValue = true; | gotValue = true; |
|
|
| |
Boolean empty = entry.type == XmlEntry::EMPTY_TAG; | Boolean empty = entry.type == XmlEntry::EMPTY_TAG; |
| |
String name = getCimNameAttribute(parser.getLine(), entry, "PROPERTY"); |
CIMName name = getCimNameAttribute(parser.getLine(), entry, "METHOD"); |
| |
CIMType type; | CIMType type; |
getCimTypeAttribute(parser.getLine(), entry, type, "PROPERTY"); |
getCimTypeAttribute(parser.getLine(), entry, type, "METHOD"); |
| |
CIMName classOrigin = | CIMName classOrigin = |
getClassOriginAttribute(parser.getLine(), entry, "PROPERTY"); |
getClassOriginAttribute(parser.getLine(), entry, "METHOD"); |
| |
Boolean propagated = getCimBooleanAttribute( | Boolean propagated = getCimBooleanAttribute( |
parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false); |
parser.getLine(), entry, "METHOD", "PROPAGATED", false, false); |
| |
method = CIMMethod(name, type, classOrigin, propagated); | method = CIMMethod(name, type, classOrigin, propagated); |
| |
|
|
{ | { |
XmlEntry entry; | XmlEntry entry; |
| |
if (!testStartTag(parser, entry, "CLASS")) |
if (!testStartTagOrEmptyTag(parser, entry, "CLASS")) |
return false; | return false; |
| |
String name = getCimNameAttribute(parser.getLine(), entry, "CLASS"); |
CIMName name = getCimNameAttribute(parser.getLine(), entry, "CLASS"); |
| |
CIMName superClass = getSuperClassAttribute(parser.getLine(), entry,"CLASS"); |
CIMName superClass = |
|
getSuperClassAttribute(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; |
} | } |
|
|
| |
if (!getInstanceNameElement(parser, instanceName)) | if (!getInstanceNameElement(parser, instanceName)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_INSTANCENAME_ELEMENT", |
"expected INSTANCENAME element"); | "expected INSTANCENAME element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
// Get INSTANCE elements: | // Get INSTANCE elements: |
| |
if (!getInstanceElement(parser, namedInstance)) | if (!getInstanceElement(parser, namedInstance)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_INSTANCE_ELEMENT", |
"expected INSTANCE element"); | "expected INSTANCE element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
// Get VALUE.NAMEDINSTANCE end tag: | // Get VALUE.NAMEDINSTANCE end tag: |
|
|
{ | { |
if (!getClassElement(parser, x)) | if (!getClassElement(parser, x)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_CLASS_ELEMENT", |
"expected CLASS element"); | "expected CLASS element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
} | } |
| |
|
|
{ | { |
if (!getInstanceElement(parser, x)) | if (!getInstanceElement(parser, x)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_INSTANCE_ELEMENT", |
"expected INSTANCE element"); | "expected INSTANCE element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
} | } |
| |
|
|
{ | { |
if (!getQualifierDeclElement(parser, x)) | if (!getQualifierDeclElement(parser, x)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_QUALIFIER_DECLARATION_ELEMENT", |
"expected QUALIFIER.DECLARATION element"); | "expected QUALIFIER.DECLARATION element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
} | } |
| |
|
|
// Get MESSAGE.ID: | // Get MESSAGE.ID: |
| |
if (!entry.getAttributeValue("ID", id)) | if (!entry.getAttributeValue("ID", id)) |
throw XmlValidationError(parser.getLine(), |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.INVALID_MISSING_MESSAGE_ID_ATTRIBUTE", |
"Invalid or missing MESSAGE.ID attribute"); | "Invalid or missing MESSAGE.ID attribute"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
|
| |
// Get MESSAGE.PROTOCOLVERSION: | // Get MESSAGE.PROTOCOLVERSION: |
| |
if (!entry.getAttributeValue("PROTOCOLVERSION", protocolVersion)) | if (!entry.getAttributeValue("PROTOCOLVERSION", protocolVersion)) |
throw XmlValidationError(parser.getLine(), |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.INVALID_MISSING_PROTOCOLVERSION_ATTRIBUTE", |
"Invalid or missing MESSAGE.PROTOCOLVERSION attribute"); | "Invalid or missing MESSAGE.PROTOCOLVERSION attribute"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
| |
return true; | return true; |
} | } |
|
|
| |
// Get IMETHODCALL.NAME attribute: | // Get IMETHODCALL.NAME attribute: |
| |
|
|
if (!entry.getAttributeValue("NAME", name)) | if (!entry.getAttributeValue("NAME", name)) |
throw XmlValidationError(parser.getLine(), |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_IMETHODCALL_ATTRIBUTE", |
"Missing IMETHODCALL.NAME attribute"); | "Missing IMETHODCALL.NAME attribute"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
|
| |
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)) |
throw XmlValidationError(parser.getLine(), |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_IMETHODRESPONSE_ATTRIBUTE", |
"Missing IMETHODRESPONSE.NAME attribute"); | "Missing IMETHODRESPONSE.NAME attribute"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
|
| |
return true; | return true; |
} | } |
|
|
| |
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)) |
throw XmlValidationError(parser.getLine(), |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_IPARAMVALUE_ATTRIBUTE", |
"Missing IPARAMVALUE.NAME attribute"); | "Missing IPARAMVALUE.NAME attribute"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
| |
return true; | return true; |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
// 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>" |
|
|
{ | { |
if (required) | if (required) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_VALUE_ELEMENT", |
"Expected VALUE element"); | "Expected VALUE element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
return false; | return false; |
} | } |
| |
expectContentOrCData(parser, entry); | expectContentOrCData(parser, entry); |
| |
if (CompareNoCase(entry.text, "TRUE") == 0) |
if (System::strcasecmp(entry.text, "TRUE") == 0) |
result = true; | result = true; |
else if (CompareNoCase(entry.text, "FALSE") == 0) |
else if (System::strcasecmp(entry.text, "FALSE") == 0) |
result = false; | result = false; |
else | else |
throw XmlSemanticError(parser.getLine(), |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.INVALID_VALUE_FOR_VALUE_ELEMENT", |
"Invalid value for VALUE element: must be \"TRUE\" or \"FALSE\""); | "Invalid value for VALUE element: must be \"TRUE\" or \"FALSE\""); |
|
throw XmlSemanticError(parser.getLine(), mlParms); |
|
} |
| |
expectEndTag(parser, "VALUE"); | expectEndTag(parser, "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> |
|
|
if (!testStartTagOrEmptyTag(parser, entry, "ERROR")) | if (!testStartTagOrEmptyTag(parser, entry, "ERROR")) |
{ | { |
if (required) | if (required) |
throw XmlValidationError(parser.getLine(),"Expected ERROR element"); |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_ERROR_ELEMENT", |
|
"Expected ERROR element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
return false; | return false; |
} | } |
| |
|
|
Uint32 tmpCode; | Uint32 tmpCode; |
| |
if (!entry.getAttributeValue("CODE", tmpCode)) | if (!entry.getAttributeValue("CODE", tmpCode)) |
throw XmlValidationError( |
{ |
parser.getLine(), "missing ERROR.CODE attribute"); |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_ERROR_CODE_ATTRIBUTE", |
|
"missing ERROR.CODE attribute"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
| |
// Get ERROR.DESCRIPTION: | // Get ERROR.DESCRIPTION: |
| |
|
|
| |
entry.getAttributeValue("DESCRIPTION", tmpDescription); | entry.getAttributeValue("DESCRIPTION", tmpDescription); |
| |
|
cimException = |
|
PEGASUS_CIM_EXCEPTION(CIMStatusCode(tmpCode), tmpDescription); |
|
|
if (!empty) | if (!empty) |
|
{ |
|
CIMInstance instance; |
|
|
|
while (getInstanceElement(parser, instance)) |
|
{ |
|
cimException.addError(instance); |
|
} |
|
|
expectEndTag(parser, "ERROR"); | expectEndTag(parser, "ERROR"); |
|
} |
| |
cimException = PEGASUS_CIM_EXCEPTION(CIMStatusCode(tmpCode), tmpDescription); |
|
return true; | return true; |
} | } |
| |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// getValueObjectElement() | // getValueObjectElement() |
// | // |
|
|
{ | { |
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 | else |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_INSTANCE_OR_CLASS_ELEMENT", |
"Expected INSTANCE or CLASS element"); | "Expected INSTANCE or CLASS element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
expectEndTag(parser, "VALUE.OBJECT"); | expectEndTag(parser, "VALUE.OBJECT"); |
|
|
isInstance = true; | isInstance = true; |
else if (!XmlReader::getClassPathElement(parser, reference)) | else if (!XmlReader::getClassPathElement(parser, reference)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_INSTANCEPATH_OR_CLASSPATH_ELEMENT", |
"Expected INSTANCEPATH or CLASSPATH element"); | "Expected INSTANCEPATH or CLASSPATH element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
if (isInstance) | if (isInstance) |
|
|
| |
if (!XmlReader::getInstanceElement(parser, cimInstance)) | if (!XmlReader::getInstanceElement(parser, cimInstance)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_INSTANCE_ELEMENT", |
"Expected INSTANCE element"); | "Expected INSTANCE element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
objectWithPath = CIMObject (cimInstance); | objectWithPath = CIMObject (cimInstance); |
objectWithPath.setPath (reference); | objectWithPath.setPath (reference); |
|
|
| |
if (!XmlReader::getClassElement(parser, cimClass)) | if (!XmlReader::getClassElement(parser, cimClass)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_CLASS_ELEMENT", |
"Expected CLASS element"); | "Expected CLASS element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
objectWithPath = CIMObject (cimClass); | objectWithPath = CIMObject (cimClass); |
objectWithPath.setPath (reference); | objectWithPath.setPath (reference); |
|
|
isInstance = true; | isInstance = true; |
else if (!XmlReader::getLocalClassPathElement(parser, reference)) | else if (!XmlReader::getLocalClassPathElement(parser, reference)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
"Expected LOCALINSTANCEPATH or LOCALCLASSPATH element"); |
"Common.XmlConstants.MISSING_ELEMENT_LOCALPATH", |
|
MISSING_ELEMENT_LOCALPATH); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
if (isInstance) | if (isInstance) |
|
|
| |
if (!XmlReader::getInstanceElement(parser, cimInstance)) | if (!XmlReader::getInstanceElement(parser, cimInstance)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_INSTANCE_ELEMENT", |
"Expected INSTANCE element"); | "Expected INSTANCE element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
objectWithPath = CIMObject (cimInstance); | objectWithPath = CIMObject (cimInstance); |
objectWithPath.setPath (reference); | objectWithPath.setPath (reference); |
|
|
| |
if (!XmlReader::getClassElement(parser, cimClass)) | if (!XmlReader::getClassElement(parser, cimClass)) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_CLASS_ELEMENT", |
"Expected CLASS element"); | "Expected CLASS element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
objectWithPath = CIMObject (cimClass); | objectWithPath = CIMObject (cimClass); |
objectWithPath.setPath (reference); | objectWithPath.setPath (reference); |
|
|
XmlParser& parser, | XmlParser& parser, |
CIMObjectPath& objectName) | CIMObjectPath& objectName) |
{ | { |
String className; |
CIMName className; |
| |
if (getClassNameElement(parser, className, false)) | if (getClassNameElement(parser, className, false)) |
{ | { |
objectName.set(String(), CIMNamespaceName(), className); | objectName.set(String(), CIMNamespaceName(), className); |
return true; | return true; |
} | } |
else if (getInstanceNameElement(parser, objectName)) |
|
return true; |
if (!getInstanceNameElement(parser, objectName)) |
else |
|
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
"expected CLASSNAME or INSTANCENAME element"); |
"Common.XmlReader.EXPECTED_CLASSNAME_OR_INSTANCENAME_ELEMENT", |
|
"Expected CLASSNAME or INSTANCENAME element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
return false; |
return true; |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
if (!testStartTag(parser, entry, "OBJECTPATH")) | if (!testStartTag(parser, entry, "OBJECTPATH")) |
return false; | return false; |
| |
if (getClassPathElement(parser, objectPath)) |
if (!getClassPathElement(parser, objectPath) && |
{ |
!getInstancePathElement(parser, objectPath)) |
expectEndTag(parser, "OBJECTPATH"); |
|
return true; |
|
} |
|
else if (getInstancePathElement(parser, objectPath)) |
|
{ |
|
expectEndTag(parser, "OBJECTPATH"); |
|
return true; |
|
} |
|
else |
|
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_INSTANCEPATH_OR_CLASSPATH_ELEMENT", |
"expected INSTANCEPATH or CLASSPATH element"); | "expected INSTANCEPATH or CLASSPATH element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
| |
PEGASUS_UNREACHABLE ( return false; ) |
expectEndTag(parser, "OBJECTPATH"); |
|
return true; |
} | } |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
|
|
| |
// Get EXPMETHODCALL.NAME attribute: | // Get EXPMETHODCALL.NAME attribute: |
| |
|
|
if (!entry.getAttributeValue("NAME", name)) | if (!entry.getAttributeValue("NAME", name)) |
throw XmlValidationError(parser.getLine(), |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_EXPMETHODCALL_ATTRIBUTE", |
"Missing EXPMETHODCALL.NAME attribute"); | "Missing EXPMETHODCALL.NAME attribute"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
| |
return true; | return true; |
} | } |
|
|
| |
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: |
| |
|
|
if (!entry.getAttributeValue("NAME", name)) | if (!entry.getAttributeValue("NAME", name)) |
throw XmlValidationError(parser.getLine(), |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_EXPMETHODRESPONSE_ATTRIBUTE", |
"Missing EXPMETHODRESPONSE.NAME attribute"); | "Missing EXPMETHODRESPONSE.NAME attribute"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
|
|
return true; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// getEParamValueTag() |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
Boolean XmlReader::getEParamValueTag( |
|
XmlParser& parser, |
|
const char*& name) |
|
{ |
|
XmlEntry entry; |
|
|
|
if (!testStartTag(parser, entry, "EXPPARAMVALUE")) |
|
return false; |
|
|
|
// Get EXPPARAMVALUE.NAME attribute: |
|
|
|
|
|
if (!entry.getAttributeValue("NAME", name)) |
|
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_EXPPARAMVALUE_ATTRIBUTE", |
|
"Missing EXPPARAMVALUE.NAME attribute"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
|
|
|
| |
return true; | return true; |
} | } |
|
|
| |
// Get METHODCALL.NAME attribute: | // Get METHODCALL.NAME attribute: |
| |
|
|
if (!entry.getAttributeValue("NAME", name)) | if (!entry.getAttributeValue("NAME", name)) |
throw XmlValidationError(parser.getLine(), |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_METHODCALL_ATTRIBUTE", |
"Missing METHODCALL.NAME attribute"); | "Missing METHODCALL.NAME attribute"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
|
| |
return true; | return true; |
} | } |
|
|
| |
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: |
| |
|
|
if (!entry.getAttributeValue("NAME", name)) | if (!entry.getAttributeValue("NAME", name)) |
throw XmlValidationError(parser.getLine(), |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_METHODRESPONSE_ATTRIBUTE", |
"Missing METHODRESPONSE.NAME attribute"); | "Missing METHODRESPONSE.NAME attribute"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
| |
return true; | return true; |
} | } |
|
|
// <!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")) |
|
|
// Get PARAMVALUE.NAME attribute: | // Get PARAMVALUE.NAME attribute: |
| |
if (!entry.getAttributeValue("NAME", name)) | if (!entry.getAttributeValue("NAME", name)) |
throw XmlValidationError(parser.getLine(), |
{ |
|
MessageLoaderParms mlParms( |
|
"Common.XmlReader.MISSING_PARAMVALUE_ATTRIBUTE", |
"Missing PARAMVALUE.NAME attribute"); | "Missing PARAMVALUE.NAME attribute"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
|
} |
|
|
|
// Get PROPERTY.EmbeddedObject |
|
|
|
EmbeddedObjectAttributeType 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 ) |
|
|
type = CIMTYPE_REFERENCE; | type = CIMTYPE_REFERENCE; |
gotType = true; | gotType = true; |
} | } |
// If type==reference but no VALUE.REFERENCE found, use null value |
else |
|
{ |
|
gotType = false; // Can't distinguish array and non-array types |
|
} |
} | } |
| |
// Parse non-reference value | // Parse non-reference value |
|
|
effectiveType = type; | effectiveType = type; |
} | } |
| |
if ( !XmlReader::getValueArrayElement(parser, effectiveType, value) && |
// If the EmbeddedObject attribute is present with value "object" |
!XmlReader::getValueElement(parser, effectiveType, value) ) |
// then |
|
// Convert the EmbeddedObject-encoded string into a CIMObject |
|
if (embeddedObject != NO_EMBEDDED_OBJECT) |
|
{ |
|
// The EmbeddedObject attribute is only valid on Parameters |
|
// of type string |
|
// The type must have been specified. |
|
if (gotType && (type == CIMTYPE_STRING)) |
|
{ |
|
if (embeddedObject == EMBEDDED_OBJECT_ATTR) |
|
// Used below by getValueElement() or |
|
// getValueArrayElement() |
|
effectiveType = CIMTYPE_OBJECT; |
|
else |
|
effectiveType = CIMTYPE_INSTANCE; |
|
} |
|
else |
|
{ |
|
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) |
|
&& !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 |
} | } |
} | } |
|
|
// | // |
// <!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 |
|
|
|
EmbeddedObjectAttributeType 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) |
| |
|
|
} | } |
else if (type == CIMTYPE_REFERENCE) | else if (type == CIMTYPE_REFERENCE) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_VALUE_REFERENCE_ELEMENT", |
"expected VALUE.REFERENCE element"); | "expected VALUE.REFERENCE element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
} | } |
| |
|
|
// 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; |
} | } |
|
if (embeddedObject != NO_EMBEDDED_OBJECT) |
|
{ |
|
if (gotType && (type == CIMTYPE_STRING)) |
|
{ |
|
if (embeddedObject == EMBEDDED_OBJECT_ATTR) |
|
// Used below by getValueElement() or getValueArrayElement() |
|
type = CIMTYPE_OBJECT; |
|
else |
|
type = CIMTYPE_INSTANCE; |
|
} |
|
else |
|
{ |
|
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) ) |
{ | { |
throw XmlValidationError(parser.getLine(), |
MessageLoaderParms mlParms( |
|
"Common.XmlReader.EXPECTED_VALUE_ELEMENT", |
"expected VALUE element"); | "expected VALUE element"); |
|
throw XmlValidationError(parser.getLine(), mlParms); |
} | } |
} | } |
| |
|
|
return true; | return true; |
} | } |
| |
|
//----------------------------------------------------------------------------- |
|
// |
|
// The following is a common set of version tests used by the different |
|
// Pegasus Request and Response Decoders |
|
// |
|
//------------------------------------------------------------------------------ |
|
// |
|
// isSupportedCIMVersion() |
|
// tests for valid CIMVersion number |
|
// |
|
// Reject cimVersion not in 2.[0-9]+ |
|
// |
|
// CIMXML Secification, Version 2.2 Final, Sect 3.2.1.1 |
|
// The CIMVERSION attribute defines the version of the CIM Specification to |
|
// which the XML Document conforms. It MUST be in the form of "M.N". Where |
|
// M is the Major Version of the specification in numeric form and N is the |
|
// minor version of the specification in numeric form. For example, "2.0", |
|
// "2.1". Implementations must only validate the major version as all minor |
|
// versions are backward compatible. Implementations may look at the minor |
|
// version to determine additional capabilites. |
|
// |
|
//------------------------------------------------------------------------------ |
|
Boolean XmlReader::isSupportedCIMVersion( |
|
const char* cimVersion) |
|
{ |
|
Boolean cimVersionAccepted = false; |
|
//printf("testCIMVersion %s \n", cimVersion); |
|
if ((cimVersion[0] == '2') && |
|
(cimVersion[1] == '.') && |
|
(cimVersion[2] != 0)) |
|
{ |
|
// Verify that all characters after the '.' are digits |
|
Uint32 index = 2; |
|
while (isdigit(cimVersion[index])) |
|
{ |
|
index++; |
|
} |
|
|
|
if (cimVersion[index] == 0) |
|
{ |
|
cimVersionAccepted = true; |
|
} |
|
} |
|
return cimVersionAccepted; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// isSupportedProtocolVersion() |
|
// tests for valid ProtocolVersion number |
|
// |
|
// Reject ProtocolVersion not 1.[0-9] |
|
// |
|
// cimxml spec 2.2 Final Section 3261 |
|
// The PROTOCOLVERSION attribute defines the version of the CIM Operations to |
|
// which this message conforms. It MUST be in the form of "M.N". Where M is |
|
// the Major Version of the specification in numeric form and N is the minor |
|
// version of the specification in numeric form. For example, "1.0", "1.1". |
|
// Implementations must only validate the major version as all minor versions |
|
// are backward compatible. Implementations may look at the minor version to |
|
// determine additional capabilites. |
|
// |
|
//------------------------------------------------------------------------------ |
|
Boolean XmlReader::isSupportedProtocolVersion( |
|
const String& protocolVersion) |
|
{ |
|
Boolean protocolVersionAccepted = false; |
|
|
|
//cout << "testProtocolVersion " << protocolVersion << endl; |
|
if ((protocolVersion.size() >= 3) && |
|
(protocolVersion[0] == '1') && |
|
(protocolVersion[1] == '.')) |
|
{ |
|
// Verify that all characters after the '.' are digits |
|
Uint32 index = 2; |
|
while ((index < protocolVersion.size()) && |
|
(protocolVersion[index] >= '0') && |
|
(protocolVersion[index] <= '9')) |
|
{ |
|
index++; |
|
} |
|
|
|
if (index == protocolVersion.size()) |
|
{ |
|
protocolVersionAccepted = true; |
|
} |
|
} |
|
return protocolVersionAccepted; |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// isSupportedDTDVersion() |
|
// Tests for Valid dtdVersion number |
|
// We accept DTD version 2.[0-9]+ (see Bugzilla 1556)// |
|
// |
|
// CIM/XML Specification, V 2.2 Final, Section 3.2.1.1 |
|
// The DTDVERSION attribute defines the version of the CIM XML Mapping to |
|
// which the XML Document conforms. It MUST be in the form of "M.N". Where |
|
// M is the Major Version of the specification in numeric form and N is the |
|
// minor version of the specification in numeric form. For example, "2.0", |
|
// "2.1". Implementations must only validate the major version as all minor |
|
// versions are backward compatible. Implementations may look at the minor |
|
// version to determine additional capabilites. |
|
// |
|
//------------------------------------------------------------------------------ |
|
Boolean XmlReader::isSupportedDTDVersion( |
|
const char* dtdVersion) |
|
{ |
|
Boolean dtdVersionAccepted = false; |
|
|
|
//printf("testDTDVersion %s \n", dtdVersion); |
|
if ((dtdVersion[0] == '2') && |
|
(dtdVersion[1] == '.') && |
|
(dtdVersion[2] != 0)) |
|
{ |
|
// Verify that all characters after the '.' are digits |
|
Uint32 index = 2; |
|
while (isdigit(dtdVersion[index])) |
|
{ |
|
index++; |
|
} |
|
|
|
if (dtdVersion[index] == 0) |
|
{ |
|
dtdVersionAccepted = true; |
|
} |
|
} |
|
return dtdVersionAccepted; |
|
} |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |