(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 dl.meetei     1.175                 PEGASUS_UNREACHABLE(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 dl.meetei     1.175                 PEGASUS_UNREACHABLE(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 ashok.pathak   1.177     char nn[] = { char('0' + (rand() % 10)), char('0' + (rand() % 10)),'\0'};
1778 mike           1.23  
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 ashok.pathak   1.177          char nn[] = {char('0'+(rand() % 10)),char('0' + (rand() % 10)),'\0'};
1930 mike           1.164 
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 marek          1.176 //        PGErrorDetail: <error text>    (if specified by caller)
1987 s.kodali       1.161 //        WWW-Authenticate: Basic realm="HostName"
1988 kumpf          1.27  //        <HTML><HEAD>
1989                      //        <TITLE>401 Unauthorized</TITLE>
1990                      //        </HEAD><BODY BGCOLOR="#99cc99">
1991                      //        <H2>TEST401 Unauthorized</H2>
1992                      //        <HR>
1993                      //        </BODY></HTML>
1994                      //
1995                      //------------------------------------------------------------------------------
1996                      
1997                      void XmlWriter::appendUnauthorizedResponseHeader(
1998 mike           1.125     Buffer& out,
1999 marek          1.176     const String& errorDetail,
2000 kumpf          1.27      const String& content)
2001                      {
2002 mike           1.126     out << STRLIT("HTTP/1.1 " HTTP_STATUS_UNAUTHORIZED "\r\n");
2003 marek          1.176     if (errorDetail.size() > 0)
2004                          {
2005                              out << STRLIT(PEGASUS_HTTPHEADERTAG_ERRORDETAIL ": ")
2006                                  << encodeURICharacters(errorDetail) << STRLIT("\r\n");
2007                          }
2008                      
2009 kumpf          1.157     OUTPUT_CONTENTLENGTH(out, 0);
2010 thilo.boehm    1.162     out << content << STRLIT("\r\n\r\n");
2011 kumpf          1.27  
2012                      //ATTN: We may need to include the following line, so that the browsers
2013                      //      can display the error message.
2014                      //    out << "<HTML><HEAD>\r\n";
2015                      //    out << "<TITLE>" << "401 Unauthorized" <<  "</TITLE>\r\n";
2016                      //    out << "</HEAD><BODY BGCOLOR=\"#99cc99\">\r\n";
2017                      //    out << "<H2>TEST" << "401 Unauthorized" << "</H2>\r\n";
2018                      //    out << "<HR>\r\n";
2019                      //    out << "</BODY></HTML>\r\n";
2020                      }
2021                      
2022 gerarda        1.90  
2023 kumpf          1.27  //------------------------------------------------------------------------------
2024                      //
2025 kumpf          1.29  // _appendMessageElementBegin()
2026                      // _appendMessageElementEnd()
2027 mike           1.23  //
2028                      //     <!ELEMENT MESSAGE (SIMPLEREQ|MULTIREQ|SIMPLERSP|MULTIRSP)>
2029                      //     <!ATTLIST MESSAGE
2030                      //         ID CDATA #REQUIRED
2031                      //         PROTOCOLVERSION CDATA #REQUIRED>
2032                      //
2033                      //------------------------------------------------------------------------------
2034                      
2035 kumpf          1.29  void XmlWriter::_appendMessageElementBegin(
2036 mike           1.125     Buffer& out,
2037 kumpf          1.27      const String& messageId)
2038 mike           1.23  {
2039 kumpf          1.167     out << STRLIT("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
2040                                        "<CIM CIMVERSION=\"2.0\" DTDVERSION=\"2.0\">\n"
2041 thilo.boehm    1.162                   "<MESSAGE ID=\"") << messageId;
2042 mike           1.126     out << STRLIT("\" PROTOCOLVERSION=\"1.0\">\n");
2043 kumpf          1.27  }
2044                      
2045 kumpf          1.29  void XmlWriter::_appendMessageElementEnd(
2046 mike           1.125     Buffer& out)
2047 kumpf          1.27  {
2048 thilo.boehm    1.162     out << STRLIT("</MESSAGE>\n</CIM>\n");
2049 mike           1.23  }
2050                      
2051                      //------------------------------------------------------------------------------
2052                      //
2053 kumpf          1.29  // _appendSimpleReqElementBegin()
2054                      // _appendSimpleReqElementEnd()
2055 mike           1.23  //
2056                      //     <!ELEMENT SIMPLEREQ (IMETHODCALL|METHODCALL)>
2057                      //
2058                      //------------------------------------------------------------------------------
2059                      
2060 kumpf          1.29  void XmlWriter::_appendSimpleReqElementBegin(
2061 mike           1.125     Buffer& out)
2062 kumpf          1.27  {
2063 mike           1.126     out << STRLIT("<SIMPLEREQ>\n");
2064 kumpf          1.27  }
2065                      
2066 kumpf          1.29  void XmlWriter::_appendSimpleReqElementEnd(
2067 mike           1.125     Buffer& out)
2068 mike           1.23  {
2069 mike           1.126     out << STRLIT("</SIMPLEREQ>\n");
2070 mike           1.23  }
2071                      
2072                      //------------------------------------------------------------------------------
2073                      //
2074 kumpf          1.29  // _appendMethodCallElementBegin()
2075                      // _appendMethodCallElementEnd()
2076 mike           1.23  //
2077 kumpf          1.27  //     <!ELEMENT METHODCALL ((LOCALCLASSPATH|LOCALINSTANCEPATH),PARAMVALUE*)>
2078                      //     <!ATTLIST METHODCALL %CIMName;>
2079 mike           1.23  //
2080                      //------------------------------------------------------------------------------
2081                      
2082 kumpf          1.29  void XmlWriter::_appendMethodCallElementBegin(
2083 mike           1.125     Buffer& out,
2084 kumpf          1.80      const CIMName& name)
2085 kumpf          1.27  {
2086 mike           1.126     out << STRLIT("<METHODCALL NAME=\"") << name << STRLIT("\">\n");
2087 kumpf          1.27  }
2088                      
2089 kumpf          1.29  void XmlWriter::_appendMethodCallElementEnd(
2090 mike           1.125     Buffer& out)
2091 mike           1.23  {
2092 mike           1.126     out << STRLIT("</METHODCALL>\n");
2093 mike           1.23  }
2094                      
2095                      //------------------------------------------------------------------------------
2096                      //
2097 kumpf          1.29  // _appendIMethodCallElementBegin()
2098                      // _appendIMethodCallElementEnd()
2099 mike           1.23  //
2100                      //     <!ELEMENT IMETHODCALL (LOCALNAMESPACEPATH,IPARAMVALUE*)>
2101                      //     <!ATTLIST IMETHODCALL %CIMName;>
2102                      //
2103                      //------------------------------------------------------------------------------
2104                      
2105 kumpf          1.29  void XmlWriter::_appendIMethodCallElementBegin(
2106 mike           1.125     Buffer& out,
2107 kumpf          1.80      const CIMName& name)
2108 mike           1.23  {
2109 mike           1.126     out << STRLIT("<IMETHODCALL NAME=\"") << name << STRLIT("\">\n");
2110 kumpf          1.27  }
2111                      
2112 kumpf          1.29  void XmlWriter::_appendIMethodCallElementEnd(
2113 mike           1.125     Buffer& out)
2114 kumpf          1.27  {
2115 mike           1.126     out << STRLIT("</IMETHODCALL>\n");
2116 mike           1.23  }
2117                      
2118                      //------------------------------------------------------------------------------
2119                      //
2120 kumpf          1.29  // _appendIParamValueElementBegin()
2121                      // _appendIParamValueElementEnd()
2122 mike           1.23  //
2123 kumpf          1.27  //     <!ELEMENT IPARAMVALUE (VALUE|VALUE.ARRAY|VALUE.REFERENCE
2124                      //         |INSTANCENAME|CLASSNAME|QUALIFIER.DECLARATION
2125                      //         |CLASS|INSTANCE|VALUE.NAMEDINSTANCE)?>
2126                      //     <!ATTLIST IPARAMVALUE %CIMName;>
2127 mike           1.23  //
2128                      //------------------------------------------------------------------------------
2129                      
2130 kumpf          1.29  void XmlWriter::_appendIParamValueElementBegin(
2131 mike           1.125     Buffer& out,
2132 kumpf          1.27      const char* name)
2133                      {
2134 mike           1.126     out << STRLIT("<IPARAMVALUE NAME=\"") << name << STRLIT("\">\n");
2135 kumpf          1.27  }
2136                      
2137 kumpf          1.29  void XmlWriter::_appendIParamValueElementEnd(
2138 mike           1.125     Buffer& out)
2139 mike           1.23  {
2140 mike           1.126     out << STRLIT("</IPARAMVALUE>\n");
2141 mike           1.23  }
2142                      
2143                      //------------------------------------------------------------------------------
2144                      //
2145 kumpf          1.29  // _appendSimpleRspElementBegin()
2146                      // _appendSimpleRspElementEnd()
2147 mike           1.23  //
2148 kumpf          1.27  //     <!ELEMENT SIMPLERSP (METHODRESPONSE|IMETHODRESPONSE)>
2149 mike           1.23  //
2150                      //------------------------------------------------------------------------------
2151                      
2152 kumpf          1.29  void XmlWriter::_appendSimpleRspElementBegin(
2153 mike           1.125     Buffer& out)
2154 kumpf          1.27  {
2155 mike           1.126     out << STRLIT("<SIMPLERSP>\n");
2156 kumpf          1.27  }
2157                      
2158 kumpf          1.29  void XmlWriter::_appendSimpleRspElementEnd(
2159 mike           1.125     Buffer& out)
2160 mike           1.23  {
2161 mike           1.126     out << STRLIT("</SIMPLERSP>\n");
2162 mike           1.23  }
2163                      
2164                      //------------------------------------------------------------------------------
2165                      //
2166 kumpf          1.29  // _appendMethodResponseElementBegin()
2167                      // _appendMethodResponseElementEnd()
2168 mike           1.23  //
2169 kumpf          1.27  //     <!ELEMENT METHODRESPONSE (ERROR|IRETURNVALUE?)>
2170                      //     <!ATTLIST METHODRESPONSE %CIMName;>
2171 mike           1.23  //
2172                      //------------------------------------------------------------------------------
2173                      
2174 kumpf          1.29  void XmlWriter::_appendMethodResponseElementBegin(
2175 mike           1.125     Buffer& out,
2176 kumpf          1.80      const CIMName& name)
2177 kumpf          1.27  {
2178 mike           1.126     out << STRLIT("<METHODRESPONSE NAME=\"") << name << STRLIT("\">\n");
2179 kumpf          1.27  }
2180                      
2181 kumpf          1.29  void XmlWriter::_appendMethodResponseElementEnd(
2182 mike           1.125     Buffer& out)
2183 mike           1.23  {
2184 mike           1.126     out << STRLIT("</METHODRESPONSE>\n");
2185 kumpf          1.27  }
2186                      
2187                      //------------------------------------------------------------------------------
2188                      //
2189 kumpf          1.29  // _appendIMethodResponseElementBegin()
2190                      // _appendIMethodResponseElementEnd()
2191 kumpf          1.27  //
2192                      //     <!ELEMENT IMETHODRESPONSE (ERROR|IRETURNVALUE?)>
2193                      //     <!ATTLIST IMETHODRESPONSE %CIMName;>
2194                      //
2195                      //------------------------------------------------------------------------------
2196                      
2197 kumpf          1.29  void XmlWriter::_appendIMethodResponseElementBegin(
2198 mike           1.125     Buffer& out,
2199 kumpf          1.80      const CIMName& name)
2200 kumpf          1.27  {
2201 mike           1.126     out << STRLIT("<IMETHODRESPONSE NAME=\"") << name << STRLIT("\">\n");
2202 kumpf          1.27  }
2203                      
2204 kumpf          1.29  void XmlWriter::_appendIMethodResponseElementEnd(
2205 mike           1.125     Buffer& out)
2206 kumpf          1.27  {
2207 mike           1.126     out << STRLIT("</IMETHODRESPONSE>\n");
2208 mike           1.23  }
2209                      
2210                      //------------------------------------------------------------------------------
2211                      //
2212 kumpf          1.29  // _appendErrorElement()
2213 mike           1.23  //
2214                      //------------------------------------------------------------------------------
2215                      
2216 kumpf          1.29  void XmlWriter::_appendErrorElement(
2217 mike           1.125     Buffer& out,
2218 kumpf          1.42      const CIMException& cimException)
2219 mike           1.23  {
2220 thilo.boehm    1.163     Tracer::traceCIMException(TRC_XML, Tracer::LEVEL2, cimException);
2221 kumpf          1.44  
2222 thilo.boehm    1.162     out << STRLIT("<ERROR CODE=\"") << Uint32(cimException.getCode());
2223 karl           1.145     out.append('"');
2224 karl           1.142 
2225 kumpf          1.71      String description = TraceableCIMException(cimException).getDescription();
2226 karl           1.145 
2227 kumpf          1.51      if (description != String::EMPTY)
2228 kumpf          1.42      {
2229 mike           1.126         out << STRLIT(" DESCRIPTION=\"");
2230 kumpf          1.51          appendSpecial(out, description);
2231 kumpf          1.146         out.append('"');
2232 kumpf          1.42      }
2233 karl           1.142 
2234 karl           1.145     if (cimException.getErrorCount())
2235 karl           1.142     {
2236 karl           1.145         out << STRLIT(">");
2237                      
2238                              for (Uint32 i = 0, n = cimException.getErrorCount(); i < n; i++)
2239                                  appendInstanceElement(out, cimException.getError(i));
2240                      
2241                              out << STRLIT("</ERROR>");
2242 karl           1.142     }
2243 karl           1.145     else
2244                              out << STRLIT("/>");
2245 mike           1.23  }
2246                      
2247 kumpf          1.157 //----------------------------------------------------------------------
2248                      //
2249                      // appendParamTypeAndEmbeddedObjAttrib
2250                      // Appends the Param type and EmbeddedObject Info to the buffer
2251                      //     %EmbeddedObject; #IMPLIED
2252                      //     %ParamType;>
2253                      //
2254 karl           1.154 //---------------------------------------------------------------------
2255 kumpf          1.157 
2256 karl           1.154 void XmlWriter::appendParamTypeAndEmbeddedObjAttrib(
2257 mike           1.125     Buffer& out,
2258 karl           1.154     const CIMType& type)
2259 kumpf          1.27  {
2260                      
2261 david.dillard  1.121     // If the property type is CIMObject, then
2262 karl           1.154     //   encode the property in CIM-XML as a string with the EmbeddedObject
2263                          //   attribute (there is not currently a CIM-XML "object"
2264                          //   datatype).
2265                          //   Because of an error in Pegasus we were earlier outputting
2266                          //   upper case "EMBEDDEDOBJECT" as the attribute name. The
2267                          //   spec calls for mixed case "EmbeddedObject. Fixed in
2268                          //   bug 7131 to output EmbeddedObject  attribute in upper
2269                          //   case and mixed case. Receiver will ignore one or the
2270                          //   other.
2271                          //else
2272                          //      output the real type
2273 dave.sudlik    1.117     if (type == CIMTYPE_OBJECT)
2274                          {
2275 karl           1.154 
2276 kumpf          1.167         out << STRLIT(" PARAMTYPE=\"string\""
2277                                            " EmbeddedObject=\"object\""
2278 thilo.boehm    1.162                       " EMBEDDEDOBJECT=\"object\"");
2279 dave.sudlik    1.117     }
2280 a.dunfey       1.137     else if (type == CIMTYPE_INSTANCE)
2281                          {
2282 thilo.boehm    1.162         out << STRLIT(" PARAMTYPE=\"string\""
2283 kumpf          1.167                       " EmbeddedObject=\"instance\""
2284 thilo.boehm    1.162                       " EMBEDDEDOBJECT=\"instance\"");
2285 a.dunfey       1.137     }
2286 dave.sudlik    1.117     else
2287                          {
2288 thilo.boehm    1.169         out << STRLIT(" PARAM") << xmlWriterTypeStrings(type);
2289 dave.sudlik    1.117     }
2290 karl           1.154 }
2291                      
2292                      //------------------------------------------------------------------------------
2293                      //
2294                      // appendReturnValueElement()
2295                      //
2296                      // <!ELEMENT RETURNVALUE (VALUE|VALUE.REFERENCE)>
2297                      // <!ATTLIST RETURNVALUE
2298                      //     %EmbeddedObject; #IMPLIED
2299                      //     %ParamType;>
2300                      //
2301                      //------------------------------------------------------------------------------
2302                      
2303                      void XmlWriter::appendReturnValueElement(
2304                          Buffer& out,
2305                          const CIMValue& value)
2306                      {
2307                          out << STRLIT("<RETURNVALUE");
2308                      
2309                          CIMType type = value.getType();
2310                      
2311 karl           1.154     appendParamTypeAndEmbeddedObjAttrib(out, type);
2312 kumpf          1.27  
2313 mike           1.126     out << STRLIT(">\n");
2314 karl           1.37  
2315 kumpf          1.54      // Add value.
2316                          appendValueElement(out, value);
2317 mike           1.126     out << STRLIT("</RETURNVALUE>\n");
2318 kumpf          1.27  }
2319                      
2320                      //------------------------------------------------------------------------------
2321                      //
2322 kumpf          1.29  // _appendIReturnValueElementBegin()
2323                      // _appendIReturnValueElementEnd()
2324 kumpf          1.27  //
2325                      //      <!ELEMENT IRETURNVALUE (CLASSNAME*|INSTANCENAME*|VALUE*|
2326                      //          VALUE.OBJECTWITHPATH*|VALUE.OBJECTWITHLOCALPATH*|VALUE.OBJECT*|
2327                      //          OBJECTPATH*|QUALIFIER.DECLARATION*|VALUE.ARRAY?|VALUE.REFERENCE?|
2328                      //          CLASS*|INSTANCE*|VALUE.NAMEDINSTANCE*)>
2329                      //
2330                      //------------------------------------------------------------------------------
2331                      
2332 kumpf          1.29  void XmlWriter::_appendIReturnValueElementBegin(
2333 mike           1.125     Buffer& out)
2334 kumpf          1.27  {
2335 mike           1.126     out << STRLIT("<IRETURNVALUE>\n");
2336 kumpf          1.27  }
2337                      
2338 kumpf          1.29  void XmlWriter::_appendIReturnValueElementEnd(
2339 mike           1.125     Buffer& out)
2340 mike           1.23  {
2341 mike           1.126     out << STRLIT("</IRETURNVALUE>\n");
2342 mike           1.23  }
2343                      
2344                      //------------------------------------------------------------------------------
2345                      //
2346 kumpf          1.27  // appendBooleanIParameter()
2347 mike           1.23  //
2348                      //------------------------------------------------------------------------------
2349                      
2350 kumpf          1.27  void XmlWriter::appendBooleanIParameter(
2351 mike           1.125     Buffer& out,
2352 mike           1.23      const char* name,
2353 kumpf          1.27      Boolean flag)
2354 mike           1.23  {
2355 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2356 mike           1.126     out << STRLIT("<VALUE>");
2357 kumpf          1.54      append(out, flag);
2358 mike           1.126     out << STRLIT("</VALUE>\n");
2359 kumpf          1.29      _appendIParamValueElementEnd(out);
2360 mike           1.23  }
2361                      
2362                      //------------------------------------------------------------------------------
2363                      //
2364 kumpf          1.27  // appendStringIParameter()
2365 mike           1.23  //
2366                      //------------------------------------------------------------------------------
2367                      
2368 kumpf          1.27  void XmlWriter::appendStringIParameter(
2369 mike           1.125     Buffer& out,
2370 mike           1.23      const char* name,
2371 kumpf          1.27      const String& str)
2372 mike           1.23  {
2373 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2374 mike           1.126     out << STRLIT("<VALUE>");
2375 kumpf          1.27      appendSpecial(out, str);
2376 mike           1.126     out << STRLIT("</VALUE>\n");
2377 kumpf          1.29      _appendIParamValueElementEnd(out);
2378 mike           1.23  }
2379                      
2380                      //------------------------------------------------------------------------------
2381                      //
2382 kumpf          1.27  // appendClassNameIParameter()
2383 mike           1.23  //
2384                      //------------------------------------------------------------------------------
2385                      
2386 kumpf          1.27  void XmlWriter::appendClassNameIParameter(
2387 mike           1.125     Buffer& out,
2388 kumpf          1.27      const char* name,
2389 kumpf          1.80      const CIMName& className)
2390 mike           1.23  {
2391 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2392 kumpf          1.83  
2393                          //
2394 david.dillard  1.121     //  A NULL (unassigned) value for a parameter is specified by an
2395 kumpf          1.83      //  <IPARAMVALUE> element with no subelement
2396                          //
2397                          if (!className.isNull ())
2398                          {
2399                              appendClassNameElement(out, className);
2400                          }
2401                      
2402 kumpf          1.29      _appendIParamValueElementEnd(out);
2403 mike           1.23  }
2404                      
2405                      //------------------------------------------------------------------------------
2406                      //
2407 kumpf          1.27  // appendInstanceNameIParameter()
2408 mike           1.23  //
2409                      //------------------------------------------------------------------------------
2410                      
2411 kumpf          1.27  void XmlWriter::appendInstanceNameIParameter(
2412 mike           1.125     Buffer& out,
2413 kumpf          1.27      const char* name,
2414 kumpf          1.59      const CIMObjectPath& instanceName)
2415 mike           1.23  {
2416 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2417                          appendInstanceNameElement(out, instanceName);
2418                          _appendIParamValueElementEnd(out);
2419 kumpf          1.27  }
2420                      
2421                      //------------------------------------------------------------------------------
2422                      //
2423                      // appendClassIParameter()
2424                      //
2425                      //------------------------------------------------------------------------------
2426                      
2427                      void XmlWriter::appendClassIParameter(
2428 mike           1.125     Buffer& out,
2429 kumpf          1.27      const char* name,
2430                          const CIMConstClass& cimClass)
2431                      {
2432 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2433 kumpf          1.55      appendClassElement(out, cimClass);
2434 kumpf          1.29      _appendIParamValueElementEnd(out);
2435 mike           1.23  }
2436                      
2437                      //------------------------------------------------------------------------------
2438                      //
2439 kumpf          1.27  // appendInstanceIParameter()
2440 mike           1.23  //
2441                      //------------------------------------------------------------------------------
2442                      
2443 kumpf          1.27  void XmlWriter::appendInstanceIParameter(
2444 mike           1.125     Buffer& out,
2445 kumpf          1.27      const char* name,
2446 mike           1.23      const CIMConstInstance& instance)
2447                      {
2448 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2449 kumpf          1.55      appendInstanceElement(out, instance);
2450 kumpf          1.29      _appendIParamValueElementEnd(out);
2451 mike           1.23  }
2452                      
2453 mike           1.24  //------------------------------------------------------------------------------
2454                      //
2455 kumpf          1.27  // appendNamedInstanceIParameter()
2456 mike           1.24  //
2457                      //------------------------------------------------------------------------------
2458                      
2459 kumpf          1.27  void XmlWriter::appendNamedInstanceIParameter(
2460 mike           1.125     Buffer& out,
2461 kumpf          1.27      const char* name,
2462 kumpf          1.61      const CIMInstance& namedInstance)
2463 mike           1.24  {
2464 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2465 kumpf          1.56      appendValueNamedInstanceElement(out, namedInstance);
2466 kumpf          1.29      _appendIParamValueElementEnd(out);
2467 mike           1.24  }
2468                      
2469 mike           1.23  //----------------------------------------------------------
2470                      //
2471 kumpf          1.27  //  appendPropertyNameIParameter()
2472 david.dillard  1.121 //
2473 mike           1.23  //     </IPARAMVALUE>
2474                      //     <IPARAMVALUE NAME="PropertyName"><VALUE>FreeSpace</VALUE></IPARAMVALUE>
2475                      //
2476                      //     USE: Create parameter for getProperty operation
2477 brian.campbell 1.113 //==========================================================
2478 kumpf          1.27  void XmlWriter::appendPropertyNameIParameter(
2479 mike           1.125     Buffer& out,
2480 kumpf          1.80      const CIMName& propertyName)
2481 mike           1.23  {
2482 kumpf          1.29      _appendIParamValueElementBegin(out, "PropertyName");
2483 mike           1.126     out << STRLIT("<VALUE>") << propertyName << STRLIT("</VALUE>\n");
2484 kumpf          1.29      _appendIParamValueElementEnd(out);
2485 kumpf          1.27  }
2486 mike           1.23  
2487                      //------------------------------------------------------------------------------
2488                      //
2489 kumpf          1.27  // appendPropertyValueIParameter()
2490 mike           1.24  //
2491                      //------------------------------------------------------------------------------
2492                      
2493 kumpf          1.27  void XmlWriter::appendPropertyValueIParameter(
2494 mike           1.125     Buffer& out,
2495 kumpf          1.27      const char* name,
2496 mike           1.24      const CIMValue& value)
2497                      {
2498 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2499 kumpf          1.54      appendValueElement(out, value);
2500 kumpf          1.29      _appendIParamValueElementEnd(out);
2501 mike           1.24  }
2502                      
2503                      //------------------------------------------------------------------------------
2504                      //
2505 kumpf          1.27  // appendPropertyListIParameter()
2506 mike           1.24  //
2507                      //------------------------------------------------------------------------------
2508                      
2509 kumpf          1.27  void XmlWriter::appendPropertyListIParameter(
2510 mike           1.125     Buffer& out,
2511 mike           1.24      const CIMPropertyList& propertyList)
2512                      {
2513 kumpf          1.29      _appendIParamValueElementBegin(out, "PropertyList");
2514 mike           1.24  
2515 kumpf          1.83      //
2516 david.dillard  1.121     //  A NULL (unassigned) value for a parameter is specified by an
2517 kumpf          1.83      //  <IPARAMVALUE> element with no subelement
2518                          //
2519                          if (!propertyList.isNull ())
2520 mike           1.24      {
2521 mike           1.126         out << STRLIT("<VALUE.ARRAY>\n");
2522 kumpf          1.83          for (Uint32 i = 0; i < propertyList.size(); i++)
2523                              {
2524 mike           1.126             out << STRLIT("<VALUE>") << propertyList[i] << STRLIT("</VALUE>\n");
2525 kumpf          1.83          }
2526 mike           1.126         out << STRLIT("</VALUE.ARRAY>\n");
2527 mike           1.24      }
2528 kumpf          1.27  
2529 kumpf          1.29      _appendIParamValueElementEnd(out);
2530 mike           1.24  }
2531                      
2532                      //------------------------------------------------------------------------------
2533                      //
2534 kumpf          1.27  // appendQualifierDeclarationIParameter()
2535 mike           1.23  //
2536                      //------------------------------------------------------------------------------
2537                      
2538 kumpf          1.27  void XmlWriter::appendQualifierDeclarationIParameter(
2539 mike           1.125     Buffer& out,
2540 kumpf          1.27      const char* name,
2541 mike           1.23      const CIMConstQualifierDecl& qualifierDecl)
2542                      {
2543 kumpf          1.29      _appendIParamValueElementBegin(out, name);
2544 kumpf          1.56      appendQualifierDeclElement(out, qualifierDecl);
2545 kumpf          1.29      _appendIParamValueElementEnd(out);
2546 kumpf          1.40  }
2547                      
2548                      //------------------------------------------------------------------------------
2549                      //
2550                      // XmlWriter::formatHttpErrorRspMessage()
2551                      //
2552                      //------------------------------------------------------------------------------
2553                      
2554 mike           1.125 Buffer XmlWriter::formatHttpErrorRspMessage(
2555 kumpf          1.40      const String& status,
2556                          const String& cimError,
2557 kumpf          1.41      const String& errorDetail)
2558 kumpf          1.40  {
2559 mike           1.125     Buffer out;
2560 kumpf          1.40  
2561 kumpf          1.41      appendHttpErrorResponseHeader(out, status, cimError, errorDetail);
2562 kumpf          1.40  
2563 kumpf          1.41      return out;
2564 mike           1.23  }
2565                      
2566 chuck          1.89  // l10n - add content language support to the format methods below
2567                      
2568 mike           1.23  //------------------------------------------------------------------------------
2569                      //
2570 kumpf          1.27  // XmlWriter::formatSimpleMethodReqMessage()
2571 mike           1.23  //
2572                      //------------------------------------------------------------------------------
2573                      
2574 kumpf          1.27  // ATTN-RK-P1-20020228: Need to complete copy elimination optimization
2575 mike           1.125 Buffer XmlWriter::formatSimpleMethodReqMessage(
2576 kumpf          1.27      const char* host,
2577 kumpf          1.80      const CIMNamespaceName& nameSpace,
2578 kumpf          1.59      const CIMObjectPath& path,
2579 kumpf          1.80      const CIMName& methodName,
2580 kumpf          1.30      const Array<CIMParamValue>& parameters,
2581 kumpf          1.27      const String& messageId,
2582 kumpf          1.82      HttpMethod httpMethod,
2583 chuck          1.89      const String& authenticationHeader,
2584 kumpf          1.133     const AcceptLanguageList& httpAcceptLanguages,
2585 mike           1.164     const ContentLanguageList& httpContentLanguages,
2586                          bool binaryResponse)
2587 kumpf          1.27  {
2588 mike           1.125     Buffer out;
2589                          Buffer tmp;
2590 kumpf          1.59      CIMObjectPath localObjectPath = path;
2591 kumpf          1.80      localObjectPath.setNameSpace(nameSpace.getString());
2592 kumpf          1.77      localObjectPath.setHost(String::EMPTY);
2593 kumpf          1.27  
2594 kumpf          1.29      _appendMessageElementBegin(out, messageId);
2595                          _appendSimpleReqElementBegin(out);
2596                          _appendMethodCallElementBegin(out, methodName);
2597 kumpf          1.38      appendLocalObjectPathElement(out, localObjectPath);
2598 kumpf          1.30      for (Uint32 i=0; i < parameters.size(); i++)
2599 kumpf          1.29      {
2600 kumpf          1.56          appendParamValueElement(out, parameters[i]);
2601 kumpf          1.29      }
2602                          _appendMethodCallElementEnd(out);
2603                          _appendSimpleReqElementEnd(out);
2604                          _appendMessageElementEnd(out);
2605 kumpf          1.27  
2606                          appendMethodCallHeader(
2607 kumpf          1.146         tmp,
2608                              host,
2609                              methodName,
2610                              localObjectPath.toString(),
2611 kumpf          1.27          authenticationHeader,
2612 kumpf          1.82          httpMethod,
2613 chuck          1.89          httpAcceptLanguages,
2614                              httpContentLanguages,
2615 mike           1.164         out.size(),
2616                              false,
2617                              binaryResponse);
2618 kumpf          1.27      tmp << out;
2619                      
2620                          return tmp;
2621                      }
2622                      
2623 mike           1.125 Buffer XmlWriter::formatSimpleMethodRspMessage(
2624 w.white        1.108     const CIMName& methodName,
2625                          const String& messageId,
2626                          HttpMethod httpMethod,
2627 kumpf          1.133     const ContentLanguageList& httpContentLanguages,
2628 mike           1.125     const Buffer& body,
2629 kumpf          1.146     Uint64 serverResponseTime,
2630                          Boolean isFirst,
2631                          Boolean isLast)
2632                      {
2633                          Buffer out;
2634                      
2635                          if (isFirst == true)
2636                          {
2637                              // NOTE: temporarily put zero for content length. the http code
2638                              // will later decide to fill in the length or remove it altogether
2639                              appendMethodResponseHeader(
2640                                  out, httpMethod, httpContentLanguages, 0, serverResponseTime);
2641                              _appendMessageElementBegin(out, messageId);
2642                              _appendSimpleRspElementBegin(out);
2643                              _appendMethodResponseElementBegin(out, methodName);
2644                          }
2645                      
2646                          if (body.size() != 0)
2647                          {
2648                              out << body;
2649                          }
2650 kumpf          1.146 
2651                          if (isLast == true)
2652                          {
2653                              _appendMethodResponseElementEnd(out);
2654                              _appendSimpleRspElementEnd(out);
2655                              _appendMessageElementEnd(out);
2656                          }
2657 david.dillard  1.121 
2658 kumpf          1.146     return out;
2659 w.white        1.108 }
2660                      
2661                      
2662 mike           1.23  //------------------------------------------------------------------------------
2663                      //
2664 kumpf          1.28  // XmlWriter::formatSimpleMethodErrorRspMessage()
2665                      //
2666                      //------------------------------------------------------------------------------
2667                      
2668 mike           1.125 Buffer XmlWriter::formatSimpleMethodErrorRspMessage(
2669 kumpf          1.80      const CIMName& methodName,
2670 kumpf          1.28      const String& messageId,
2671 kumpf          1.82      HttpMethod httpMethod,
2672 kumpf          1.42      const CIMException& cimException)
2673 kumpf          1.28  {
2674 mike           1.125     Buffer out;
2675                          Buffer tmp;
2676 kumpf          1.28  
2677 kumpf          1.29      _appendMessageElementBegin(out, messageId);
2678                          _appendSimpleRspElementBegin(out);
2679 kumpf          1.80      _appendMethodResponseElementBegin(out, methodName);
2680 kumpf          1.42      _appendErrorElement(out, cimException);
2681 kumpf          1.29      _appendMethodResponseElementEnd(out);
2682                          _appendSimpleRspElementEnd(out);
2683                          _appendMessageElementEnd(out);
2684 kumpf          1.28  
2685 kumpf          1.146     appendMethodResponseHeader(
2686                              tmp,
2687                              httpMethod,
2688                              cimException.getContentLanguages(),
2689 mike           1.164         out.size(),
2690                              false);
2691 kumpf          1.28      tmp << out;
2692                      
2693                          return tmp;
2694                      }
2695                      
2696                      //------------------------------------------------------------------------------
2697                      //
2698 kumpf          1.27  // XmlWriter::formatSimpleIMethodReqMessage()
2699 mike           1.23  //
2700                      //------------------------------------------------------------------------------
2701                      
2702 mike           1.125 Buffer XmlWriter::formatSimpleIMethodReqMessage(
2703 kumpf          1.27      const char* host,
2704 kumpf          1.80      const CIMNamespaceName& nameSpace,
2705                          const CIMName& iMethodName,
2706 kumpf          1.27      const String& messageId,
2707 kumpf          1.82      HttpMethod httpMethod,
2708 kumpf          1.27      const String& authenticationHeader,
2709 kumpf          1.133     const AcceptLanguageList& httpAcceptLanguages,
2710                          const ContentLanguageList& httpContentLanguages,
2711 mike           1.164     const Buffer& body,
2712                          bool binaryResponse)
2713 mike           1.23  {
2714 mike           1.125     Buffer out;
2715                          Buffer tmp;
2716 kumpf          1.27  
2717 kumpf          1.29      _appendMessageElementBegin(out, messageId);
2718                          _appendSimpleReqElementBegin(out);
2719                          _appendIMethodCallElementBegin(out, iMethodName);
2720 kumpf          1.80      appendLocalNameSpacePathElement(out, nameSpace.getString());
2721 kumpf          1.27      out << body;
2722 kumpf          1.29      _appendIMethodCallElementEnd(out);
2723                          _appendSimpleReqElementEnd(out);
2724                          _appendMessageElementEnd(out);
2725 kumpf          1.27  
2726                          appendMethodCallHeader(
2727 kumpf          1.146         tmp,
2728                              host,
2729                              iMethodName,
2730                              nameSpace.getString(),
2731 kumpf          1.27          authenticationHeader,
2732 kumpf          1.82          httpMethod,
2733 chuck          1.89          httpAcceptLanguages,
2734                              httpContentLanguages,
2735 kumpf          1.167         out.size(),
2736 mike           1.164         false,
2737                              binaryResponse);
2738 kumpf          1.27      tmp << out;
2739 mike           1.23  
2740 kumpf          1.27      return tmp;
2741 mike           1.23  }
2742                      
2743                      //------------------------------------------------------------------------------
2744                      //
2745 kumpf          1.27  // XmlWriter::formatSimpleIMethodRspMessage()
2746 mike           1.23  //
2747                      //------------------------------------------------------------------------------
2748                      
2749 mike           1.125 Buffer XmlWriter::formatSimpleIMethodRspMessage(
2750 kumpf          1.80      const CIMName& iMethodName,
2751 kumpf          1.27      const String& messageId,
2752 kumpf          1.82      HttpMethod httpMethod,
2753 kumpf          1.133     const ContentLanguageList& httpContentLanguages,
2754 mike           1.125     const Buffer& body,
2755 david.dillard  1.130     Uint64 serverResponseTime,
2756 david.dillard  1.121     Boolean isFirst,
2757                          Boolean isLast)
2758 mike           1.23  {
2759 mike           1.125     Buffer out;
2760 mike           1.23  
2761 kumpf          1.146     if (isFirst == true)
2762                          {
2763                              // NOTE: temporarily put zero for content length. the http code
2764                              // will later decide to fill in the length or remove it altogether
2765                              appendMethodResponseHeader(
2766                                  out, httpMethod, httpContentLanguages, 0, serverResponseTime);
2767                              _appendMessageElementBegin(out, messageId);
2768                              _appendSimpleRspElementBegin(out);
2769                              _appendIMethodResponseElementBegin(out, iMethodName);
2770                      
2771                              // output the start of the return tag. Test if there is response data
2772                              // by:
2773                              // 1. there is data on the first chunk OR
2774                              // 2. there is no data on the first chunk but isLast is false implying
2775                              //    there is more non-empty data to come. If all subsequent chunks
2776                              //    are empty, then this generates and empty response.
2777                              if (body.size() != 0 || isLast == false)
2778                                  _appendIReturnValueElementBegin(out);
2779                          }
2780 w.white        1.108 
2781                          if (body.size() != 0)
2782                          {
2783 kumpf          1.146         out << body;
2784 w.white        1.108     }
2785                      
2786 kumpf          1.146     if (isLast == true)
2787                          {
2788                              if (body.size() != 0 || isFirst == false)
2789                                  _appendIReturnValueElementEnd(out);
2790                              _appendIMethodResponseElementEnd(out);
2791                              _appendSimpleRspElementEnd(out);
2792                              _appendMessageElementEnd(out);
2793                          }
2794 w.white        1.108 
2795                          return out;
2796                      }
2797                      
2798                      
2799 kumpf          1.28  //------------------------------------------------------------------------------
2800                      //
2801                      // XmlWriter::formatSimpleIMethodErrorRspMessage()
2802                      //
2803                      //------------------------------------------------------------------------------
2804                      
2805 mike           1.125 Buffer XmlWriter::formatSimpleIMethodErrorRspMessage(
2806 kumpf          1.80      const CIMName& iMethodName,
2807 kumpf          1.28      const String& messageId,
2808 kumpf          1.82      HttpMethod httpMethod,
2809 kumpf          1.42      const CIMException& cimException)
2810 kumpf          1.28  {
2811 mike           1.125     Buffer out;
2812                          Buffer tmp;
2813 kumpf          1.28  
2814 kumpf          1.29      _appendMessageElementBegin(out, messageId);
2815                          _appendSimpleRspElementBegin(out);
2816 kumpf          1.80      _appendIMethodResponseElementBegin(out, iMethodName);
2817 kumpf          1.42      _appendErrorElement(out, cimException);
2818 kumpf          1.29      _appendIMethodResponseElementEnd(out);
2819                          _appendSimpleRspElementEnd(out);
2820                          _appendMessageElementEnd(out);
2821 kumpf          1.28  
2822 chuck          1.89      appendMethodResponseHeader(tmp,
2823 kumpf          1.146         httpMethod,
2824                              cimException.getContentLanguages(),
2825 mike           1.164         out.size(), false);
2826 kumpf          1.28      tmp << out;
2827                      
2828                          return tmp;
2829                      }
2830                      
2831 kumpf          1.27  //******************************************************************************
2832                      //
2833                      // Export Messages (used for indications)
2834                      //
2835                      //******************************************************************************
2836 mike           1.23  
2837 kumpf          1.27  //------------------------------------------------------------------------------
2838                      //
2839                      // appendEMethodRequestHeader()
2840                      //
2841                      //     Build HTTP request header for export operation.
2842                      //
2843                      //------------------------------------------------------------------------------
2844 mike           1.23  
2845 kumpf          1.27  void XmlWriter::appendEMethodRequestHeader(
2846 mike           1.125     Buffer& out,
2847 kumpf          1.50      const char* requestUri,
2848 kumpf          1.27      const char* host,
2849 kumpf          1.80      const CIMName& cimMethod,
2850 kumpf          1.82      HttpMethod httpMethod,
2851 kumpf          1.27      const String& authenticationHeader,
2852 kumpf          1.133     const AcceptLanguageList& acceptLanguages,
2853                          const ContentLanguageList& contentLanguages,
2854 kumpf          1.27      Uint32 contentLength)
2855                      {
2856 ashok.pathak   1.177     char nn[] = { char('0' + (rand() % 10)), char('0' + (rand() % 10)), '\0' };
2857 mike           1.23  
2858 kumpf          1.82      if (httpMethod == HTTP_METHOD_M_POST)
2859                          {
2860 mike           1.126       out << STRLIT("M-POST ") << requestUri << STRLIT(" HTTP/1.1\r\n");
2861 kumpf          1.82      }
2862                          else
2863                          {
2864 mike           1.126       out << STRLIT("POST ") << requestUri << STRLIT(" HTTP/1.1\r\n");
2865 kumpf          1.82      }
2866 kumpf          1.167     out << STRLIT("HOST: ") << host << STRLIT("\r\n"
2867 marek          1.171                   "Content-Type: application/xml; charset=utf-8\r\n");
2868 kumpf          1.157     OUTPUT_CONTENTLENGTH(out, contentLength);
2869 brian.campbell 1.107 
2870 chuck          1.89      if (acceptLanguages.size() > 0)
2871                          {
2872 kumpf          1.146         out << STRLIT("Accept-Language: ") << acceptLanguages << STRLIT("\r\n");
2873 chuck          1.89      }
2874                          if (contentLanguages.size() > 0)
2875                          {
2876 kumpf          1.146         out << STRLIT("Content-Language: ") << contentLanguages <<
2877                                  STRLIT("\r\n");
2878 david.dillard  1.121     }
2879 brian.campbell 1.107 
2880 brian.campbell 1.113 #ifdef PEGASUS_DEBUG
2881 kumpf          1.146     // backdoor environment variable to turn OFF client requesting transfer
2882                          // encoding. The default is on. to turn off, set this variable to zero.
2883                          // This should be removed when stable. This should only be turned off in
2884                          // a debugging/testing environment.
2885                      
2886                          static const char *clientTransferEncodingOff =
2887                              getenv("PEGASUS_HTTP_TRANSFER_ENCODING_REQUEST");
2888                          if (!clientTransferEncodingOff || *clientTransferEncodingOff != '0')
2889 a.dunfey       1.110 #endif
2890 kumpf          1.146     out << STRLIT("TE: chunked, trailers\r\n");
2891 brian.campbell 1.107 
2892 kumpf          1.82      if (httpMethod == HTTP_METHOD_M_POST)
2893                          {
2894 kumpf          1.146         out << STRLIT("Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");
2895 mike           1.126         out << nn << STRLIT("\r\n");
2896                              out << nn << STRLIT("-CIMExport: MethodRequest\r\n");
2897 kumpf          1.146         out << nn << STRLIT("-CIMExportMethod: ") << cimMethod <<
2898                                  STRLIT("\r\n");
2899 kumpf          1.82      }
2900                          else
2901                          {
2902 kumpf          1.167         out << STRLIT("CIMExport: MethodRequest\r\n"
2903 thilo.boehm    1.162                       "CIMExportMethod: ") << cimMethod << STRLIT("\r\n");
2904 kumpf          1.82      }
2905                      
2906 kumpf          1.27      if (authenticationHeader.size())
2907                          {
2908 mike           1.126         out << authenticationHeader << STRLIT("\r\n");
2909 kumpf          1.27      }
2910 brian.campbell 1.107 
2911 mike           1.126     out << STRLIT("\r\n");
2912 kumpf          1.27  }
2913 mike           1.23  
2914 kumpf          1.27  //------------------------------------------------------------------------------
2915                      //
2916                      // appendEMethodResponseHeader()
2917                      //
2918                      //     Build HTTP response header for export operation.
2919                      //
2920                      //------------------------------------------------------------------------------
2921 mike           1.23  
2922 kumpf          1.27  void XmlWriter::appendEMethodResponseHeader(
2923 mike           1.125     Buffer& out,
2924 kumpf          1.82      HttpMethod httpMethod,
2925 kumpf          1.133     const ContentLanguageList& contentLanguages,
2926 kumpf          1.27      Uint32 contentLength)
2927                      {
2928 ashok.pathak   1.177     char nn[] = { char('0' + (rand() % 10)), char('0' + (rand() % 10)), '\0' };
2929 mike           1.23  
2930 kumpf          1.167     out << STRLIT("HTTP/1.1 " HTTP_STATUS_OK "\r\n"
2931 marek          1.171                   "Content-Type: application/xml; charset=utf-8\r\n");
2932 kumpf          1.157     OUTPUT_CONTENTLENGTH(out, contentLength);
2933 brian.campbell 1.107 
2934 chuck          1.89      if (contentLanguages.size() > 0)
2935                          {
2936 kumpf          1.146         out << STRLIT("Content-Language: ") << contentLanguages <<
2937                                  STRLIT("\r\n");
2938 david.dillard  1.121     }
2939 kumpf          1.82      if (httpMethod == HTTP_METHOD_M_POST)
2940                          {
2941 kumpf          1.167         out << STRLIT("Ext:\r\n"
2942                                            "Cache-Control: no-cache\r\n"
2943 thilo.boehm    1.162                       "Man: http://www.dmtf.org/cim/mapping/http/v1.0; ns=");
2944 mike           1.126         out << nn << STRLIT("\r\n");
2945                              out << nn << STRLIT("-CIMExport: MethodResponse\r\n\r\n");
2946 kumpf          1.82      }
2947                          else
2948                          {
2949 mike           1.126         out << STRLIT("CIMExport: MethodResponse\r\n\r\n");
2950 kumpf          1.82      }
2951 mike           1.23  }
2952                      
2953                      //------------------------------------------------------------------------------
2954                      //
2955 kumpf          1.29  // _appendSimpleExportReqElementBegin()
2956                      // _appendSimpleExportReqElementEnd()
2957 kumpf          1.27  //
2958                      //     <!ELEMENT SIMPLEEXPREQ (EXPMETHODCALL)>
2959 mike           1.23  //
2960                      //------------------------------------------------------------------------------
2961                      
2962 kumpf          1.29  void XmlWriter::_appendSimpleExportReqElementBegin(
2963 mike           1.125     Buffer& out)
2964 mike           1.23  {
2965 mike           1.126     out << STRLIT("<SIMPLEEXPREQ>\n");
2966 kumpf          1.27  }
2967 mike           1.23  
2968 kumpf          1.29  void XmlWriter::_appendSimpleExportReqElementEnd(
2969 mike           1.125     Buffer& out)
2970 kumpf          1.27  {
2971 mike           1.126     out << STRLIT("</SIMPLEEXPREQ>\n");
2972 mike           1.23  }
2973                      
2974                      //------------------------------------------------------------------------------
2975                      //
2976 kumpf          1.29  // _appendEMethodCallElementBegin()
2977                      // _appendEMethodCallElementEnd()
2978 kumpf          1.27  //
2979                      //     <!ELEMENT EXPMETHODCALL (IPARAMVALUE*)>
2980                      //     <!ATTLIST EXPMETHODCALL %CIMName;>
2981 mike           1.23  //
2982                      //------------------------------------------------------------------------------
2983                      
2984 kumpf          1.29  void XmlWriter::_appendEMethodCallElementBegin(
2985 mike           1.125     Buffer& out,
2986 kumpf          1.80      const CIMName& name)
2987 mike           1.23  {
2988 mike           1.126     out << STRLIT("<EXPMETHODCALL NAME=\"") << name << STRLIT("\">\n");
2989 mike           1.24  }
2990                      
2991 kumpf          1.29  void XmlWriter::_appendEMethodCallElementEnd(
2992 mike           1.125     Buffer& out)
2993 mike           1.24  {
2994 mike           1.126     out << STRLIT("</EXPMETHODCALL>\n");
2995 mike           1.24  }
2996                      
2997                      //------------------------------------------------------------------------------
2998                      //
2999 kumpf          1.85  // _appendEParamValueElementBegin()
3000                      // _appendEParamValueElementEnd()
3001                      //
3002 david.dillard  1.121 //     <!ELEMENT EXPPARAMVALUE (INSTANCE)>
3003                      //     <!ATTLIST EXPPARAMVALUE
3004 kumpf          1.85  //         %CIMName;>
3005                      //
3006                      //------------------------------------------------------------------------------
3007                      
3008                      void XmlWriter::_appendEParamValueElementBegin(
3009 mike           1.125     Buffer& out,
3010 kumpf          1.85      const char* name)
3011                      {
3012 mike           1.126     out << STRLIT("<EXPPARAMVALUE NAME=\"") << name << STRLIT("\">\n");
3013 kumpf          1.85  }
3014                      
3015                      void XmlWriter::_appendEParamValueElementEnd(
3016 mike           1.125     Buffer& out)
3017 kumpf          1.85  {
3018 mike           1.126     out << STRLIT("</EXPPARAMVALUE>\n");
3019 kumpf          1.85  }
3020                      
3021                      //------------------------------------------------------------------------------
3022                      //
3023                      // appendInstanceEParameter()
3024                      //
3025                      //------------------------------------------------------------------------------
3026                      
3027                      void XmlWriter::appendInstanceEParameter(
3028 mike           1.125     Buffer& out,
3029 kumpf          1.85      const char* name,
3030                          const CIMInstance& instance)
3031                      {
3032                          _appendEParamValueElementBegin(out, name);
3033                          appendInstanceElement(out, instance);
3034                          _appendEParamValueElementEnd(out);
3035                      }
3036                      
3037                      //------------------------------------------------------------------------------
3038                      //
3039 kumpf          1.29  // _appendSimpleExportRspElementBegin()
3040                      // _appendSimpleExportRspElementEnd()
3041 mike           1.24  //
3042 kumpf          1.27  //     <!ELEMENT SIMPLEEXPRSP (EXPMETHODRESPONSE)>
3043 mike           1.24  //
3044                      //------------------------------------------------------------------------------
3045                      
3046 kumpf          1.29  void XmlWriter::_appendSimpleExportRspElementBegin(
3047 mike           1.125     Buffer& out)
3048 kumpf          1.27  {
3049 mike           1.126     out << STRLIT("<SIMPLEEXPRSP>\n");
3050 kumpf          1.27  }
3051                      
3052 kumpf          1.29  void XmlWriter::_appendSimpleExportRspElementEnd(
3053 mike           1.125     Buffer& out)
3054 mike           1.24  {
3055 mike           1.126     out << STRLIT("</SIMPLEEXPRSP>\n");
3056 mike           1.24  }
3057                      
3058                      //------------------------------------------------------------------------------
3059                      //
3060 kumpf          1.29  // _appendEMethodResponseElementBegin()
3061                      // _appendEMethodResponseElementEnd()
3062 mike           1.24  //
3063                      //     <!ELEMENT EXPMETHODRESPONSE (ERROR|IRETURNVALUE?)>
3064                      //     <!ATTLIST EXPMETHODRESPONSE %CIMName;>
3065                      //
3066                      //------------------------------------------------------------------------------
3067                      
3068 kumpf          1.29  void XmlWriter::_appendEMethodResponseElementBegin(
3069 mike           1.125     Buffer& out,
3070 kumpf          1.80      const CIMName& name)
3071 mike           1.24  {
3072 mike           1.126     out << STRLIT("<EXPMETHODRESPONSE NAME=\"") << name << STRLIT("\">\n");
3073 kumpf          1.27  }
3074                      
3075 kumpf          1.29  void XmlWriter::_appendEMethodResponseElementEnd(
3076 mike           1.125     Buffer& out)
3077 kumpf          1.27  {
3078 mike           1.126     out << STRLIT("</EXPMETHODRESPONSE>\n");
3079 mike           1.24  }
3080                      
3081                      //------------------------------------------------------------------------------
3082                      //
3083 kumpf          1.27  // XmlWriter::formatSimpleEMethodReqMessage()
3084 mike           1.24  //
3085                      //------------------------------------------------------------------------------
3086                      
3087 mike           1.125 Buffer XmlWriter::formatSimpleEMethodReqMessage(
3088 kumpf          1.50      const char* requestUri,
3089 kumpf          1.27      const char* host,
3090 kumpf          1.80      const CIMName& eMethodName,
3091 kumpf          1.27      const String& messageId,
3092 kumpf          1.82      HttpMethod httpMethod,
3093 kumpf          1.27      const String& authenticationHeader,
3094 kumpf          1.133     const AcceptLanguageList& httpAcceptLanguages,
3095                          const ContentLanguageList& httpContentLanguages,
3096 mike           1.125     const Buffer& body)
3097 mike           1.24  {
3098 mike           1.125     Buffer out;
3099                          Buffer tmp;
3100 kumpf          1.27  
3101 kumpf          1.29      _appendMessageElementBegin(out, messageId);
3102                          _appendSimpleExportReqElementBegin(out);
3103                          _appendEMethodCallElementBegin(out, eMethodName);
3104 kumpf          1.27      out << body;
3105 kumpf          1.29      _appendEMethodCallElementEnd(out);
3106                          _appendSimpleExportReqElementEnd(out);
3107                          _appendMessageElementEnd(out);
3108 kumpf          1.27  
3109                          appendEMethodRequestHeader(
3110                              tmp,
3111 kumpf          1.50          requestUri,
3112 kumpf          1.27          host,
3113                              eMethodName,
3114 kumpf          1.82          httpMethod,
3115 kumpf          1.27          authenticationHeader,
3116 chuck          1.89          httpAcceptLanguages,
3117                              httpContentLanguages,
3118 kumpf          1.148         out.size());
3119 kumpf          1.27      tmp << out;
3120 mike           1.24  
3121 kumpf          1.50      return tmp;
3122 mike           1.24  }
3123                      
3124                      //------------------------------------------------------------------------------
3125                      //
3126 kumpf          1.27  // XmlWriter::formatSimpleEMethodRspMessage()
3127 mike           1.24  //
3128                      //------------------------------------------------------------------------------
3129                      
3130 mike           1.125 Buffer XmlWriter::formatSimpleEMethodRspMessage(
3131 kumpf          1.80      const CIMName& eMethodName,
3132 mike           1.24      const String& messageId,
3133 kumpf          1.82      HttpMethod httpMethod,
3134 kumpf          1.133     const ContentLanguageList& httpContentLanguages,
3135 mike           1.125     const Buffer& body)
3136 mike           1.24  {
3137 mike           1.125     Buffer out;
3138                          Buffer tmp;
3139 kumpf          1.27  
3140 kumpf          1.29      _appendMessageElementBegin(out, messageId);
3141                          _appendSimpleExportRspElementBegin(out);
3142                          _appendEMethodResponseElementBegin(out, eMethodName);
3143 kumpf          1.27      out << body;
3144 kumpf          1.29      _appendEMethodResponseElementEnd(out);
3145                          _appendSimpleExportRspElementEnd(out);
3146                          _appendMessageElementEnd(out);
3147 kumpf          1.28  
3148 david.dillard  1.121     appendEMethodResponseHeader(tmp,
3149 kumpf          1.146         httpMethod,
3150                              httpContentLanguages,
3151 kumpf          1.148         out.size());
3152 kumpf          1.28      tmp << out;
3153                      
3154                          return tmp;
3155                      }
3156                      
3157                      //------------------------------------------------------------------------------
3158                      //
3159                      // XmlWriter::formatSimpleEMethodErrorRspMessage()
3160                      //
3161                      //------------------------------------------------------------------------------
3162                      
3163 mike           1.125 Buffer XmlWriter::formatSimpleEMethodErrorRspMessage(
3164 kumpf          1.80      const CIMName& eMethodName,
3165 kumpf          1.28      const String& messageId,
3166 kumpf          1.82      HttpMethod httpMethod,
3167 kumpf          1.42      const CIMException& cimException)
3168 kumpf          1.28  {
3169 mike           1.125     Buffer out;
3170                          Buffer tmp;
3171 kumpf          1.28  
3172 kumpf          1.29      _appendMessageElementBegin(out, messageId);
3173                          _appendSimpleExportRspElementBegin(out);
3174 kumpf          1.80      _appendEMethodResponseElementBegin(out, eMethodName);
3175 kumpf          1.42      _appendErrorElement(out, cimException);
3176 kumpf          1.29      _appendEMethodResponseElementEnd(out);
3177                          _appendSimpleExportRspElementEnd(out);
3178                          _appendMessageElementEnd(out);
3179 kumpf          1.27  
3180 kumpf          1.146     appendEMethodResponseHeader(
3181                              tmp,
3182                              httpMethod,
3183                              cimException.getContentLanguages(),
3184 kumpf          1.148         out.size());
3185 kumpf          1.27      tmp << out;
3186                      
3187                          return tmp;
3188 mike           1.24  }
3189                      
3190                      //------------------------------------------------------------------------------
3191                      //
3192 kumpf          1.27  // XmlWriter::getNextMessageId()
3193 mike           1.24  //
3194                      //------------------------------------------------------------------------------
3195                      
3196 mike           1.139 static IDFactory _messageIDFactory(1000);
3197                      
3198 kumpf          1.27  String XmlWriter::getNextMessageId()
3199 mike           1.24  {
3200 marek          1.151     char scratchBuffer[22];
3201                          Uint32 n;
3202 kumpf          1.167     const char * startP = Uint32ToString(scratchBuffer,
3203 marek          1.151                                          _messageIDFactory.getID(),
3204                                                               n);
3205                          return String(startP, n);
3206 kumpf          1.68  }
3207                      
3208                      //------------------------------------------------------------------------------
3209                      //
3210                      // XmlWriter::keyBindingTypeToString
3211                      //
3212                      //------------------------------------------------------------------------------
3213 thilo.boehm    1.162 const StrLit XmlWriter::keyBindingTypeToString (CIMKeyBinding::Type type)
3214 kumpf          1.68  {
3215                          switch (type)
3216                          {
3217 kumpf          1.79          case CIMKeyBinding::BOOLEAN:
3218 thilo.boehm    1.162             return STRLIT("boolean");
3219 kumpf          1.68  
3220 kumpf          1.79          case CIMKeyBinding::STRING:
3221 thilo.boehm    1.162             return STRLIT("string");
3222 kumpf          1.68  
3223 kumpf          1.79          case CIMKeyBinding::NUMERIC:
3224 thilo.boehm    1.162             return STRLIT("numeric");
3225 kumpf          1.68  
3226 kumpf          1.79          case CIMKeyBinding::REFERENCE:
3227 kumpf          1.68          default:
3228 dl.meetei      1.175             PEGASUS_UNREACHABLE(PEGASUS_ASSERT(false);)
3229 kumpf          1.68      }
3230                      
3231 thilo.boehm    1.162     return STRLIT("unknown");
3232 mike           1.23  }
3233                      
3234                      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2