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

Diff for /pegasus/src/Pegasus/Common/XmlWriter.cpp between version 1.169 and 1.169.4.11

version 1.169, 2009/12/15 11:39:34 version 1.169.4.11, 2014/04/28 00:29:12
Line 58 
Line 58 
 #include "StrLit.h" #include "StrLit.h"
 #include "IDFactory.h" #include "IDFactory.h"
 #include "StringConversion.h" #include "StringConversion.h"
   
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 148 
Line 147 
     const Array<CIMKeyBinding>& keyBindings = instanceName.getKeyBindings();     const Array<CIMKeyBinding>& keyBindings = instanceName.getKeyBindings();
     for (Uint32 i = 0, n = keyBindings.size(); i < n; i++)     for (Uint32 i = 0, n = keyBindings.size(); i < n; i++)
     {     {
           // Append KEYBINDING ELEMENT
           // <!ELEMENT KEYBINDING (KEYVALUE|VALUE.REFERENCE)>
           //   <!ATTLIST KEYBINDING
         out << STRLIT("<KEYBINDING NAME=\"");         out << STRLIT("<KEYBINDING NAME=\"");
         out << keyBindings[i].getName() << STRLIT("\">\n");         out << keyBindings[i].getName() << STRLIT("\">\n");
  
         if (keyBindings[i].getType() == CIMKeyBinding::REFERENCE)         if (keyBindings[i].getType() == CIMKeyBinding::REFERENCE)
         {         {
             CIMObjectPath ref = keyBindings[i].getValue();             CIMObjectPath ref = keyBindings[i].getValue();
             appendValueReferenceElement(out, ref, true);              // isClassPath = false
               appendValueReferenceElement(out, ref, false);
         }         }
         else         else
         {         {
Line 162 
Line 165 
             out << keyBindingTypeToString(keyBindings[i].getType());             out << keyBindingTypeToString(keyBindings[i].getType());
             out << STRLIT("\">");             out << STRLIT("\">");
  
             // fixed the special character problem - Markus              // fixed the special characters
  
             appendSpecial(out, keyBindings[i].getValue());             appendSpecial(out, keyBindings[i].getValue());
             out << STRLIT("</KEYVALUE>\n");             out << STRLIT("</KEYVALUE>\n");
Line 257 
Line 260 
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
   // appendValueReferenceElement does this correctly with isClassPath flag
   // Called only but formatSimple
 void XmlWriter::appendLocalObjectPathElement( void XmlWriter::appendLocalObjectPathElement(
     Buffer& out,     Buffer& out,
     const CIMObjectPath& objectPath)     const CIMObjectPath& objectPath)
Line 266 
Line 271 
     //  distinguish instanceNames from classNames in every case     //  distinguish instanceNames from classNames in every case
     //  The instanceName of a singleton instance of a keyless class has no     //  The instanceName of a singleton instance of a keyless class has no
     //  key bindings     //  key bindings
       //  See bBUG_3302.
     //     //
     if (objectPath.getKeyBindings ().size () != 0)     if (objectPath.getKeyBindings ().size () != 0)
     {     {
Line 357 
Line 363 
  
 inline void _xmlWritter_appendValue(Buffer& out, const CIMObjectPath& x) inline void _xmlWritter_appendValue(Buffer& out, const CIMObjectPath& x)
 { {
     XmlWriter::appendValueReferenceElement(out, x, true);      // Emit Instance Path with VALUE.REFERENCE wrapper element
       XmlWriter::appendValueReferenceElement(out, x, false);
 } }
  
 inline void _xmlWritter_appendValue(Buffer& out, const CIMObject& x) inline void _xmlWritter_appendValue(Buffer& out, const CIMObject& x)
Line 553 
Line 560 
                 break;                 break;
             }             }
             default:             default:
                 PEGASUS_ASSERT(false);                  PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);)
         }         }
     }     }
     else if (value.getType() == CIMTYPE_REFERENCE)     else if (value.getType() == CIMTYPE_REFERENCE)
Line 696 
Line 703 
                 break;                 break;
             }             }
             default:             default:
                 PEGASUS_ASSERT(false);                  PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);)
         }         }
  
         out << STRLIT("</VALUE>\n");         out << STRLIT("</VALUE>\n");
