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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2