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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2