Line 723 
Line 730 
  
 void XmlWriter::appendValueObjectWithPathElement( void XmlWriter::appendValueObjectWithPathElement(
     Buffer& out,     Buffer& out,
     const CIMObject& objectWithPath)      const CIMObject& objectWithPath,
       Boolean includeQualifiers,
       Boolean includeClassOrigin,
       Boolean isClassObject,
       const CIMPropertyList& propertyList)
 { {
     out << STRLIT("<VALUE.OBJECTWITHPATH>\n");     out << STRLIT("<VALUE.OBJECTWITHPATH>\n");
  
     appendValueReferenceElement(out, objectWithPath.getPath (), false);      appendClassOrInstancePathElement(out, objectWithPath.getPath (),
     appendObjectElement(out, objectWithPath);          isClassObject);
   
       appendObjectElement(
           out,
           objectWithPath,
           includeQualifiers,
           includeClassOrigin,
           propertyList);
  
     out << STRLIT("</VALUE.OBJECTWITHPATH>\n");     out << STRLIT("</VALUE.OBJECTWITHPATH>\n");
 } }
  
 //------------------------------------------------------------------------------  // Append INSTANCEPATH | LOCALINSTANCEPATH | INSTANCENAME
 //  void XmlWriter::appendInstancePath(
 // appendValueReferenceElement()  
 //  
 //    <!ELEMENT VALUE.REFERENCE  
 //        (CLASSPATH|LOCALCLASSPATH|CLASSNAME|INSTANCEPATH|LOCALINSTANCEPATH|  
 //         INSTANCENAME)>  
 //  
 //------------------------------------------------------------------------------  
   
 void XmlWriter::appendValueReferenceElement(  
     Buffer& out,     Buffer& out,
     const CIMObjectPath& reference,      const CIMObjectPath& reference)
     Boolean putValueWrapper)  
 {  
     if (putValueWrapper)  
         out << STRLIT("<VALUE.REFERENCE>\n");  
   
     // See if it is a class or instance reference (instance references have  
     // key-bindings; class references do not).  
     //  
     //  ATTN-CAKG-P2-20020726:  The following condition does not correctly  
     //  distinguish instanceNames from classNames in every case  
     //  The instanceName of a singleton instance of a keyless class has no  
     //  key bindings  
     //  
   
     const Array<CIMKeyBinding>& kbs = reference.getKeyBindings();  
   
     if (kbs.size())  
     {     {
         if (reference.getHost().size())         if (reference.getHost().size())
         {         {
Line 777 
Line 769 
             appendInstanceNameElement(out, reference);             appendInstanceNameElement(out, reference);
         }         }
     }     }
     else  
   // appends CLASSPATH | LOCALCLASSPATH | CLASSNAME
   void XmlWriter::appendClassPath(
       Buffer& out,
       const CIMObjectPath& reference)
     {     {
         if (reference.getHost().size())         if (reference.getHost().size())
         {         {
Line 792 
Line 788 
             appendClassNameElement(out, reference.getClassName());             appendClassNameElement(out, reference.getClassName());
         }         }
     }     }
   //------------------------------------------------------------------------------
   //
   // appendValueReferenceElement()
   //
   //    <!ELEMENT VALUE.REFERENCE
   //        (CLASSPATH|LOCALCLASSPATH|CLASSNAME|INSTANCEPATH|LOCALINSTANCEPATH|
   //         INSTANCENAME)>
   //
   //------------------------------------------------------------------------------
   // Builds either a classPath or InstancePath based on isClassPath
   // parameter which was carried forward from, for example, the
   // request.
   // The caller must determine if this is a class or instance
   // path rather than trying to interpret that difference from reference arg.
   void XmlWriter::appendValueReferenceElement(
       Buffer& out,
       const CIMObjectPath& reference,
       Boolean isClassPath)
   {
       out << STRLIT("<VALUE.REFERENCE>\n");
   
       appendClassOrInstancePathElement(out, reference, isClassPath);
  
     if (putValueWrapper)  
         out << STRLIT("</VALUE.REFERENCE>\n");         out << STRLIT("</VALUE.REFERENCE>\n");
 } }
  
   
   // Append either the classPathElement or InstancePathElement depending on
   // the isClassPath input argument.
   //  INSTANCENAME | CLASSNAME
   
   void XmlWriter::appendClassOrInstancePathElement(
       Buffer& out,
       const CIMObjectPath& reference,
       Boolean isClassPath)
   {
       if (isClassPath)
       {
           appendClassPath(out,reference);
       }
       else
       {
           appendInstancePath(out,reference);
       }
   }
   
 void XmlWriter::printValueReferenceElement( void XmlWriter::printValueReferenceElement(
     const CIMObjectPath& reference,     const CIMObjectPath& reference,
       Boolean isClassPath,
     PEGASUS_STD(ostream)& os)     PEGASUS_STD(ostream)& os)
 { {
     Buffer tmp;     Buffer tmp;
     appendValueReferenceElement(tmp, reference, true);      appendValueReferenceElement(tmp, reference, isClassPath);
     indentedPrint(os, tmp.getData());     indentedPrint(os, tmp.getData());
 } }
  
