(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.157.4.1 and 1.179

version 1.157.4.1, 2008/07/01 15:18:03 version 1.179, 2014/08/27 23:10:08
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.  
 // //
 //==============================================================================  //////////////////////////////////////////////////////////////////////////
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 60 
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 107 
Line 104 
     const String& host,     const String& host,
     const CIMNamespaceName& nameSpace)     const CIMNamespaceName& nameSpace)
 { {
     out << STRLIT("<NAMESPACEPATH>\n");      out << STRLIT("<NAMESPACEPATH>\n"
     out << STRLIT("<HOST>") << host << STRLIT("</HOST>\n");                    "<HOST>") << host << STRLIT("</HOST>\n");
     appendLocalNameSpacePathElement(out, nameSpace);     appendLocalNameSpacePathElement(out, nameSpace);
     out << STRLIT("</NAMESPACEPATH>\n");     out << STRLIT("</NAMESPACEPATH>\n");
 } }
Line 150 
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 164 
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 259 
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 268 
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 359 
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 547 
Line 552 
                 _xmlWritter_appendValueArray(out, a.getData(), a.size());                 _xmlWritter_appendValueArray(out, a.getData(), a.size());
                 break;                 break;
             }             }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
             case CIMTYPE_INSTANCE:             case CIMTYPE_INSTANCE:
             {             {
                 Array<CIMInstance> a;                 Array<CIMInstance> a;
Line 555 
Line 559 
                 _xmlWritter_appendValueArray(out, a.getData(), a.size());                 _xmlWritter_appendValueArray(out, a.getData(), a.size());
                 break;                 break;
             }             }
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
             default:             default:
                 PEGASUS_ASSERT(false);                  PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);)
         }         }
     }     }
     else if (value.getType() == CIMTYPE_REFERENCE)     else if (value.getType() == CIMTYPE_REFERENCE)
Line 692 
Line 695 
                 _xmlWritter_appendValue(out, v);                 _xmlWritter_appendValue(out, v);
                 break;                 break;
             }             }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
             case CIMTYPE_INSTANCE:             case CIMTYPE_INSTANCE:
             {             {
                 CIMInstance v;                 CIMInstance v;
Line 700 
Line 702 
                 _xmlWritter_appendValue(out, v);                 _xmlWritter_appendValue(out, v);
                 break;                 break;
             }             }
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
             default:             default:
                 PEGASUS_ASSERT(false);                  PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);)
         }         }
  
         out << STRLIT("</VALUE>\n");         out << STRLIT("</VALUE>\n");
Line 729 
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 783 
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 798 
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 define if this is a class or instance path
   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 822 
Line 852 
  
 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 908 
Line 975 
  
 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 920 
Line 990 
         << 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 953 
Line 1056 
  
 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 963 
Line 1069 
     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 998 
Line 1109 
  
 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 1023 
Line 1136 
             // EmbeddedObject attribute.             // EmbeddedObject attribute.
             if (a.size() > 0 && a[0].isInstance())             if (a.size() > 0 && a[0].isInstance())
             {             {
                 out << STRLIT(" EmbeddedObject=\"object\"");                  out << STRLIT(" EmbeddedObject=\"object\""
                 out << STRLIT(" EMBEDDEDOBJECT=\"object\"");                                " EMBEDDEDOBJECT=\"object\"");
             }             }
 #ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY #ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY
             else             else
