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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2