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