Line 1035 
Line 1148 
                 // PEGASUS_SNIA_INTEROP_COMPATIBILITY is defined, then                 // PEGASUS_SNIA_INTEROP_COMPATIBILITY is defined, then
                 // the EmbeddedObject qualifier will always be added,                 // the EmbeddedObject qualifier will always be added,
                 // whether it's a class or an instance.                 // whether it's a class or an instance.
                 if (rep->findQualifier(CIMName("EmbeddedObject")) ==                  if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT) ==
                         PEG_NOT_FOUND)                         PEG_NOT_FOUND)
                 {                 {
                     // Note that addQualifiers() cannot be called on a const                     // Note that addQualifiers() cannot be called on a const
Line 1044 
Line 1157 
                     // constness.                     // constness.
                     CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);                     CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);
                     tmpRep->addQualifier(                     tmpRep->addQualifier(
                         CIMQualifier(CIMName("EmbeddedObject"), true));                          CIMQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT,
                                        true));
                 }                 }
             }             }
         }         }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         else if (rep->getValue().getType() == CIMTYPE_INSTANCE)         else if (rep->getValue().getType() == CIMTYPE_INSTANCE)
         {         {
             // If the property array type is CIMInstance, then             // If the property array type is CIMInstance, then
Line 1063 
Line 1176 
             // add the EmbeddedObject attribute             // add the EmbeddedObject attribute
             if (a.size() > 0)             if (a.size() > 0)
             {             {
                 out << STRLIT(" EmbeddedObject=\"instance\"");                  out << STRLIT(" EmbeddedObject=\"instance\""
                 out << STRLIT(" EMBEDDEDOBJECT=\"instance\"");                                " EMBEDDEDOBJECT=\"instance\"");
  
                 // 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(CIMName("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 1081 
Line 1194 
                     // the array are of the same type                     // the array are of the same type
                     CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);                     CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);
                     tmpRep->addQualifier(CIMQualifier(                     tmpRep->addQualifier(CIMQualifier(
                         CIMName("EmbeddedInstance"),                          PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE,
                         a[0].getClassName().getString()));                         a[0].getClassName().getString()));
                 }                 }
 # endif # endif
             }             }
         }         }
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         else         else
         {         {
             out << STRLIT(" TYPE=\"")              out.append(' ');
                 << cimTypeToString(rep->getValue().getType());              out << xmlWriterTypeStrings(rep->getValue().getType());
             out.append('"');  
         }         }
  
         if (rep->getArraySize())         if (rep->getArraySize())
Line 1103 
Line 1214 
             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 1115 
Line 1226 
         }         }
  
         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 1238 
     }     }
     else if (rep->getValue().getType() == CIMTYPE_REFERENCE)     else if (rep->getValue().getType() == CIMTYPE_REFERENCE)
     {     {
         out << STRLIT("<PROPERTY.REFERENCE");          out << STRLIT("<PROPERTY.REFERENCE"
                         " NAME=\"") << rep->getName() << STRLIT("\" ");
         out << STRLIT(" NAME=\"") << rep->getName() << STRLIT("\" ");  
  
         if (!rep->getReferenceClassName().isNull())         if (!rep->getReferenceClassName().isNull())
         {         {
             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 1147 
Line 1258 
         }         }
  
         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 1158 
Line 1271 
     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 1185 
Line 1297 
             // EmbeddedObject attribute.             // EmbeddedObject attribute.
             if (a.isInstance())             if (a.isInstance())
             {             {
                 out << STRLIT(" EmbeddedObject=\"object\"");                  out << STRLIT(" EmbeddedObject=\"object\""
                 out << STRLIT(" EMBEDDEDOBJECT=\"object\"");                                " EMBEDDEDOBJECT=\"object\"");
             }             }
             // Else the Embedded Object is a class, always add the             // Else the Embedded Object is a class, always add the
             // EmbeddedObject qualifier.             // EmbeddedObject qualifier.
Line 1197 
Line 1309 
                 // Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY                 // Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY
                 // is defined, then the EmbeddedObject qualifier will always                 // is defined, then the EmbeddedObject qualifier will always
                 // be added, whether it's a class or an instance.                 // be added, whether it's a class or an instance.
                 if (rep->findQualifier(CIMName("EmbeddedObject")) ==                  if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT) ==
                         PEG_NOT_FOUND)                         PEG_NOT_FOUND)
                 {                 {
                     // Note that addQualifiers() cannot be called on a const                     // Note that addQualifiers() cannot be called on a const
Line 1206 
Line 1318 
                     // constness.                     // constness.
                     CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);                     CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);
                     tmpRep->addQualifier(                     tmpRep->addQualifier(
                         CIMQualifier(CIMName("EmbeddedObject"), true));                          CIMQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT,
                                        true));
                 }                 }
             }             }
         }         }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         else if (rep->getValue().getType() == CIMTYPE_INSTANCE)         else if (rep->getValue().getType() == CIMTYPE_INSTANCE)
         {         {
             CIMInstance a;             CIMInstance a;
             rep->getValue().get(a);             rep->getValue().get(a);
             out << " TYPE=\"string\"";              out << STRLIT(" TYPE=\"string\""
             out << " EmbeddedObject=\"instance\"";                            " EmbeddedObject=\"instance\""
             out << " EMBEDDEDOBJECT=\"instance\"";                            " EMBEDDEDOBJECT=\"instance\"");
  
 # ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY # ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY
             if (rep->findQualifier(CIMName("EmbeddedObject")) == PEG_NOT_FOUND)              if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT)
                   == 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 1228 
Line 1341 
                 // constness.                 // constness.
                 CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);                 CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);
                 tmpRep->addQualifier(CIMQualifier(                 tmpRep->addQualifier(CIMQualifier(
                     CIMName("EmbeddedInstance"),                      PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE,
                     a.getClassName().getString()));                     a.getClassName().getString()));
             }             }
 # endif # endif
         }         }
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
         else         else
         {         {
             out << STRLIT(" TYPE=\"")              out.append(' ');
                 << cimTypeToString(rep->getValue().getType());              out << xmlWriterTypeStrings(rep->getValue().getType());
             out.append('"');  
         }         }
  
         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 1283 