Line 816 
Line 854 
  
 void XmlWriter::appendValueNamedInstanceElement( void XmlWriter::appendValueNamedInstanceElement(
     Buffer& out,     Buffer& out,
     const CIMInstance& namedInstance)      const CIMInstance& namedInstance,
       Boolean includeQualifiers,
       Boolean includeClassOrigin,
       const CIMPropertyList& propertyList)
 { {
     out << STRLIT("<VALUE.NAMEDINSTANCE>\n");     out << STRLIT("<VALUE.NAMEDINSTANCE>\n");
  
     appendInstanceNameElement(out, namedInstance.getPath ());     appendInstanceNameElement(out, namedInstance.getPath ());
     appendInstanceElement(out, namedInstance);      appendInstanceElement(
           out,
           namedInstance,
           includeQualifiers,
           includeClassOrigin,
           propertyList);
  
     out << STRLIT("</VALUE.NAMEDINSTANCE>\n");     out << STRLIT("</VALUE.NAMEDINSTANCE>\n");
 } }
  
   //EXP_PULL_BEGIN
   //------------------------------------------------------------------------------
   //
   // appendValueInstanceWithPathElement()
   //
   //     <!ELEMENT VALUE.INSTANCEWITHPATH (INSTANCEPATH,INSTANCE)>
   //
   //------------------------------------------------------------------------------
   //
   void XmlWriter::appendValueInstanceWithPathElement(
       Buffer& out,
       const CIMInstance& namedInstance,
           Boolean includeQualifiers,
           Boolean includeClassOrigin,
           const CIMPropertyList& propertyList)
   {
       out << STRLIT("<VALUE.INSTANCEWITHPATH>\n");
   
       appendInstancePathElement(out, namedInstance.getPath ());
       appendInstanceElement(
           out,
           namedInstance,
           includeQualifiers,
           includeClassOrigin,
           propertyList);
   
       out << STRLIT("</VALUE.INSTANCEWITHPATH>\n");
   }
   //EXP_PULL_END
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // appendClassElement() // appendClassElement()
Line 902 
Line 977 
  
 void XmlWriter::appendInstanceElement( void XmlWriter::appendInstanceElement(
     Buffer& out,     Buffer& out,
     const CIMConstInstance& instance)      const CIMConstInstance& instance,
       Boolean includeQualifiers,
       Boolean includeClassOrigin,
       const CIMPropertyList& propertyList)
 { {
     CheckRep(instance._rep);     CheckRep(instance._rep);
     const CIMInstanceRep* rep = instance._rep;     const CIMInstanceRep* rep = instance._rep;
Line 914 
Line 992 
         << STRLIT("\" >\n");         << STRLIT("\" >\n");
  
     // Append Instance Qualifiers:     // Append Instance Qualifiers:
       if(includeQualifiers)
       {
     for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)     for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
         XmlWriter::appendQualifierElement(out, rep->getQualifier(i));         XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
       }
     // Append Properties:      if(propertyList.isNull())
       {
     for (Uint32 i = 0, n = rep->getPropertyCount(); i < n; i++)     for (Uint32 i = 0, n = rep->getPropertyCount(); i < n; i++)
         XmlWriter::appendPropertyElement(out, rep->getProperty(i));          {
               XmlWriter::appendPropertyElement(
                   out,
                   rep->getProperty(i),
                   includeQualifiers,includeClassOrigin);
           }
       }
       else
       {
           for (Uint32 i = 0, n = propertyList.size(); i < n; i++)
           {
               CIMName name = propertyList[i];
               Uint32 pos = rep->_properties.find(
                   propertyList[i],
                   propertyList.getCIMNameTag(i));
               if(pos != PEG_NOT_FOUND)
               {
                   PEG_TRACE((TRC_XML,Tracer::LEVEL4,
                       "XmlWriter::appendInstanceElement"
                           " Filtering the property name:%s for the className:%s"
                       "since it was not filtered by the provider.",
                       (const char *)name.getString().getCString(),
                       (const char *)instance.getClassName().
                           getString().getCString()));
   
                   XmlWriter::appendPropertyElement(
                       out,
                       rep->getProperty(pos),
                       includeQualifiers,includeClassOrigin);
               }
           }
   
       }
  
     // Instance closing element:     // Instance closing element:
  
Line 947 
Line 1058 
  
 void XmlWriter::appendObjectElement( void XmlWriter::appendObjectElement(
     Buffer& out,     Buffer& out,
     const CIMConstObject& object)      const CIMConstObject& object,
       Boolean includeQualifiers,
       Boolean includeClassOrigin,
       const CIMPropertyList& propertyList)
 { {
     if (object.isClass())     if (object.isClass())
     {     {
Line 957 
Line 1071 
     else if (object.isInstance())     else if (object.isInstance())
     {     {
         CIMConstInstance i(object);         CIMConstInstance i(object);
         appendInstanceElement(out, i);          appendInstanceElement(
               out,
               i,
               includeQualifiers,
               includeClassOrigin,
               propertyList);
     }     }
     // else PEGASUS_ASSERT(0);     // else PEGASUS_ASSERT(0);
 } }
Line 992 
Line 1111 
  
 void XmlWriter::appendPropertyElement( void XmlWriter::appendPropertyElement(
     Buffer& out,     Buffer& out,
     const CIMConstProperty& property)      const CIMConstProperty& property,
       Boolean includeQualifiers,
       Boolean includeClassOrigin)
 { {
     CheckRep(property._rep);     CheckRep(property._rep);
     const CIMPropertyRep* rep = property._rep;     const CIMPropertyRep* rep = property._rep;
Line 1063 
Line 1184 
                 // Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY is                 // Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY is
                 // defined, then the EmbeddedInstance qualifier will be added                 // defined, then the EmbeddedInstance qualifier will be added
 # ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY # ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY
                 if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE ==                  if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE)
                         PEG_NOT_FOUND)                          == PEG_NOT_FOUND)
                 {                 {
                     // Note that addQualifiers() cannot be called on a const                     // Note that addQualifiers() cannot be called on a const
                     // CIMQualifierRep.  In this case we really do want to add                     // CIMQualifierRep.  In this case we really do want to add
Line 1095 
Line 1216 
             out.append('"');             out.append('"');
         }         }
  
         if (!rep->getClassOrigin().isNull())          if(includeClassOrigin && !rep->getClassOrigin().isNull())
         {         {
             out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin();             out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin();
             out.append('"');             out.append('"');
Line 1107 
Line 1228 
         }         }
  
         out << STRLIT(">\n");         out << STRLIT(">\n");
           if(includeQualifiers)
           {
         for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)         for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
             XmlWriter::appendQualifierElement(out, rep->getQualifier(i));             XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
           }
  
         XmlWriter::appendValueElement(out, rep->getValue());         XmlWriter::appendValueElement(out, rep->getValue());
  
Line 1125 
Line 1248 
             out << STRLIT(" REFERENCECLASS=\"") << rep->getReferenceClassName();             out << STRLIT(" REFERENCECLASS=\"") << rep->getReferenceClassName();
             out.append('"');             out.append('"');
         }         }
           if(includeClassOrigin && !rep->getClassOrigin().isNull())
         if (!rep->getClassOrigin().isNull())  
         {         {
             out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin();             out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin();
             out.append('"');             out.append('"');
Line 1138 
Line 1260 
         }         }
  
         out << STRLIT(">\n");         out << STRLIT(">\n");
           if(includeQualifiers)
           {
         for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)         for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
             XmlWriter::appendQualifierElement(out, rep->getQualifier(i));             XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
           }
  
         XmlWriter::appendValueElement(out, rep->getValue());         XmlWriter::appendValueElement(out, rep->getValue());
  
