(file) Return to XmlReader.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/XmlReader.cpp between version 1.129.12.3 and 1.144.4.4

version 1.129.12.3, 2009/03/17 13:59:13 version 1.144.4.4, 2013/06/03 22:35:14
Line 1 
Line 1 
 //%2006////////////////////////////////////////////////////////////////////////  //%LICENSE////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development  // Licensed to The Open Group (TOG) under one or more contributor license
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.  // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;  // this work for additional information regarding copyright ownership.
 // IBM Corp.; EMC Corporation, The Open Group.  // Each contributor licenses this file to you under the OpenPegasus Open
 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;  // Source License; you may not use this file except in compliance with the
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.  // License.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;  //
 // EMC Corporation; VERITAS Software Corporation; The Open Group.  // Permission is hereby granted, free of charge, to any person obtaining a
 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;  // copy of this software and associated documentation files (the "Software"),
 // EMC Corporation; Symantec Corporation; The Open Group.  // to deal in the Software without restriction, including without limitation
 //  // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 // Permission is hereby granted, free of charge, to any person obtaining a copy  // and/or sell copies of the Software, and to permit persons to whom the
 // of this software and associated documentation files (the "Software"), to  // Software is furnished to do so, subject to the following conditions:
 // deal in the Software without restriction, including without limitation the  //
 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  // The above copyright notice and this permission notice shall be included
 // sell copies of the Software, and to permit persons to whom the Software is  // in all copies or substantial portions of the Software.
 // furnished to do so, subject to the following conditions:  //
 //  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT  // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR  // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT  // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN  // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // 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.  
 // //
 //==============================================================================  //////////////////////////////////////////////////////////////////////////
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
Line 40 
Line 38 
 # 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"
Line 54 
Line 53 
 #include <Pegasus/Common/MessageLoader.h> #include <Pegasus/Common/MessageLoader.h>
 #include <Pegasus/Common/StringConversion.h> #include <Pegasus/Common/StringConversion.h>
 #include <Pegasus/Common/AutoPtr.h> #include <Pegasus/Common/AutoPtr.h>
 #include "CIMNameUnchecked.h"  
  
 PEGASUS_USING_STD; PEGASUS_USING_STD;
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
Line 206 
Line 204 
     {     {
         MessageLoaderParms mlParms(         MessageLoaderParms mlParms(
             "Common.XmlReader.EXPECTED_CDATA",             "Common.XmlReader.EXPECTED_CDATA",
             "Expected content of CDATA");              "Expected content or CDATA");
         throw XmlValidationError(parser.getLine(), mlParms);         throw XmlValidationError(parser.getLine(), mlParms);
     }     }
  
Line 267 
Line 265 
     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)
     {     {
Line 371 
Line 372 
     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))
     {     {
Line 385 
Line 386 
         throw XmlValidationError(lineNumber, mlParms);         throw XmlValidationError(lineNumber, mlParms);
     }     }
  
     if (acceptNull && name.size() == 0)      if (acceptNull && *name == '\0')
         return CIMName ();         return CIMName ();
  
     if (!CIMName::legal(name))      Uint32 size = CIMNameLegalASCII(name);
   
       if (size)
     {     {
 #ifdef PEGASUS_SNIA_INTEROP_TEST          String tmp(name, size);
     // In testing, replace illegal CIMName with this value to avoid the          return CIMName(CIMNameCast(tmp));
     // exception and let xml parsing continue.  THIS IS TEMP.      }
     name = "BADNAMESUBSTITUTEDBYPEGASUSCLIENT";  
 #else  
  
       if (!CIMName::legal(name))
       {
     char buffer[MESSAGE_SIZE];     char buffer[MESSAGE_SIZE];
     sprintf(buffer, "%s.NAME", elementName);     sprintf(buffer, "%s.NAME", elementName);
  
Line 405 
Line 408 
         buffer);         buffer);
  
     throw XmlSemanticError(lineNumber, mlParms);     throw XmlSemanticError(lineNumber, mlParms);
   
 #endif  
     }     }
     return CIMNameUnchecked(name);  
       return CIMNameCast(name);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 495 
Line 497 
         throw XmlSemanticError(lineNumber, mlParms);         throw XmlSemanticError(lineNumber, mlParms);
     }     }
     // The CIMName was already checked with legal() + String()     // The CIMName was already checked with legal() + String()
     return CIMNameUnchecked(name);      return CIMNameCast(name);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 570 