Line 1396 
     const CIMMethodRep* rep = method._rep;     const CIMMethodRep* rep = method._rep;
  
     out << STRLIT("<METHOD NAME=\"") << rep->getName();     out << STRLIT("<METHOD NAME=\"") << rep->getName();
     out.append('"');      out << STRLIT("\" ");
  
     out << STRLIT(" TYPE=\"") << cimTypeToString(rep->getType());      out << xmlWriterTypeStrings(rep->getType());
     out.append('"');  
  
     if (!rep->getClassOrigin().isNull())     if (!rep->getClassOrigin().isNull())
     {     {
Line 1386 
Line 1498 
         }         }
         else         else
         {         {
             out << STRLIT("<PARAMETER.ARRAY");              out << STRLIT("<PARAMETER.ARRAY"
             out << STRLIT(" NAME=\"") << rep->getName();                            " NAME=\"") << rep->getName();
             out << STRLIT("\" ");              out << STRLIT("\" ") << xmlWriterTypeStrings(rep->getType());
             out << STRLIT(" TYPE=\"") << cimTypeToString(rep->getType());  
             out.append('"');  
  
             if (rep->getArraySize())             if (rep->getArraySize())
             {             {
Line 1410 
Line 1520 
     }     }
     else if (rep->getType() == CIMTYPE_REFERENCE)     else if (rep->getType() == CIMTYPE_REFERENCE)
     {     {
         out << STRLIT("<PARAMETER.REFERENCE");          out << STRLIT("<PARAMETER.REFERENCE"
         out << STRLIT(" NAME=\"") << rep->getName();                        " NAME=\"") << rep->getName();
         out.append('"');         out.append('"');
  
         if (!rep->getReferenceClassName().isNull())         if (!rep->getReferenceClassName().isNull())
Line 1429 
Line 1539 
     }     }
     else     else
     {     {
         out << STRLIT("<PARAMETER");          out << STRLIT("<PARAMETER"
         out << STRLIT(" NAME=\"") << rep->getName();                        " NAME=\"") << rep->getName();
         out << STRLIT("\" ");          out << STRLIT("\" ") << xmlWriterTypeStrings(rep->getType());
         out << STRLIT(" TYPE=\"") << cimTypeToString(rep->getType());  
         out << STRLIT("\">\n");          out << STRLIT(">\n");
  
         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));
Line 1516 
Line 1626 
     const CIMQualifierRep* rep = qualifier._rep;     const CIMQualifierRep* rep = qualifier._rep;
  
     out << STRLIT("<QUALIFIER NAME=\"") << rep->getName();     out << STRLIT("<QUALIFIER NAME=\"") << rep->getName();
     out.append('"');      out << STRLIT("\" ") << xmlWriterTypeStrings(rep->getValue().getType());
     out << STRLIT(" TYPE=\"") << cimTypeToString(rep->getValue().getType());  
     out.append('"');  
  
     if (rep->getPropagated())     if (rep->getPropagated())
     {     {
Line 1565 
Line 1673 
     const CIMQualifierDeclRep* rep = qualifierDecl._rep;     const CIMQualifierDeclRep* rep = qualifierDecl._rep;
  
     out << STRLIT("<QUALIFIER.DECLARATION NAME=\"") << rep->getName();     out << STRLIT("<QUALIFIER.DECLARATION NAME=\"") << rep->getName();
     out.append('"');      out << STRLIT("\" ") << xmlWriterTypeStrings(rep->getValue().getType());
     out << STRLIT(" TYPE=\"") << cimTypeToString(rep->getValue().getType());  
     out.append('"');  
  
     if (rep->getValue().isArray())     if (rep->getValue().isArray())
     {     {
Line 1609 
Line 1715 
 //                                 TOINSTANCE   (true|false)   'false' //                                 TOINSTANCE   (true|false)   'false'
 //                                 TRANSLATABLE (true|false)   'false'"> //                                 TRANSLATABLE (true|false)   'false'">
 // //
   //     DEPRECATION NOTE:  The attribute TOINSTANCE is DEPRECATED and MAY be
   //     removed from the QualifierFlavor entity in a future version of this
   //     document.  Use of this qualifier is discouraged.
   //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
 void XmlWriter::appendQualifierFlavorEntity( void XmlWriter::appendQualifierFlavorEntity(
Line 1621 
Line 1731 
     if (!(flavor.hasFlavor (CIMFlavor::TOSUBCLASS)))     if (!(flavor.hasFlavor (CIMFlavor::TOSUBCLASS)))
         out << STRLIT(" TOSUBCLASS=\"false\"");         out << STRLIT(" TOSUBCLASS=\"false\"");
  
     if (flavor.hasFlavor (CIMFlavor::TOINSTANCE))      //if (flavor.hasFlavor (CIMFlavor::TOINSTANCE))
         out << STRLIT(" TOINSTANCE=\"true\"");      //    out << STRLIT(" TOINSTANCE=\"true\"");
  
     if (flavor.hasFlavor (CIMFlavor::TRANSLATABLE))     if (flavor.hasFlavor (CIMFlavor::TRANSLATABLE))
         out << STRLIT(" TRANSLATABLE=\"true\"");         out << STRLIT(" TRANSLATABLE=\"true\"");
Line 1697 
Line 1807 
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const AcceptLanguageList& acceptLanguages,     const AcceptLanguageList& acceptLanguages,
     const ContentLanguageList& contentLanguages,     const ContentLanguageList& contentLanguages,
     Uint32 contentLength)      Uint32 contentLength,
       bool binaryRequest,
       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 1716 
Line 1828 
         out << STRLIT("POST /cimom HTTP/1.1\r\n");         out << STRLIT("POST /cimom HTTP/1.1\r\n");
     }     }
     out << STRLIT("HOST: ") << host << STRLIT("\r\n");     out << STRLIT("HOST: ") << host << STRLIT("\r\n");
     out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n");  
       if (binaryRequest)
       {
           // Tell the server that the payload is encoded in the OpenPegasus
           // binary protocol.
           out << STRLIT("Content-Type: application/x-openpegasus\r\n");
       }
       else
       {
           out << STRLIT("Content-Type: application/xml; charset=utf-8\r\n");
       }
   
       if (binaryResponse)
       {
           // Tell the server that this client accepts the OpenPegasus binary
           // protocol.
           out << STRLIT("Accept: application/x-openpegasus\r\n");
       }
   
     OUTPUT_CONTENTLENGTH(out, contentLength);     OUTPUT_CONTENTLENGTH(out, contentLength);
     if (acceptLanguages.size() > 0)     if (acceptLanguages.size() > 0)
     {     {
Line 1740 
Line 1870 
     if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0')     if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0')
 #endif #endif
  
       if (!binaryResponse)
       {
           // The binary protocol does not allow chunking.
     out << STRLIT("TE: chunked, trailers\r\n");     out << STRLIT("TE: chunked, trailers\r\n");
       }
  
     if (httpMethod == HTTP_METHOD_M_POST)     if (httpMethod == HTTP_METHOD_M_POST)
     {     {
Line 1775 
Line 1909 
      HttpMethod httpMethod,      HttpMethod httpMethod,
      const ContentLanguageList& contentLanguages,      const ContentLanguageList& contentLanguages,
      Uint32 contentLength,      Uint32 contentLength,
      Uint64 serverResponseTime)       Uint64 serverResponseTime,
        bool binaryResponse)
 { {
      char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };      // Optimize the typical case for binary messages, circumventing the
       // more expensive logic below.
       if (binaryResponse &&
           contentLength == 0 &&
           httpMethod != HTTP_METHOD_M_POST &&
           contentLanguages.size() == 0)
       {
           static const char HEADERS[] =
               "HTTP/1.1 200 OK\r\n"
               "Content-Type: application/x-openpegasus\r\n"
               "content-length: 0000000000\r\n"
               "CIMOperation: MethodResponse\r\n"
               "\r\n";
   
           // The HTTP processor fills in the content-length value later.
           // It searches for a field matching "content-length" (so the first
           // character must be lower case).
           out.append(HEADERS, sizeof(HEADERS) - 1);
           return;
       }
   
      out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n");      out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n");
  
 #ifndef PEGASUS_DISABLE_PERFINST #ifndef PEGASUS_DISABLE_PERFINST
Line 1788 
Line 1943 
      }      }
 #endif #endif
  
      out << STRLIT("Content-Type: application/xml; charset=\"utf-8\"\r\n");       if (binaryResponse)
        {
           // According to MIME RFC, the "x-" prefix should be used for all
           // non-registered values.
            out << STRLIT("Content-Type: application/x-openpegasus\r\n");
        }
        else
        {
            out << STRLIT("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 1798 
Line 1963 
      }      }
      if (httpMethod == HTTP_METHOD_M_POST)      if (httpMethod == HTTP_METHOD_M_POST)
      {      {
          out << STRLIT("Ext:\r\n");           char nn[] = {char('0'+(rand() % 10)),char('0' + (rand() % 10)),'\0'};
          out << STRLIT("Cache-Control: no-cache\r\n");  
          out << STRLIT("Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");           out << STRLIT("Ext:\r\n"
                          "Cache-Control: no-cache\r\n"
                          "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");
          out << nn << STRLIT("\r\n");          out << nn << STRLIT("\r\n");
          out << nn << STRLIT("-CIMOperation: MethodResponse\r\n\r\n");          out << nn << STRLIT("-CIMOperation: MethodResponse\r\n\r\n");
      }      }
Line 1853 
Line 2020 
 //     Returns unauthorized message in the following format: //     Returns unauthorized message in the following format:
 // //
 //        HTTP/1.1 401 Unauthorized //        HTTP/1.1 401 Unauthorized
 //        WWW-Authenticate: Basic "hostname:80"  //        PGErrorDetail: <error text>    (if specified by caller)
   //        WWW-Authenticate: Basic realm="HostName"
 //        <HTML><HEAD> //        <HTML><HEAD>
 //        <TITLE>401 Unauthorized</TITLE> //        <TITLE>401 Unauthorized</TITLE>
 //        </HEAD><BODY BGCOLOR="#99cc99"> //        </HEAD><BODY BGCOLOR="#99cc99">
Line 1865 
Line 2033 
  
 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");      out << content << STRLIT("\r\n\r\n");
     out << STRLIT("\r\n");  
  
 //ATTN: We may need to include the following line, so that the browsers //ATTN: We may need to include the following line, so that the browsers
 //      can display the error message. //      can display the error message.
Line 1882 
Line 2056 
 //    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");  
     out << STRLIT("\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 1943 
Line 2073 
     Buffer& out,     Buffer& out,
     const String& messageId)     const String& messageId)
 { {
     out << STRLIT("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");      out << STRLIT("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
     out << STRLIT("<CIM CIMVERSION=\"2.0\" DTDVERSION=\"2.0\">\n");                    "<CIM CIMVERSION=\"2.0\" DTDVERSION=\"2.0\">\n"
     out << STRLIT("<MESSAGE ID=\"") << messageId;                    "<MESSAGE ID=\"") << messageId;
     out << STRLIT("\" PROTOCOLVERSION=\"1.0\">\n");     out << STRLIT("\" PROTOCOLVERSION=\"1.0\">\n");
 } }
  
 void XmlWriter::_appendMessageElementEnd( void XmlWriter::_appendMessageElementEnd(
     Buffer& out)     Buffer& out)
 { {
     out << STRLIT("</MESSAGE>\n");      out << STRLIT("</MESSAGE>\n</CIM>\n");
     out << STRLIT("</CIM>\n");  
 } }
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 2048 
Line 2177 
     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 2125 
Line 2281 
     Buffer& out,     Buffer& out,
     const CIMException& cimException)     const CIMException& cimException)
 { {
     Tracer::traceCIMException(TRC_XML_WRITER, Tracer::LEVEL2, cimException);      Tracer::traceCIMException(TRC_XML, Tracer::LEVEL2, cimException);
  
     out << STRLIT("<ERROR");      out << STRLIT("<ERROR CODE=\"") << Uint32(cimException.getCode());
     out << STRLIT(" CODE=\"") << Uint32(cimException.getCode());  
     out.append('"');     out.append('"');
  
     String description = TraceableCIMException(cimException).getDescription();     String description = TraceableCIMException(cimException).getDescription();
Line 2182 
Line 2337 
     if (type == CIMTYPE_OBJECT)     if (type == CIMTYPE_OBJECT)
     {     {
  
         out << STRLIT(" PARAMTYPE=\"string\"");          out << STRLIT(" PARAMTYPE=\"string\""
         out << STRLIT(" EmbeddedObject=\"object\"");                        " EmbeddedObject=\"object\""
         out << STRLIT(" EMBEDDEDOBJECT=\"object\"");                        " EMBEDDEDOBJECT=\"object\"");
     }     }
 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     else if (type == CIMTYPE_INSTANCE)     else if (type == CIMTYPE_INSTANCE)
     {     {
         out << STRLIT(" PARAMTYPE=\"string\"");          out << STRLIT(" PARAMTYPE=\"string\""
         out << STRLIT(" EmbeddedObject=\"instance\"");                        " EmbeddedObject=\"instance\""
         out << STRLIT(" EMBEDDEDOBJECT=\"instance\"");                        " EMBEDDEDOBJECT=\"instance\"");
     }     }
 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT  
     else     else
     {     {
         out << STRLIT(" PARAMTYPE=\"") << cimTypeToString (type);          out << STRLIT(" PARAM") << xmlWriterTypeStrings(type);
         out.append('"');  
     }     }
 } }
  
Line 2253 
Line 2405 
     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 2271 
Line 2432 
     _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 2289 
Line 2532 
     _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 2330 
Line 2627 
     _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 2517 
Line 2791 
     HttpMethod httpMethod,     HttpMethod httpMethod,
     const String& authenticationHeader,     const String& authenticationHeader,
     const AcceptLanguageList& httpAcceptLanguages,     const AcceptLanguageList& httpAcceptLanguages,
     const ContentLanguageList& httpContentLanguages)      const ContentLanguageList& httpContentLanguages,
       bool binaryResponse)
 { {
     Buffer out;     Buffer out;
     Buffer tmp;     Buffer tmp;
Line 2546 
Line 2821 
         httpMethod,         httpMethod,
         httpAcceptLanguages,         httpAcceptLanguages,
         httpContentLanguages,         httpContentLanguages,
         out.size());          out.size(),
           false,
           binaryResponse);
     tmp << out;     tmp << out;
  
     return tmp;     return tmp;
