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