Line 572 
  
     if (!CIMName::legal(name))     if (!CIMName::legal(name))
     {     {
 #ifdef PEGASUS_SNIA_INTEROP_TEST  
         name = "PEGASUS_SUBSTITUED_THIS_FOR_BAD_NAME";  
         return name;  
 #endif  
   
         char buffer[MESSAGE_SIZE];         char buffer[MESSAGE_SIZE];
         sprintf(buffer, "%s.REFERENCECLASS", elementName);         sprintf(buffer, "%s.REFERENCECLASS", elementName);
  
Line 585 
Line 582 
         throw XmlSemanticError(lineNumber, mlParms);         throw XmlSemanticError(lineNumber, mlParms);
     }     }
     // The CIMName was already checked with legal() + String()     // The CIMName was already checked with legal() + String()
     return CIMNameUnchecked(name);      return CIMNameCast(name);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 618 
Line 615 
         throw XmlSemanticError(lineNumber, mlParms);         throw XmlSemanticError(lineNumber, mlParms);
     }     }
     // The CIMName was already checked with legal() + String()     // The CIMName was already checked with legal() + String()
     return CIMNameUnchecked(superClass);      return CIMNameCast(superClass);
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 783 
Line 780 
 { {
     Uint32 i;     Uint32 i;
  
     Array<Uint8> utf8Chars;      Buffer utf8Chars;
  
     for (i=0; i<uriString.size(); i++)     for (i=0; i<uriString.size(); i++)
     {     {
Line 810 
Line 807 
             }             }
  
             Uint16 decodedChar = Uint16(digit1<<4) + Uint16(digit2);             Uint16 decodedChar = Uint16(digit1<<4) + Uint16(digit2);
             utf8Chars.append((Uint8)decodedChar);              utf8Chars.append((char)decodedChar);
         }         }
         else         else
         {         {
             utf8Chars.append((Uint8)uriString[i]);              utf8Chars.append((char)uriString[i]);
         }         }
     }     }
  
