(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.122 and 1.122.4.3

version 1.122, 2006/11/10 18:14:58 version 1.122.4.3, 2008/02/11 16:52:12
Line 495 
Line 495 
 // //
 // getEmbeddedObjectAttribute() // getEmbeddedObjectAttribute()
 // //
 //     <!ENTITY % EmbeddedObject "EMBEDDEDOBJECT (object | instance) #IMPLIED">  //     <!ENTITY % EmbeddedObject "EmbeddedObject (object | instance) #IMPLIED">
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
Line 506 
Line 506 
 { {
     String embeddedObject;     String embeddedObject;
  
     if (!entry.getAttributeValue("EMBEDDEDOBJECT", 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 String();         return String();
  
     // The embeddedObject attribute, if present, must have the string     // The embeddedObject attribute, if present, must have the string
Line 515 
Line 520 
           String::equal(embeddedObject, "instance")))           String::equal(embeddedObject, "instance")))
     {     {
         char buffer[MESSAGE_SIZE];         char buffer[MESSAGE_SIZE];
         sprintf(buffer, "%s.EMBEDDEDOBJECT", elementName);          sprintf(buffer, "%s.EmbeddedObject", elementName);
  
         MessageLoaderParms mlParms(         MessageLoaderParms mlParms(
             "Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE",             "Common.XmlReader.ILLEGAL_VALUE_FOR_ATTRIBUTE",
Line 2042 
Line 2047 
     Boolean propagated = getCimBooleanAttribute(     Boolean propagated = getCimBooleanAttribute(
         parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false);         parser.getLine(), entry, "PROPERTY", "PROPAGATED", false, false);
  
     // Get PROPERTY.EMBEDDEDOBJECT attribute:      // Get PROPERTY.EmbeddedObject attribute:
  
     String embeddedObject = getEmbeddedObjectAttribute(     String embeddedObject = getEmbeddedObjectAttribute(
         parser.getLine(), entry, "PROPERTY");         parser.getLine(), entry, "PROPERTY");
Line 2080 
Line 2085 
             embeddedInstanceQualifierValue);             embeddedInstanceQualifierValue);
     }     }
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT #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 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
     Boolean isEmbeddedObject = String::equal(embeddedObject, "object") ||     Boolean isEmbeddedObject = String::equal(embeddedObject, "object") ||
         embeddedObjectQualifierValue;         embeddedObjectQualifierValue;
Line 2091 
Line 2095 
         embeddedInstanceQualifierValue.size() > 0;         embeddedInstanceQualifierValue.size() > 0;
     if (isEmbeddedObject || isEmbeddedInstance)     if (isEmbeddedObject || isEmbeddedInstance)
     {     {
         // The EMBEDDEDOBJECT attribute is only valid on Properties of type          // The EmbeddedObject attribute is only valid on Properties of type
         // string         // string
         if (type == CIMTYPE_STRING)         if (type == CIMTYPE_STRING)
         {         {
Line 2121 
Line 2125 
         {         {
             MessageLoaderParms mlParms(             MessageLoaderParms mlParms(
                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",
                 "The EMBEDDEDOBJECT attribute is only valid on string types.");                  "The EmbeddedObject attribute is only valid on string types.");
             throw XmlValidationError(parser.getLine(), mlParms);             throw XmlValidationError(parser.getLine(), mlParms);
         }         }
     }     }
 #else #else
     if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue)     if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue)
     {     {
         // The EMBEDDEDOBJECT attribute is only valid on Properties of type          // The EmbeddedObject attribute is only valid on Properties of type
         // string         // string
         if (type == CIMTYPE_STRING)         if (type == CIMTYPE_STRING)
         {         {
Line 2155 
Line 2159 
         {         {
             MessageLoaderParms mlParms(             MessageLoaderParms mlParms(
                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",
                 "The EMBEDDEDOBJECT attribute is only valid on string types.");                  "The EmbeddedObject attribute is only valid on string types.");
             throw XmlValidationError(parser.getLine(), mlParms);             throw XmlValidationError(parser.getLine(), mlParms);
         }         }
     }     }
Line 2269 
Line 2273 
         false,         false,
         false);         false);
  
     // Get PROPERTY.EMBEDDEDOBJECT attribute:      // Get PROPERTY.EmbeddedObject attribute:
  
     String embeddedObject = getEmbeddedObjectAttribute(     String embeddedObject = getEmbeddedObjectAttribute(
         parser.getLine(), entry, "PROPERTY.ARRAY");         parser.getLine(), entry, "PROPERTY.ARRAY");
Line 2301 
Line 2305 
             embeddedInstanceQualifierValue);             embeddedInstanceQualifierValue);
     }     }
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT #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
Line 2312 
Line 2316 
         embeddedInstanceQualifierValue.size() > 0;         embeddedInstanceQualifierValue.size() > 0;
     if (isEmbeddedObject || isEmbeddedInstance)     if (isEmbeddedObject || isEmbeddedInstance)
     {     {
         // The EMBEDDEDOBJECT attribute is only valid on Properties of type          // The EmbeddedObject attribute is only valid on Properties of type
         // string         // string
         if (type == CIMTYPE_STRING)         if (type == CIMTYPE_STRING)
         {         {
Line 2342 
Line 2346 
         {         {
             MessageLoaderParms mlParms(             MessageLoaderParms mlParms(
                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",
                 "The EMBEDDEDOBJECT attribute is only valid on string types.");                  "The EmbeddedObject attribute is only valid on string types.");
             throw XmlValidationError(parser.getLine(), mlParms);             throw XmlValidationError(parser.getLine(), mlParms);
         }         }
     }     }
 #else #else
     if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue)     if (String::equal(embeddedObject, "object") || embeddedObjectQualifierValue)
     {     {
         // The EMBEDDEDOBJECT attribute is only valid on Properties of type          // The EmbeddedObject attribute is only valid on Properties of type
         // string         // string
         if (type == CIMTYPE_STRING)         if (type == CIMTYPE_STRING)
         {         {
Line 2376 
Line 2380 
         {         {
             MessageLoaderParms mlParms(             MessageLoaderParms mlParms(
                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",                 "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",
                 "The EMBEDDEDOBJECT attribute is only valid on string types.");                  "The EmbeddedObject attribute is only valid on string types.");
             throw XmlValidationError(parser.getLine(), mlParms);             throw XmlValidationError(parser.getLine(), mlParms);
         }         }
     }     }
Line 4490 
Line 4494 
         throw XmlValidationError(parser.getLine(), mlParms);         throw XmlValidationError(parser.getLine(), mlParms);
     }     }
  
     // Get PROPERTY.EMBEDDEDOBJECT      // Get PROPERTY.EmbeddedObject
  
     String embeddedObject = getEmbeddedObjectAttribute(     String embeddedObject = getEmbeddedObjectAttribute(
         parser.getLine(), entry, "PARAMVALUE");         parser.getLine(), entry, "PARAMVALUE");
Line 4521 
Line 4525 
                 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
Line 4538 
Line 4545 
                 effectiveType = type;                 effectiveType = type;
             }             }
  
             // 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 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