Line 1149 
Line 1273 
     else     else
     {     {
         out << STRLIT("<PROPERTY NAME=\"") << rep->getName() << STRLIT("\" ");         out << STRLIT("<PROPERTY NAME=\"") << rep->getName() << STRLIT("\" ");
           if(includeClassOrigin && !rep->getClassOrigin().isNull())
         if (!rep->getClassOrigin().isNull())  
         {         {
             out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin();             out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin();
             out.append('"');             out.append('"');
Line 1232 
Line 1355 
         }         }
  
         out << STRLIT(">\n");         out << STRLIT(">\n");
           if(includeQualifiers)
           {
         for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)         for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
             XmlWriter::appendQualifierElement(out, rep->getQualifier(i));             XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
           }
  
         XmlWriter::appendValueElement(out, rep->getValue());         XmlWriter::appendValueElement(out, rep->getValue());
  
Line 1688 
Line 1813 
     bool binaryRequest,     bool binaryRequest,
     bool binaryResponse)     bool binaryResponse)
 { {
     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };      char nn[] = { char('0' + (rand() % 10)), char('0' + (rand() % 10)),'\0'};
  
     // ATTN: KS 20020926 - Temporary change to issue only POST. This may     // ATTN: KS 20020926 - Temporary change to issue only POST. This may
     // be changed in the DMTF CIM Operations standard in the future.     // be changed in the DMTF CIM Operations standard in the future.
Line 1714 
Line 1839 
     }     }
     else     else
     {     {
         out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n");          out << STRLIT("Content-Type: application/xml; charset=utf-8\r\n");
     }     }
  
     if (binaryResponse)     if (binaryResponse)