Line 822 
Line 819 
     if (uriString.size() > 0)     if (uriString.size() > 0)
     {     {
         // Convert UTF-8 to UTF-16 and return the String         // Convert UTF-8 to UTF-16 and return the String
         utf8Chars.append('\0');          return String(utf8Chars.getData(), utf8Chars.size());
         return String((char *)utf8Chars.getData());  
     }     }
     else     else
     {     {
Line 833 
Line 829 
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // stringToSignedInteger  
 //  
 //      [ "+" | "-" ] ( positiveDecimalDigit *decimalDigit | "0" )  
 //    or  
 //      [ "+" | "-" ] ( "0x" | "0X" ) 1*hexDigit  
 //  
 //------------------------------------------------------------------------------  
   
 Boolean XmlReader::stringToSignedInteger(  
     const char* stringValue,  
     Sint64& x)  
 {  
     return (StringConversion::stringToSint64(  
                 stringValue, StringConversion::decimalStringToUint64, x) ||  
             StringConversion::stringToSint64(  
                 stringValue, StringConversion::hexStringToUint64, x));  
 }  
   
 //------------------------------------------------------------------------------  
 //  
 // stringToUnsignedInteger  
 //  
 //      ( positiveDecimalDigit *decimalDigit | "0" )  
 //    or  
 //      ( "0x" | "0X" ) 1*hexDigit  
 //  
 //------------------------------------------------------------------------------  
   
 Boolean XmlReader::stringToUnsignedInteger(  
     const char* stringValue,  
     Uint64& x)  
 {  
     return (StringConversion::decimalStringToUint64(stringValue, x) ||  
             StringConversion::hexStringToUint64(stringValue, x));  
 }  
   
 //------------------------------------------------------------------------------  
 //  
 // stringToValue() // stringToValue()
 // //
 // Return: CIMValue. If the string input is zero length creates a CIMValue // Return: CIMValue. If the string input is zero length creates a CIMValue
Line 944 
Line 902 
         {         {
             Uint64 x;             Uint64 x;
  
             if (!stringToUnsignedInteger(valueString, x))              if (!StringConversion::stringToUnsignedInteger(valueString, x))
             {             {
                 MessageLoaderParms mlParms(                 MessageLoaderParms mlParms(
                     "Common.XmlReader.INVALID_UI_VALUE",                     "Common.XmlReader.INVALID_UI_VALUE",
Line 999 
Line 957 
         {         {
             Sint64 x;             Sint64 x;
  
             if (!stringToSignedInteger(valueString, x))              if (!StringConversion::stringToSignedInteger(valueString, x))
             {             {
                 MessageLoaderParms mlParms(                 MessageLoaderParms mlParms(
                     "Common.XmlReader.INVALID_SI_VALUE",                     "Common.XmlReader.INVALID_SI_VALUE",
Line 1053 
Line 1011 
  
             try             try
             {             {
                 // KS 20021002 - Exception if no datetime value. Test for  
                 // zero length and leave the NULL value in the variable  
                 // Bugzilla 137  Adds the following if line.  
                 // Expect this to become permanent but test only for now  
 #ifdef PEGASUS_SNIA_INTEROP_TEST  
                 if (valueStringLen != 0)                 if (valueStringLen != 0)
 #endif                  {
                     tmp.set(valueString);                     tmp.set(valueString);
             }             }
               }
             catch (InvalidDateTimeFormatException&)             catch (InvalidDateTimeFormatException&)
             {             {
                 MessageLoaderParms mlParms(                 MessageLoaderParms mlParms(
Line 1106 
Line 1060 
 //  just a Pegasus internal representation of an embedded object. However, //  just a Pegasus internal representation of an embedded object. However,
 //  this case is used when decoding string representations of embedded objects. //  this case is used when decoding string representations of embedded objects.
         case CIMTYPE_OBJECT:         case CIMTYPE_OBJECT:
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         case CIMTYPE_INSTANCE:         case CIMTYPE_INSTANCE:
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         {         {
             CIMObject x;             CIMObject x;
  
Line 1137 
Line 1089 
  
                 if (XmlReader::getInstanceElement(tmp_parser, cimInstance))                 if (XmlReader::getInstanceElement(tmp_parser, cimInstance))
                 {                 {
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
                     if (type == CIMTYPE_INSTANCE)                     if (type == CIMTYPE_INSTANCE)
                         return CIMValue(cimInstance);                         return CIMValue(cimInstance);
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
                     x = CIMObject(cimInstance);                     x = CIMObject(cimInstance);
                 }                 }
                 else if (XmlReader::getClassElement(tmp_parser, cimClass))                 else if (XmlReader::getClassElement(tmp_parser, cimClass))
Line 1149 
Line 1099 
                 }                 }
                 else                 else
                 {                 {
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
                     if (type == CIMTYPE_OBJECT)                     if (type == CIMTYPE_OBJECT)
                     {                     {
                         // change "element" to "embedded object"                         // change "element" to "embedded object"
Line 1167 
Line 1116 
                             "Expected INSTANCE element");                             "Expected INSTANCE element");
                         throw XmlValidationError(lineNumber, mlParms);                         throw XmlValidationError(lineNumber, mlParms);
                     }                     }
 #else  
                     // change "element" to "embedded object"  
                     MessageLoaderParms mlParms(  
                         "Common.XmlReader.EXPECTED_INSTANCE_OR_CLASS_ELEMENT",  
                         "Expected INSTANCE or CLASS element");  
                     throw XmlValidationError(lineNumber, mlParms);  
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
                 }                 }
                 // Ok, now we can delete the storage for the temporary                 // Ok, now we can delete the storage for the temporary
                 // XmlParser.                 // XmlParser.
Line 1261 
Line 1203 
  
         expectEndTag(parser, "VALUE");         expectEndTag(parser, "VALUE");
     }     }
 #ifdef PEGASUS_SNIA_INTEROP_TEST      value = stringToValue(parser.getLine(),valueString,valueStringLen,type);
     // KS 20021004 - tries to put value in even if empty.  
     // Think this is general problem with empty value  
     // Need to check meaning of (#PCDATA) - Does it allow empty.  
     // Bugzilla tbd  
     if (!empty)  
 #endif  
         value = stringToValue(  
             parser.getLine(),  
             valueString,  
             valueStringLen,  
             type);  
  
     return true;     return true;
 } }
Line 1324 
Line 1255 
     return true;     return true;
 } }
  
   // EXP_PULL_BEGIN
   //------------------------------------------------------------------------------
   //
   // getUint32ArgValueElement()
   //
   //     <!ELEMENT VALUE (#PCDATA)>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getUint32ArgValueElement(
       XmlParser& parser,
       Uint32Arg& val,
       Boolean required)
   {
       XmlEntry entry;
   
       if (!testStartTagOrEmptyTag(parser, entry, "VALUE"))
       {
           if (required)
           {
               MessageLoaderParms mlParms(
                   "Common.XmlReader.EXPECTED_VALUE_ELEMENT",
                   "Expected VALUE element");
               throw XmlValidationError(parser.getLine(), mlParms);
           }
           return false;
       }
   
       Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
   
       const char* valueString = "";
   
       if (!empty)
       {
           if (testContentOrCData(parser, entry))
               valueString = entry.text;
   
           expectEndTag(parser, "VALUE");
       }
       else
       {
           // create the arg object with the NULL value in it.
           val = Uint32Arg();
           return true;
       }
   
       //convert to Uint32. Note error if overflow.
   
       Uint64 x;
       if (!StringConversion::stringToUnsignedInteger(valueString, x))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.INVALID_UI_VALUE",
               "Invalid unsigned integer value");
           throw XmlSemanticError(parser.getLine(), mlParms);
       }
   
       if (!StringConversion::checkUintBounds(x, CIMTYPE_UINT32))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.U32_VALUE_OUT_OF_RANGE",
               "Uint32 value out of range");
           throw XmlSemanticError(parser.getLine(), mlParms);
       }
       // create the arg object with the value in it.
       val = Uint32Arg(x);
   
       return true;
   }
   //------------------------------------------------------------------------------
   //
   // getUint64ValueElement()
   //
   //     <!ELEMENT VALUE (#PCDATA)>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getUint64ValueElement(
       XmlParser& parser,
       Uint64Arg& val,
       Boolean required)
   {
       XmlEntry entry;
   
       if (!testStartTagOrEmptyTag(parser, entry, "VALUE"))
       {
           if (required)
           {
               MessageLoaderParms mlParms(
                   "Common.XmlReader.EXPECTED_VALUE_ELEMENT",
                   "Expected VALUE element");
               throw XmlValidationError(parser.getLine(), mlParms);
           }
           return false;
       }
   
       Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
   
       const char* valueString = "";
   
       if (!empty)
       {
           if (testContentOrCData(parser, entry))
               valueString = entry.text;
   
           expectEndTag(parser, "VALUE");
       }
       else
       {
           // create the arg object with the NULL value in it.
           val = Uint64Arg();
           return true;
       }
   
       Uint64 x;
       // EXP_PULL clean this up KS_TODO
       if (!StringConversion::stringToUnsignedInteger(valueString, x))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.INVALID_UI_VALUE",
               "Invalid unsigned integer value");
           throw XmlSemanticError(parser.getLine(), mlParms);
       }
       //EXP_PULL_QUESTION- Is there even a check for 64 bit too large
   
       if (!StringConversion::checkUintBounds(x, CIMTYPE_UINT64))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.U64_VALUE_OUT_OF_RANGE",
               "Uint64 value out of range");
           throw XmlSemanticError(parser.getLine(), mlParms);
       }
       // create the arg object with the value in it.
       val = Uint64Arg(x);
   
       return true;
   }
   
   
   //------------------------------------------------------------------------------
   //
   // getUint32ValueElement()
   //
   //     <!ELEMENT VALUE (#PCDATA)>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getUint32ValueElement(
       XmlParser& parser,
       Uint32& val,
       Boolean required)
   {
       XmlEntry entry;
   
       if (!testStartTagOrEmptyTag(parser, entry, "VALUE"))
       {
           if (required)
           {
               MessageLoaderParms mlParms(
                   "Common.XmlReader.EXPECTED_VALUE_ELEMENT",
                   "Expected VALUE element");
               throw XmlValidationError(parser.getLine(), mlParms);
           }
           return false;
       }
   
       Boolean empty = entry.type == XmlEntry::EMPTY_TAG;
   
       const char* valueString = "";
   
       if (!empty)
       {
           if (testContentOrCData(parser, entry))
               valueString = entry.text;
   
           expectEndTag(parser, "VALUE");
       }
       else
       {
           // leave the existing value
           return true;
       }
   
       //convert to Uint32. Note error if overflow.
   
       Uint64 x;
       if (!StringConversion::stringToUnsignedInteger(valueString, x))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.INVALID_UI_VALUE",
               "Invalid unsigned integer value");
           throw XmlSemanticError(parser.getLine(), mlParms);
       }
   
       if (!StringConversion::checkUintBounds(x, CIMTYPE_UINT32))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.U32_VALUE_OUT_OF_RANGE",
               "Uint32 value out of range");
           throw XmlSemanticError(parser.getLine(), mlParms);
       }
       // create the arg object with the value in it.
       val = x;
   
       return true;
   }
   //EXP_PULL_END
   
 //---------------------------------------------------------------------------- //----------------------------------------------------------------------------
 // //
 // getPropertyValue // getPropertyValue