Line 4547 
Line 4554 
                 String::equal(embeddedObject, "instance");                 String::equal(embeddedObject, "instance");
             if (isEmbeddedObject || isEmbeddedInstance)             if (isEmbeddedObject || isEmbeddedInstance)
             {             {
                 // The EMBEDDEDOBJECT attribute is only valid on Parameters                  // The EmbeddedObject attribute is only valid on Parameters
                 // of type string                 // of type string
                 // The type must have been specified.                 // The type must have been specified.
                 if (gotType && (type == CIMTYPE_STRING))                 if (gotType && (type == CIMTYPE_STRING))
Line 4563 
Line 4570 
                 {                 {
                     MessageLoaderParms mlParms(                     MessageLoaderParms mlParms(
                         "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",                         "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",
                         "The EMBEDDEDOBJECT attribute is only valid on "                          "The EmbeddedObject attribute is only valid on "
                             "string types.");                             "string types.");
                     throw XmlValidationError(parser.getLine(), mlParms);                     throw XmlValidationError(parser.getLine(), mlParms);
                 }                 }
Line 4571 
Line 4578 
 #else #else
             if (String::equal(embeddedObject, "object"))             if (String::equal(embeddedObject, "object"))
             {             {
                 // The EMBEDDEDOBJECT attribute is only valid on Parameters                  // The EmbeddedObject attribute is only valid on Parameters
                 // of type string                 // of type string
                 // The type must have been specified.                 // The type must have been specified.
                 if (gotType && (type == CIMTYPE_STRING))                 if (gotType && (type == CIMTYPE_STRING))
Line 4583 
Line 4590 
                 {                 {
                     MessageLoaderParms mlParms(                     MessageLoaderParms mlParms(
                         "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",                         "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",
                         "The EMBEDDEDOBJECT attribute is only valid on "                          "The EmbeddedObject attribute is only valid on "
                             "string types.");                             "string types.");
                     throw XmlValidationError(parser.getLine(), mlParms);                     throw XmlValidationError(parser.getLine(), mlParms);
                 }                 }
Line 4628 
Line 4635 
     if (!testStartTag(parser, entry, "RETURNVALUE"))     if (!testStartTag(parser, entry, "RETURNVALUE"))
         return false;         return false;
  
     // Get PROPERTY.EMBEDDEDOBJECT      // Get PROPERTY.EmbeddedObject
  
     String embeddedObject = getEmbeddedObjectAttribute(     String embeddedObject = getEmbeddedObjectAttribute(
         parser.getLine(), entry, "RETURNVALUE");         parser.getLine(), entry, "RETURNVALUE");
Line 4683 
Line 4690 
             {             {
                 MessageLoaderParms mlParms(                 MessageLoaderParms mlParms(
                     "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",                     "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",
                     "The EMBEDDEDOBJECT attribute is only valid on string "                      "The EmbeddedObject attribute is only valid on string "
                         "types.");                         "types.");
                 throw XmlValidationError(parser.getLine(), mlParms);                 throw XmlValidationError(parser.getLine(), mlParms);
             }             }
Line 4699 
Line 4706 
             {             {
                 MessageLoaderParms mlParms(                 MessageLoaderParms mlParms(
                     "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",                     "Common.XmlReader.INVALID_EMBEDDEDOBJECT_TYPE",
                     "The EMBEDDEDOBJECT attribute is only valid on string "                      "The EmbeddedObject attribute is only valid on string "
                         "types.");                         "types.");
                 throw XmlValidationError(parser.getLine(), mlParms);                 throw XmlValidationError(parser.getLine(), mlParms);
             }             }
Line 4719 
Line 4726 
     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


Legend:
Removed from v.1.122  
changed lines
  Added in v.1.122.4.3

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2