Line 1828 
Line 1953 
      }      }
      else      else
      {      {
          out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n");           out << STRLIT("Content-Type: application/xml; charset=utf-8\r\n");
      }      }
  
      OUTPUT_CONTENTLENGTH(out, contentLength);      OUTPUT_CONTENTLENGTH(out, contentLength);
Line 1840 
Line 1965 
      }      }
      if (httpMethod == HTTP_METHOD_M_POST)      if (httpMethod == HTTP_METHOD_M_POST)
      {      {
          char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };           char nn[] = {char('0'+(rand() % 10)),char('0' + (rand() % 10)),'\0'};
  
          out << STRLIT("Ext:\r\n"          out << STRLIT("Ext:\r\n"
                        "Cache-Control: no-cache\r\n"                        "Cache-Control: no-cache\r\n"
Line 1897 
Line 2022 
 //     Returns unauthorized message in the following format: //     Returns unauthorized message in the following format:
 // //
 //        HTTP/1.1 401 Unauthorized //        HTTP/1.1 401 Unauthorized
   //        PGErrorDetail: <error text>    (if specified by caller)
 //        WWW-Authenticate: Basic realm="HostName" //        WWW-Authenticate: Basic realm="HostName"
 //        <HTML><HEAD> //        <HTML><HEAD>
 //        <TITLE>401 Unauthorized</TITLE> //        <TITLE>401 Unauthorized</TITLE>
Line 1909 
Line 2035 
  
 void XmlWriter::appendUnauthorizedResponseHeader( void XmlWriter::appendUnauthorizedResponseHeader(
     Buffer& out,     Buffer& out,
       const String& errorDetail,
     const String& content)     const String& content)
 { {
     out << STRLIT("HTTP/1.1 " HTTP_STATUS_UNAUTHORIZED "\r\n");     out << STRLIT("HTTP/1.1 " HTTP_STATUS_UNAUTHORIZED "\r\n");
       if (errorDetail.size() > 0)
       {
           out << STRLIT(PEGASUS_HTTPHEADERTAG_ERRORDETAIL ": ")
               << encodeURICharacters(errorDetail) << STRLIT("\r\n");
       }
   
     OUTPUT_CONTENTLENGTH(out, 0);     OUTPUT_CONTENTLENGTH(out, 0);
     out << content << STRLIT("\r\n\r\n");     out << content << STRLIT("\r\n\r\n");
  
Line 1925 
Line 2058 
 //    out << "</BODY></HTML>\r\n"; //    out << "</BODY></HTML>\r\n";
 } }
  
 #ifdef PEGASUS_KERBEROS_AUTHENTICATION  
 //------------------------------------------------------------------------------  
 //  
 // appendOKResponseHeader()  
 //  
 //     Build HTTP authentication response header for unauthorized requests.  
 //  
 //     Returns OK message in the following format:  
 //  
 //        HTTP/1.1 200 OK  
 //        Content-Length: 0  
 //        WWW-Authenticate: Negotiate "token"  
 //        <HTML><HEAD>  
 //        <TITLE>200 OK</TITLE>  
 //        </HEAD><BODY BGCOLOR="#99cc99">  
 //        <H2>TEST200 OK</H2>  
 //        <HR>  
 //        </BODY></HTML>  
 //  
 //------------------------------------------------------------------------------  
   
 void XmlWriter::appendOKResponseHeader(  
     Buffer& out,  
     const String& content)  
 {  
     out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n");  
     // Content-Length header needs to be added because 200 OK record  
     // is usually intended to have content.  But, for Kerberos this  
     // may not always be the case so we need to indicate that there  
     // is no content  
     OUTPUT_CONTENTLENGTH(out, 0);  
     out << content << STRLIT("\r\n\r\n");  
   
 //ATTN: We may need to include the following line, so that the browsers  
 //      can display the error message.  
 //    out << "<HTML><HEAD>\r\n";  
 //    out << "<TITLE>" << "200 OK" <<  "</TITLE>\r\n";  
 //    out << "</HEAD><BODY BGCOLOR=\"#99cc99\">\r\n";  
 //    out << "<H2>TEST" << "200 OK" << "</H2>\r\n";  
 //    out << "<HR>\r\n";  
 //    out << "</BODY></HTML>\r\n";  
 }  
 #endif  
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
Line 2089 
Line 2179 
     out << STRLIT("</IPARAMVALUE>\n");     out << STRLIT("</IPARAMVALUE>\n");
 } }
  
   //EXP_PULL_BEGIN
   //------------------------------------------------------------------------------
   //
   // _appendParamValueElementBegin()
   // _appendParamValueElementEnd()
   //
   //     <!ELEMENT IPARAMVALUE (VALUE|VALUE.ARRAY|VALUE.REFERENCE
   //         |INSTANCENAME|CLASSNAME|QUALIFIER.DECLARATION
   //         |CLASS|INSTANCE|VALUE.NAMEDINSTANCE)?>
   //     <!ATTLIST IPARAMVALUE %CIMName;>
   //
   //------------------------------------------------------------------------------
   
   void XmlWriter::_appendParamValueElementBegin(
       Buffer& out,
       const char* name)
   {
       out << STRLIT("<PARAMVALUE NAME=\"") << name << STRLIT("\">\n");
   }
   
   void XmlWriter::_appendParamValueElementEnd(
       Buffer& out)
   {
       out << STRLIT("</PARAMVALUE>\n");
   }
   //EXP_PULL_END
   
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // _appendSimpleRspElementBegin() // _appendSimpleRspElementBegin()
Line 2290 
Line 2407 
     out << STRLIT("</IRETURNVALUE>\n");     out << STRLIT("</IRETURNVALUE>\n");
 } }
  
   //EXP_PULL_BEGIN
   void XmlWriter::_appendIReturnValueElementWithNameBegin(
       Buffer& out,
       const char* name)
   {
       out << STRLIT("<IRETURNVALUE NAME=\"") << name << STRLIT("\">\n");
   }
   //EXP_PULL_END
   
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // appendBooleanIParameter() // appendBooleanIParameter()
Line 2308 
Line 2434 
     _appendIParamValueElementEnd(out);     _appendIParamValueElementEnd(out);
 } }
  
   //EXP_PULL_BEGIN
   void XmlWriter::appendBooleanParameter(
       Buffer& out,
       const char* name,
       Boolean flag)
   {
       _appendParamValueElementBegin(out, name);
       out << STRLIT("<VALUE>");
       append(out, flag);
       out << STRLIT("</VALUE>\n");
       _appendParamValueElementEnd(out);
   }
   
   void XmlWriter::appendBooleanIReturnValue(
       Buffer& out,
       const char* name,
       Boolean flag)
   {
       _appendIReturnValueElementWithNameBegin(out, name);
       out << STRLIT("<VALUE>");
       append(out, flag);
       out << STRLIT("</VALUE>\n");
       _appendIReturnValueElementEnd(out);
   }
   void XmlWriter::appendUint32IParameter(
       Buffer& out,
       const char* name,
       Uint32 val)
   {
       _appendIParamValueElementBegin(out, name);
       out << STRLIT("<VALUE>");
       append(out, val);
       out << STRLIT("</VALUE>\n");
       _appendIParamValueElementEnd(out);
   }
   
   // Can be used to generate either parameters with value,
   // parameters with NULL (i.e. no value element) or
   // no parameters output at all.
   void XmlWriter::appendUint32ArgIParameter(
       Buffer& out,
       const char* name,
       const Uint32Arg& val,
       const Boolean required)
   {
       if (!required && val.isNull())
       {
           return;
       }
   
       _appendIParamValueElementBegin(out, name);
       if (!val.isNull())
       {
           out << STRLIT("<VALUE>");
           append(out, val.getValue());
           out << STRLIT("</VALUE>\n");
       }
       _appendIParamValueElementEnd(out);
   }
   
   /* Output return value from Uint64Arg object as
      Value inside IRETURNVALUE
      If the state of the object is NULL output
      the parameter without value.  Else
      output the value
   */
   void XmlWriter::appendUint64ReturnValue(
       Buffer& out,
       const char* name,
       const Uint64Arg& val)
   {
       _appendIReturnValueElementBegin(out);
       out << STRLIT("<VALUE>");
       if (!val.isNull())
       {
           append(out, val.getValue());
       }
       out << STRLIT("</VALUE>\n");
       _appendIReturnValueElementEnd(out);
   }
   //EXP_PULL_END
   
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // appendStringIParameter() // appendStringIParameter()
Line 2326 
Line 2534 
     _appendIParamValueElementEnd(out);     _appendIParamValueElementEnd(out);
 } }
  
   // EXP_PULL_BEGIN
   //------------------------------------------------------------------------------
   //
   // appendStringIParameterIfNotEmpty()
   //
   //------------------------------------------------------------------------------
   
   void XmlWriter::appendStringIParameterIfNotEmpty(
       Buffer& out,
       const char* name,
       const String& str)
   {
       if (str != String::EMPTY)
       {
           appendStringIParameter(out,name,str);
       }
   }
   
   //------------------------------------------------------------------------------
   //
   // appendStringParameter()
   //
   //------------------------------------------------------------------------------
   
   void XmlWriter::appendStringParameter(
       Buffer& out,
       const char* name,
       const String& str)
   {
       _appendParamValueElementBegin(out, name);
       out << STRLIT("<VALUE>");
       appendSpecial(out, str);
       out << STRLIT("</VALUE>\n");
       _appendParamValueElementEnd(out);
   }
   
   //------------------------------------------------------------------------------
   //
   // appendStringIReturnValue()
   //
   //------------------------------------------------------------------------------
   
   void XmlWriter::appendStringIReturnValue(
       Buffer& out,
       const char* name,
       const String& str)
   {
       _appendIReturnValueElementWithNameBegin(out, name);
       out << STRLIT("<VALUE>");
       appendSpecial(out, str);
       out << STRLIT("</VALUE>\n");
       _appendIReturnValueElementEnd(out);
   }
   //EXP_PULL_END
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // appendClassNameIParameter() // appendClassNameIParameter()
Line 2367 
Line 2629 
     _appendIParamValueElementEnd(out);     _appendIParamValueElementEnd(out);
 } }
  
 void XmlWriter::appendObjectNameIParameter(  
     Buffer& out,  
     const char* name,  
     const CIMObjectPath& objectName)  
 {  
     //  
     //  ATTN-CAKG-P2-20020726:  The following condition does not correctly  
     //  distinguish instanceNames from classNames in every case  
     //  The instanceName of a singleton instance of a keyless class also  
     //  has no key bindings  
     //  
     if (objectName.getKeyBindings ().size () == 0)  
     {  
         XmlWriter::appendClassNameIParameter(  
             out, name, objectName.getClassName());  
     }  
     else  
     {  
         XmlWriter::appendInstanceNameIParameter(  
             out, name, objectName);  
     }  
 }  
   
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 // //
 // appendClassIParameter() // appendClassIParameter()