Line 1483 
Line 1622 
         case CIMTYPE_OBJECT:         case CIMTYPE_OBJECT:
             return StringArrayToValueAux(             return StringArrayToValueAux(
                 lineNumber, array, type, (CIMObject*)0);                 lineNumber, array, type, (CIMObject*)0);
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         case CIMTYPE_INSTANCE:         case CIMTYPE_INSTANCE:
             return StringArrayToValueAux(             return StringArrayToValueAux(
                 lineNumber, array, type, (CIMInstance*)0);                 lineNumber, array, type, (CIMInstance*)0);
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
   
         default:         default:
             break;             break;
     }     }
Line 1846 
Line 1982 
     {     {
         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);
     }     }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     String embeddedInstanceQualifierValue;     String embeddedInstanceQualifierValue;
     ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE);     ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE);
     if (ix != PEG_NOT_FOUND)     if (ix != PEG_NOT_FOUND)
Line 1854 
Line 1989 
         property.getQualifier(ix).getValue().get(         property.getQualifier(ix).getValue().get(
             embeddedInstanceQualifierValue);             embeddedInstanceQualifierValue);
     }     }
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     // If the EmbeddedObject attribute is present with value "object"     // If the EmbeddedObject attribute is present with value "object"
     // or the EmbeddedObject qualifier exists on this property with value "true"     // or the EmbeddedObject qualifier exists on this property with value "true"
     // then convert the EmbeddedObject-encoded string into a CIMObject     // then convert the EmbeddedObject-encoded string into a CIMObject
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) ||     Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) ||
         embeddedObjectQualifierValue;         embeddedObjectQualifierValue;
     Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) ||     Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) ||
