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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2