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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2