Line 1879 
Line 2012 
  
             // Copy the qualifiers from the String property to the CIMObject             // Copy the qualifiers from the String property to the CIMObject
             // property.             // property.
             for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix)              for (Uint32 i = 0; i < property.getQualifierCount(); ++i)
             {             {
                 // All properties are copied, including the EmbeddedObject                 // All properties are copied, including the EmbeddedObject
                 // qualifier.  This way we don't have to keep track to know                 // qualifier.  This way we don't have to keep track to know
                 // that the EmbeddedObject qualifier needs to be added back                 // that the EmbeddedObject qualifier needs to be added back
                 // during the encode step.                 // during the encode step.
                 new_property.addQualifier(property.getQualifier(ix));                  new_property.addQualifier(property.getQualifier(i));
             }             }
  
             value = new_value;             value = new_value;
Line 1899 
Line 2032 
             throw XmlValidationError(parser.getLine(), mlParms);             throw XmlValidationError(parser.getLine(), mlParms);
         }         }
     }     }
 #else  
     if ((embeddedObject == EMBEDDED_OBJECT_ATTR)|| embeddedObjectQualifierValue)  
     {  
         // The EmbeddedObject attribute is only valid on Properties of type  
         // string  
         if (type == CIMTYPE_STRING)  
         {  
             type = CIMTYPE_OBJECT;  
             CIMValue new_value(type, false);  
             CIMProperty new_property = CIMProperty(  
                 name, new_value, 0, CIMName(), classOrigin, propagated);  
   
             // Copy the qualifiers from the String property to the CIMObject  
             // property.  
             for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix)  
             {  
                 // All properties are copied, including the EmbeddedObject  
                 // qualifier.  This way we don't have to keep track to know  
                 // that the EmbeddedObject qualifier needs to be added back  
                 // during the encode step.  
                 new_property.addQualifier(property.getQualifier(ix));  
             }  
   
             value = new_value;  
             property = new_property;  
         }  
         else  
         {  
             MessageLoaderParms mlParms(  
                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",  
                 "The EmbeddedObject attribute is only valid on string types.");  
             throw XmlValidationError(parser.getLine(), mlParms);  
         }  
     }  
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     // Continue on to get property value, if not empty.     // Continue on to get property value, if not empty.
     if (!empty)     if (!empty)
     {     {
Line 1969 
Line 2067 
  
     Uint64 arraySize;     Uint64 arraySize;
  
     if (!stringToUnsignedInteger(tmp, arraySize) || (arraySize == 0) ||      if (!StringConversion::stringToUnsignedInteger(tmp, arraySize) ||
           (arraySize == 0) ||
         !StringConversion::checkUintBounds(arraySize, CIMTYPE_UINT32))         !StringConversion::checkUintBounds(arraySize, CIMTYPE_UINT32))
     {     {
         char message[128];         char message[128];
Line 2067 
Line 2166 
     {     {
         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);         property.getQualifier(ix).getValue().get(embeddedObjectQualifierValue);
     }     }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     String embeddedInstanceQualifierValue;     String embeddedInstanceQualifierValue;
     ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE);     ix = property.findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE);
     if (ix != PEG_NOT_FOUND)     if (ix != PEG_NOT_FOUND)
Line 2075 
Line 2173 
         property.getQualifier(ix).getValue().get(         property.getQualifier(ix).getValue().get(
             embeddedInstanceQualifierValue);             embeddedInstanceQualifierValue);
     }     }
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     // If the EmbeddedObject attribute is present with value "object"     // If the EmbeddedObject attribute is present with value "object"
     // or the EmbeddedObject qualifier exists on this property with value "true"     // or the EmbeddedObject qualifier exists on this property with value "true"
     // then     // then
     //     Convert the EmbeddedObject-encoded string into a CIMObject     //     Convert the EmbeddedObject-encoded string into a CIMObject
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) ||     Boolean isEmbeddedObject = (embeddedObject == EMBEDDED_OBJECT_ATTR) ||
         embeddedObjectQualifierValue;         embeddedObjectQualifierValue;
     Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) ||     Boolean isEmbeddedInstance = (embeddedObject == EMBEDDED_INSTANCE_ATTR) ||
