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