Line 2597 
Line 2836 
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const ContentLanguageList& httpContentLanguages,     const ContentLanguageList& httpContentLanguages,
       const Buffer& bodyParams,
     const Buffer& body,     const Buffer& body,
     Uint64 serverResponseTime,     Uint64 serverResponseTime,
     Boolean isFirst,     Boolean isFirst,
Line 2718 
Line 2958 
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
   /*
       Formats a IMethod Response Message.  This function formats
       messages for chunking based on the isFirst and isLast parameters.
       If isFirst is set, it outputs headers and ResponseElement begin.
       It always sends the body.  If isLast is set,  it sends the rtnParams
       and the ResponseElement end followed by any parameter in the rtnParams.
       KS_PULL_TBD_TODO - Determine what we want to do with chunking. Since this
       This whole thing is based on the concept of each message sending a  single
       chunk and we will want in the future to modify so we can chose easily
       whether we want to chunk or not and send the chunks.
   */
 Buffer XmlWriter::formatSimpleIMethodRspMessage( Buffer XmlWriter::formatSimpleIMethodRspMessage(
     const CIMName& iMethodName,     const CIMName& iMethodName,
     const String& messageId,     const String& messageId,
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const ContentLanguageList& httpContentLanguages,     const ContentLanguageList& httpContentLanguages,
       const Buffer& rtnParams,
     const Buffer& body,     const Buffer& body,
     Uint64 serverResponseTime,     Uint64 serverResponseTime,
     Boolean isFirst,     Boolean isFirst,
Line 2759 
Line 3011 
     {     {
         if (body.size() != 0 || isFirst == false)         if (body.size() != 0 || isFirst == false)
             _appendIReturnValueElementEnd(out);             _appendIReturnValueElementEnd(out);
   
           // EXP_PULL_BEGIN
           // Insert any return parameters.
           if (rtnParams.size() != 0)
           {
               out << rtnParams;
           }
           // EXP_PULL_END
   
         _appendIMethodResponseElementEnd(out);         _appendIMethodResponseElementEnd(out);
         _appendSimpleRspElementEnd(out);         _appendSimpleRspElementEnd(out);
         _appendMessageElementEnd(out);         _appendMessageElementEnd(out);
Line 2825 
Line 3086 
     const ContentLanguageList& contentLanguages,     const ContentLanguageList& contentLanguages,
     Uint32 contentLength)     Uint32 contentLength)
 { {
     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };      char nn[] = { char('0' + (rand() % 10)), char('0' + (rand() % 10)), '\0' };
  
     if (httpMethod == HTTP_METHOD_M_POST)     if (httpMethod == HTTP_METHOD_M_POST)
     {     {
Line 2836 
Line 3097 
       out << STRLIT("POST ") << requestUri << STRLIT(" HTTP/1.1\r\n");       out << STRLIT("POST ") << requestUri << STRLIT(" HTTP/1.1\r\n");
     }     }
     out << STRLIT("HOST: ") << host << STRLIT("\r\n"     out << STRLIT("HOST: ") << host << STRLIT("\r\n"
                   "Content-Type: application/xml; charset=\"utf-8\"\r\n");                    "Content-Type: application/xml; charset=utf-8\r\n");
     OUTPUT_CONTENTLENGTH(out, contentLength);     OUTPUT_CONTENTLENGTH(out, contentLength);
  
     if (acceptLanguages.size() > 0)     if (acceptLanguages.size() > 0)
Line 2897 
Line 3158 
     const ContentLanguageList& contentLanguages,     const ContentLanguageList& contentLanguages,
     Uint32 contentLength)     Uint32 contentLength)
 { {
     char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };      char nn[] = { char('0' + (rand() % 10)), char('0' + (rand() % 10)), '\0' };
  
     out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n"     out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n"
                   "Content-Type: application/xml; charset=\"utf-8\"\r\n");                    "Content-Type: application/xml; charset=utf-8\r\n");
     OUTPUT_CONTENTLENGTH(out, contentLength);     OUTPUT_CONTENTLENGTH(out, contentLength);
  
     if (contentLanguages.size() > 0)     if (contentLanguages.size() > 0)
Line 3197 
Line 3458 
  
         case CIMKeyBinding::REFERENCE:         case CIMKeyBinding::REFERENCE:
         default:         default:
             PEGASUS_ASSERT(false);              PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);)
     }     }
  
     return STRLIT("unknown");     return STRLIT("unknown");


Legend:
Removed from v.1.169  
changed lines
  Added in v.1.169.4.11

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2