(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.140.2.1 and 1.144.4.5

version 1.140.2.1, 2009/02/09 11:35:00 version 1.144.4.5, 2013/06/09 17:18:38
Line 204 
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 265 
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 396 
Line 399 
  
     if (!CIMName::legal(name))     if (!CIMName::legal(name))
     {     {
 #ifdef PEGASUS_SNIA_INTEROP_TEST  
     // In testing, replace illegal CIMName with this value to avoid the  
     // exception and let xml parsing continue.  THIS IS TEMP.  
     name = "BADNAMESUBSTITUTEDBYPEGASUSCLIENT";  
 #else  
   
     char buffer[MESSAGE_SIZE];     char buffer[MESSAGE_SIZE];
     sprintf(buffer, "%s.NAME", elementName);     sprintf(buffer, "%s.NAME", elementName);
  
Line 411 
Line 408 
         buffer);         buffer);
  
     throw XmlSemanticError(lineNumber, mlParms);     throw XmlSemanticError(lineNumber, mlParms);
   
 #endif  
     }     }
  
     return CIMNameCast(name);     return CIMNameCast(name);
Line 577 
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 839 
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 950 
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 1005 
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 1059 
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 1255 
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 1318 
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 1922 
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 2109 
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 2135 
Line 2265 
     }     }
  
     host = String(entry.text);     host = String(entry.text);
 #endif  
     expectEndTag(parser, "HOST");     expectEndTag(parser, "HOST");
     return true;     return true;
 } }
Line 2468 
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 2676 
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 3143 
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 3402 
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_Question 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 3586 
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 3606 
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 3930 
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 3939 
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 3950 
Line 4244 
         throw XmlValidationError(parser.getLine(), mlParms);         throw XmlValidationError(parser.getLine(), mlParms);
     }     }
  
     return true;      // Return flag indicating this is InstanceNameElement
       return false;
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------


Legend:
Removed from v.1.140.2.1  
changed lines
  Added in v.1.144.4.5

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2