Line 2101 
Line 2197 
  
             // Copy the qualifiers from the String property to the CIMObject             // Copy the qualifiers from the String property to the CIMObject
             // property.             // property.
             for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix)              for (Uint32 i = 0; i < property.getQualifierCount(); ++i)
             {             {
                 // All properties are copied, including the EmbeddedObject                 // All properties are copied, including the EmbeddedObject
                 // qualifier.  This way we don't have to keep track to know                 // qualifier.  This way we don't have to keep track to know
                 // that the EmbeddedObject qualifier needs to be added back                 // that the EmbeddedObject qualifier needs to be added back
                 // during the encode step.                 // during the encode step.
                 new_property.addQualifier(property.getQualifier(ix));                  new_property.addQualifier(property.getQualifier(i));
             }             }
  
             value = new_value;             value = new_value;
Line 2121 
Line 2217 
             throw XmlValidationError(parser.getLine(), mlParms);             throw XmlValidationError(parser.getLine(), mlParms);
         }         }
     }     }
 #else  
     if ((embeddedObject == EMBEDDED_OBJECT_ATTR)||embeddedObjectQualifierValue)  
     {  
         // The EmbeddedObject attribute is only valid on Properties of type  
         // string  
         if (type == CIMTYPE_STRING)  
         {  
             type = CIMTYPE_OBJECT;  
             CIMValue new_value(type, true, arraySize);  
             CIMProperty new_property = CIMProperty(  
                 name, new_value, arraySize, CIMName(), classOrigin, propagated);  
   
             // Copy the qualifiers from the String property to the CIMObject  
             // property.  
             for (Uint32 ix = 0; ix < property.getQualifierCount(); ++ix)  
             {  
                 // All properties are copied, including the EmbeddedObject  
                 // qualifier.  This way we don't have to keep track to know  
                 // that the EmbeddedObject qualifier needs to be added back  
                 // during the encode step.  
                 new_property.addQualifier(property.getQualifier(ix));  
             }  
   
             value = new_value;  
             property = new_property;  
         }  
         else  
         {  
             MessageLoaderParms mlParms(  
                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",  
                 "The EmbeddedObject attribute is only valid on string types.");  
             throw XmlValidationError(parser.getLine(), mlParms);  
         }  
     }  
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     // Continue on to get property array value, if not empty.     // Continue on to get property array value, if not empty.
     // Else not an embedded object, if not empty, get the property array value.     // Else not an embedded object, if not empty, get the property array value.
     if (!empty)     if (!empty)
Line 2194 
Line 2255 
  
     if (!testStartTag(parser, entry, "HOST"))     if (!testStartTag(parser, entry, "HOST"))
         return false;         return false;
 #ifdef PEGASUS_SNIA_INTEROP_TEST  
     // Temp code to allow empty HOST field.  
     // SNIA CIMOMs return empty field particularly on enumerateinstance.  
     // Simply substitute a string for the empty.  
     if (!parser.next(entry))  
         throw XmlException(XmlException::UNCLOSED_TAGS, parser.getLine());  
   
     if (entry.type == XmlEntry::CONTENT)  
         host = String(entry.text);  
     else  
     {  
         parser.putBack(entry);  
         host = "HOSTNAMEINSERTEDBYPEGASUSCLIENT";  
     }  
   
 #else  
  
     if (!parser.next(entry) || entry.type != XmlEntry::CONTENT)     if (!parser.next(entry) || entry.type != XmlEntry::CONTENT)
     {     {
Line 2220 
Line 2265 
     }     }
  
     host = String(entry.text);     host = String(entry.text);
 #endif  
     expectEndTag(parser, "HOST");     expectEndTag(parser, "HOST");
     return true;     return true;
 } }
Line 2553 
Line 2597 
     else     else
     {     {
         while (getKeyBindingElement(parser, name, value, type))         while (getKeyBindingElement(parser, name, value, type))
           {
             keyBindings.append(CIMKeyBinding(name, value, type));             keyBindings.append(CIMKeyBinding(name, value, type));
               if (keyBindings.size() > PEGASUS_MAXELEMENTS_NUM)
               {
                   MessageLoaderParms mlParms(
                       "Common.XmlReader.TOO_MANY_KEYBINDINGS",
                       "More than $0 key-value pairs per object path"
                           " are not supported.",
                       PEGASUS_MAXELEMENTS_NUM);
                   throw XmlValidationError(parser.getLine(), mlParms);
               }
           }
     }     }
  
     expectEndTag(parser, "INSTANCENAME");     expectEndTag(parser, "INSTANCENAME");
Line 2761 
Line 2816 
 // //
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
   //
   // Parses the input to a CIMObjectPath.  Note that today the differences
   // between ClassPath and InstancePath are lost in this mapping because
   // Pegasus uses the existence of keys as separator . See BUG_3302
 Boolean XmlReader::getValueReferenceElement( Boolean XmlReader::getValueReferenceElement(
     XmlParser& parser,     XmlParser& parser,
     CIMObjectPath& reference)     CIMObjectPath& reference)