Line 2557 
Line 2834 
     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 2618 
Line 2896 
         tmp,         tmp,
         httpMethod,         httpMethod,
         cimException.getContentLanguages(),         cimException.getContentLanguages(),
         out.size());          out.size(),
           false);
     tmp << out;     tmp << out;
  
     return tmp;     return tmp;
Line 2639 
Line 2918 
     const String& authenticationHeader,     const String& authenticationHeader,
     const AcceptLanguageList& httpAcceptLanguages,     const AcceptLanguageList& httpAcceptLanguages,
     const ContentLanguageList& httpContentLanguages,     const ContentLanguageList& httpContentLanguages,
     const Buffer& body)      const Buffer& body,
       bool binaryResponse)
 { {
     Buffer out;     Buffer out;
     Buffer tmp;     Buffer tmp;
Line 2662 
Line 2942 
         httpMethod,         httpMethod,
         httpAcceptLanguages,         httpAcceptLanguages,
         httpContentLanguages,         httpContentLanguages,
         out.size());          out.size(),
           false,
           binaryResponse);
     tmp << out;     tmp << out;
  
     return tmp;     return tmp;
Line 2674 
Line 2956 
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
  
   /*
       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 2715 
Line 3009 
     {     {
         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 2750 
Line 3053 
     appendMethodResponseHeader(tmp,     appendMethodResponseHeader(tmp,
         httpMethod,         httpMethod,
         cimException.getContentLanguages(),         cimException.getContentLanguages(),
         out.size());          out.size(), false);
     tmp << out;     tmp << out;
  
     return tmp;     return tmp;
Line 2781 
Line 3084 
     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 2791 
Line 3094 
     {     {
       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"
     out << STRLIT("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 2827 
Line 3130 
     }     }
     else     else
     {     {
         out << STRLIT("CIMExport: MethodRequest\r\n");          out << STRLIT("CIMExport: MethodRequest\r\n"
         out << STRLIT("CIMExportMethod: ") << cimMethod << STRLIT("\r\n");                        "CIMExportMethod: ") << cimMethod << STRLIT("\r\n");
     }     }
  
     if (authenticationHeader.size())     if (authenticationHeader.size())
Line 2853 
Line 3156 
     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"
     out << STRLIT("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 2866 
Line 3169 
     }     }
     if (httpMethod == HTTP_METHOD_M_POST)     if (httpMethod == HTTP_METHOD_M_POST)
     {     {
         out << STRLIT("Ext:\r\n");          out << STRLIT("Ext:\r\n"
         out << STRLIT("Cache-Control: no-cache\r\n");                        "Cache-Control: no-cache\r\n"
         out << STRLIT("Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");                        "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");
         out << nn << STRLIT("\r\n");         out << nn << STRLIT("\r\n");
         out << nn << STRLIT("-CIMExport: MethodResponse\r\n\r\n");         out << nn << STRLIT("-CIMExport: MethodResponse\r\n\r\n");
     }     }
Line 3138 
Line 3441 
 // XmlWriter::keyBindingTypeToString // XmlWriter::keyBindingTypeToString
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 const char* XmlWriter::keyBindingTypeToString (CIMKeyBinding::Type type)  const StrLit XmlWriter::keyBindingTypeToString (CIMKeyBinding::Type type)
 { {
     switch (type)     switch (type)
     {     {
         case CIMKeyBinding::BOOLEAN:         case CIMKeyBinding::BOOLEAN:
             return "boolean";              return STRLIT("boolean");
  
         case CIMKeyBinding::STRING:         case CIMKeyBinding::STRING:
             return "string";              return STRLIT("string");
  
         case CIMKeyBinding::NUMERIC:         case CIMKeyBinding::NUMERIC:
             return "numeric";              return STRLIT("numeric");
  
         case CIMKeyBinding::REFERENCE:         case CIMKeyBinding::REFERENCE:
         default:         default:
             PEGASUS_ASSERT(false);              PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);)
     }     }
  
     return "unknown";      return STRLIT("unknown");
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.157.4.1  
changed lines
  Added in v.1.179

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2