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

   1 martin 1.165 //%LICENSE////////////////////////////////////////////////////////////////
   2 martin 1.166 //
   3 martin 1.165 // Licensed to The Open Group (TOG) under one or more contributor license
   4              // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
   5              // this work for additional information regarding copyright ownership.
   6              // Each contributor licenses this file to you under the OpenPegasus Open
   7              // Source License; you may not use this file except in compliance with the
   8              // License.
   9 martin 1.166 //
  10 martin 1.165 // Permission is hereby granted, free of charge, to any person obtaining a
  11              // copy of this software and associated documentation files (the "Software"),
  12              // to deal in the Software without restriction, including without limitation
  13              // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  14              // and/or sell copies of the Software, and to permit persons to whom the
  15              // Software is furnished to do so, subject to the following conditions:
  16 martin 1.166 //
  17 martin 1.165 // The above copyright notice and this permission notice shall be included
  18              // in all copies or substantial portions of the Software.
  19 martin 1.166 //
  20 martin 1.165 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  21 martin 1.166 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22 martin 1.165 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  23              // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  24              // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  25              // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  26              // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27 martin 1.166 //
  28 martin 1.165 //////////////////////////////////////////////////////////////////////////
  29 mike   1.23  //
  30              //%/////////////////////////////////////////////////////////////////////////////
  31              
  32 sage   1.49  #include <Pegasus/Common/Config.h>
  33 mike   1.23  #include <cstdlib>
  34              #include <cstdio>
  35 kumpf  1.46  #include "Constants.h"
  36 mike   1.23  #include "CIMClass.h"
  37 kumpf  1.55  #include "CIMClassRep.h"
  38 mike   1.23  #include "CIMInstance.h"
  39 kumpf  1.55  #include "CIMInstanceRep.h"
  40 kumpf  1.56  #include "CIMProperty.h"
  41              #include "CIMPropertyRep.h"
  42              #include "CIMMethod.h"
  43              #include "CIMMethodRep.h"
  44              #include "CIMParameter.h"
  45              #include "CIMParameterRep.h"
  46              #include "CIMParamValue.h"
  47              #include "CIMParamValueRep.h"
  48              #include "CIMQualifier.h"
  49              #include "CIMQualifierRep.h"
  50              #include "CIMQualifierDecl.h"
  51              #include "CIMQualifierDeclRep.h"
  52 kumpf  1.54  #include "CIMValue.h"
  53 mike   1.23  #include "XmlWriter.h"
  54 kumpf  1.44  #include "Tracer.h"
  55 sage   1.49  #include <Pegasus/Common/StatisticalData.h>
  56 david  1.92  #include "CommonUTF.h"
  57 mike   1.125 #include "Buffer.h"
  58 mike   1.127 #include "StrLit.h"
  59 mike   1.139 #include "IDFactory.h"
  60 marek  1.151 #include "StringConversion.h"
  61 mike   1.23  PEGASUS_NAMESPACE_BEGIN
  62              
  63 kumpf  1.29  //------------------------------------------------------------------------------
  64              //
  65              // appendLocalNameSpacePathElement()
  66              //
  67              //     <!ELEMENT LOCALNAMESPACEPATH (NAMESPACE+)>
  68              //
  69              //------------------------------------------------------------------------------
  70              
  71              void XmlWriter::appendLocalNameSpacePathElement(
  72 mike   1.125     Buffer& out,
  73 kumpf  1.80      const CIMNamespaceName& nameSpace)
  74 mike   1.23  {
  75 mike   1.126     out << STRLIT("<LOCALNAMESPACEPATH>\n");
  76 mike   1.23  
  77 david  1.103     char* nameSpaceCopy = strdup(nameSpace.getString().getCString());
  78 chuck  1.105 
  79 marek  1.140 #if !defined(PEGASUS_COMPILER_MSVC) && !defined(PEGASUS_OS_ZOS)
  80 keith.petley 1.91      char *last;
  81                        for (const char* p = strtok_r(nameSpaceCopy, "/", &last); p;
  82 kumpf        1.93           p = strtok_r(NULL, "/", &last))
  83 keith.petley 1.91  #else
  84 kumpf        1.76      for (const char* p = strtok(nameSpaceCopy, "/"); p; p = strtok(NULL, "/"))
  85 keith.petley 1.91  #endif
  86 mike         1.23      {
  87 david.dillard 1.131         out << STRLIT("<NAMESPACE NAME=\"") << p << STRLIT("\"/>\n");
  88 mike          1.23      }
  89 kumpf         1.96      free(nameSpaceCopy);
  90 mike          1.23  
  91 mike          1.126     out << STRLIT("</LOCALNAMESPACEPATH>\n");
  92 mike          1.23  }
  93                     
  94                     //------------------------------------------------------------------------------
  95                     //
  96 kumpf         1.29  // appendNameSpacePathElement()
  97                     //
  98                     //     <!ELEMENT NAMESPACEPATH (HOST,LOCALNAMESPACEPATH)>
  99                     //
 100                     //------------------------------------------------------------------------------
 101                     
 102                     void XmlWriter::appendNameSpacePathElement(
 103 mike          1.125     Buffer& out,
 104 kumpf         1.29      const String& host,
 105 kumpf         1.80      const CIMNamespaceName& nameSpace)
 106 kumpf         1.29  {
 107 kumpf         1.167     out << STRLIT("<NAMESPACEPATH>\n"
 108 thilo.boehm   1.162                   "<HOST>") << host << STRLIT("</HOST>\n");
 109 kumpf         1.29      appendLocalNameSpacePathElement(out, nameSpace);
 110 mike          1.126     out << STRLIT("</NAMESPACEPATH>\n");
 111 kumpf         1.29  }
 112                     
 113                     //------------------------------------------------------------------------------
 114                     //
 115                     // appendClassNameElement()
 116                     //
 117                     //     <!ELEMENT CLASSNAME EMPTY>
 118                     //     <!ATTLIST CLASSNAME
 119                     //              %CIMName;>
 120                     //
 121                     //------------------------------------------------------------------------------
 122                     
 123                     void XmlWriter::appendClassNameElement(
 124 mike          1.125     Buffer& out,
 125 kumpf         1.80      const CIMName& className)
 126 kumpf         1.29  {
 127 mike          1.126     out << STRLIT("<CLASSNAME NAME=\"") << className << STRLIT("\"/>\n");
 128 kumpf         1.29  }
 129                     
 130                     //------------------------------------------------------------------------------
 131                     //
 132                     // appendInstanceNameElement()
 133                     //
 134                     //    <!ELEMENT INSTANCENAME (KEYBINDING*|KEYVALUE?|VALUE.REFERENCE?)>
 135                     //    <!ATTLIST INSTANCENAME
 136                     //              %ClassName;>
 137                     //
 138                     //------------------------------------------------------------------------------
 139                     
 140                     void XmlWriter::appendInstanceNameElement(
 141 mike          1.125     Buffer& out,
 142 kumpf         1.59      const CIMObjectPath& instanceName)
 143 kumpf         1.29  {
 144 mike          1.126     out << STRLIT("<INSTANCENAME CLASSNAME=\"");
 145                         out << instanceName.getClassName() << STRLIT("\">\n");
 146 kumpf         1.29  
 147 mike          1.126     const Array<CIMKeyBinding>& keyBindings = instanceName.getKeyBindings();
 148 kumpf         1.29      for (Uint32 i = 0, n = keyBindings.size(); i < n; i++)
 149                         {
 150 mike          1.126         out << STRLIT("<KEYBINDING NAME=\"");
 151 kumpf         1.146         out << keyBindings[i].getName() << STRLIT("\">\n");
 152 kumpf         1.29  
 153 kumpf         1.79          if (keyBindings[i].getType() == CIMKeyBinding::REFERENCE)
 154 kumpf         1.29          {
 155 kumpf         1.59              CIMObjectPath ref = keyBindings[i].getValue();
 156 karl          1.173             // create an instancePath (i.e. isClassPath = false)
 157                                 appendValueReferenceElement(out, ref, false, true);
 158 kumpf         1.29          }
 159 kumpf         1.146         else
 160                             {
 161 mike          1.126             out << STRLIT("<KEYVALUE VALUETYPE=\"");
 162 kumpf         1.68              out << keyBindingTypeToString(keyBindings[i].getType());
 163 mike          1.126             out << STRLIT("\">");
 164 kumpf         1.29  
 165 karl          1.173             // fixed the special characters
 166 kumpf         1.29  
 167                                 appendSpecial(out, keyBindings[i].getValue());
 168 mike          1.126             out << STRLIT("</KEYVALUE>\n");
 169 kumpf         1.29          }
 170 mike          1.126         out << STRLIT("</KEYBINDING>\n");
 171 kumpf         1.29      }
 172 mike          1.126     out << STRLIT("</INSTANCENAME>\n");
 173 kumpf         1.29  }
 174                     
 175                     //------------------------------------------------------------------------------
 176                     //
 177                     // appendClassPathElement()
 178                     //
 179                     //     <!ELEMENT CLASSPATH (NAMESPACEPATH,CLASSNAME)>
 180                     //
 181                     //------------------------------------------------------------------------------
 182                     
 183                     void XmlWriter::appendClassPathElement(
 184 mike          1.125     Buffer& out,
 185 kumpf         1.59      const CIMObjectPath& classPath)
 186 kumpf         1.29  {
 187 mike          1.126     out << STRLIT("<CLASSPATH>\n");
 188 kumpf         1.29      appendNameSpacePathElement(out,
 189                                                    classPath.getHost(),
 190                                                    classPath.getNameSpace());
 191                         appendClassNameElement(out, classPath.getClassName());
 192 mike          1.126     out << STRLIT("</CLASSPATH>\n");
 193 kumpf         1.29  }
 194                     
 195                     //------------------------------------------------------------------------------
 196                     //
 197                     // appendInstancePathElement()
 198                     //
 199                     //     <!ELEMENT INSTANCEPATH (NAMESPACEPATH,INSTANCENAME)>
 200                     //
 201                     //------------------------------------------------------------------------------
 202                     
 203                     void XmlWriter::appendInstancePathElement(
 204 mike          1.125     Buffer& out,
 205 kumpf         1.59      const CIMObjectPath& instancePath)
 206 kumpf         1.29  {
 207 mike          1.126     out << STRLIT("<INSTANCEPATH>\n");
 208 kumpf         1.29      appendNameSpacePathElement(out,
 209                                                    instancePath.getHost(),
 210                                                    instancePath.getNameSpace());
 211                         appendInstanceNameElement(out, instancePath);
 212 mike          1.126     out << STRLIT("</INSTANCEPATH>\n");
 213 kumpf         1.29  }
 214                     
 215                     //------------------------------------------------------------------------------
 216                     //
 217                     // appendLocalClassPathElement()
 218                     //
 219                     //     <!ELEMENT LOCALCLASSPATH (LOCALNAMESPACEPATH, CLASSNAME)>
 220                     //
 221                     //------------------------------------------------------------------------------
 222                     
 223                     void XmlWriter::appendLocalClassPathElement(
 224 mike          1.125     Buffer& out,
 225 kumpf         1.59      const CIMObjectPath& classPath)
 226 kumpf         1.29  {
 227 mike          1.126     out << STRLIT("<LOCALCLASSPATH>\n");
 228 kumpf         1.29      appendLocalNameSpacePathElement(out, classPath.getNameSpace());
 229                         appendClassNameElement(out, classPath.getClassName());
 230 mike          1.126     out << STRLIT("</LOCALCLASSPATH>\n");
 231 kumpf         1.29  }
 232                     
 233                     //------------------------------------------------------------------------------
 234                     //
 235                     // appendLocalInstancePathElement()
 236                     //
 237                     //     <!ELEMENT LOCALINSTANCEPATH (LOCALNAMESPACEPATH, INSTANCENAME)>
 238                     //
 239                     //------------------------------------------------------------------------------
 240                     
 241                     void XmlWriter::appendLocalInstancePathElement(
 242 mike          1.125     Buffer& out,
 243 kumpf         1.59      const CIMObjectPath& instancePath)
 244 kumpf         1.29  {
 245 mike          1.126     out << STRLIT("<LOCALINSTANCEPATH>\n");
 246 kumpf         1.29      appendLocalNameSpacePathElement(out, instancePath.getNameSpace());
 247                         appendInstanceNameElement(out, instancePath);
 248 mike          1.126     out << STRLIT("</LOCALINSTANCEPATH>\n");
 249 kumpf         1.29  }
 250                     
 251                     //------------------------------------------------------------------------------
 252                     //
 253 kumpf         1.30  // appendLocalObjectPathElement()
 254                     //
 255 kumpf         1.31  //     If the reference refers to an instance, write a LOCALINSTANCEPATH;
 256                     //     otherwise write a LOCALCLASSPATH.
 257 kumpf         1.30  //
 258                     //------------------------------------------------------------------------------
 259                     
 260 karl          1.173 // appendValueReferenceElement does this correctly with isClassPath flag
 261                     // Called only but formatSimple
 262 kumpf         1.30  void XmlWriter::appendLocalObjectPathElement(
 263 mike          1.125     Buffer& out,
 264 kumpf         1.59      const CIMObjectPath& objectPath)
 265 kumpf         1.30  {
 266 kumpf         1.68      //
 267                         //  ATTN-CAKG-P2-20020726:  The following condition does not correctly
 268                         //  distinguish instanceNames from classNames in every case
 269 david.dillard 1.121     //  The instanceName of a singleton instance of a keyless class has no
 270 kumpf         1.68      //  key bindings
 271 karl          1.174     //  See bBUG_3302.
 272 kumpf         1.68      //
 273                         if (objectPath.getKeyBindings ().size () != 0)
 274 kumpf         1.30      {
 275                             appendLocalInstancePathElement(out, objectPath);
 276                         }
 277                         else
 278                         {
 279                             appendLocalClassPathElement(out, objectPath);
 280                         }
 281                     }
 282                     
 283                     //------------------------------------------------------------------------------
 284                     //
 285 kumpf         1.54  // Helper functions for appendValueElement()
 286                     //
 287                     //------------------------------------------------------------------------------
 288                     
 289 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, Boolean x)
 290 kumpf         1.54  {
 291                         XmlWriter::append(out, x);
 292                     }
 293                     
 294 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, Uint8 x)
 295 kumpf         1.54  {
 296                         XmlWriter::append(out, Uint32(x));
 297                     }
 298                     
 299 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, Sint8 x)
 300 kumpf         1.54  {
 301                         XmlWriter::append(out, Sint32(x));
 302                     }
 303                     
 304 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, Uint16 x)
 305 kumpf         1.54  {
 306                         XmlWriter::append(out, Uint32(x));
 307                     }
 308                     
 309 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, Sint16 x)
 310 kumpf         1.54  {
 311                         XmlWriter::append(out, Sint32(x));
 312                     }
 313                     
 314 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, Uint32 x)
 315 kumpf         1.54  {
 316                         XmlWriter::append(out, x);
 317                     }
 318                     
 319 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, Sint32 x)
 320 kumpf         1.54  {
 321                         XmlWriter::append(out, x);
 322                     }
 323                     
 324 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, Uint64 x)
 325 kumpf         1.54  {
 326                         XmlWriter::append(out, x);
 327                     }
 328                     
 329 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, Sint64 x)
 330 kumpf         1.54  {
 331                         XmlWriter::append(out, x);
 332                     }
 333                     
 334 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, Real32 x)
 335 kumpf         1.54  {
 336 chuck         1.102     XmlWriter::append(out, x);
 337 kumpf         1.54  }
 338                     
 339 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, Real64 x)
 340 kumpf         1.54  {
 341                         XmlWriter::append(out, x);
 342                     }
 343                     
 344 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, const Char16& x)
 345 kumpf         1.54  {
 346                         XmlWriter::appendSpecial(out, x);
 347                     }
 348                     
 349 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, const String& x)
 350 kumpf         1.54  {
 351                         XmlWriter::appendSpecial(out, x);
 352                     }
 353                     
 354 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, const CIMDateTime& x)
 355 kumpf         1.54  {
 356 kumpf         1.136     // It is not necessary to use XmlWriter::appendSpecial(), because
 357                         // CIMDateTime values do not contain special characters.
 358                         out << x.toString();
 359 kumpf         1.54  }
 360                     
 361 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, const CIMObjectPath& x)
 362 kumpf         1.54  {
 363 karl          1.173     // Emit Instance Path with value wrapper
 364                         XmlWriter::appendValueReferenceElement(out, x, false, true);
 365 kumpf         1.54  }
 366                     
 367 mike          1.125 inline void _xmlWritter_appendValue(Buffer& out, const CIMObject& x)
 368 dave.sudlik   1.114 {
 369 dave.sudlik   1.120     String myStr = x.toString();
 370                         _xmlWritter_appendValue(out, myStr);
 371 dave.sudlik   1.114 }
 372                     
 373 mike          1.126 void _xmlWritter_appendValueArray(
 374                         Buffer& out, const CIMObjectPath* p, Uint32 size)
 375 kumpf         1.54  {
 376 mike          1.126     out << STRLIT("<VALUE.REFARRAY>\n");
 377 kumpf         1.54      while (size--)
 378                         {
 379 s.hills       1.99          _xmlWritter_appendValue(out, *p++);
 380 kumpf         1.54      }
 381 mike          1.126     out << STRLIT("</VALUE.REFARRAY>\n");
 382 kumpf         1.54  }
 383                     
 384                     template<class T>
 385 mike          1.125 void _xmlWritter_appendValueArray(Buffer& out, const T* p, Uint32 size)
 386 kumpf         1.54  {
 387 mike          1.126     out << STRLIT("<VALUE.ARRAY>\n");
 388 kumpf         1.54  
 389                         while (size--)
 390                         {
 391 mike          1.126         out << STRLIT("<VALUE>");
 392 s.hills       1.99          _xmlWritter_appendValue(out, *p++);
 393 mike          1.126         out << STRLIT("</VALUE>\n");
 394 kumpf         1.54      }
 395                     
 396 mike          1.126     out << STRLIT("</VALUE.ARRAY>\n");
 397 kumpf         1.54  }
 398                     
 399                     //------------------------------------------------------------------------------
 400                     //
 401                     // appendValueElement()
 402                     //
 403 kumpf         1.55  //    <!ELEMENT VALUE (#PCDATA)>
 404                     //    <!ELEMENT VALUE.ARRAY (VALUE*)>
 405                     //    <!ELEMENT VALUE.REFERENCE
 406                     //        (CLASSPATH|LOCALCLASSPATH|CLASSNAME|INSTANCEPATH|LOCALINSTANCEPATH|
 407                     //         INSTANCENAME)>
 408                     //    <!ELEMENT VALUE.REFARRAY (VALUE.REFERENCE*)>
 409                     //
 410 kumpf         1.54  //------------------------------------------------------------------------------
 411                     
 412                     void XmlWriter::appendValueElement(
 413 mike          1.125     Buffer& out,
 414 kumpf         1.54      const CIMValue& value)
 415                     {
 416                         if (value.isNull())
 417                         {
 418                             return;
 419                         }
 420                         if (value.isArray())
 421                         {
 422                             switch (value.getType())
 423                             {
 424 kumpf         1.66              case CIMTYPE_BOOLEAN:
 425 kumpf         1.54              {
 426                                     Array<Boolean> a;
 427                                     value.get(a);
 428 s.hills       1.99                  _xmlWritter_appendValueArray(out, a.getData(), a.size());
 429 kumpf         1.54                  break;
 430                                 }
 431                     
 432 kumpf         1.66              case CIMTYPE_UINT8:
 433 kumpf         1.54              {
 434                                     Array<Uint8> a;
 435                                     value.get(a);
 436 s.hills       1.99                  _xmlWritter_appendValueArray(out, a.getData(), a.size());
 437 kumpf         1.54                  break;
 438                                 }
 439                     
 440 kumpf         1.66              case CIMTYPE_SINT8:
 441 kumpf         1.54              {
 442                                     Array<Sint8> a;
 443                                     value.get(a);
 444 s.hills       1.99                  _xmlWritter_appendValueArray(out, a.getData(), a.size());
 445 kumpf         1.54                  break;
 446                                 }
 447                     
 448 kumpf         1.66              case CIMTYPE_UINT16:
 449 kumpf         1.54              {
 450                                     Array<Uint16> a;
 451                                     value.get(a);
 452 s.hills       1.99                  _xmlWritter_appendValueArray(out, a.getData(), a.size());
 453 kumpf         1.54                  break;
 454                                 }
 455                     
 456 kumpf         1.66              case CIMTYPE_SINT16:
 457 kumpf         1.54              {
 458                                     Array<Sint16> a;
 459                                     value.get(a);
 460 s.hills       1.99                  _xmlWritter_appendValueArray(out, a.getData(), a.size());
 461 kumpf         1.54                  break;
 462                                 }
 463                     
 464 kumpf         1.66              case CIMTYPE_UINT32:
 465 kumpf         1.54              {
 466                                     Array<Uint32> a;
 467                                     value.get(a);
 468 s.hills       1.99                  _xmlWritter_appendValueArray(out, a.getData(), a.size());
 469 kumpf         1.54                  break;
 470                                 }
 471                     
 472 kumpf         1.66              case CIMTYPE_SINT32:
 473 kumpf         1.54              {
 474                                     Array<Sint32> a;
 475                                     value.get(a);
 476 s.hills       1.99                  _xmlWritter_appendValueArray(out, a.getData(), a.size());
 477 kumpf         1.54                  break;
 478                                 }
 479                     
 480 kumpf         1.66              case CIMTYPE_UINT64:
 481 kumpf         1.54              {
 482                                     Array<Uint64> a;
 483                                     value.get(a);
 484 s.hills       1.99                  _xmlWritter_appendValueArray(out, a.getData(), a.size());
 485 kumpf         1.54                  break;
 486                                 }
 487                     
 488 kumpf         1.66              case CIMTYPE_SINT64:
 489 kumpf         1.54              {
 490                                     Array<Sint64> a;
 491                                     value.get(a);
 492 s.hills       1.99                  _xmlWritter_appendValueArray(out, a.getData(), a.size());
 493 kumpf         1.54                  break;
 494                                 }
 495                     
 496 kumpf         1.66              case CIMTYPE_REAL32:
 497 kumpf         1.54              {
 498                                     Array<Real32> a;
 499                                     value.get(a);
 500 s.hills       1.99                  _xmlWritter_appendValueArray(out, a.getData(), a.size());
 501 kumpf         1.54                  break;
 502                                 }
 503                     
 504 kumpf         1.66              case CIMTYPE_REAL64:
 505 kumpf         1.54              {
 506                                     Array<Real64> a;
 507                                     value.get(a);
 508 s.hills       1.99                  _xmlWritter_appendValueArray(out, a.getData(), a.size());
 509 kumpf         1.54                  break;
 510                                 }
 511                     
 512 kumpf         1.66              case CIMTYPE_CHAR16:
 513 kumpf         1.54              {
 514                                     Array<Char16> a;
 515                                     value.get(a);
 516 s.hills       1.99                  _xmlWritter_appendValueArray(out, a.getData(), a.size());
 517 kumpf         1.54                  break;
 518                                 }
 519                     
 520 kumpf         1.66              case CIMTYPE_STRING:
 521 kumpf         1.54              {
 522 kumpf         1.146                 const String* data;
 523                                     Uint32 size;
 524                                     value._get(data, size);
 525 mike          1.126                 _xmlWritter_appendValueArray(out, data, size);
 526 kumpf         1.54                  break;
 527                                 }
 528                     
 529 kumpf         1.66              case CIMTYPE_DATETIME:
 530 kumpf         1.54              {
 531                                     Array<CIMDateTime> a;
 532                                     value.get(a);
 533 s.hills       1.99                  _xmlWritter_appendValueArray(out, a.getData(), a.size());
 534 kumpf         1.54                  break;
 535                                 }
 536                     
 537 kumpf         1.66              case CIMTYPE_REFERENCE:
 538 kumpf         1.54              {
 539 kumpf         1.59                  Array<CIMObjectPath> a;
 540 kumpf         1.54                  value.get(a);
 541 s.hills       1.99                  _xmlWritter_appendValueArray(out, a.getData(), a.size());
 542 kumpf         1.54                  break;
 543                                 }
 544                     
 545 dave.sudlik   1.114             case CIMTYPE_OBJECT:
 546                                 {
 547                                     Array<CIMObject> a;
 548                                     value.get(a);
 549                                     _xmlWritter_appendValueArray(out, a.getData(), a.size());
 550                                     break;
 551                                 }
 552 a.dunfey      1.137             case CIMTYPE_INSTANCE:
 553                                 {
 554                                     Array<CIMInstance> a;
 555                                     value.get(a);
 556                                     _xmlWritter_appendValueArray(out, a.getData(), a.size());
 557                                     break;
 558                                 }
 559 kumpf         1.54              default:
 560 kumpf         1.78                  PEGASUS_ASSERT(false);
 561 kumpf         1.54          }
 562                         }
 563 kumpf         1.66      else if (value.getType() == CIMTYPE_REFERENCE)
 564 kumpf         1.54      {
 565                             // Has to be separate because it uses VALUE.REFERENCE tag
 566 kumpf         1.59          CIMObjectPath v;
 567 kumpf         1.54          value.get(v);
 568 s.hills       1.99          _xmlWritter_appendValue(out, v);
 569 kumpf         1.54      }
 570                         else
 571                         {
 572 mike          1.126         out << STRLIT("<VALUE>");
 573 kumpf         1.54  
 574                             switch (value.getType())
 575                             {
 576 kumpf         1.66              case CIMTYPE_BOOLEAN:
 577 kumpf         1.54              {
 578                                     Boolean v;
 579                                     value.get(v);
 580 s.hills       1.99                  _xmlWritter_appendValue(out, v);
 581 kumpf         1.54                  break;
 582                                 }
 583                     
 584 kumpf         1.66              case CIMTYPE_UINT8:
 585 kumpf         1.54              {
 586                                     Uint8 v;
 587                                     value.get(v);
 588 s.hills       1.99                  _xmlWritter_appendValue(out, v);
 589 kumpf         1.54                  break;
 590                                 }
 591                     
 592 kumpf         1.66              case CIMTYPE_SINT8:
 593 kumpf         1.54              {
 594                                     Sint8 v;
 595                                     value.get(v);
 596 s.hills       1.99                  _xmlWritter_appendValue(out, v);
 597 kumpf         1.54                  break;
 598                                 }
 599                     
 600 kumpf         1.66              case CIMTYPE_UINT16:
 601 kumpf         1.54              {
 602                                     Uint16 v;
 603                                     value.get(v);
 604 s.hills       1.99                  _xmlWritter_appendValue(out, v);
 605 kumpf         1.54                  break;
 606                                 }
 607                     
 608 kumpf         1.66              case CIMTYPE_SINT16:
 609 kumpf         1.54              {
 610                                     Sint16 v;
 611                                     value.get(v);
 612 s.hills       1.99                  _xmlWritter_appendValue(out, v);
 613 kumpf         1.54                  break;
 614                                 }
 615                     
 616 kumpf         1.66              case CIMTYPE_UINT32:
 617 kumpf         1.54              {
 618                                     Uint32 v;
 619                                     value.get(v);
 620 s.hills       1.99                  _xmlWritter_appendValue(out, v);
 621 kumpf         1.54                  break;
 622                                 }
 623                     
 624 kumpf         1.66              case CIMTYPE_SINT32:
 625 kumpf         1.54              {
 626                                     Sint32 v;
 627                                     value.get(v);
 628 s.hills       1.99                  _xmlWritter_appendValue(out, v);
 629 kumpf         1.54                  break;
 630                                 }
 631                     
 632 kumpf         1.66              case CIMTYPE_UINT64:
 633 kumpf         1.54              {
 634                                     Uint64 v;
 635                                     value.get(v);
 636 s.hills       1.99                  _xmlWritter_appendValue(out, v);
 637 kumpf         1.54                  break;
 638                                 }
 639                     
 640 kumpf         1.66              case CIMTYPE_SINT64:
 641 kumpf         1.54              {
 642                                     Sint64 v;
 643                                     value.get(v);
 644 s.hills       1.99                  _xmlWritter_appendValue(out, v);
 645 kumpf         1.54                  break;
 646                                 }
 647                     
 648 kumpf         1.66              case CIMTYPE_REAL32:
 649 kumpf         1.54              {
 650                                     Real32 v;
 651                                     value.get(v);
 652 s.hills       1.99                  _xmlWritter_appendValue(out, v);
 653 kumpf         1.54                  break;
 654                                 }
 655                     
 656 kumpf         1.66              case CIMTYPE_REAL64:
 657 kumpf         1.54              {
 658                                     Real64 v;
 659                                     value.get(v);
 660 s.hills       1.99                  _xmlWritter_appendValue(out, v);
 661 kumpf         1.54                  break;
 662                                 }
 663                     
 664 kumpf         1.66              case CIMTYPE_CHAR16:
 665 kumpf         1.54              {
 666                                     Char16 v;
 667                                     value.get(v);
 668 s.hills       1.99                  _xmlWritter_appendValue(out, v);
 669 kumpf         1.54                  break;
 670                                 }
 671                     
 672 kumpf         1.66              case CIMTYPE_STRING:
 673 kumpf         1.54              {
 674                                     String v;
 675                                     value.get(v);
 676 s.hills       1.99                  _xmlWritter_appendValue(out, v);
 677 kumpf         1.54                  break;
 678                                 }
 679                     
 680 kumpf         1.66              case CIMTYPE_DATETIME:
 681 kumpf         1.54              {
 682                                     CIMDateTime v;
 683                                     value.get(v);
 684 s.hills       1.99                  _xmlWritter_appendValue(out, v);
 685 kumpf         1.54                  break;
 686                                 }
 687                     
 688 dave.sudlik   1.114             case CIMTYPE_OBJECT:
 689                                 {
 690                                     CIMObject v;
 691                                     value.get(v);
 692                                     _xmlWritter_appendValue(out, v);
 693                                     break;
 694                                 }
 695 a.dunfey      1.137             case CIMTYPE_INSTANCE:
 696                                 {
 697                                     CIMInstance v;
 698                                     value.get(v);
 699                                     _xmlWritter_appendValue(out, v);
 700                                     break;
 701                                 }
 702 kumpf         1.54              default:
 703 kumpf         1.78                  PEGASUS_ASSERT(false);
 704 kumpf         1.54          }
 705                     
 706 mike          1.126         out << STRLIT("</VALUE>\n");
 707 kumpf         1.54      }
 708                     }
 709                     
 710                     void XmlWriter::printValueElement(
 711                         const CIMValue& value,
 712                         PEGASUS_STD(ostream)& os)
 713                     {
 714 mike          1.125     Buffer tmp;
 715 kumpf         1.54      appendValueElement(tmp, value);
 716                         os << tmp.getData() << PEGASUS_STD(endl);
 717                     }
 718                     
 719                     //------------------------------------------------------------------------------
 720                     //
 721 kumpf         1.56  // appendValueObjectWithPathElement()
 722                     //
 723                     //     <!ELEMENT VALUE.OBJECTWITHPATH
 724                     //         ((CLASSPATH,CLASS)|(INSTANCEPATH,INSTANCE))>
 725                     //
 726                     //------------------------------------------------------------------------------
 727                     
 728                     void XmlWriter::appendValueObjectWithPathElement(
 729 mike          1.125     Buffer& out,
 730 anusha.kandepu 1.170     const CIMObject& objectWithPath,
 731                          Boolean includeQualifiers,
 732                          Boolean includeClassOrigin,
 733 karl           1.173     Boolean isClassObject,
 734 anusha.kandepu 1.170     const CIMPropertyList& propertyList)
 735 kumpf          1.56  {
 736 mike           1.126     out << STRLIT("<VALUE.OBJECTWITHPATH>\n");
 737 kumpf          1.56  
 738 karl           1.173     appendValueReferenceElement(out, objectWithPath.getPath (),
 739                              isClassObject , false);
 740                      
 741 anusha.kandepu 1.170     appendObjectElement(
 742                              out,
 743                              objectWithPath,
 744                              includeQualifiers,
 745                              includeClassOrigin,
 746                              propertyList);
 747 kumpf          1.56  
 748 mike           1.126     out << STRLIT("</VALUE.OBJECTWITHPATH>\n");
 749 kumpf          1.56  }
 750                      
 751                      //------------------------------------------------------------------------------
 752                      //
 753                      // appendValueReferenceElement()
 754                      //
 755                      //    <!ELEMENT VALUE.REFERENCE
 756                      //        (CLASSPATH|LOCALCLASSPATH|CLASSNAME|INSTANCEPATH|LOCALINSTANCEPATH|
 757                      //         INSTANCENAME)>
 758                      //
 759                      //------------------------------------------------------------------------------
 760                      
 761 karl           1.173 // appends INSTANCEPATH | LOCALINSTANCEPATH | INSTANCENAME
 762                      void XmlWriter::appendValueInstancePathElement(
 763                          Buffer& out,
 764                          const CIMObjectPath& reference)
 765                      {
 766                          if (reference.getHost().size())
 767                          {
 768                              appendInstancePathElement(out, reference);
 769                          }
 770                          else if (!reference.getNameSpace().isNull())
 771                          {
 772                              appendLocalInstancePathElement(out, reference);
 773                          }
 774                          else
 775                          {
 776                              appendInstanceNameElement(out, reference);
 777                          }
 778                      }
 779                      
 780                      // appends CLASSPATH | LOCALCLASSPATH | CLASSNAME
 781                      void XmlWriter::appendValueClassPathElement(
 782 karl           1.173     Buffer& out,
 783                          const CIMObjectPath& reference)
 784                      {
 785                          if (reference.getHost().size())
 786                          {
 787                              appendClassPathElement(out, reference);
 788                          }
 789                          else if (!reference.getNameSpace().isNull())
 790                          {
 791                              appendLocalClassPathElement(out, reference);
 792                          }
 793                          else
 794                          {
 795                              appendClassNameElement(out, reference.getClassName());
 796                          }
 797                      }
 798                      
 799                      // Builds either a classPath or InstancePath based on isClassPath
 800                      // parameter which was carried forward from, for example, the
 801                      // request. If wrapper true, wrap output with <VALUE.REFERENCE>
 802 kumpf          1.56  void XmlWriter::appendValueReferenceElement(
 803 mike           1.125     Buffer& out,
 804 kumpf          1.59      const CIMObjectPath& reference,
 805 karl           1.173     Boolean isClassPath,
 806                          Boolean addValueWrapper)
 807 kumpf          1.56  {
 808 karl           1.173     if (addValueWrapper)
 809                          {
 810                               out << STRLIT("<VALUE.REFERENCE>\n");
 811                          }
 812                          if (isClassPath)
 813 kumpf          1.56      {
 814 karl           1.173         appendValueClassPathElement(out,reference);
 815 kumpf          1.56      }
 816                          else
 817                          {
 818 karl           1.173         appendValueInstancePathElement(out,reference);
 819 kumpf          1.56      }
 820                      
 821 karl           1.173     if (addValueWrapper)
 822                          {
 823 mike           1.126         out << STRLIT("</VALUE.REFERENCE>\n");
 824 karl           1.173     }
 825 kumpf          1.56  }
 826                      
 827                      void XmlWriter::printValueReferenceElement(
 828 kumpf          1.59      const CIMObjectPath& reference,
 829 karl           1.173     Boolean isClassPath,
 830 kumpf          1.56      PEGASUS_STD(ostream)& os)
 831                      {
 832 mike           1.125     Buffer tmp;
 833 karl           1.173     appendValueReferenceElement(tmp, reference, isClassPath, true);
 834 kumpf          1.56      indentedPrint(os, tmp.getData());
 835                      }
 836                      
 837                      //------------------------------------------------------------------------------
 838                      //
 839                      // appendValueNamedInstanceElement()
 840                      //
 841                      //     <!ELEMENT VALUE.NAMEDINSTANCE (INSTANCENAME,INSTANCE)>
 842                      //
 843                      //------------------------------------------------------------------------------
 844                      
 845                      void XmlWriter::appendValueNamedInstanceElement(
 846 mike           1.125     Buffer& out,
 847 anusha.kandepu 1.170     const CIMInstance& namedInstance,
 848                          Boolean includeQualifiers,
 849                          Boolean includeClassOrigin,
 850                          const CIMPropertyList& propertyList)
 851 kumpf          1.56  {
 852 mike           1.126     out << STRLIT("<VALUE.NAMEDINSTANCE>\n");
 853 kumpf          1.56  
 854 kumpf          1.61      appendInstanceNameElement(out, namedInstance.getPath ());
 855 anusha.kandepu 1.170     appendInstanceElement(
 856                              out,
 857                              namedInstance,
 858                              includeQualifiers,
 859                              includeClassOrigin,
 860                              propertyList);
 861 kumpf          1.56  
 862 mike           1.126     out << STRLIT("</VALUE.NAMEDINSTANCE>\n");
 863 kumpf          1.56  }
 864                      
 865                      //------------------------------------------------------------------------------
 866                      //
 867 kumpf          1.55  // appendClassElement()
 868                      //
 869                      //     <!ELEMENT CLASS
 870                      //         (QUALIFIER*,(PROPERTY|PROPERTY.ARRAY|PROPERTY.REFERENCE)*,METHOD*)>
 871 kumpf          1.56  //     <!ATTLIST CLASS
 872 kumpf          1.55  //         %CIMName;
 873                      //         %SuperClass;>
 874                      //
 875                      //------------------------------------------------------------------------------
 876                      
 877                      void XmlWriter::appendClassElement(
 878 mike           1.125     Buffer& out,
 879 kumpf          1.156     const CIMConstClass& cimClass)
 880 kumpf          1.55  {
 881 kumpf          1.156     CheckRep(cimClass._rep);
 882                          const CIMClassRep* rep = cimClass._rep;
 883                      
 884                          // Class opening element:
 885                      
 886                          out << STRLIT("<CLASS NAME=\"")
 887                              << rep->getClassName()
 888                              << STRLIT("\" ");
 889                      
 890                          if (!rep->getSuperClassName().isNull())
 891                          {
 892                              out << STRLIT(" SUPERCLASS=\"")
 893                                  << rep->getSuperClassName()
 894                                  << STRLIT("\" ");
 895                          }
 896                      
 897                          out << STRLIT(">\n");
 898                      
 899                          // Append Class Qualifiers:
 900                      
 901                          for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
 902 kumpf          1.156         XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
 903                      
 904                          // Append Property definitions:
 905                      
 906                          for (Uint32 i = 0, n = rep->getPropertyCount(); i < n; i++)
 907                              XmlWriter::appendPropertyElement(out, rep->getProperty(i));
 908                      
 909                          // Append Method definitions:
 910                      
 911                          for (Uint32 i = 0, n = rep->getMethodCount(); i < n; i++)
 912                              XmlWriter::appendMethodElement(out, rep->getMethod(i));
 913                      
 914                          // Class closing element:
 915                      
 916                          out << STRLIT("</CLASS>\n");
 917 kumpf          1.55  }
 918                      
 919                      void XmlWriter::printClassElement(
 920                          const CIMConstClass& cimclass,
 921                          PEGASUS_STD(ostream)& os)
 922                      {
 923 mike           1.125     Buffer tmp;
 924 kumpf          1.55      appendClassElement(tmp, cimclass);
 925                          indentedPrint(os, tmp.getData(), 4);
 926                      }
 927                      
 928                      //------------------------------------------------------------------------------
 929                      //
 930                      // appendInstanceElement()
 931                      //
 932                      //     <!ELEMENT INSTANCE
 933                      //         (QUALIFIER*,(PROPERTY|PROPERTY.ARRAY|PROPERTY.REFERENCE)*)>
 934                      //     <!ATTLIST INSTANCE
 935                      //         %ClassName;>
 936                      //
 937                      //------------------------------------------------------------------------------
 938                      
 939                      void XmlWriter::appendInstanceElement(
 940 mike           1.125     Buffer& out,
 941 anusha.kandepu 1.170     const CIMConstInstance& instance,
 942                          Boolean includeQualifiers,
 943                          Boolean includeClassOrigin,
 944                          const CIMPropertyList& propertyList)
 945 kumpf          1.55  {
 946 marek          1.152     CheckRep(instance._rep);
 947 kumpf          1.156     const CIMInstanceRep* rep = instance._rep;
 948                      
 949                          // Class opening element:
 950                      
 951                          out << STRLIT("<INSTANCE CLASSNAME=\"")
 952                              << rep->getClassName()
 953                              << STRLIT("\" >\n");
 954                      
 955                          // Append Instance Qualifiers:
 956 anusha.kandepu 1.170     if(includeQualifiers)
 957                          {
 958                              for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
 959                                  XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
 960                          }
 961                          if(propertyList.isNull())
 962 karl           1.173     {
 963 anusha.kandepu 1.170         for (Uint32 i = 0, n = rep->getPropertyCount(); i < n; i++)
 964                              {
 965                                  XmlWriter::appendPropertyElement(
 966                                      out,
 967                                      rep->getProperty(i),
 968                                      includeQualifiers,includeClassOrigin);
 969                              }
 970                          }
 971                          else
 972                          {
 973                              for (Uint32 i = 0, n = propertyList.size(); i < n; i++)
 974                              {
 975                                  CIMName name = propertyList[i];
 976                                  Uint32 pos = rep->_properties.find(
 977                                      propertyList[i],
 978                                      propertyList.getCIMNameTag(i));
 979                                  if(pos != PEG_NOT_FOUND)
 980                                  {
 981                                      PEG_TRACE((TRC_XML,Tracer::LEVEL4,
 982                                          "XmlWriter::appendInstanceElement"
 983                                              " Filtering the property name:%s for the className:%s"
 984 anusha.kandepu 1.170                     "since it was not filtered by the provider.",
 985                                          (const char *)name.getString().getCString(),
 986                                          (const char *)instance.getClassName().
 987                                              getString().getCString()));
 988                      
 989                                      XmlWriter::appendPropertyElement(
 990                                          out,
 991                                          rep->getProperty(pos),
 992                                          includeQualifiers,includeClassOrigin);
 993                                  }
 994                              }
 995 kumpf          1.156 
 996 anusha.kandepu 1.170     }
 997 kumpf          1.156 
 998                          // Instance closing element:
 999                      
1000                          out << STRLIT("</INSTANCE>\n");
1001 kumpf          1.55  }
1002                      
1003                      void XmlWriter::printInstanceElement(
1004                          const CIMConstInstance& instance,
1005                          PEGASUS_STD(ostream)& os)
1006                      {
1007 mike           1.125     Buffer tmp;
1008 kumpf          1.55      appendInstanceElement(tmp, instance);
1009                          os << tmp.getData() << PEGASUS_STD(endl);
1010                      }
1011                      
1012                      //------------------------------------------------------------------------------
1013                      //
1014 kumpf          1.56  // appendObjectElement()
1015                      //
1016                      // May refer to a CLASS or an INSTANCE
1017                      //
1018                      //------------------------------------------------------------------------------
1019                      
1020                      void XmlWriter::appendObjectElement(
1021 mike           1.125     Buffer& out,
1022 anusha.kandepu 1.170     const CIMConstObject& object,
1023                          Boolean includeQualifiers,
1024                          Boolean includeClassOrigin,
1025                          const CIMPropertyList& propertyList)
1026 kumpf          1.56  {
1027 kumpf          1.73      if (object.isClass())
1028 kumpf          1.56      {
1029                              CIMConstClass c(object);
1030                              appendClassElement(out, c);
1031                          }
1032 kumpf          1.73      else if (object.isInstance())
1033 kumpf          1.56      {
1034 kumpf          1.73          CIMConstInstance i(object);
1035 anusha.kandepu 1.170         appendInstanceElement(
1036                                  out,
1037                                  i,
1038                                  includeQualifiers,
1039                                  includeClassOrigin,
1040                                  propertyList);
1041 kumpf          1.56      }
1042 kumpf          1.73      // else PEGASUS_ASSERT(0);
1043 kumpf          1.56  }
1044                      
1045                      //------------------------------------------------------------------------------
1046                      //
1047                      // appendPropertyElement()
1048                      //
1049                      //     <!ELEMENT PROPERTY (QUALIFIER*,VALUE?)>
1050                      //     <!ATTLIST PROPERTY
1051                      //              %CIMName;
1052                      //              %CIMType;           #REQUIRED
1053                      //              %ClassOrigin;
1054                      //              %Propagated;>
1055                      //
1056                      //     <!ELEMENT PROPERTY.ARRAY (QUALIFIER*,VALUE.ARRAY?)>
1057                      //     <!ATTLIST PROPERTY.ARRAY
1058                      //              %CIMName;
1059                      //              %CIMType;           #REQUIRED
1060                      //              %ArraySize;
1061                      //              %ClassOrigin;
1062                      //              %Propagated;>
1063                      //
1064 kumpf          1.56  //     <!ELEMENT PROPERTY.REFERENCE (QUALIFIER*,VALUE.REFERENCE?)>
1065                      //     <!ATTLIST PROPERTY.REFERENCE
1066                      //              %CIMName;
1067                      //              %ReferenceClass;
1068                      //              %ClassOrigin;
1069                      //              %Propagated;>
1070                      //
1071                      //------------------------------------------------------------------------------
1072                      
1073                      void XmlWriter::appendPropertyElement(
1074 mike           1.125     Buffer& out,
1075 anusha.kandepu 1.170     const CIMConstProperty& property,
1076                          Boolean includeQualifiers,
1077                          Boolean includeClassOrigin)
1078 kumpf          1.56  {
1079 marek          1.152     CheckRep(property._rep);
1080 kumpf          1.156     const CIMPropertyRep* rep = property._rep;
1081                      
1082                          if (rep->getValue().isArray())
1083                          {
1084                              out << STRLIT("<PROPERTY.ARRAY NAME=\"")
1085                                  << rep->getName()
1086                                  << STRLIT("\" ");
1087                      
1088                              if (rep->getValue().getType() == CIMTYPE_OBJECT)
1089                              {
1090                                  // If the property array type is CIMObject, then
1091                                  //     encode the property in CIM-XML as a string array with the
1092                                  //     EmbeddedObject attribute (there is not currently a CIM-XML
1093                                  //     "object" datatype)
1094                      
1095                                  Array<CIMObject> a;
1096                                  rep->getValue().get(a);
1097                                  out << STRLIT(" TYPE=\"string\"");
1098                                  // If the Embedded Object is an instance, always add the
1099                                  // EmbeddedObject attribute.
1100                                  if (a.size() > 0 && a[0].isInstance())
1101 kumpf          1.156             {
1102 kumpf          1.167                 out << STRLIT(" EmbeddedObject=\"object\""
1103 thilo.boehm    1.162                               " EMBEDDEDOBJECT=\"object\"");
1104 kumpf          1.156             }
1105                      #ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY
1106                                  else
1107                      #endif
1108                                  {
1109                                      // Else the Embedded Object is a class, always add the
1110                                      // EmbeddedObject qualifier.  Note that if the macro
1111                                      // PEGASUS_SNIA_INTEROP_COMPATIBILITY is defined, then
1112                                      // the EmbeddedObject qualifier will always be added,
1113                                      // whether it's a class or an instance.
1114 thilo.boehm    1.159                 if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT) ==
1115 kumpf          1.156                         PEG_NOT_FOUND)
1116                                      {
1117                                          // Note that addQualifiers() cannot be called on a const
1118                                          // CIMQualifierRep.  In this case we really do want to add
1119                                          // the EmbeddedObject qualifier, so we cast away the
1120                                          // constness.
1121                                          CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);
1122                                          tmpRep->addQualifier(
1123 kumpf          1.167                         CIMQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT,
1124 thilo.boehm    1.159                                      true));
1125 kumpf          1.156                 }
1126                                  }
1127                              }
1128                              else if (rep->getValue().getType() == CIMTYPE_INSTANCE)
1129                              {
1130                                  // If the property array type is CIMInstance, then
1131                                  //   encode the property in CIM-XML as a string array with the
1132                                  //   EmbeddedObject attribute (there is not currently a CIM-XML
1133                                  //   "instance" datatype)
1134                      
1135                                  Array<CIMInstance> a;
1136                                  rep->getValue().get(a);
1137                                  out << STRLIT(" TYPE=\"string\"");
1138                      
1139                                  // add the EmbeddedObject attribute
1140                                  if (a.size() > 0)
1141                                  {
1142 kumpf          1.167                 out << STRLIT(" EmbeddedObject=\"instance\""
1143 thilo.boehm    1.162                               " EMBEDDEDOBJECT=\"instance\"");
1144 kumpf          1.156 
1145                                      // Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY is
1146                                      // defined, then the EmbeddedInstance qualifier will be added
1147                      # ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY
1148 karl           1.173                 if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE)
1149 dev.meetei     1.172                         == PEG_NOT_FOUND)
1150 kumpf          1.156                 {
1151                                          // Note that addQualifiers() cannot be called on a const
1152                                          // CIMQualifierRep.  In this case we really do want to add
1153                                          // the EmbeddedInstance qualifier, so we cast away the
1154                                          // constness.
1155                      
1156                                          // For now, we assume that all the embedded instances in
1157                                          // the array are of the same type
1158                                          CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);
1159                                          tmpRep->addQualifier(CIMQualifier(
1160 thilo.boehm    1.159                         PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE,
1161 kumpf          1.156                         a[0].getClassName().getString()));
1162                                      }
1163                      # endif
1164                                  }
1165                              }
1166                              else
1167                              {
1168 thilo.boehm    1.162             out.append(' ');
1169 thilo.boehm    1.169             out << xmlWriterTypeStrings(rep->getValue().getType());
1170 kumpf          1.156         }
1171                      
1172                              if (rep->getArraySize())
1173                              {
1174                                  char buffer[32];
1175 kumpf          1.158             sprintf(buffer, "%u", rep->getArraySize());
1176 kumpf          1.156             out << STRLIT(" ARRAYSIZE=\"") << buffer;
1177                                  out.append('"');
1178                              }
1179                      
1180 anusha.kandepu 1.170         if(includeClassOrigin && !rep->getClassOrigin().isNull())
1181 kumpf          1.156         {
1182                                  out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin();
1183                                  out.append('"');
1184                              }
1185                      
1186                              if (rep->getPropagated())
1187                              {
1188                                  out << STRLIT(" PROPAGATED=\"true\"");
1189                              }
1190                      
1191                              out << STRLIT(">\n");
1192 anusha.kandepu 1.170         if(includeQualifiers)
1193                              {
1194                                  for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
1195                                      XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
1196                              }
1197 kumpf          1.156 
1198                              XmlWriter::appendValueElement(out, rep->getValue());
1199                      
1200                              out << STRLIT("</PROPERTY.ARRAY>\n");
1201                          }
1202                          else if (rep->getValue().getType() == CIMTYPE_REFERENCE)
1203                          {
1204 kumpf          1.167         out << STRLIT("<PROPERTY.REFERENCE"
1205 thilo.boehm    1.162                       " NAME=\"") << rep->getName() << STRLIT("\" ");
1206 kumpf          1.156 
1207                              if (!rep->getReferenceClassName().isNull())
1208                              {
1209                                  out << STRLIT(" REFERENCECLASS=\"") << rep->getReferenceClassName();
1210                                  out.append('"');
1211                              }
1212 anusha.kandepu 1.170         if(includeClassOrigin && !rep->getClassOrigin().isNull())
1213 kumpf          1.156         {
1214                                  out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin();
1215                                  out.append('"');
1216                              }
1217                      
1218                              if (rep->getPropagated())
1219                              {
1220                                  out << STRLIT(" PROPAGATED=\"true\"");
1221                              }
1222                      
1223                              out << STRLIT(">\n");
1224 anusha.kandepu 1.170         if(includeQualifiers)
1225 karl           1.173         {
1226 anusha.kandepu 1.170             for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
1227                                      XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
1228                              }
1229 kumpf          1.156 
1230                              XmlWriter::appendValueElement(out, rep->getValue());
1231                      
1232                              out << STRLIT("</PROPERTY.REFERENCE>\n");
1233                          }
1234                          else
1235                          {
1236                              out << STRLIT("<PROPERTY NAME=\"") << rep->getName() << STRLIT("\" ");
1237 anusha.kandepu 1.170         if(includeClassOrigin && !rep->getClassOrigin().isNull())
1238 kumpf          1.156         {
1239                                  out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin();
1240                                  out.append('"');
1241                              }
1242                      
1243                              if (rep->getPropagated())
1244                              {
1245                                  out << STRLIT(" PROPAGATED=\"true\"");
1246                              }
1247                      
1248                              if (rep->getValue().getType() == CIMTYPE_OBJECT)
1249                              {
1250                                  // If the property type is CIMObject, then
1251                                  //   encode the property in CIM-XML as a string with the
1252                                  //   EmbeddedObject attribute (there is not currently a CIM-XML
1253                                  //   "object" datatype)
1254                      
1255                                  CIMObject a;
1256                                  rep->getValue().get(a);
1257                                  out << STRLIT(" TYPE=\"string\"");
1258                      
1259 kumpf          1.156             // If the Embedded Object is an instance, always add the
1260                                  // EmbeddedObject attribute.
1261                                  if (a.isInstance())
1262                                  {
1263 kumpf          1.167                 out << STRLIT(" EmbeddedObject=\"object\""
1264 thilo.boehm    1.162                               " EMBEDDEDOBJECT=\"object\"");
1265 kumpf          1.156             }
1266                                  // Else the Embedded Object is a class, always add the
1267                                  // EmbeddedObject qualifier.
1268                      #ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY
1269                                  else
1270                      #endif
1271                                  {
1272                                      // Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY
1273                                      // is defined, then the EmbeddedObject qualifier will always
1274                                      // be added, whether it's a class or an instance.
1275 thilo.boehm    1.159                 if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT) ==
1276 kumpf          1.156                         PEG_NOT_FOUND)
1277                                      {
1278                                          // Note that addQualifiers() cannot be called on a const
1279                                          // CIMQualifierRep.  In this case we really do want to add
1280                                          // the EmbeddedObject qualifier, so we cast away the
1281                                          // constness.
1282                                          CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);
1283                                          tmpRep->addQualifier(
1284 kumpf          1.167                         CIMQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT,
1285 thilo.boehm    1.159                                      true));
1286 kumpf          1.156                 }
1287                                  }
1288                              }
1289                              else if (rep->getValue().getType() == CIMTYPE_INSTANCE)
1290                              {
1291                                  CIMInstance a;
1292                                  rep->getValue().get(a);
1293 kumpf          1.167             out << STRLIT(" TYPE=\"string\""
1294                                                " EmbeddedObject=\"instance\""
1295 thilo.boehm    1.162                           " EMBEDDEDOBJECT=\"instance\"");
1296 kumpf          1.156 
1297                      # ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY
1298 kumpf          1.167             if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT)
1299 thilo.boehm    1.159                 == PEG_NOT_FOUND)
1300 kumpf          1.156             {
1301                                      // Note that addQualifiers() cannot be called on a const
1302                                      // CIMQualifierRep.  In this case we really do want to add
1303                                      // the EmbeddedInstance qualifier, so we cast away the
1304                                      // constness.
1305                                      CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);
1306                                      tmpRep->addQualifier(CIMQualifier(
1307 thilo.boehm    1.159                     PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE,
1308 kumpf          1.156                     a.getClassName().getString()));
1309                                  }
1310                      # endif
1311                              }
1312                              else
1313                              {
1314 thilo.boehm    1.162             out.append(' ');
1315 thilo.boehm    1.169             out << xmlWriterTypeStrings(rep->getValue().getType());
1316 kumpf          1.156         }
1317                      
1318                              out << STRLIT(">\n");
1319 anusha.kandepu 1.170         if(includeQualifiers)
1320                              {
1321                                  for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
1322                                      XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
1323                              }
1324 kumpf          1.156 
1325                              XmlWriter::appendValueElement(out, rep->getValue());
1326                      
1327                              out << STRLIT("</PROPERTY>\n");
1328                          }
1329 kumpf          1.56  }
1330                      
1331                      void XmlWriter::printPropertyElement(
1332                          const CIMConstProperty& property,
1333                          PEGASUS_STD(ostream)& os)
1334                      {
1335 mike           1.125     Buffer tmp;
1336 kumpf          1.56      appendPropertyElement(tmp, property);
1337                          os << tmp.getData() << PEGASUS_STD(endl);
1338                      }
1339                      
1340                      //------------------------------------------------------------------------------
1341                      //
1342                      // appendMethodElement()
1343                      //
1344                      //     <!ELEMENT METHOD (QUALIFIER*,
1345                      //         (PARAMETER|PARAMETER.REFERENCE|PARAMETER.ARRAY|PARAMETER.REFARRAY)*)>
1346                      //     <!ATTLIST METHOD
1347                      //              %CIMName;
1348                      //              %CIMType;          #IMPLIED
1349                      //              %ClassOrigin;
1350                      //              %Propagated;>
1351                      //
1352                      //------------------------------------------------------------------------------
1353                      
1354                      void XmlWriter::appendMethodElement(
1355 mike           1.125     Buffer& out,
1356 kumpf          1.56      const CIMConstMethod& method)
1357                      {
1358 marek          1.152     CheckRep(method._rep);
1359 kumpf          1.156     const CIMMethodRep* rep = method._rep;
1360                      
1361                          out << STRLIT("<METHOD NAME=\"") << rep->getName();
1362 thilo.boehm    1.162     out << STRLIT("\" ");
1363 kumpf          1.156 
1364 thilo.boehm    1.169     out << xmlWriterTypeStrings(rep->getType());
1365 kumpf          1.156 
1366                          if (!rep->getClassOrigin().isNull())
1367                          {
1368                              out << STRLIT(" CLASSORIGIN=\"") << rep->getClassOrigin();
1369                              out.append('"');
1370                          }
1371                      
1372                          if (rep->getPropagated())
1373                          {
1374                              out << STRLIT(" PROPAGATED=\"true\"");
1375                          }
1376                      
1377                          out << STRLIT(">\n");
1378                      
1379                          for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
1380                              XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
1381                      
1382                          for (Uint32 i = 0, n = rep->getParameterCount(); i < n; i++)
1383                              XmlWriter::appendParameterElement(out, rep->getParameter(i));
1384                      
1385                          out << STRLIT("</METHOD>\n");
1386 kumpf          1.56  }
1387                      
1388                      void XmlWriter::printMethodElement(
1389                          const CIMConstMethod& method,
1390                          PEGASUS_STD(ostream)& os)
1391                      {
1392 mike           1.125     Buffer tmp;
1393 kumpf          1.56      appendMethodElement(tmp, method);
1394                          os << tmp.getData() << PEGASUS_STD(endl);
1395                      }
1396                      
1397                      //------------------------------------------------------------------------------
1398                      //
1399                      // appendParameterElement()
1400                      //
1401                      //     <!ELEMENT PARAMETER (QUALIFIER*)>
1402                      //     <!ATTLIST PARAMETER
1403                      //              %CIMName;
1404                      //              %CIMType;      #REQUIRED>
1405                      //
1406                      //     <!ELEMENT PARAMETER.REFERENCE (QUALIFIER*)>
1407                      //     <!ATTLIST PARAMETER.REFERENCE
1408                      //              %CIMName;
1409                      //              %ReferenceClass;>
1410                      //
1411                      //     <!ELEMENT PARAMETER.ARRAY (QUALIFIER*)>
1412                      //     <!ATTLIST PARAMETER.ARRAY
1413                      //              %CIMName;
1414 kumpf          1.56  //              %CIMType;           #REQUIRED
1415                      //              %ArraySize;>
1416                      //
1417                      //     <!ELEMENT PARAMETER.REFARRAY (QUALIFIER*)>
1418                      //     <!ATTLIST PARAMETER.REFARRAY
1419                      //              %CIMName;
1420                      //              %ReferenceClass;
1421                      //              %ArraySize;>
1422                      //
1423                      //------------------------------------------------------------------------------
1424                      
1425                      void XmlWriter::appendParameterElement(
1426 mike           1.125     Buffer& out,
1427 kumpf          1.56      const CIMConstParameter& parameter)
1428                      {
1429 marek          1.152     CheckRep(parameter._rep);
1430 kumpf          1.156     const CIMParameterRep* rep = parameter._rep;
1431                      
1432                          if (rep->isArray())
1433                          {
1434                              if (rep->getType() == CIMTYPE_REFERENCE)
1435                              {
1436                                  out << STRLIT("<PARAMETER.REFARRAY NAME=\"") << rep->getName();
1437                                  out.append('"');
1438                      
1439                                  if (!rep->getReferenceClassName().isNull())
1440                                  {
1441                                      out << STRLIT(" REFERENCECLASS=\"");
1442                                      out << rep->getReferenceClassName().getString();
1443                                      out.append('"');
1444                                  }
1445                      
1446                                  if (rep->getArraySize())
1447                                  {
1448                                      char buffer[32];
1449 kumpf          1.158                 int n = sprintf(buffer, "%u", rep->getArraySize());
1450 kumpf          1.156                 out << STRLIT(" ARRAYSIZE=\"");
1451                                      out.append(buffer, n);
1452                                      out.append('"');
1453                                  }
1454                      
1455                                  out << STRLIT(">\n");
1456                      
1457                                  for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
1458                                      XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
1459                      
1460                                  out << STRLIT("</PARAMETER.REFARRAY>\n");
1461                              }
1462                              else
1463                              {
1464 kumpf          1.167             out << STRLIT("<PARAMETER.ARRAY"
1465 thilo.boehm    1.162                           " NAME=\"") << rep->getName();
1466 thilo.boehm    1.169             out << STRLIT("\" ") << xmlWriterTypeStrings(rep->getType());
1467 kumpf          1.167 
1468 kumpf          1.156             if (rep->getArraySize())
1469                                  {
1470                                      char buffer[32];
1471 kumpf          1.158                 sprintf(buffer, "%u", rep->getArraySize());
1472 kumpf          1.156                 out << STRLIT(" ARRAYSIZE=\"") << buffer;
1473                                      out.append('"');
1474                                  }
1475                      
1476                                  out << STRLIT(">\n");
1477                      
1478                                  for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
1479                                      XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
1480                      
1481                                  out << STRLIT("</PARAMETER.ARRAY>\n");
1482                              }
1483                          }
1484                          else if (rep->getType() == CIMTYPE_REFERENCE)
1485                          {
1486 kumpf          1.167         out << STRLIT("<PARAMETER.REFERENCE"
1487 thilo.boehm    1.162                       " NAME=\"") << rep->getName();
1488 kumpf          1.156         out.append('"');
1489                      
1490                              if (!rep->getReferenceClassName().isNull())
1491                              {
1492                                  out << STRLIT(" REFERENCECLASS=\"");
1493                                  out << rep->getReferenceClassName().getString();
1494                                  out.append('"');
1495                              }
1496                              out << STRLIT(">\n");
1497                      
1498                              for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
1499                                  XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
1500                      
1501                              out << STRLIT("</PARAMETER.REFERENCE>\n");
1502                          }
1503                          else
1504                          {
1505 kumpf          1.167         out << STRLIT("<PARAMETER"
1506 thilo.boehm    1.162                       " NAME=\"") << rep->getName();
1507 thilo.boehm    1.169         out << STRLIT("\" ") << xmlWriterTypeStrings(rep->getType());
1508 thilo.boehm    1.162 
1509                              out << STRLIT(">\n");
1510 kumpf          1.156 
1511                              for (Uint32 i = 0, n = rep->getQualifierCount(); i < n; i++)
1512                                  XmlWriter::appendQualifierElement(out, rep->getQualifier(i));
1513                      
1514                              out << STRLIT("</PARAMETER>\n");
1515                          }
1516 kumpf          1.56  }
1517                      
1518                      void XmlWriter::printParameterElement(
1519                          const CIMConstParameter& parameter,
1520                          PEGASUS_STD(ostream)& os)
1521                      {
1522 mike           1.125     Buffer tmp;
1523 kumpf          1.56      appendParameterElement(tmp, parameter);
1524                          os << tmp.getData() << PEGASUS_STD(endl);
1525                      }
1526                      
1527                      //------------------------------------------------------------------------------
1528                      //
1529                      // appendParamValueElement()
1530                      //
1531                      //     <!ELEMENT PARAMVALUE (VALUE|VALUE.REFERENCE|VALUE.ARRAY|VALUE.REFARRAY)?>
1532                      //     <!ATTLIST PARAMVALUE
1533 kumpf          1.156 //         %CIMName;
1534                      //         %EmbeddedObject; #IMPLIED
1535                      //         %ParamType;>
1536 kumpf          1.56  //
1537                      //------------------------------------------------------------------------------
1538                      
1539                      void XmlWriter::appendParamValueElement(
1540 mike           1.125     Buffer& out,
1541 kumpf          1.56      const CIMParamValue& paramValue)
1542                      {
1543 marek          1.152     CheckRep(paramValue._rep);
1544 kumpf          1.156     const CIMParamValueRep* rep = paramValue._rep;
1545                      
1546                          out << STRLIT("<PARAMVALUE NAME=\"") << rep->getParameterName();
1547                          out.append('"');
1548                      
1549                          CIMType type = rep->getValue().getType();
1550                      
1551                          if (rep->isTyped())
1552                          {
1553                              XmlWriter::appendParamTypeAndEmbeddedObjAttrib(out, type);
1554                          }
1555                      
1556                          out << STRLIT(">\n");
1557                          XmlWriter::appendValueElement(out, rep->getValue());
1558                      
1559                          out << STRLIT("</PARAMVALUE>\n");
1560 kumpf          1.56  }
1561                      
1562                      void XmlWriter::printParamValueElement(
1563                          const CIMParamValue& paramValue,
1564                          PEGASUS_STD(ostream)& os)
1565                      {
1566 mike           1.125     Buffer tmp;
1567 kumpf          1.56      appendParamValueElement(tmp, paramValue);
1568                          os << tmp.getData() << PEGASUS_STD(endl);
1569                      }
1570                      
1571                      //------------------------------------------------------------------------------
1572                      //
1573                      // appendQualifierElement()
1574                      //
1575                      //     <!ELEMENT QUALIFIER (VALUE|VALUE.ARRAY)>
1576                      //     <!ATTLIST QUALIFIER
1577                      //              %CIMName;
1578                      //              %CIMType;               #REQUIRED
1579                      //              %Propagated;
1580                      //              %QualifierFlavor;>
1581                      //
1582                      //------------------------------------------------------------------------------
1583                      
1584                      void XmlWriter::appendQualifierElement(
1585 mike           1.125     Buffer& out,
1586 kumpf          1.56      const CIMConstQualifier& qualifier)
1587                      {
1588 marek          1.152     CheckRep(qualifier._rep);
1589 kumpf          1.156     const CIMQualifierRep* rep = qualifier._rep;
1590                      
1591                          out << STRLIT("<QUALIFIER NAME=\"") << rep->getName();
1592 thilo.boehm    1.169     out << STRLIT("\" ") << xmlWriterTypeStrings(rep->getValue().getType());
1593 kumpf          1.156 
1594                          if (rep->getPropagated())
1595                          {
1596                              out << STRLIT(" PROPAGATED=\"true\"");
1597                          }
1598                      
1599                          XmlWriter::appendQualifierFlavorEntity(out, rep->getFlavor());
1600                      
1601                          out << STRLIT(">\n");
1602                      
1603                          XmlWriter::appendValueElement(out, rep->getValue());
1604                      
1605                          out << STRLIT("</QUALIFIER>\n");
1606 kumpf          1.56  }
1607                      
1608                      void XmlWriter::printQualifierElement(
1609                          const CIMConstQualifier& qualifier,
1610                          PEGASUS_STD(ostream)& os)
1611                      {
1612 mike           1.125     Buffer tmp;
1613 kumpf          1.56      appendQualifierElement(tmp, qualifier);
1614                          os << tmp.getData() << PEGASUS_STD(endl);
1615                      }
1616                      
1617                      //------------------------------------------------------------------------------
1618                      //
1619                      // appendQualifierDeclElement()
1620                      //
1621                      //     <!ELEMENT QUALIFIER.DECLARATION (SCOPE?,(VALUE|VALUE.ARRAY)?)>
1622                      //     <!ATTLIST QUALIFIER.DECLARATION
1623                      //              %CIMName;
1624                      //              %CIMType;                       #REQUIRED
1625                      //              ISARRAY        (true|false)     #IMPLIED
1626                      //              %ArraySize;
1627                      //              %QualifierFlavor;>
1628                      //
1629                      //------------------------------------------------------------------------------
1630                      
1631                      void XmlWriter::appendQualifierDeclElement(
1632 mike           1.125     Buffer& out,
1633 kumpf          1.56      const CIMConstQualifierDecl& qualifierDecl)
1634                      {
1635 marek          1.152     CheckRep(qualifierDecl._rep);
1636 kumpf          1.156     const CIMQualifierDeclRep* rep = qualifierDecl._rep;
1637                      
1638                          out << STRLIT("<QUALIFIER.DECLARATION NAME=\"") << rep->getName();
1639 thilo.boehm    1.169     out << STRLIT("\" ") << xmlWriterTypeStrings(rep->getValue().getType());
1640 kumpf          1.156 
1641                          if (rep->getValue().isArray())
1642                          {
1643                              out << STRLIT(" ISARRAY=\"true\"");
1644                      
1645                              if (rep->getArraySize())
1646                              {
1647                                  char buffer[64];
1648 kumpf          1.158             int n = sprintf(buffer, " ARRAYSIZE=\"%u\"", rep->getArraySize());
1649 kumpf          1.156             out.append(buffer, n);
1650                              }
1651                          }
1652                      
1653                          XmlWriter::appendQualifierFlavorEntity(out, rep->getFlavor());
1654                      
1655                          out << STRLIT(">\n");
1656                      
1657                          XmlWriter::appendScopeElement(out, rep->getScope());
1658                          XmlWriter::appendValueElement(out, rep->getValue());
1659                      
1660                          out << STRLIT("</QUALIFIER.DECLARATION>\n");
1661 kumpf          1.56  }
1662                      
1663                      void XmlWriter::printQualifierDeclElement(
1664                          const CIMConstQualifierDecl& qualifierDecl,
1665                          PEGASUS_STD(ostream)& os)
1666                      {
1667 mike           1.125     Buffer tmp;
1668 kumpf          1.56      appendQualifierDeclElement(tmp, qualifierDecl);
1669                          os << tmp.getData() << PEGASUS_STD(endl);
1670                      }
1671                      
1672                      //------------------------------------------------------------------------------
1673                      //
1674 kumpf          1.57  // appendQualifierFlavorEntity()
1675                      //
1676                      //     <!ENTITY % QualifierFlavor "OVERRIDABLE  (true|false)   'true'
1677                      //                                 TOSUBCLASS   (true|false)   'true'
1678                      //                                 TOINSTANCE   (true|false)   'false'
1679                      //                                 TRANSLATABLE (true|false)   'false'">
1680                      //
1681 kumpf          1.168 //     DEPRECATION NOTE:  The attribute TOINSTANCE is DEPRECATED and MAY be
1682                      //     removed from the QualifierFlavor entity in a future version of this
1683                      //     document.  Use of this qualifier is discouraged.
1684                      //
1685 kumpf          1.57  //------------------------------------------------------------------------------
1686                      
1687                      void XmlWriter::appendQualifierFlavorEntity(
1688 mike           1.125     Buffer& out,
1689 kumpf          1.70      const CIMFlavor & flavor)
1690 kumpf          1.57  {
1691 kumpf          1.70      if (!(flavor.hasFlavor (CIMFlavor::OVERRIDABLE)))
1692 mike           1.126         out << STRLIT(" OVERRIDABLE=\"false\"");
1693 kumpf          1.57  
1694 kumpf          1.70      if (!(flavor.hasFlavor (CIMFlavor::TOSUBCLASS)))
1695 mike           1.126         out << STRLIT(" TOSUBCLASS=\"false\"");
1696 kumpf          1.57  
1697 kumpf          1.168     //if (flavor.hasFlavor (CIMFlavor::TOINSTANCE))
1698                          //    out << STRLIT(" TOINSTANCE=\"true\"");
1699 kumpf          1.57  
1700 kumpf          1.70      if (flavor.hasFlavor (CIMFlavor::TRANSLATABLE))
1701 mike           1.126         out << STRLIT(" TRANSLATABLE=\"true\"");
1702 kumpf          1.57  }
1703                      
1704                      //------------------------------------------------------------------------------
1705                      //
1706 kumpf          1.58  // appendScopeElement()
1707                      //
1708                      //     <!ELEMENT SCOPE EMPTY>
1709                      //     <!ATTLIST SCOPE
1710                      //              CLASS        (true|false)      'false'
1711                      //              ASSOCIATION  (true|false)      'false'
1712                      //              REFERENCE    (true|false)      'false'
1713                      //              PROPERTY     (true|false)      'false'
1714                      //              METHOD       (true|false)      'false'
1715                      //              PARAMETER    (true|false)      'false'
1716                      //              INDICATION   (true|false)      'false'>
1717                      //
1718                      //------------------------------------------------------------------------------
1719                      
1720                      void XmlWriter::appendScopeElement(
1721 mike           1.125     Buffer& out,
1722 kumpf          1.69      const CIMScope & scope)
1723 kumpf          1.58  {
1724 kumpf          1.69      if (!(scope.equal (CIMScope ())))
1725 kumpf          1.58      {
1726 mike           1.126         out << STRLIT("<SCOPE");
1727 kumpf          1.58  
1728 kumpf          1.69          if (scope.hasScope (CIMScope::CLASS))
1729 mike           1.126             out << STRLIT(" CLASS=\"true\"");
1730 kumpf          1.58  
1731 kumpf          1.69          if (scope.hasScope (CIMScope::ASSOCIATION))
1732 mike           1.126             out << STRLIT(" ASSOCIATION=\"true\"");
1733 kumpf          1.58  
1734 kumpf          1.69          if (scope.hasScope (CIMScope::REFERENCE))
1735 mike           1.126             out << STRLIT(" REFERENCE=\"true\"");
1736 kumpf          1.58  
1737 kumpf          1.69          if (scope.hasScope (CIMScope::PROPERTY))
1738 mike           1.126             out << STRLIT(" PROPERTY=\"true\"");
1739 kumpf          1.58  
1740 kumpf          1.69          if (scope.hasScope (CIMScope::METHOD))
1741 mike           1.126             out << STRLIT(" METHOD=\"true\"");
1742 kumpf          1.58  
1743 kumpf          1.69          if (scope.hasScope (CIMScope::PARAMETER))
1744 mike           1.126             out << STRLIT(" PARAMETER=\"true\"");
1745 kumpf          1.58  
1746 kumpf          1.69          if (scope.hasScope (CIMScope::INDICATION))
1747 mike           1.126             out << STRLIT(" INDICATION=\"true\"");
1748 kumpf          1.58  
1749 mike           1.126         out << STRLIT("/>");
1750 kumpf          1.58      }
1751                      }
1752                      
1753 david.dillard  1.121 // l10n - added content language and accept language support to
1754 chuck          1.89  // the header methods below
1755                      
1756 kumpf          1.58  //------------------------------------------------------------------------------
1757                      //
1758 kumpf          1.27  // appendMethodCallHeader()
1759 mike           1.23  //
1760 kumpf          1.31  //     Build HTTP method call request header.
1761 mike           1.23  //
1762                      //------------------------------------------------------------------------------
1763                      
1764 kumpf          1.27  void XmlWriter::appendMethodCallHeader(
1765 mike           1.125     Buffer& out,
1766 mike           1.23      const char* host,
1767 kumpf          1.80      const CIMName& cimMethod,
1768 mike           1.23      const String& cimObject,
1769 mike           1.24      const String& authenticationHeader,
1770 kumpf          1.82      HttpMethod httpMethod,
1771 kumpf          1.133     const AcceptLanguageList& acceptLanguages,
1772                          const ContentLanguageList& contentLanguages,
1773 mike           1.164     Uint32 contentLength,
1774                          bool binaryRequest,
1775                          bool binaryResponse)
1776 mike           1.23  {
1777                          char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };
1778                      
1779 karl           1.81      // ATTN: KS 20020926 - Temporary change to issue only POST. This may
1780                          // be changed in the DMTF CIM Operations standard in the future.
1781                          // If we kept M-Post we would have to retry with Post. Does not
1782                          // do that in client today. Permanent change is to retry until spec
1783                          // updated. This change is temp to finish tests or until the retry
1784                          // installed.  Required because of change to wbemservices cimom
1785 kumpf          1.82      if (httpMethod == HTTP_METHOD_M_POST)
1786                          {
1787 mike           1.126         out << STRLIT("M-POST /cimom HTTP/1.1\r\n");
1788 kumpf          1.82      }
1789                          else
1790                          {
1791 mike           1.126         out << STRLIT("POST /cimom HTTP/1.1\r\n");
1792 kumpf          1.82      }
1793 mike           1.164     out << STRLIT("HOST: ") << host << STRLIT("\r\n");
1794                      
1795                          if (binaryRequest)
1796                          {
1797                              // Tell the server that the payload is encoded in the OpenPegasus
1798                              // binary protocol.
1799                              out << STRLIT("Content-Type: application/x-openpegasus\r\n");
1800                          }
1801                          else
1802                          {
1803 marek          1.171         out << STRLIT("Content-Type: application/xml; charset=utf-8\r\n");
1804 mike           1.164     }
1805                      
1806                          if (binaryResponse)
1807                          {
1808                              // Tell the server that this client accepts the OpenPegasus binary
1809                              // protocol.
1810                              out << STRLIT("Accept: application/x-openpegasus\r\n");
1811                          }
1812                      
1813 kumpf          1.157     OUTPUT_CONTENTLENGTH(out, contentLength);
1814 chuck          1.89      if (acceptLanguages.size() > 0)
1815                          {
1816 kumpf          1.146         out << STRLIT("Accept-Language: ") << acceptLanguages << STRLIT("\r\n");
1817 chuck          1.89      }
1818                          if (contentLanguages.size() > 0)
1819                          {
1820 kumpf          1.146         out << STRLIT("Content-Language: ") << contentLanguages <<
1821                                  STRLIT("\r\n");
1822 david.dillard  1.121     }
1823 brian.campbell 1.107 
1824 brian.campbell 1.113 #ifdef PEGASUS_DEBUG
1825 kumpf          1.146     // backdoor environment variable to turn OFF client requesting transfer
1826                          // encoding. The default is on. to turn off, set this variable to zero.
1827                          // This should be removed when stable. This should only be turned off in
1828                          // a debugging/testing environment.
1829 brian.campbell 1.113 
1830 kumpf          1.146     static const char *clientTransferEncodingOff =
1831                              getenv("PEGASUS_HTTP_TRANSFER_ENCODING_REQUEST");
1832 karl           1.142 
1833 kumpf          1.146     if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0')
1834 a.dunfey       1.110 #endif
1835 brian.campbell 1.113 
1836 mike           1.164     if (!binaryResponse)
1837                          {
1838                              // The binary protocol does not allow chunking.
1839                              out << STRLIT("TE: chunked, trailers\r\n");
1840                          }
1841 brian.campbell 1.107 
1842 kumpf          1.82      if (httpMethod == HTTP_METHOD_M_POST)
1843                          {
1844 mike           1.126         out << STRLIT("Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");
1845                              out << nn << STRLIT("\r\n");
1846                              out << nn << STRLIT("-CIMOperation: MethodCall\r\n");
1847                              out << nn << STRLIT("-CIMMethod: ")
1848                                  << encodeURICharacters(cimMethod.getString()) << STRLIT("\r\n");
1849 kumpf          1.167         out << nn << STRLIT("-CIMObject: ")
1850 kumpf          1.157             << encodeURICharacters(cimObject) << STRLIT("\r\n");
1851 kumpf          1.82      }
1852 david.dillard  1.121     else
1853 kumpf          1.82      {
1854 mike           1.126         out << STRLIT("CIMOperation: MethodCall\r\n");
1855 kumpf          1.146         out << STRLIT("CIMMethod: ")
1856 kumpf          1.157             << encodeURICharacters(cimMethod.getString()) << STRLIT("\r\n");
1857 david.dillard  1.130         out << STRLIT("CIMObject: ") << encodeURICharacters(cimObject)
1858 kumpf          1.146             << STRLIT("\r\n");
1859 kumpf          1.82      }
1860                      
1861 mike           1.24      if (authenticationHeader.size())
1862                          {
1863 mike           1.126         out << authenticationHeader << STRLIT("\r\n");
1864 mike           1.24      }
1865 brian.campbell 1.107 
1866 mike           1.126     out << STRLIT("\r\n");
1867 mike           1.23  }
1868                      
1869 chuck          1.89  
1870 kumpf          1.27  void XmlWriter::appendMethodResponseHeader(
1871 mike           1.125      Buffer& out,
1872 w.white        1.108      HttpMethod httpMethod,
1873 kumpf          1.133      const ContentLanguageList& contentLanguages,
1874 w.white        1.108      Uint32 contentLength,
1875 mike           1.164      Uint64 serverResponseTime,
1876                           bool binaryResponse)
1877 brian.campbell 1.113 {
1878 mike           1.164     // Optimize the typical case for binary messages, circumventing the
1879                          // more expensive logic below.
1880 kumpf          1.167     if (binaryResponse &&
1881 mike           1.164         contentLength == 0 &&
1882                              httpMethod != HTTP_METHOD_M_POST &&
1883                              contentLanguages.size() == 0)
1884                          {
1885                              static const char HEADERS[] =
1886                                  "HTTP/1.1 200 OK\r\n"
1887                                  "Content-Type: application/x-openpegasus\r\n"
1888                                  "content-length: 0000000000\r\n"
1889                                  "CIMOperation: MethodResponse\r\n"
1890                                  "\r\n";
1891                      
1892                              // The HTTP processor fills in the content-length value later.
1893                              // It searches for a field matching "content-length" (so the first
1894                              // character must be lower case).
1895                              out.append(HEADERS, sizeof(HEADERS) - 1);
1896                              return;
1897                          }
1898                      
1899 mike           1.126      out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n");
1900 kumpf          1.141 
1901                      #ifndef PEGASUS_DISABLE_PERFINST
1902                           if (StatisticalData::current()->copyGSD)
1903                           {
1904                               out << STRLIT("WBEMServerResponseTime: ") <<
1905                                   CIMValue(serverResponseTime).toString() << STRLIT("\r\n");
1906                           }
1907                      #endif
1908                      
1909 mike           1.164      if (binaryResponse)
1910                           {
1911                              // According to MIME RFC, the "x-" prefix should be used for all
1912                              // non-registered values.
1913                               out << STRLIT("Content-Type: application/x-openpegasus\r\n");
1914                           }
1915                           else
1916                           {
1917 marek          1.171          out << STRLIT("Content-Type: application/xml; charset=utf-8\r\n");
1918 mike           1.164      }
1919                      
1920 kumpf          1.157      OUTPUT_CONTENTLENGTH(out, contentLength);
1921 w.white        1.108 
1922                           if (contentLanguages.size() > 0)
1923                           {
1924 kumpf          1.146          out << STRLIT("Content-Language: ") << contentLanguages <<
1925                                   STRLIT("\r\n");
1926 w.white        1.108      }
1927                           if (httpMethod == HTTP_METHOD_M_POST)
1928                           {
1929 mike           1.164          char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };
1930                      
1931 kumpf          1.167          out << STRLIT("Ext:\r\n"
1932                                             "Cache-Control: no-cache\r\n"
1933 thilo.boehm    1.162                        "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");
1934 mike           1.126          out << nn << STRLIT("\r\n");
1935                               out << nn << STRLIT("-CIMOperation: MethodResponse\r\n\r\n");
1936 w.white        1.108      }
1937                           else
1938                           {
1939 mike           1.126          out << STRLIT("CIMOperation: MethodResponse\r\n\r\n");
1940 w.white        1.108      }
1941 brian.campbell 1.113 }
1942 w.white        1.108 
1943                      
1944 mike           1.23  //------------------------------------------------------------------------------
1945                      //
1946 kumpf          1.40  // appendHttpErrorResponseHeader()
1947                      //
1948                      //     Build HTTP error response header.
1949                      //
1950                      //     Returns error response message in the following format:
1951                      //
1952 kumpf          1.41  //        HTTP/1.1 400 Bad Request       (using specified status code)
1953                      //        CIMError: <error type>         (if specified by caller)
1954                      //        PGErrorDetail: <error text>    (if specified by caller)
1955 kumpf          1.40  //
1956                      //------------------------------------------------------------------------------
1957                      
1958                      void XmlWriter::appendHttpErrorResponseHeader(
1959 mike           1.125     Buffer& out,
1960 kumpf          1.40      const String& status,
1961                          const String& cimError,
1962 kumpf          1.41      const String& errorDetail)
1963 kumpf          1.40  {
1964 mike           1.126     out << STRLIT("HTTP/1.1 ") << status << STRLIT("\r\n");
1965 kumpf          1.40      if (cimError != String::EMPTY)
1966                          {
1967 mike           1.126         out << STRLIT("CIMError: ") << cimError << STRLIT("\r\n");
1968 kumpf          1.40      }
1969 kumpf          1.41      if (errorDetail != String::EMPTY)
1970 kumpf          1.40      {
1971 mike           1.126         out << STRLIT(PEGASUS_HTTPHEADERTAG_ERRORDETAIL ": ")
1972                                  << encodeURICharacters(errorDetail) << STRLIT("\r\n");
1973 kumpf          1.40      }
1974 mike           1.126     out << STRLIT("\r\n");
1975 kumpf          1.40  }
1976                      
1977                      //------------------------------------------------------------------------------
1978                      //
1979 kumpf          1.27  // appendUnauthorizedResponseHeader()
1980                      //
1981                      //     Build HTTP authentication response header for unauthorized requests.
1982                      //
1983                      //     Returns unauthorized message in the following format:
1984                      //
1985                      //        HTTP/1.1 401 Unauthorized
1986 s.kodali       1.161 //        WWW-Authenticate: Basic realm="HostName"
1987 kumpf          1.27  //        <HTML><HEAD>
1988                      //        <TITLE>401 Unauthorized</TITLE>
1989                      //        </HEAD><BODY BGCOLOR="#99cc99">
1990                      //        <H2>TEST401 Unauthorized</H2>
1991                      //        <HR>
1992                      //        </BODY></HTML>
1993                      //
1994                      //------------------------------------------------------------------------------
1995                      
1996                      void XmlWriter::appendUnauthorizedResponseHeader(
1997 mike           1.125     Buffer& out,
1998 kumpf          1.27      const String& content)
1999                      {
2000 mike           1.126     out << STRLIT("HTTP/1.1 " HTTP_STATUS_UNAUTHORIZED "\r\n");
2001 kumpf          1.157     OUTPUT_CONTENTLENGTH(out, 0);
2002 thilo.boehm    1.162     out << content << STRLIT("\r\n\r\n");
2003 kumpf          1.27  
2004                      //ATTN: We may need to include the following line, so that the browsers
2005                      //      can display the error message.
2006                      //    out << "<HTML><HEAD>\r\n";
2007                      //    out << "<TITLE>" << "401 Unauthorized" <<  "</TITLE>\r\n";
2008                      //    out << "</HEAD><BODY BGCOLOR=\"#99cc99\">\r\n";
2009                      //    out << "<H2>TEST" << "401 Unauthorized" << "</H2>\r\n";
2010                      //    out << "<HR>\r\n";
2011                      //    out << "</BODY></HTML>\r\n";
2012                      }
2013                      
2014 gerarda        1.90  #ifdef PEGASUS_KERBEROS_AUTHENTICATION
2015                      //------------------------------------------------------------------------------
2016                      //
2017                      // appendOKResponseHeader()
2018                      //
2019                      //     Build HTTP authentication response header for unauthorized requests.
2020                      //
2021                      //     Returns OK message in the following format:
2022                      //
2023                      //        HTTP/1.1 200 OK
2024 gerarda        1.101 //        Content-Length: 0
2025 gerarda        1.90  //        WWW-Authenticate: Negotiate "token"
2026                      //        <HTML><HEAD>
2027                      //        <TITLE>200 OK</TITLE>
2028                      //        </HEAD><BODY BGCOLOR="#99cc99">
2029                      //        <H2>TEST200 OK</H2>
2030                      //        <HR>
2031                      //        </BODY></HTML>
2032                      //
2033                      //------------------------------------------------------------------------------
2034                      
2035                      void XmlWriter::appendOKResponseHeader(
2036 mike           1.125     Buffer& out,
2037 gerarda        1.90      const String& content)
2038                      {
2039 mike           1.126     out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n");
2040 gerarda        1.101     // Content-Length header needs to be added because 200 OK record
2041                          // is usually intended to have content.  But, for Kerberos this
2042                          // may not always be the case so we need to indicate that there
2043                          // is no content
2044 kumpf          1.157     OUTPUT_CONTENTLENGTH(out, 0);
2045 thilo.boehm    1.162     out << content << STRLIT("\r\n\r\n");
2046 gerarda        1.90  
2047                      //ATTN: We may need to include the following line, so that the browsers
2048                      //      can display the error message.
2049                      //    out << "<HTML><HEAD>\r\n";
2050                      //    out << "<TITLE>" << "200 OK" <<  "</TITLE>\r\n";
2051                      //    out << "</HEAD><BODY BGCOLOR=\"#99cc99\">\r\n";
2052                      //    out << "<H2>TEST" << "200 OK" << "</H2>\r\n";
2053                      //    out << "<HR>\r\n";
2054                      //    out << "</BODY></HTML>\r\n";
2055                      }
2056                      #endif
2057                      
2058 kumpf          1.27  //------------------------------------------------------------------------------
2059                      //
2060 kumpf          1.29  // _appendMessageElementBegin()
2061                      // _appendMessageElementEnd()
2062 mike           1.23  //
2063                      //     <!ELEMENT MESSAGE (SIMPLEREQ|MULTIREQ|SIMPLERSP|MULTIRSP)>
2064                      //     <!ATTLIST MESSAGE
2065                      //         ID CDATA #REQUIRED
2066                      //         PROTOCOLVERSION CDATA #REQUIRED>
2067                      //
2068                      //------------------------------------------------------------------------------
2069                      
2070 kumpf          1.29  void XmlWriter::_appendMessageElementBegin(
2071 mike           1.125     Buffer& out,
2072 kumpf          1.27      const String& messageId)
2073 mike           1.23  {
2074 kumpf          1.167     out << STRLIT("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
2075                                        "<CIM CIMVERSION=\"2.0\" DTDVERSION=\"2.0\">\n"
2076 thilo.boehm    1.162                   "<MESSAGE ID=\"") << messageId;
2077 mike           1.126     out << STRLIT("\" PROTOCOLVERSION=\"1.0\">\n");
2078 kumpf          1.27  }
2079                      
2080 kumpf          1.29  void XmlWriter::_appendMessageElementEnd(
2081 mike           1.125     Buffer& out)
2082 kumpf          1.27  {
2083 thilo.boehm    1.162     out << STRLIT("</MESSAGE>\n</CIM>\n");
2084 mike           1.23  }
2085                      
2086                      //------------------------------------------------------------------------------
2087                      //
2088 kumpf          1.29  // _appendSimpleReqElementBegin()
2089                      // _appendSimpleReqElementEnd()
2090 mike           1.23  //
2091                      //     <!ELEMENT SIMPLEREQ (IMETHODCALL|METHODCALL)>
2092                      //
2093                      //------------------------------------------------------------------------------
2094                      
2095 kumpf          1.29  void XmlWriter::_appendSimpleReqElementBegin(
2096 mike           1.125     Buffer& out)
2097 kumpf          1.27  {
2098 mike           1.126     out << STRLIT("<SIMPLEREQ>\n");
2099 kumpf          1.27  }
2100                      
2101 kumpf          1.29  void XmlWriter::_appendSimpleReqElementEnd(
2102 mike           1.125     Buffer& out)
2103 mike           1.23  {
2104 mike           1.126     out << STRLIT("</SIMPLEREQ>\n");
2105 mike           1.23  }
2106                      
2107                      //------------------------------------------------------------------------------
2108                      //
2109 kumpf          1.29  // _appendMethodCallElementBegin()
2110                      // _appendMethodCallElementEnd()
2111 mike           1.23  //
2112 kumpf          1.27  //     <!ELEMENT METHODCALL ((LOCALCLASSPATH|LOCALINSTANCEPATH),PARAMVALUE*)>
2113                      //     <!ATTLIST METHODCALL %CIMName;>
2114 mike           1.23  //
2115                      //------------------------------------------------------------------------------
2116                      
2117 kumpf          1.29  void XmlWriter::_appendMethodCallElementBegin(
2118 mike           1.125     Buffer& out,
2119 kumpf          1.80      const CIMName& name)
2120 kumpf          1.27  {
2121 mike           1.126     out << STRLIT("<METHODCALL NAME=\"") << name << STRLIT("\">\n");
2122 kumpf          1.27  }
2123                      
2124 kumpf          1.29  void XmlWriter::_appendMethodCallElementEnd(
2125 mike           1.125     Buffer& out)
2126 mike           1.23  {
2127 mike           1.126     out << STRLIT("</METHODCALL>\n");
2128 mike           1.23  }
2129                      
2130                      //------------------------------------------------------------------------------
2131                      //
2132 kumpf          1.29  // _appendIMethodCallElementBegin()
2133                      // _appendIMethodCallElementEnd()
2134 mike           1.23  //
2135                      //     <!ELEMENT IMETHODCALL (LOCALNAMESPACEPATH,IPARAMVALUE*)>
2136                      //     <!ATTLIST IMETHODCALL %CIMName;>
2137                      //
2138                      //------------------------------------------------------------------------------
2139                      
2140 kumpf          1.29  void XmlWriter::_appendIMethodCallElementBegin(
2141 mike           1.125     Buffer& out,
2142 kumpf          1.80      const CIMName& name)
2143 mike           1.23  {
2144 mike           1.126     out << STRLIT("<IMETHODCALL NAME=\"") << name << STRLIT("\">\n");
2145 kumpf          1.27  }
2146                      
2147 kumpf          1.29  void XmlWriter::_appendIMethodCallElementEnd(
2148 mike           1.125     Buffer& out)
2149 kumpf          1.27  {
2150 mike           1.126     out << STRLIT("</IMETHODCALL>\n");
2151 mike           1.23  }
2152                      
2153                      //------------------------------------------------------------------------------
2154                      //
2155 kumpf          1.29  // _appendIParamValueElementBegin()
2156                      // _appendIParamValueElementEnd()
2157 mike           1.23  //
2158 kumpf          1.27  //     <!ELEMENT IPARAMVALUE (VALUE|VALUE.ARRAY|VALUE.REFERENCE
2159                      //         |INSTANCENAME|CLASSNAME|QUALIFIER.DECLARATION
2160                      //         |CLASS|INSTANCE|VALUE.NAMEDINSTANCE)?>
2161                      //     <!ATTLIST IPARAMVALUE %CIMName;>
2162 mike           1.23  //
2163                      //------------------------------------------------------------------------------
2164                      
2165 kumpf          1.29  void XmlWriter::_appendIParamValueElementBegin(
2166 mike           1.125     Buffer& out,
2167 kumpf          1.27      const char* name)
2168                      {
2169 mike           1.126     out << STRLIT("<IPARAMVALUE NAME=\"") << name << STRLIT("\">\n");
2170 kumpf          1.27  }
2171                      
2172 kumpf          1.29  void XmlWriter::_appendIParamValueElementEnd(
2173 mike           1.125     Buffer& out)
2174 mike           1.23  {
2175 mike           1.126     out << STRLIT("</IPARAMVALUE>\n");
2176 mike           1.23  }
2177                      
2178                      //------------------------------------------------------------------------------
2179                      //
2180 kumpf          1.29  // _appendSimpleRspElementBegin()
2181                      // _appendSimpleRspElementEnd()
2182 mike           1.23  //
2183 kumpf          1.27  //     <!ELEMENT SIMPLERSP (METHODRESPONSE|IMETHODRESPONSE)>
2184 mike           1.23  //
2185                      //------------------------------------------------------------------------------
2186                      
2187 kumpf          1.29  void XmlWriter::_appendSimpleRspElementBegin(
2188 mike           1.125     Buffer& out)
2189 kumpf          1.27  {
2190 mike           1.126     out << STRLIT("<SIMPLERSP>\n");
2191 kumpf          1.27  }
2192                      
2193 kumpf          1.29  void XmlWriter::_appendSimpleRspElementEnd(
2194 mike           1.125     Buffer& out)
2195 mike           1.23  {
2196 mike           1.126     out << STRLIT("</SIMPLERSP>\n");
2197 mike           1.23  }
2198                      
2199                      //------------------------------------------------------------------------------
2200                      //
2201 kumpf          1.29  // _appendMethodResponseElementBegin()
2202                      // _appendMethodResponseElementEnd()
2203 mike           1.23  //
2204 kumpf          1.27  //     <!ELEMENT METHODRESPONSE (ERROR|IRETURNVALUE?)>
2205                      //     <!ATTLIST METHODRESPONSE %CIMName;>
2206 mike           1.23  //
2207                      //------------------------------------------------------------------------------
2208                      
2209 kumpf          1.29  void XmlWriter::_appendMethodResponseElementBegin(
2210 mike           1.125     Buffer& out,
2211 kumpf          1.80      const CIMName& name)
2212 kumpf          1.27  {
2213 mike           1.126     out << STRLIT("<METHODRESPONSE NAME=\"") << name << STRLIT("\">\n");
2214 kumpf          1.27  }
2215                      
2216 kumpf          1.29  void XmlWriter::_appendMethodResponseElementEnd(
2217 mike           1.125     Buffer& out)
2218 mike           1.23  {
2219 mike           1.126     out << STRLIT("</METHODRESPONSE>\n");
2220 kumpf          1.27  }
2221                      
2222                      //------------------------------------------------------------------------------
2223                      //
2224 kumpf          1.29  // _appendIMethodResponseElementBegin()
2225                      // _appendIMethodResponseElementEnd()
2226 kumpf          1.27  //
2227                      //     <!ELEMENT IMETHODRESPONSE (ERROR|IRETURNVALUE?)>
2228                      //     <!ATTLIST IMETHODRESPONSE %CIMName;>
2229                      //
2230                      //------------------------------------------------------------------------------
2231                      
2232 kumpf          1.29  void XmlWriter::_appendIMethodResponseElementBegin(
2233 mike           1.125     Buffer& out,
2234 kumpf          1.80      const CIMName& name)
2235 kumpf          1.27  {
2236 mike           1.126     out << STRLIT("<IMETHODRESPONSE NAME=\"") << name << STRLIT("\">\n");
2237 kumpf          1.27  }
2238                      
2239 kumpf          1.29  void XmlWriter::_appendIMethodResponseElementEnd(
2240 mike           1.125     Buffer& out)
2241 kumpf          1.27  {
2242 mike           1.126     out << STRLIT("</IMETHODRESPONSE>\n");
2243 mike           1.23  }
2244                      
2245                      //------------------------------------------------------------------------------
2246                      //
2247 kumpf          1.29  // _appendErrorElement()
2248 mike           1.23  //
2249                      //------------------------------------------------------------------------------
2250                      
2251 kumpf          1.29  void XmlWriter::_appendErrorElement(
2252 mike           1.125     Buffer& out,
2253 kumpf          1.42      const CIMException& cimException)
2254 mike           1.23  {
2255 thilo.boehm    1.163     Tracer::traceCIMException(TRC_XML, Tracer::LEVEL2, cimException);
2256 kumpf          1.44  
2257 thilo.boehm    1.162     out << STRLIT("<ERROR CODE=\"") << Uint32(cimException.getCode());
2258 karl           1.145     out.append('"');
2259 karl           1.142 
2260 kumpf          1.71      String description = TraceableCIMException(cimException).getDescription();
2261 karl           1.145 
2262 kumpf          1.51      if (description != String::EMPTY)
2263 kumpf          1.42      {
2264 mike           1.126         out << STRLIT(" DESCRIPTION=\"");
2265 kumpf          1.51          appendSpecial(out, description);
2266 kumpf          1.146         out.append('"');
2267 kumpf          1.42      }
2268 karl           1.142 
2269 karl           1.145     if (cimException.getErrorCount())
2270 karl           1.142     {
2271 karl           1.145         out << STRLIT(">");
2272                      
2273                              for (Uint32 i = 0, n = cimException.getErrorCount(); i < n; i++)
2274                                  appendInstanceElement(out, cimException.getError(i));
2275                      
2276                              out << STRLIT("</ERROR>");
2277 karl           1.142     }
2278 karl           1.145     else
2279                              out << STRLIT("/>");
2280 mike           1.23  }
2281                      
2282 kumpf          1.157 //----------------------------------------------------------------------
2283                      //
2284                      // appendParamTypeAndEmbeddedObjAttrib
2285                      // Appends the Param type and EmbeddedObject Info to the buffer
2286                      //     %EmbeddedObject; #IMPLIED
2287                      //     %ParamType;>
2288                      //
2289 karl           1.154 //---------------------------------------------------------------------
2290 kumpf          1.157 
2291 karl           1.154 void XmlWriter::appendParamTypeAndEmbeddedObjAttrib(
2292 mike           1.125     Buffer& out,
2293 karl           1.154     const CIMType& type)
2294 kumpf          1.27  {
2295                      
2296 david.dillard  1.121     // If the property type is CIMObject, then
2297 karl           1.154     //   encode the property in CIM-XML as a string with the EmbeddedObject
2298                          //   attribute (there is not currently a CIM-XML "object"
2299                          //   datatype).
2300                          //   Because of an error in Pegasus we were earlier outputting
2301                          //   upper case "EMBEDDEDOBJECT" as the attribute name. The
2302                          //   spec calls for mixed case "EmbeddedObject. Fixed in
2303                          //   bug 7131 to output EmbeddedObject  attribute in upper
2304                          //   case and mixed case. Receiver will ignore one or the
2305                          //   other.
2306                          //else
2307                          //      output the real type
2308 dave.sudlik    1.117     if (type == CIMTYPE_OBJECT)
2309                          {
2310 karl           1.154 
2311 kumpf          1.167         out << STRLIT(" PARAMTYPE=\"string\""
2312                                            " EmbeddedObject=\"object\""
2313 thilo.boehm    1.162                       " EMBEDDEDOBJECT=\"object\"");
2314 dave.sudlik    1.117     }
2315 a.dunfey       1.137     else if (type == CIMTYPE_INSTANCE)
2316                          {
2317 thilo.boehm    1.162         out << STRLIT(" PARAMTYPE=\"string\""
2318 kumpf          1.167                       " EmbeddedObject=\"instance\""
2319 thilo.boehm    1.162                       " EMBEDDEDOBJECT=\"instance\"");
2320 a.dunfey       1.137     }
2321 dave.sudlik    1.117     else
2322                          {
2323 thilo.boehm    1.169         out << STRLIT(" PARAM") << xmlWriterTypeStrings(type);
2324 dave.sudlik    1.117     }
2325 karl           1.154 }
2326                      
2327                      //------------------------------------------------------------------------------
2328                      //
2329                      // appendReturnValueElement()
2330                      //
2331                      // <!ELEMENT RETURNVALUE (VALUE|VALUE.REFERENCE)>
2332                      // <!ATTLIST RETURNVALUE
2333                      //     %EmbeddedObject; #IMPLIED
2334                      //     %ParamType;>
2335                      //
2336                      //------------------------------------------------------------------------------
2337                      
2338                      void XmlWriter::appendReturnValueElement(
2339                          Buffer& out,
2340                          const CIMValue& value)
2341                      {
2342                          out << STRLIT("<RETURNVALUE");
2343                      
2344                          CIMType type = value.getType();
2345                      
2346 karl           1.154     appendParamTypeAndEmbeddedObjAttrib(out, type);
2347 kumpf          1.27  
2348 mike           1.126     out << STRLIT(">\n");
2349 karl           1.37  
2350 kumpf          1.54      // Add value.
2351                          appendValueElement(out, value);
2352 mike           1.126     out << STRLIT("</RETURNVALUE>\n");
2353 kumpf          1.27  }
2354                      
2355                      //------------------------------------------------------------------------------
2356                      //
2357 kumpf          1.29  // _appendIReturnValueElementBegin()
2358                      // _appendIReturnValueElementEnd()
2359 kumpf          1.27  //
2360                      //      <!ELEMENT IRETURNVALUE (CLASSNAME*|INSTANCENAME*|VALUE*|
2361                      //          VALUE.OBJECTWITHPATH*|VALUE.OBJECTWITHLOCALPATH*|VALUE.OBJECT*|
2362                      //          OBJECTPATH*|QUALIFIER.DECLARATION*|VALUE.ARRAY?|VALUE.REFERENCE?|
2363                      //          CLASS*|INSTANCE*|VALUE.NAMEDINSTANCE*)>
2364                      //
2365                      //------------------------------------------------------------------------------
2366                      
2367 kumpf          1.29  void XmlWriter::_appendIReturnValueElementBegin(
2368 mike           1.125     Buffer& out)
2369 kumpf          1.27  {
2370 mike           1.126     out << STRLIT("<IRETURNVALUE>\n");
2371 kumpf          1.27  }
2372                      
2373 kumpf          1.29  void XmlWriter::_appendIReturnValueElementEnd(
2374 mike           1.125     Buffer& out)
2375 mike           1.23  {
2376 mike           1.126     out << STRLIT("</IRETURNVALUE>\n");
2377 mike           1.23  }
2378                      
2379                      //------------------------------------------------------------------------------
2380                      //
2381 kumpf          1.27  // appendBooleanIParameter()
2382 mike           1.23  //
2383                      //------------------------------------------------------------------------------
2384                      
2385 kumpf          1.27  void XmlWriter::appendBooleanIParameter(
2386 mike           1.125     Buffer& out,
2387 mike           1.23      const char* name,
2388 kumpf          1.27      Boolean flag)
2389 mike           1.23  {
2390 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2391 mike           1.126     out << STRLIT("<VALUE>");
2392 kumpf          1.54      append(out, flag);
2393 mike           1.126     out << STRLIT("</VALUE>\n");
2394 kumpf          1.29      _appendIParamValueElementEnd(out);
2395 mike           1.23  }
2396                      
2397                      //------------------------------------------------------------------------------
2398                      //
2399 kumpf          1.27  // appendStringIParameter()
2400 mike           1.23  //
2401                      //------------------------------------------------------------------------------
2402                      
2403 kumpf          1.27  void XmlWriter::appendStringIParameter(
2404 mike           1.125     Buffer& out,
2405 mike           1.23      const char* name,
2406 kumpf          1.27      const String& str)
2407 mike           1.23  {
2408 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2409 mike           1.126     out << STRLIT("<VALUE>");
2410 kumpf          1.27      appendSpecial(out, str);
2411 mike           1.126     out << STRLIT("</VALUE>\n");
2412 kumpf          1.29      _appendIParamValueElementEnd(out);
2413 mike           1.23  }
2414                      
2415                      //------------------------------------------------------------------------------
2416                      //
2417 kumpf          1.27  // appendClassNameIParameter()
2418 mike           1.23  //
2419                      //------------------------------------------------------------------------------
2420                      
2421 kumpf          1.27  void XmlWriter::appendClassNameIParameter(
2422 mike           1.125     Buffer& out,
2423 kumpf          1.27      const char* name,
2424 kumpf          1.80      const CIMName& className)
2425 mike           1.23  {
2426 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2427 kumpf          1.83  
2428                          //
2429 david.dillard  1.121     //  A NULL (unassigned) value for a parameter is specified by an
2430 kumpf          1.83      //  <IPARAMVALUE> element with no subelement
2431                          //
2432                          if (!className.isNull ())
2433                          {
2434                              appendClassNameElement(out, className);
2435                          }
2436                      
2437 kumpf          1.29      _appendIParamValueElementEnd(out);
2438 mike           1.23  }
2439                      
2440                      //------------------------------------------------------------------------------
2441                      //
2442 kumpf          1.27  // appendInstanceNameIParameter()
2443 mike           1.23  //
2444                      //------------------------------------------------------------------------------
2445                      
2446 kumpf          1.27  void XmlWriter::appendInstanceNameIParameter(
2447 mike           1.125     Buffer& out,
2448 kumpf          1.27      const char* name,
2449 kumpf          1.59      const CIMObjectPath& instanceName)
2450 mike           1.23  {
2451 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2452                          appendInstanceNameElement(out, instanceName);
2453                          _appendIParamValueElementEnd(out);
2454 kumpf          1.27  }
2455                      
2456                      //------------------------------------------------------------------------------
2457                      //
2458                      // appendClassIParameter()
2459                      //
2460                      //------------------------------------------------------------------------------
2461                      
2462                      void XmlWriter::appendClassIParameter(
2463 mike           1.125     Buffer& out,
2464 kumpf          1.27      const char* name,
2465                          const CIMConstClass& cimClass)
2466                      {
2467 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2468 kumpf          1.55      appendClassElement(out, cimClass);
2469 kumpf          1.29      _appendIParamValueElementEnd(out);
2470 mike           1.23  }
2471                      
2472                      //------------------------------------------------------------------------------
2473                      //
2474 kumpf          1.27  // appendInstanceIParameter()
2475 mike           1.23  //
2476                      //------------------------------------------------------------------------------
2477                      
2478 kumpf          1.27  void XmlWriter::appendInstanceIParameter(
2479 mike           1.125     Buffer& out,
2480 kumpf          1.27      const char* name,
2481 mike           1.23      const CIMConstInstance& instance)
2482                      {
2483 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2484 kumpf          1.55      appendInstanceElement(out, instance);
2485 kumpf          1.29      _appendIParamValueElementEnd(out);
2486 mike           1.23  }
2487                      
2488 mike           1.24  //------------------------------------------------------------------------------
2489                      //
2490 kumpf          1.27  // appendNamedInstanceIParameter()
2491 mike           1.24  //
2492                      //------------------------------------------------------------------------------
2493                      
2494 kumpf          1.27  void XmlWriter::appendNamedInstanceIParameter(
2495 mike           1.125     Buffer& out,
2496 kumpf          1.27      const char* name,
2497 kumpf          1.61      const CIMInstance& namedInstance)
2498 mike           1.24  {
2499 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2500 kumpf          1.56      appendValueNamedInstanceElement(out, namedInstance);
2501 kumpf          1.29      _appendIParamValueElementEnd(out);
2502 mike           1.24  }
2503                      
2504 mike           1.23  //----------------------------------------------------------
2505                      //
2506 kumpf          1.27  //  appendPropertyNameIParameter()
2507 david.dillard  1.121 //
2508 mike           1.23  //     </IPARAMVALUE>
2509                      //     <IPARAMVALUE NAME="PropertyName"><VALUE>FreeSpace</VALUE></IPARAMVALUE>
2510                      //
2511                      //     USE: Create parameter for getProperty operation
2512 brian.campbell 1.113 //==========================================================
2513 kumpf          1.27  void XmlWriter::appendPropertyNameIParameter(
2514 mike           1.125     Buffer& out,
2515 kumpf          1.80      const CIMName& propertyName)
2516 mike           1.23  {
2517 kumpf          1.29      _appendIParamValueElementBegin(out, "PropertyName");
2518 mike           1.126     out << STRLIT("<VALUE>") << propertyName << STRLIT("</VALUE>\n");
2519 kumpf          1.29      _appendIParamValueElementEnd(out);
2520 kumpf          1.27  }
2521 mike           1.23  
2522                      //------------------------------------------------------------------------------
2523                      //
2524 kumpf          1.27  // appendPropertyValueIParameter()
2525 mike           1.24  //
2526                      //------------------------------------------------------------------------------
2527                      
2528 kumpf          1.27  void XmlWriter::appendPropertyValueIParameter(
2529 mike           1.125     Buffer& out,
2530 kumpf          1.27      const char* name,
2531 mike           1.24      const CIMValue& value)
2532                      {
2533 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2534 kumpf          1.54      appendValueElement(out, value);
2535 kumpf          1.29      _appendIParamValueElementEnd(out);
2536 mike           1.24  }
2537                      
2538                      //------------------------------------------------------------------------------
2539                      //
2540 kumpf          1.27  // appendPropertyListIParameter()
2541 mike           1.24  //
2542                      //------------------------------------------------------------------------------
2543                      
2544 kumpf          1.27  void XmlWriter::appendPropertyListIParameter(
2545 mike           1.125     Buffer& out,
2546 mike           1.24      const CIMPropertyList& propertyList)
2547                      {
2548 kumpf          1.29      _appendIParamValueElementBegin(out, "PropertyList");
2549 mike           1.24  
2550 kumpf          1.83      //
2551 david.dillard  1.121     //  A NULL (unassigned) value for a parameter is specified by an
2552 kumpf          1.83      //  <IPARAMVALUE> element with no subelement
2553                          //
2554                          if (!propertyList.isNull ())
2555 mike           1.24      {
2556 mike           1.126         out << STRLIT("<VALUE.ARRAY>\n");
2557 kumpf          1.83          for (Uint32 i = 0; i < propertyList.size(); i++)
2558                              {
2559 mike           1.126             out << STRLIT("<VALUE>") << propertyList[i] << STRLIT("</VALUE>\n");
2560 kumpf          1.83          }
2561 mike           1.126         out << STRLIT("</VALUE.ARRAY>\n");
2562 mike           1.24      }
2563 kumpf          1.27  
2564 kumpf          1.29      _appendIParamValueElementEnd(out);
2565 mike           1.24  }
2566                      
2567                      //------------------------------------------------------------------------------
2568                      //
2569 kumpf          1.27  // appendQualifierDeclarationIParameter()
2570 mike           1.23  //
2571                      //------------------------------------------------------------------------------
2572                      
2573 kumpf          1.27  void XmlWriter::appendQualifierDeclarationIParameter(
2574 mike           1.125     Buffer& out,
2575 kumpf          1.27      const char* name,
2576 mike           1.23      const CIMConstQualifierDecl& qualifierDecl)
2577                      {
2578 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2579 kumpf          1.56      appendQualifierDeclElement(out, qualifierDecl);
2580 kumpf          1.29      _appendIParamValueElementEnd(out);
2581 kumpf          1.40  }
2582                      
2583                      //------------------------------------------------------------------------------
2584                      //
2585                      // XmlWriter::formatHttpErrorRspMessage()
2586                      //
2587                      //------------------------------------------------------------------------------
2588                      
2589 mike           1.125 Buffer XmlWriter::formatHttpErrorRspMessage(
2590 kumpf          1.40      const String& status,
2591                          const String& cimError,
2592 kumpf          1.41      const String& errorDetail)
2593 kumpf          1.40  {
2594 mike           1.125     Buffer out;
2595 kumpf          1.40  
2596 kumpf          1.41      appendHttpErrorResponseHeader(out, status, cimError, errorDetail);
2597 kumpf          1.40  
2598 kumpf          1.41      return out;
2599 mike           1.23  }
2600                      
2601 chuck          1.89  // l10n - add content language support to the format methods below
2602                      
2603 mike           1.23  //------------------------------------------------------------------------------
2604                      //
2605 kumpf          1.27  // XmlWriter::formatSimpleMethodReqMessage()
2606 mike           1.23  //
2607                      //------------------------------------------------------------------------------
2608                      
2609 kumpf          1.27  // ATTN-RK-P1-20020228: Need to complete copy elimination optimization
2610 mike           1.125 Buffer XmlWriter::formatSimpleMethodReqMessage(
2611 kumpf          1.27      const char* host,
2612 kumpf          1.80      const CIMNamespaceName& nameSpace,
2613 kumpf          1.59      const CIMObjectPath& path,
2614 kumpf          1.80      const CIMName& methodName,
2615 kumpf          1.30      const Array<CIMParamValue>& parameters,
2616 kumpf          1.27      const String& messageId,
2617 kumpf          1.82      HttpMethod httpMethod,
2618 chuck          1.89      const String& authenticationHeader,
2619 kumpf          1.133     const AcceptLanguageList& httpAcceptLanguages,
2620 mike           1.164     const ContentLanguageList& httpContentLanguages,
2621                          bool binaryResponse)
2622 kumpf          1.27  {
2623 mike           1.125     Buffer out;
2624                          Buffer tmp;
2625 kumpf          1.59      CIMObjectPath localObjectPath = path;
2626 kumpf          1.80      localObjectPath.setNameSpace(nameSpace.getString());
2627 kumpf          1.77      localObjectPath.setHost(String::EMPTY);
2628 kumpf          1.27  
2629 kumpf          1.29      _appendMessageElementBegin(out, messageId);
2630                          _appendSimpleReqElementBegin(out);
2631                          _appendMethodCallElementBegin(out, methodName);
2632 kumpf          1.38      appendLocalObjectPathElement(out, localObjectPath);
2633 kumpf          1.30      for (Uint32 i=0; i < parameters.size(); i++)
2634 kumpf          1.29      {
2635 kumpf          1.56          appendParamValueElement(out, parameters[i]);
2636 kumpf          1.29      }
2637                          _appendMethodCallElementEnd(out);
2638                          _appendSimpleReqElementEnd(out);
2639                          _appendMessageElementEnd(out);
2640 kumpf          1.27  
2641                          appendMethodCallHeader(
2642 kumpf          1.146         tmp,
2643                              host,
2644                              methodName,
2645                              localObjectPath.toString(),
2646 kumpf          1.27          authenticationHeader,
2647 kumpf          1.82          httpMethod,
2648 chuck          1.89          httpAcceptLanguages,
2649                              httpContentLanguages,
2650 mike           1.164         out.size(),
2651                              false,
2652                              binaryResponse);
2653 kumpf          1.27      tmp << out;
2654                      
2655                          return tmp;
2656                      }
2657                      
2658 mike           1.125 Buffer XmlWriter::formatSimpleMethodRspMessage(
2659 w.white        1.108     const CIMName& methodName,
2660                          const String& messageId,
2661                          HttpMethod httpMethod,
2662 kumpf          1.133     const ContentLanguageList& httpContentLanguages,
2663 mike           1.125     const Buffer& body,
2664 kumpf          1.146     Uint64 serverResponseTime,
2665                          Boolean isFirst,
2666                          Boolean isLast)
2667                      {
2668                          Buffer out;
2669                      
2670                          if (isFirst == true)
2671                          {
2672                              // NOTE: temporarily put zero for content length. the http code
2673                              // will later decide to fill in the length or remove it altogether
2674                              appendMethodResponseHeader(
2675                                  out, httpMethod, httpContentLanguages, 0, serverResponseTime);
2676                              _appendMessageElementBegin(out, messageId);
2677                              _appendSimpleRspElementBegin(out);
2678                              _appendMethodResponseElementBegin(out, methodName);
2679                          }
2680                      
2681                          if (body.size() != 0)
2682                          {
2683                              out << body;
2684                          }
2685 kumpf          1.146 
2686                          if (isLast == true)
2687                          {
2688                              _appendMethodResponseElementEnd(out);
2689                              _appendSimpleRspElementEnd(out);
2690                              _appendMessageElementEnd(out);
2691                          }
2692 david.dillard  1.121 
2693 kumpf          1.146     return out;
2694 w.white        1.108 }
2695                      
2696                      
2697 mike           1.23  //------------------------------------------------------------------------------
2698                      //
2699 kumpf          1.28  // XmlWriter::formatSimpleMethodErrorRspMessage()
2700                      //
2701                      //------------------------------------------------------------------------------
2702                      
2703 mike           1.125 Buffer XmlWriter::formatSimpleMethodErrorRspMessage(
2704 kumpf          1.80      const CIMName& methodName,
2705 kumpf          1.28      const String& messageId,
2706 kumpf          1.82      HttpMethod httpMethod,
2707 kumpf          1.42      const CIMException& cimException)
2708 kumpf          1.28  {
2709 mike           1.125     Buffer out;
2710                          Buffer tmp;
2711 kumpf          1.28  
2712 kumpf          1.29      _appendMessageElementBegin(out, messageId);
2713                          _appendSimpleRspElementBegin(out);
2714 kumpf          1.80      _appendMethodResponseElementBegin(out, methodName);
2715 kumpf          1.42      _appendErrorElement(out, cimException);
2716 kumpf          1.29      _appendMethodResponseElementEnd(out);
2717                          _appendSimpleRspElementEnd(out);
2718                          _appendMessageElementEnd(out);
2719 kumpf          1.28  
2720 kumpf          1.146     appendMethodResponseHeader(
2721                              tmp,
2722                              httpMethod,
2723                              cimException.getContentLanguages(),
2724 mike           1.164         out.size(),
2725                              false);
2726 kumpf          1.28      tmp << out;
2727                      
2728                          return tmp;
2729                      }
2730                      
2731                      //------------------------------------------------------------------------------
2732                      //
2733 kumpf          1.27  // XmlWriter::formatSimpleIMethodReqMessage()
2734 mike           1.23  //
2735                      //------------------------------------------------------------------------------
2736                      
2737 mike           1.125 Buffer XmlWriter::formatSimpleIMethodReqMessage(
2738 kumpf          1.27      const char* host,
2739 kumpf          1.80      const CIMNamespaceName& nameSpace,
2740                          const CIMName& iMethodName,
2741 kumpf          1.27      const String& messageId,
2742 kumpf          1.82      HttpMethod httpMethod,
2743 kumpf          1.27      const String& authenticationHeader,
2744 kumpf          1.133     const AcceptLanguageList& httpAcceptLanguages,
2745                          const ContentLanguageList& httpContentLanguages,
2746 mike           1.164     const Buffer& body,
2747                          bool binaryResponse)
2748 mike           1.23  {
2749 mike           1.125     Buffer out;
2750                          Buffer tmp;
2751 kumpf          1.27  
2752 kumpf          1.29      _appendMessageElementBegin(out, messageId);
2753                          _appendSimpleReqElementBegin(out);
2754                          _appendIMethodCallElementBegin(out, iMethodName);
2755 kumpf          1.80      appendLocalNameSpacePathElement(out, nameSpace.getString());
2756 kumpf          1.27      out << body;
2757 kumpf          1.29      _appendIMethodCallElementEnd(out);
2758                          _appendSimpleReqElementEnd(out);
2759                          _appendMessageElementEnd(out);
2760 kumpf          1.27  
2761                          appendMethodCallHeader(
2762 kumpf          1.146         tmp,
2763                              host,
2764                              iMethodName,
2765                              nameSpace.getString(),
2766 kumpf          1.27          authenticationHeader,
2767 kumpf          1.82          httpMethod,
2768 chuck          1.89          httpAcceptLanguages,
2769                              httpContentLanguages,
2770 kumpf          1.167         out.size(),
2771 mike           1.164         false,
2772                              binaryResponse);
2773 kumpf          1.27      tmp << out;
2774 mike           1.23  
2775 kumpf          1.27      return tmp;
2776 mike           1.23  }
2777                      
2778                      //------------------------------------------------------------------------------
2779                      //
2780 kumpf          1.27  // XmlWriter::formatSimpleIMethodRspMessage()
2781 mike           1.23  //
2782                      //------------------------------------------------------------------------------
2783                      
2784 mike           1.125 Buffer XmlWriter::formatSimpleIMethodRspMessage(
2785 kumpf          1.80      const CIMName& iMethodName,
2786 kumpf          1.27      const String& messageId,
2787 kumpf          1.82      HttpMethod httpMethod,
2788 kumpf          1.133     const ContentLanguageList& httpContentLanguages,
2789 mike           1.125     const Buffer& body,
2790 david.dillard  1.130     Uint64 serverResponseTime,
2791 david.dillard  1.121     Boolean isFirst,
2792                          Boolean isLast)
2793 mike           1.23  {
2794 mike           1.125     Buffer out;
2795 mike           1.23  
2796 kumpf          1.146     if (isFirst == true)
2797                          {
2798                              // NOTE: temporarily put zero for content length. the http code
2799                              // will later decide to fill in the length or remove it altogether
2800                              appendMethodResponseHeader(
2801                                  out, httpMethod, httpContentLanguages, 0, serverResponseTime);
2802                              _appendMessageElementBegin(out, messageId);
2803                              _appendSimpleRspElementBegin(out);
2804                              _appendIMethodResponseElementBegin(out, iMethodName);
2805                      
2806                              // output the start of the return tag. Test if there is response data
2807                              // by:
2808                              // 1. there is data on the first chunk OR
2809                              // 2. there is no data on the first chunk but isLast is false implying
2810                              //    there is more non-empty data to come. If all subsequent chunks
2811                              //    are empty, then this generates and empty response.
2812                              if (body.size() != 0 || isLast == false)
2813                                  _appendIReturnValueElementBegin(out);
2814                          }
2815 w.white        1.108 
2816                          if (body.size() != 0)
2817                          {
2818 kumpf          1.146         out << body;
2819 w.white        1.108     }
2820                      
2821 kumpf          1.146     if (isLast == true)
2822                          {
2823                              if (body.size() != 0 || isFirst == false)
2824                                  _appendIReturnValueElementEnd(out);
2825                              _appendIMethodResponseElementEnd(out);
2826                              _appendSimpleRspElementEnd(out);
2827                              _appendMessageElementEnd(out);
2828                          }
2829 w.white        1.108 
2830                          return out;
2831                      }
2832                      
2833                      
2834 kumpf          1.28  //------------------------------------------------------------------------------
2835                      //
2836                      // XmlWriter::formatSimpleIMethodErrorRspMessage()
2837                      //
2838                      //------------------------------------------------------------------------------
2839                      
2840 mike           1.125 Buffer XmlWriter::formatSimpleIMethodErrorRspMessage(
2841 kumpf          1.80      const CIMName& iMethodName,
2842 kumpf          1.28      const String& messageId,
2843 kumpf          1.82      HttpMethod httpMethod,
2844 kumpf          1.42      const CIMException& cimException)
2845 kumpf          1.28  {
2846 mike           1.125     Buffer out;
2847                          Buffer tmp;
2848 kumpf          1.28  
2849 kumpf          1.29      _appendMessageElementBegin(out, messageId);
2850                          _appendSimpleRspElementBegin(out);
2851 kumpf          1.80      _appendIMethodResponseElementBegin(out, iMethodName);
2852 kumpf          1.42      _appendErrorElement(out, cimException);
2853 kumpf          1.29      _appendIMethodResponseElementEnd(out);
2854                          _appendSimpleRspElementEnd(out);
2855                          _appendMessageElementEnd(out);
2856 kumpf          1.28  
2857 chuck          1.89      appendMethodResponseHeader(tmp,
2858 kumpf          1.146         httpMethod,
2859                              cimException.getContentLanguages(),
2860 mike           1.164         out.size(), false);
2861 kumpf          1.28      tmp << out;
2862                      
2863                          return tmp;
2864                      }
2865                      
2866 kumpf          1.27  //******************************************************************************
2867                      //
2868                      // Export Messages (used for indications)
2869                      //
2870                      //******************************************************************************
2871 mike           1.23  
2872 kumpf          1.27  //------------------------------------------------------------------------------
2873                      //
2874                      // appendEMethodRequestHeader()
2875                      //
2876                      //     Build HTTP request header for export operation.
2877                      //
2878                      //------------------------------------------------------------------------------
2879 mike           1.23  
2880 kumpf          1.27  void XmlWriter::appendEMethodRequestHeader(
2881 mike           1.125     Buffer& out,
2882 kumpf          1.50      const char* requestUri,
2883 kumpf          1.27      const char* host,
2884 kumpf          1.80      const CIMName& cimMethod,
2885 kumpf          1.82      HttpMethod httpMethod,
2886 kumpf          1.27      const String& authenticationHeader,
2887 kumpf          1.133     const AcceptLanguageList& acceptLanguages,
2888                          const ContentLanguageList& contentLanguages,
2889 kumpf          1.27      Uint32 contentLength)
2890                      {
2891                          char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };
2892 mike           1.23  
2893 kumpf          1.82      if (httpMethod == HTTP_METHOD_M_POST)
2894                          {
2895 mike           1.126       out << STRLIT("M-POST ") << requestUri << STRLIT(" HTTP/1.1\r\n");
2896 kumpf          1.82      }
2897                          else
2898                          {
2899 mike           1.126       out << STRLIT("POST ") << requestUri << STRLIT(" HTTP/1.1\r\n");
2900 kumpf          1.82      }
2901 kumpf          1.167     out << STRLIT("HOST: ") << host << STRLIT("\r\n"
2902 marek          1.171                   "Content-Type: application/xml; charset=utf-8\r\n");
2903 kumpf          1.157     OUTPUT_CONTENTLENGTH(out, contentLength);
2904 brian.campbell 1.107 
2905 chuck          1.89      if (acceptLanguages.size() > 0)
2906                          {
2907 kumpf          1.146         out << STRLIT("Accept-Language: ") << acceptLanguages << STRLIT("\r\n");
2908 chuck          1.89      }
2909                          if (contentLanguages.size() > 0)
2910                          {
2911 kumpf          1.146         out << STRLIT("Content-Language: ") << contentLanguages <<
2912                                  STRLIT("\r\n");
2913 david.dillard  1.121     }
2914 brian.campbell 1.107 
2915 brian.campbell 1.113 #ifdef PEGASUS_DEBUG
2916 kumpf          1.146     // backdoor environment variable to turn OFF client requesting transfer
2917                          // encoding. The default is on. to turn off, set this variable to zero.
2918                          // This should be removed when stable. This should only be turned off in
2919                          // a debugging/testing environment.
2920                      
2921                          static const char *clientTransferEncodingOff =
2922                              getenv("PEGASUS_HTTP_TRANSFER_ENCODING_REQUEST");
2923                          if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0')
2924 a.dunfey       1.110 #endif
2925 kumpf          1.146     out << STRLIT("TE: chunked, trailers\r\n");
2926 brian.campbell 1.107 
2927 kumpf          1.82      if (httpMethod == HTTP_METHOD_M_POST)
2928                          {
2929 kumpf          1.146         out << STRLIT("Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");
2930 mike           1.126         out << nn << STRLIT("\r\n");
2931                              out << nn << STRLIT("-CIMExport: MethodRequest\r\n");
2932 kumpf          1.146         out << nn << STRLIT("-CIMExportMethod: ") << cimMethod <<
2933                                  STRLIT("\r\n");
2934 kumpf          1.82      }
2935                          else
2936                          {
2937 kumpf          1.167         out << STRLIT("CIMExport: MethodRequest\r\n"
2938 thilo.boehm    1.162                       "CIMExportMethod: ") << cimMethod << STRLIT("\r\n");
2939 kumpf          1.82      }
2940                      
2941 kumpf          1.27      if (authenticationHeader.size())
2942                          {
2943 mike           1.126         out << authenticationHeader << STRLIT("\r\n");
2944 kumpf          1.27      }
2945 brian.campbell 1.107 
2946 mike           1.126     out << STRLIT("\r\n");
2947 kumpf          1.27  }
2948 mike           1.23  
2949 kumpf          1.27  //------------------------------------------------------------------------------
2950                      //
2951                      // appendEMethodResponseHeader()
2952                      //
2953                      //     Build HTTP response header for export operation.
2954                      //
2955                      //------------------------------------------------------------------------------
2956 mike           1.23  
2957 kumpf          1.27  void XmlWriter::appendEMethodResponseHeader(
2958 mike           1.125     Buffer& out,
2959 kumpf          1.82      HttpMethod httpMethod,
2960 kumpf          1.133     const ContentLanguageList& contentLanguages,
2961 kumpf          1.27      Uint32 contentLength)
2962                      {
2963                          char nn[] = { '0' + (rand() % 10), '0' + (rand() % 10), '\0' };
2964 mike           1.23  
2965 kumpf          1.167     out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n"
2966 marek          1.171                   "Content-Type: application/xml; charset=utf-8\r\n");
2967 kumpf          1.157     OUTPUT_CONTENTLENGTH(out, contentLength);
2968 brian.campbell 1.107 
2969 chuck          1.89      if (contentLanguages.size() > 0)
2970                          {
2971 kumpf          1.146         out << STRLIT("Content-Language: ") << contentLanguages <<
2972                                  STRLIT("\r\n");
2973 david.dillard  1.121     }
2974 kumpf          1.82      if (httpMethod == HTTP_METHOD_M_POST)
2975                          {
2976 kumpf          1.167         out << STRLIT("Ext:\r\n"
2977                                            "Cache-Control: no-cache\r\n"
2978 thilo.boehm    1.162                       "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");
2979 mike           1.126         out << nn << STRLIT("\r\n");
2980                              out << nn << STRLIT("-CIMExport: MethodResponse\r\n\r\n");
2981 kumpf          1.82      }
2982                          else
2983                          {
2984 mike           1.126         out << STRLIT("CIMExport: MethodResponse\r\n\r\n");
2985 kumpf          1.82      }
2986 mike           1.23  }
2987                      
2988                      //------------------------------------------------------------------------------
2989                      //
2990 kumpf          1.29  // _appendSimpleExportReqElementBegin()
2991                      // _appendSimpleExportReqElementEnd()
2992 kumpf          1.27  //
2993                      //     <!ELEMENT SIMPLEEXPREQ (EXPMETHODCALL)>
2994 mike           1.23  //
2995                      //------------------------------------------------------------------------------
2996                      
2997 kumpf          1.29  void XmlWriter::_appendSimpleExportReqElementBegin(
2998 mike           1.125     Buffer& out)
2999 mike           1.23  {
3000 mike           1.126     out << STRLIT("<SIMPLEEXPREQ>\n");
3001 kumpf          1.27  }
3002 mike           1.23  
3003 kumpf          1.29  void XmlWriter::_appendSimpleExportReqElementEnd(
3004 mike           1.125     Buffer& out)
3005 kumpf          1.27  {
3006 mike           1.126     out << STRLIT("</SIMPLEEXPREQ>\n");
3007 mike           1.23  }
3008                      
3009                      //------------------------------------------------------------------------------
3010                      //
3011 kumpf          1.29  // _appendEMethodCallElementBegin()
3012                      // _appendEMethodCallElementEnd()
3013 kumpf          1.27  //
3014                      //     <!ELEMENT EXPMETHODCALL (IPARAMVALUE*)>
3015                      //     <!ATTLIST EXPMETHODCALL %CIMName;>
3016 mike           1.23  //
3017                      //------------------------------------------------------------------------------
3018                      
3019 kumpf          1.29  void XmlWriter::_appendEMethodCallElementBegin(
3020 mike           1.125     Buffer& out,
3021 kumpf          1.80      const CIMName& name)
3022 mike           1.23  {
3023 mike           1.126     out << STRLIT("<EXPMETHODCALL NAME=\"") << name << STRLIT("\">\n");
3024 mike           1.24  }
3025                      
3026 kumpf          1.29  void XmlWriter::_appendEMethodCallElementEnd(
3027 mike           1.125     Buffer& out)
3028 mike           1.24  {
3029 mike           1.126     out << STRLIT("</EXPMETHODCALL>\n");
3030 mike           1.24  }
3031                      
3032                      //------------------------------------------------------------------------------
3033                      //
3034 kumpf          1.85  // _appendEParamValueElementBegin()
3035                      // _appendEParamValueElementEnd()
3036                      //
3037 david.dillard  1.121 //     <!ELEMENT EXPPARAMVALUE (INSTANCE)>
3038                      //     <!ATTLIST EXPPARAMVALUE
3039 kumpf          1.85  //         %CIMName;>
3040                      //
3041                      //------------------------------------------------------------------------------
3042                      
3043                      void XmlWriter::_appendEParamValueElementBegin(
3044 mike           1.125     Buffer& out,
3045 kumpf          1.85      const char* name)
3046                      {
3047 mike           1.126     out << STRLIT("<EXPPARAMVALUE NAME=\"") << name << STRLIT("\">\n");
3048 kumpf          1.85  }
3049                      
3050                      void XmlWriter::_appendEParamValueElementEnd(
3051 mike           1.125     Buffer& out)
3052 kumpf          1.85  {
3053 mike           1.126     out << STRLIT("</EXPPARAMVALUE>\n");
3054 kumpf          1.85  }
3055                      
3056                      //------------------------------------------------------------------------------
3057                      //
3058                      // appendInstanceEParameter()
3059                      //
3060                      //------------------------------------------------------------------------------
3061                      
3062                      void XmlWriter::appendInstanceEParameter(
3063 mike           1.125     Buffer& out,
3064 kumpf          1.85      const char* name,
3065                          const CIMInstance& instance)
3066                      {
3067                          _appendEParamValueElementBegin(out, name);
3068                          appendInstanceElement(out, instance);
3069                          _appendEParamValueElementEnd(out);
3070                      }
3071                      
3072                      //------------------------------------------------------------------------------
3073                      //
3074 kumpf          1.29  // _appendSimpleExportRspElementBegin()
3075                      // _appendSimpleExportRspElementEnd()
3076 mike           1.24  //
3077 kumpf          1.27  //     <!ELEMENT SIMPLEEXPRSP (EXPMETHODRESPONSE)>
3078 mike           1.24  //
3079                      //------------------------------------------------------------------------------
3080                      
3081 kumpf          1.29  void XmlWriter::_appendSimpleExportRspElementBegin(
3082 mike           1.125     Buffer& out)
3083 kumpf          1.27  {
3084 mike           1.126     out << STRLIT("<SIMPLEEXPRSP>\n");
3085 kumpf          1.27  }
3086                      
3087 kumpf          1.29  void XmlWriter::_appendSimpleExportRspElementEnd(
3088 mike           1.125     Buffer& out)
3089 mike           1.24  {
3090 mike           1.126     out << STRLIT("</SIMPLEEXPRSP>\n");
3091 mike           1.24  }
3092                      
3093                      //------------------------------------------------------------------------------
3094                      //
3095 kumpf          1.29  // _appendEMethodResponseElementBegin()
3096                      // _appendEMethodResponseElementEnd()
3097 mike           1.24  //
3098                      //     <!ELEMENT EXPMETHODRESPONSE (ERROR|IRETURNVALUE?)>
3099                      //     <!ATTLIST EXPMETHODRESPONSE %CIMName;>
3100                      //
3101                      //------------------------------------------------------------------------------
3102                      
3103 kumpf          1.29  void XmlWriter::_appendEMethodResponseElementBegin(
3104 mike           1.125     Buffer& out,
3105 kumpf          1.80      const CIMName& name)
3106 mike           1.24  {
3107 mike           1.126     out << STRLIT("<EXPMETHODRESPONSE NAME=\"") << name << STRLIT("\">\n");
3108 kumpf          1.27  }
3109                      
3110 kumpf          1.29  void XmlWriter::_appendEMethodResponseElementEnd(
3111 mike           1.125     Buffer& out)
3112 kumpf          1.27  {
3113 mike           1.126     out << STRLIT("</EXPMETHODRESPONSE>\n");
3114 mike           1.24  }
3115                      
3116                      //------------------------------------------------------------------------------
3117                      //
3118 kumpf          1.27  // XmlWriter::formatSimpleEMethodReqMessage()
3119 mike           1.24  //
3120                      //------------------------------------------------------------------------------
3121                      
3122 mike           1.125 Buffer XmlWriter::formatSimpleEMethodReqMessage(
3123 kumpf          1.50      const char* requestUri,
3124 kumpf          1.27      const char* host,
3125 kumpf          1.80      const CIMName& eMethodName,
3126 kumpf          1.27      const String& messageId,
3127 kumpf          1.82      HttpMethod httpMethod,
3128 kumpf          1.27      const String& authenticationHeader,
3129 kumpf          1.133     const AcceptLanguageList& httpAcceptLanguages,
3130                          const ContentLanguageList& httpContentLanguages,
3131 mike           1.125     const Buffer& body)
3132 mike           1.24  {
3133 mike           1.125     Buffer out;
3134                          Buffer tmp;
3135 kumpf          1.27  
3136 kumpf          1.29      _appendMessageElementBegin(out, messageId);
3137                          _appendSimpleExportReqElementBegin(out);
3138                          _appendEMethodCallElementBegin(out, eMethodName);
3139 kumpf          1.27      out << body;
3140 kumpf          1.29      _appendEMethodCallElementEnd(out);
3141                          _appendSimpleExportReqElementEnd(out);
3142                          _appendMessageElementEnd(out);
3143 kumpf          1.27  
3144                          appendEMethodRequestHeader(
3145                              tmp,
3146 kumpf          1.50          requestUri,
3147 kumpf          1.27          host,
3148                              eMethodName,
3149 kumpf          1.82          httpMethod,
3150 kumpf          1.27          authenticationHeader,
3151 chuck          1.89          httpAcceptLanguages,
3152                              httpContentLanguages,
3153 kumpf          1.148         out.size());
3154 kumpf          1.27      tmp << out;
3155 mike           1.24  
3156 kumpf          1.50      return tmp;
3157 mike           1.24  }
3158                      
3159                      //------------------------------------------------------------------------------
3160                      //
3161 kumpf          1.27  // XmlWriter::formatSimpleEMethodRspMessage()
3162 mike           1.24  //
3163                      //------------------------------------------------------------------------------
3164                      
3165 mike           1.125 Buffer XmlWriter::formatSimpleEMethodRspMessage(
3166 kumpf          1.80      const CIMName& eMethodName,
3167 mike           1.24      const String& messageId,
3168 kumpf          1.82      HttpMethod httpMethod,
3169 kumpf          1.133     const ContentLanguageList& httpContentLanguages,
3170 mike           1.125     const Buffer& body)
3171 mike           1.24  {
3172 mike           1.125     Buffer out;
3173                          Buffer tmp;
3174 kumpf          1.27  
3175 kumpf          1.29      _appendMessageElementBegin(out, messageId);
3176                          _appendSimpleExportRspElementBegin(out);
3177                          _appendEMethodResponseElementBegin(out, eMethodName);
3178 kumpf          1.27      out << body;
3179 kumpf          1.29      _appendEMethodResponseElementEnd(out);
3180                          _appendSimpleExportRspElementEnd(out);
3181                          _appendMessageElementEnd(out);
3182 kumpf          1.28  
3183 david.dillard  1.121     appendEMethodResponseHeader(tmp,
3184 kumpf          1.146         httpMethod,
3185                              httpContentLanguages,
3186 kumpf          1.148         out.size());
3187 kumpf          1.28      tmp << out;
3188                      
3189                          return tmp;
3190                      }
3191                      
3192                      //------------------------------------------------------------------------------
3193                      //
3194                      // XmlWriter::formatSimpleEMethodErrorRspMessage()
3195                      //
3196                      //------------------------------------------------------------------------------
3197                      
3198 mike           1.125 Buffer XmlWriter::formatSimpleEMethodErrorRspMessage(
3199 kumpf          1.80      const CIMName& eMethodName,
3200 kumpf          1.28      const String& messageId,
3201 kumpf          1.82      HttpMethod httpMethod,
3202 kumpf          1.42      const CIMException& cimException)
3203 kumpf          1.28  {
3204 mike           1.125     Buffer out;
3205                          Buffer tmp;
3206 kumpf          1.28  
3207 kumpf          1.29      _appendMessageElementBegin(out, messageId);
3208                          _appendSimpleExportRspElementBegin(out);
3209 kumpf          1.80      _appendEMethodResponseElementBegin(out, eMethodName);
3210 kumpf          1.42      _appendErrorElement(out, cimException);
3211 kumpf          1.29      _appendEMethodResponseElementEnd(out);
3212                          _appendSimpleExportRspElementEnd(out);
3213                          _appendMessageElementEnd(out);
3214 kumpf          1.27  
3215 kumpf          1.146     appendEMethodResponseHeader(
3216                              tmp,
3217                              httpMethod,
3218                              cimException.getContentLanguages(),
3219 kumpf          1.148         out.size());
3220 kumpf          1.27      tmp << out;
3221                      
3222                          return tmp;
3223 mike           1.24  }
3224                      
3225                      //------------------------------------------------------------------------------
3226                      //
3227 kumpf          1.27  // XmlWriter::getNextMessageId()
3228 mike           1.24  //
3229                      //------------------------------------------------------------------------------
3230                      
3231 mike           1.139 static IDFactory _messageIDFactory(1000);
3232                      
3233 kumpf          1.27  String XmlWriter::getNextMessageId()
3234 mike           1.24  {
3235 marek          1.151     char scratchBuffer[22];
3236                          Uint32 n;
3237 kumpf          1.167     const char * startP = Uint32ToString(scratchBuffer,
3238 marek          1.151                                          _messageIDFactory.getID(),
3239                                                               n);
3240                          return String(startP, n);
3241 kumpf          1.68  }
3242                      
3243                      //------------------------------------------------------------------------------
3244                      //
3245                      // XmlWriter::keyBindingTypeToString
3246                      //
3247                      //------------------------------------------------------------------------------
3248 thilo.boehm    1.162 const StrLit XmlWriter::keyBindingTypeToString (CIMKeyBinding::Type type)
3249 kumpf          1.68  {
3250                          switch (type)
3251                          {
3252 kumpf          1.79          case CIMKeyBinding::BOOLEAN:
3253 thilo.boehm    1.162             return STRLIT("boolean");
3254 kumpf          1.68  
3255 kumpf          1.79          case CIMKeyBinding::STRING:
3256 thilo.boehm    1.162             return STRLIT("string");
3257 kumpf          1.68  
3258 kumpf          1.79          case CIMKeyBinding::NUMERIC:
3259 thilo.boehm    1.162             return STRLIT("numeric");
3260 kumpf          1.68  
3261 kumpf          1.79          case CIMKeyBinding::REFERENCE:
3262 kumpf          1.68          default:
3263                                  PEGASUS_ASSERT(false);
3264                          }
3265                      
3266 thilo.boehm    1.162     return STRLIT("unknown");
3267 mike           1.23  }
3268                      
3269                      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2