Line 3228 
Line 3286 
     // Get ARRAYSIZE attribute:     // Get ARRAYSIZE attribute:
  
     Uint32 arraySize = 0;     Uint32 arraySize = 0;
     Boolean gotArraySize = getArraySizeAttribute(parser.getLine(),      getArraySizeAttribute(parser.getLine(),
         entry, "QUALIFIER.DECLARATION", arraySize);         entry, "QUALIFIER.DECLARATION", arraySize);
  
     // Get flavor oriented attributes:     // Get flavor oriented attributes:
Line 3487 
Line 3545 
     return true;     return true;
 } }
  
   
   //EXP_PULL_BEGIN
   //------------------------------------------------------------------------------
   // getInstanceWithPathElement()
   //
   //     <!ELEMENT VALUE.NAMEDINSTANCE (INSTANCENAME,INSTANCE)>
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getInstanceWithPathElement(
       XmlParser& parser,
       CIMInstance& namedInstance)
   {
       XmlEntry entry;
       if (!testStartTag(parser, entry, "VALUE.INSTANCEWITHPATH"))
           return false;
   
       CIMObjectPath instanceName;
   
       // Get INSTANCENAME elements:
   //EXP_PULL_ISSUE Should we have new getInstancePathElement??? KS_TODO
       if (!getInstancePathElement(parser, instanceName))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.EXPECTED_INSTANCEPATH_ELEMENT",
               "expected INSTANCEPATH element");
           throw XmlValidationError(parser.getLine(), mlParms);
       }
   
       // Get INSTANCE elements:
   
       if (!getInstanceElement(parser, namedInstance))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.EXPECTED_INSTANCE_ELEMENT",
               "expected INSTANCE element");
           throw XmlValidationError(parser.getLine(), mlParms);
       }
       // Get VALUE.NAMEDINSTANCE end tag:
   
       expectEndTag(parser, "VALUE.INSTANCEWITHPATH");
   
       namedInstance.setPath (instanceName);
   
       return true;
   }
   
   //EXP_PULL_END
   
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // getObject() // getObject()
Line 3671 
Line 3778 
     return true;     return true;
 } }
  
   //EXP_PULL_BEGIN
   //------------------------------------------------------------------------------
   //
   // getIParamValueTag()
   //
   //------------------------------------------------------------------------------
   
   Boolean XmlReader::getParamValueTag(
       XmlParser& parser,
       const char*& name,
       Boolean& isEmptyTag)
   {
       XmlEntry entry;
   
       if (!testStartTagOrEmptyTag(parser, entry, "PARAMVALUE"))
       {
   
           return false;
       }
   
       isEmptyTag = (entry.type == XmlEntry::EMPTY_TAG);
   
       // Get PARAMVALUE.NAME attribute:
   
       if (!entry.getAttributeValue("NAME", name))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.MISSING_PARAMVALUE_ATTRIBUTE",
               "Missing PARAMVALUE.NAME attribute");
           throw XmlValidationError(parser.getLine(), mlParms);
       }
       return true;
   }
   //------------------------------------------------------------------------------
   //
   // getIReturnValueTag()
   //
   //------------------------------------------------------------------------------
   ////EXP_PULL Think we can get rid of this KS_TODO
   Boolean XmlReader::getIReturnValueTag(
       XmlParser& parser,
       const char*& name,
       Boolean& isEmptyTag)
   {
       XmlEntry entry;
       if (!testStartTagOrEmptyTag(parser, entry, "IRETURNVALUE"))
           return false;
       //entry.print();
       isEmptyTag = (entry.type == XmlEntry::EMPTY_TAG);
   
       if (!entry.getAttributeValue("NAME", name))
       {
           MessageLoaderParms mlParms(
               "Common.XmlReader.MISSING_IRETURNVALUE_ATTRIBUTE",
               "Missing IRETURNVALUE.NAME attribute");
           throw XmlValidationError(parser.getLine(), mlParms);
       }
   // EXP_PULL_TBD Add new msg above to msg bundle.  KS_TODO
       return true;
   }
   
   //EXP_PULL_END
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // rejectNullIParamValue() // rejectNullIParamValue()
Line 3691 
Line 3860 
     }     }
 } }
  
   // EXP_PULL_BEGIN
   //------------------------------------------------------------------------------
   //
   // rejectNullIReturnParamValue()
   //
   //------------------------------------------------------------------------------
   
   void XmlReader::rejectNullIReturnValue(
       XmlParser& parser,
       Boolean isEmptyTag,
       const char* paramName)
   {
       if (isEmptyTag)
       {
           MessageLoaderParms mlParms("Common.XmlReader.INVALID_NULL_IRETURNVALUE",
               "A null value is not valid for IRETURNVALUE \"$0\".",
               paramName);
           throw XmlValidationError(parser.getLine(), mlParms);
       }
   }
   
   void XmlReader::rejectNullParamValue(
       XmlParser& parser,
       Boolean isEmptyTag,
       const char* paramName)
   {
       if (isEmptyTag)
       {
           MessageLoaderParms mlParms("Common.XmlReader.INVALID_NULL_PARAMVALUE",
               "A null value is not valid for PARAMVALUE \"$0\".",
               paramName);
           throw XmlValidationError(parser.getLine(), mlParms);
       }
   }
   // EXP_PULL_TODO_TBD add above message to bundle KS_TODO
   // EXP_PULL_END
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // getBooleanValueElement() // getBooleanValueElement()
Line 4015 
Line 4220 
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
   // Returns true if ClassNameElement or false if InstanceNameElement
   // Parse errors always throw exception
 Boolean XmlReader::getObjectNameElement( Boolean XmlReader::getObjectNameElement(
     XmlParser& parser,     XmlParser& parser,
     CIMObjectPath& objectName)     CIMObjectPath& objectName)
Line 4024 
Line 4231 
     if (getClassNameElement(parser, className, false))     if (getClassNameElement(parser, className, false))
     {     {
         objectName.set(String(), CIMNamespaceName(), className);         objectName.set(String(), CIMNamespaceName(), className);
   
           // Return flag indicating this is ClassNameElement
         return true;         return true;
     }     }
  
Line 4035 
Line 4244 
         throw XmlValidationError(parser.getLine(), mlParms);         throw XmlValidationError(parser.getLine(), mlParms);
     }     }
  
     return true;      // Return flag indicating this is InstanceNameElement
       return false;
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 4310 
Line 4520 
             // If the EmbeddedObject attribute is present with value "object"             // If the EmbeddedObject attribute is present with value "object"
             // then             // then
             //     Convert the EmbeddedObject-encoded string into a CIMObject             //     Convert the EmbeddedObject-encoded string into a CIMObject
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
             if (embeddedObject != NO_EMBEDDED_OBJECT)             if (embeddedObject != NO_EMBEDDED_OBJECT)
             {             {
                 // The EmbeddedObject attribute is only valid on Parameters                 // The EmbeddedObject attribute is only valid on Parameters
Line 4334 
Line 4543 
                     throw XmlValidationError(parser.getLine(), mlParms);                     throw XmlValidationError(parser.getLine(), mlParms);
                 }                 }
             }             }
 #else  
             if (embeddedObject == EMBEDDED_OBJECT_ATTR)  
             {  
                 // The EmbeddedObject attribute is only valid on Parameters  
                 // of type string  
                 // The type must have been specified.  
                 if (gotType && (type == CIMTYPE_STRING))  
                 {  
                     // Used below by getValueElement() or getValueArrayElement()  
                     effectiveType = CIMTYPE_OBJECT;  
                 }  
                 else  
                 {  
                     MessageLoaderParms mlParms(  
                         "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",  
                         "The EmbeddedObject attribute is only valid on "  
                             "string types.");  
                     throw XmlValidationError(parser.getLine(), mlParms);  
                 }  
             }  
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
  
             if (!XmlReader::getValueArrayElement(parser, effectiveType, value)             if (!XmlReader::getValueArrayElement(parser, effectiveType, value)
                 && !XmlReader::getValueElement(parser, effectiveType, value))                 && !XmlReader::getValueElement(parser, effectiveType, value))
Line 4432 
Line 4620 
             // If we don't know what type the value is, read it as a String             // If we don't know what type the value is, read it as a String
             type = CIMTYPE_STRING;             type = CIMTYPE_STRING;
         }         }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         if (embeddedObject != NO_EMBEDDED_OBJECT)         if (embeddedObject != NO_EMBEDDED_OBJECT)
         {         {
             if (gotType && (type == CIMTYPE_STRING))             if (gotType && (type == CIMTYPE_STRING))
Line 4452 
Line 4639 
                 throw XmlValidationError(parser.getLine(), mlParms);                 throw XmlValidationError(parser.getLine(), mlParms);
             }             }
         }         }
 #else  
         if (embeddedObject == EMBEDDED_OBJECT_ATTR)  
         {  
             if (gotType && (type == CIMTYPE_STRING))  
             {  
                 type = CIMTYPE_OBJECT;  // Used below by getValueElement()  
             }  
             else  
             {  
                 MessageLoaderParms mlParms(  
                     "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",  
                     "The EmbeddedObject attribute is only valid on string "  
                         "types.");  
                 throw XmlValidationError(parser.getLine(), mlParms);  
             }  
         }  
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         if ( !XmlReader::getValueElement(parser, type, returnValue) )         if ( !XmlReader::getValueElement(parser, type, returnValue) )
         {         {
             MessageLoaderParms mlParms(             MessageLoaderParms mlParms(


Legend:
Removed from v.1.129.12.3  
changed lines
  Added in v.1.144.4.4

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2