1 r.kieninger 1.1 //%LICENSE////////////////////////////////////////////////////////////////
2 //
3 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 r.kieninger 1.1 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //////////////////////////////////////////////////////////////////////////
29 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #include "CIMResponseData.h"
|
33 thilo.boehm 1.3 #include <Pegasus/Common/Tracer.h>
34 #include <Pegasus/Common/XmlWriter.h>
35 #include <Pegasus/Common/SCMOXmlWriter.h>
36 #include <Pegasus/Common/XmlReader.h>
37 #include <Pegasus/Common/CIMInternalXmlEncoder.h>
38 #include <Pegasus/Common/SCMOInternalXmlEncoder.h>
|
39 r.kieninger 1.1
40 PEGASUS_USING_STD;
41
42 PEGASUS_NAMESPACE_BEGIN
43
|
44 thilo.boehm 1.3 // C++ objects interface handling
45
46 // Instance Names handling
47 Array<CIMObjectPath>& CIMResponseData::getInstanceNames()
48 {
49 PEGASUS_DEBUG_ASSERT(
50 (_dataType==RESP_INSTNAMES || _dataType==RESP_OBJECTPATHS));
51 _resolveToCIM();
52 PEGASUS_DEBUG_ASSERT(_encoding==RESP_ENC_CIM || _encoding == 0);
53 return _instanceNames;
54 }
55
56 // Instance handling
57 CIMInstance& CIMResponseData::getInstance()
58 {
59 PEGASUS_DEBUG_ASSERT(_dataType == RESP_INSTANCE);
60 _resolveToCIM();
61 if (0 == _instances.size())
62 {
63 _instances.append(CIMInstance());
64 }
65 thilo.boehm 1.3 return _instances[0];
66 }
67
68 // Instances handling
69 Array<CIMInstance>& CIMResponseData::getInstances()
70 {
71 PEGASUS_DEBUG_ASSERT(_dataType == RESP_INSTANCES);
72 _resolveToCIM();
73 return _instances;
74 }
75
76 // Objects handling
77 Array<CIMObject>& CIMResponseData::getObjects()
78 {
79 PEGASUS_DEBUG_ASSERT(_dataType == RESP_OBJECTS);
80 _resolveToCIM();
81 return _objects;
82 }
83
84 // SCMO representation, single instance stored as one element array
85 // object paths are represented as SCMOInstance
86 thilo.boehm 1.3 Array<SCMOInstance>& CIMResponseData::getSCMO()
87 {
88 _resolveToSCMO();
89 return _scmoInstances;
90 }
91
92 void CIMResponseData::setSCMO(const Array<SCMOInstance>& x)
93 {
94 _scmoInstances=x;
95 _encoding |= RESP_ENC_SCMO;
96 }
97
98
99 // Binary data is just a data stream
100 Array<Uint8>& CIMResponseData::getBinary()
101 {
102 PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_BINARY || _encoding == 0);
103 return _binaryData;
104 }
105
|
106 karl 1.5 bool CIMResponseData::setBinary(CIMBuffer& in)
|
107 r.kieninger 1.1 {
|
108 karl 1.5 PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setBinary");
|
109 r.kieninger 1.1
|
110 karl 1.5 // Append all serial data from the CIMBuffer to the local data store.
111 // Returns error if input not a serialized Uint8A
112 if (!in.getUint8A(_binaryData))
113 {
114 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
115 "Failed to get binary input data!");
116 PEG_METHOD_EXIT();
117 return false;
|
118 r.kieninger 1.1 }
|
119 karl 1.5 _encoding |= RESP_ENC_BINARY;
120 PEG_METHOD_EXIT();
121 return true;
122 }
123
124 bool CIMResponseData::setRemainingBinaryData(CIMBuffer& in)
125 {
126 PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setRemainingBinaryData");
127
128 // Append any data that has not been deserialized already from
129 // the CIMBuffer.
130 size_t remainingDataLength = in.remainingDataLength();
131 _binaryData.append((Uint8*)in.getPtr(), remainingDataLength);
132
|
133 thilo.boehm 1.3 _encoding |= RESP_ENC_BINARY;
|
134 r.kieninger 1.1 PEG_METHOD_EXIT();
135 return true;
|
136 thilo.boehm 1.3 }
|
137 r.kieninger 1.1
|
138 thilo.boehm 1.3 bool CIMResponseData::setXml(CIMBuffer& in)
|
139 r.kieninger 1.1 {
|
140 thilo.boehm 1.3 switch (_dataType)
|
141 r.kieninger 1.1 {
|
142 thilo.boehm 1.3 case RESP_INSTANCE:
143 {
144 Array<Sint8> inst;
145 Array<Sint8> ref;
146 CIMNamespaceName ns;
147 String host;
148 if (!in.getSint8A(inst))
149 {
150 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
151 "Failed to get XML instance data!");
152 return false;
153 }
154 _instanceData.insert(0,inst);
155 if (!in.getSint8A(ref))
156 {
157 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
158 "Failed to get XML instance data (reference)!");
159 return false;
160 }
161 _referencesData.insert(0,ref);
162 if (!in.getString(host))
163 thilo.boehm 1.3 {
164 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
165 "Failed to get XML instance data (host)!");
166 return false;
167 }
168 _hostsData.insert(0,host);
169 if (!in.getNamespaceName(ns))
170 {
171 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
172 "Failed to get XML instance data (namespace)!");
173 return false;
174 }
175 _nameSpacesData.insert(0,ns);
176 break;
177 }
178 case RESP_INSTANCES:
179 {
180 Uint32 count;
181 if (!in.getUint32(count))
182 {
183 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
184 thilo.boehm 1.3 "Failed to get XML instance data (number of instance)!");
185 return false;
186 }
187 for (Uint32 i = 0; i < count; i++)
188 {
189 Array<Sint8> inst;
190 Array<Sint8> ref;
191 CIMNamespaceName ns;
192 String host;
193 if (!in.getSint8A(inst))
194 {
195 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
196 "Failed to get XML instance data (instances)!");
197 return false;
198 }
199 if (!in.getSint8A(ref))
200 {
201 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
202 "Failed to get XML instance data (references)!");
203 return false;
204 }
205 thilo.boehm 1.3 if (!in.getString(host))
206 {
207 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
208 "Failed to get XML instance data (host)!");
209 return false;
210 }
211 if (!in.getNamespaceName(ns))
212 {
213 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
214 "Failed to get XML instance data (namespace)!");
215 return false;
216 }
217 _instanceData.append(inst);
218 _referencesData.append(ref);
219 _hostsData.append(host);
220 _nameSpacesData.append(ns);
221 }
222 break;
223 }
224 case RESP_OBJECTS:
225 {
226 thilo.boehm 1.3 Uint32 count;
227 if (!in.getUint32(count))
228 {
229 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
230 "Failed to get XML object data (number of objects)!");
231 return false;
232 }
233 for (Uint32 i = 0; i < count; i++)
234 {
235 Array<Sint8> obj;
236 Array<Sint8> ref;
237 CIMNamespaceName ns;
238 String host;
239 if (!in.getSint8A(obj))
240 {
241 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
242 "Failed to get XML object data (object)!");
243 return false;
244 }
245 if (!in.getSint8A(ref))
246 {
247 thilo.boehm 1.3 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
248 "Failed to get XML object data (reference)!");
249 return false;
250 }
251 if (!in.getString(host))
252 {
253 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
254 "Failed to get XML object data (host)!");
255 return false;
256 }
257 if (!in.getNamespaceName(ns))
258 {
259 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
260 "Failed to get XML object data (namespace)!");
261 return false;
262 }
263 _instanceData.append(obj);
264 _referencesData.append(ref);
265 _hostsData.append(host);
266 _nameSpacesData.append(ns);
267 }
268 thilo.boehm 1.3 break;
269 }
270 // internal xml encoding of instance names and object paths not
271 // done today
272 case RESP_INSTNAMES:
273 case RESP_OBJECTPATHS:
274 default:
275 {
276 PEGASUS_DEBUG_ASSERT(false);
277 }
|
278 r.kieninger 1.1 }
|
279 thilo.boehm 1.3 _encoding |= RESP_ENC_XML;
280 return true;
281 }
|
282 r.kieninger 1.1
|
283 thilo.boehm 1.3 // function used by OperationAggregator to aggregate response data in a
284 // single ResponseData object
285 void CIMResponseData::appendResponseData(const CIMResponseData & x)
286 {
287 // as the Messages set the data types, this should be impossible
288 PEGASUS_DEBUG_ASSERT(_dataType == x._dataType);
289 _encoding |= x._encoding;
290
291 // add all binary data
292 _binaryData.appendArray(x._binaryData);
293
294 // add all the C++ stuff
295 _instanceNames.appendArray(x._instanceNames);
296 _instances.appendArray(x._instances);
297 _objects.appendArray(x._objects);
298
299 // add the SCMO instances
300 _scmoInstances.appendArray(x._scmoInstances);
301
302 // add Xml encodings too
303 _referencesData.appendArray(x._referencesData);
304 thilo.boehm 1.3 _instanceData.appendArray(x._instanceData);
305 _hostsData.appendArray(x._hostsData);
306 _nameSpacesData.appendArray(x._nameSpacesData);
307 }
|
308 r.kieninger 1.1
|
309 thilo.boehm 1.3 // Encoding responses into output format
310 void CIMResponseData::encodeBinaryResponse(CIMBuffer& out)
|
311 r.kieninger 1.1 {
312 PEG_METHOD_ENTER(TRC_DISPATCHER,
|
313 thilo.boehm 1.3 "CIMResponseData::encodeBinaryResponse");
314 // Need to do a complete job here by transferring all contained data
315 // into binary format and handing it out in the CIMBuffer
316 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
|
317 r.kieninger 1.1 {
|
318 thilo.boehm 1.3 // Binary does NOT need a marker as it consists of C++ and SCMO
|
319 r.kieninger 1.1 const Array<Uint8>& data = _binaryData;
320 out.putBytes(data.getData(), data.size());
321 }
|
322 thilo.boehm 1.3 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
|
323 r.kieninger 1.1 {
|
324 thilo.boehm 1.3 out.putTypeMarker(BIN_TYPE_MARKER_CPPD);
325 switch (_dataType)
326 {
327 case RESP_INSTNAMES:
328 {
329 out.putObjectPathA(_instanceNames);
330 break;
331 }
332 case RESP_INSTANCE:
333 {
334 if (0 == _instances.size())
335 {
336 _instances.append(CIMInstance());
337 }
338 out.putInstance(_instances[0], true, true);
339 break;
340 }
341 case RESP_INSTANCES:
342 {
343 out.putInstanceA(_instances);
344 break;
345 thilo.boehm 1.3 }
346 case RESP_OBJECTS:
347 {
348 out.putObjectA(_objects);
349 break;
350 }
351 case RESP_OBJECTPATHS:
352 {
353 out.putObjectPathA(_instanceNames);
354 break;
355 }
356 default:
357 {
358 PEGASUS_DEBUG_ASSERT(false);
359 }
360 }
|
361 r.kieninger 1.1 }
|
362 thilo.boehm 1.3 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
|
363 r.kieninger 1.1 {
|
364 thilo.boehm 1.3 out.putTypeMarker(BIN_TYPE_MARKER_SCMO);
365 out.putSCMOInstanceA(_scmoInstances);
|
366 r.kieninger 1.1 }
|
367 thilo.boehm 1.3 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
|
368 r.kieninger 1.1 {
|
369 thilo.boehm 1.3 // This actually should not happen following general code logic
370 PEGASUS_DEBUG_ASSERT(false);
|
371 r.kieninger 1.1 }
|
372 thilo.boehm 1.3
|
373 r.kieninger 1.1 PEG_METHOD_EXIT();
374 }
375
|
376 thilo.boehm 1.3 void CIMResponseData::completeNamespace(const SCMOInstance * x)
|
377 r.kieninger 1.1 {
|
378 thilo.boehm 1.3 const char * ns;
379 Uint32 len;
380 ns = x->getNameSpace_l(len);
381 // Both internal XML as well as binary always contain a namespace
382 // don't have to do anything for those two encodings
383 if ((RESP_ENC_BINARY == (_encoding&RESP_ENC_BINARY)) && (len != 0))
|
384 r.kieninger 1.1 {
|
385 thilo.boehm 1.3 _defaultNamespace = CIMNamespaceName(ns);
|
386 r.kieninger 1.1 }
|
387 thilo.boehm 1.3 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
|
388 r.kieninger 1.1 {
|
389 thilo.boehm 1.3 CIMNamespaceName nsName(ns);
390 switch (_dataType)
|
391 r.kieninger 1.1 {
|
392 thilo.boehm 1.3 case RESP_INSTANCE:
393 {
394 if (_instances.size() > 0)
395 {
396 const CIMInstance& inst = _instances[0];
397 CIMObjectPath& p =
398 const_cast<CIMObjectPath&>(inst.getPath());
399 if (p.getNameSpace().isNull())
400 {
401 p.setNameSpace(nsName);
402 }
403 }
|
404 ashok.pathak 1.7 break;
|
405 thilo.boehm 1.3 }
406 case RESP_INSTANCES:
407 {
408 for (Uint32 j = 0, n = _instances.size(); j < n; j++)
409 {
410 const CIMInstance& inst = _instances[j];
411 CIMObjectPath& p =
412 const_cast<CIMObjectPath&>(inst.getPath());
413 if (p.getNameSpace().isNull())
414 {
415 p.setNameSpace(nsName);
416 }
417 }
418 break;
419 }
420 case RESP_OBJECTS:
421 {
422 for (Uint32 j = 0, n = _objects.size(); j < n; j++)
423 {
424 const CIMObject& object = _objects[j];
425 CIMObjectPath& p =
426 thilo.boehm 1.3 const_cast<CIMObjectPath&>(object.getPath());
427 if (p.getNameSpace().isNull())
428 {
429 p.setNameSpace(nsName);
430 }
431 }
432 break;
433 }
434 case RESP_INSTNAMES:
435 case RESP_OBJECTPATHS:
436 {
437 for (Uint32 j = 0, n = _instanceNames.size(); j < n; j++)
438 {
439 CIMObjectPath& p = _instanceNames[j];
440 if (p.getNameSpace().isNull())
441 {
442 p.setNameSpace(nsName);
443 }
444 }
445 break;
446 }
447 thilo.boehm 1.3 default:
448 {
449 PEGASUS_DEBUG_ASSERT(false);
450 }
|
451 r.kieninger 1.1 }
452 }
|
453 thilo.boehm 1.3 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
|
454 r.kieninger 1.1 {
|
455 thilo.boehm 1.3 for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++)
|
456 r.kieninger 1.1 {
|
457 thilo.boehm 1.3 SCMOInstance & scmoInst=_scmoInstances[j];
458 if (0 == scmoInst.getNameSpace())
459 {
460 scmoInst.setNameSpace_l(ns,len);
461 }
|
462 r.kieninger 1.1 }
463 }
464 }
465
466
|
467 thilo.boehm 1.3 void CIMResponseData::completeHostNameAndNamespace(
468 const String & hn,
469 const CIMNamespaceName & ns)
|
470 r.kieninger 1.1 {
|
471 thilo.boehm 1.3 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
472 {
473 // On binary need remember hostname and namespace in case someone
474 // builds C++ default objects or Xml types from it later on
475 // -> usage: See resolveBinary()
476 _defaultNamespace=ns;
477 _defaultHostname=hn;
478 }
479 // InternalXml does not support objectPath calls
480 if ((RESP_ENC_XML == (_encoding & RESP_ENC_XML)) &&
481 (RESP_OBJECTS == _dataType))
482 {
483 for (Uint32 j = 0, n = _referencesData.size(); j < n; j++)
484 {
485 if (0 == _hostsData[j].size())
486 {
487 _hostsData[j]=hn;
488 }
489 if (_nameSpacesData[j].isNull())
490 {
491 _nameSpacesData[j]=ns;
492 thilo.boehm 1.3 }
493 }
494 }
495 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
|
496 r.kieninger 1.1 {
|
497 thilo.boehm 1.3 switch (_dataType)
|
498 r.kieninger 1.2 {
|
499 thilo.boehm 1.3 case RESP_OBJECTS:
500 {
501 for (Uint32 j = 0, n = _objects.size(); j < n; j++)
502 {
503 const CIMObject& object = _objects[j];
504 CIMObjectPath& p =
505 const_cast<CIMObjectPath&>(object.getPath());
506 if (p.getHost().size()==0)
507 {
508 p.setHost(hn);
509 }
510 if (p.getNameSpace().isNull())
511 {
512 p.setNameSpace(ns);
513 }
514 }
515 break;
516 }
517 case RESP_OBJECTPATHS:
518 {
519 for (Uint32 j = 0, n = _instanceNames.size(); j < n; j++)
520 thilo.boehm 1.3 {
521 CIMObjectPath& p = _instanceNames[j];
522 if (p.getHost().size() == 0)
523 p.setHost(hn);
524 if (p.getNameSpace().isNull())
525 p.setNameSpace(ns);
526 }
527 break;
528 }
529 default:
530 {
531 PEGASUS_DEBUG_ASSERT(false);
532 }
|
533 r.kieninger 1.2 }
534 }
|
535 thilo.boehm 1.3 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
|
536 r.kieninger 1.2 {
|
537 thilo.boehm 1.3 CString hnCString=hn.getCString();
538 const char* hnChars = hnCString;
539 Uint32 hnLen = strlen(hnChars);
540 CString nsCString=ns.getString().getCString();
541 const char* nsChars=nsCString;
542 Uint32 nsLen = strlen(nsChars);
543 switch (_dataType)
544 {
545 case RESP_OBJECTS:
546 case RESP_OBJECTPATHS:
547 {
548 for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++)
549 {
550 SCMOInstance & scmoInst=_scmoInstances[j];
|
551 marek 1.10 scmoInst.completeHostNameAndNamespace(
552 hnChars,
553 hnLen,
554 nsChars,
555 nsLen);
|
556 thilo.boehm 1.3 }
557 break;
558 }
559 default:
560 {
561 PEGASUS_DEBUG_ASSERT(false);
562 }
563 }
|
564 r.kieninger 1.1 }
|
565 thilo.boehm 1.3 }
|
566 r.kieninger 1.1
|
567 thilo.boehm 1.3 void CIMResponseData::encodeXmlResponse(Buffer& out)
|
568 r.kieninger 1.1 {
|
569 thilo.boehm 1.3 PEG_TRACE((TRC_XML, Tracer::LEVEL3,
|
570 r.kieninger 1.4 "CIMResponseData::encodeXmlResponse(encoding=%X,content=%X)",
|
571 thilo.boehm 1.3 _encoding,
572 _dataType));
|
573 anusha.kandepu 1.6
|
574 thilo.boehm 1.3 // already existing Internal XML does not need to be encoded further
575 // binary input is not actually impossible here, but we have an established
576 // fallback
577 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
|
578 r.kieninger 1.1 {
|
579 thilo.boehm 1.3 _resolveBinary();
|
580 r.kieninger 1.1 }
|
581 thilo.boehm 1.3 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
|
582 r.kieninger 1.1 {
|
583 thilo.boehm 1.3 switch (_dataType)
|
584 r.kieninger 1.1 {
|
585 thilo.boehm 1.3 case RESP_INSTANCE:
586 {
587 const Array<ArraySint8>& a = _instanceData;
588 out.append((char*)a[0].getData(), a[0].size() - 1);
589 break;
590 }
591 case RESP_INSTANCES:
592 {
593 const Array<ArraySint8>& a = _instanceData;
594 const Array<ArraySint8>& b = _referencesData;
|
595 r.kieninger 1.1
|
596 thilo.boehm 1.3 for (Uint32 i = 0, n = a.size(); i < n; i++)
597 {
598 out << STRLIT("<VALUE.NAMEDINSTANCE>\n");
599 out.append((char*)b[i].getData(), b[i].size() - 1);
600 out.append((char*)a[i].getData(), a[i].size() - 1);
601 out << STRLIT("</VALUE.NAMEDINSTANCE>\n");
602 }
603 break;
604 }
605 case RESP_OBJECTS:
606 {
607 const Array<ArraySint8>& a = _instanceData;
608 const Array<ArraySint8>& b = _referencesData;
609 for (Uint32 i = 0, n = a.size(); i < n; i++)
610 {
611 out << STRLIT("<VALUE.OBJECTWITHPATH>\n");
612 out << STRLIT("<INSTANCEPATH>\n");
613 XmlWriter::appendNameSpacePathElement(
614 out,
615 _hostsData[i],
616 _nameSpacesData[i]);
617 thilo.boehm 1.3 // Leave out the surrounding tags "<VALUE.REFERENCE>\n"
618 // and "</VALUE.REFERENCE>\n" which are 18 and 19 characters
619 // long
620 out.append(
621 ((char*)b[i].getData())+18,
622 b[i].size() - 1 - 18 -19);
623 out << STRLIT("</INSTANCEPATH>\n");
624 // append instance body
625 out.append((char*)a[i].getData(), a[i].size() - 1);
626 out << STRLIT("</VALUE.OBJECTWITHPATH>\n");
627 }
628 break;
629 }
630 // internal xml encoding of instance names and object paths not
631 // done today
632 case RESP_INSTNAMES:
633 case RESP_OBJECTPATHS:
634 default:
635 {
636 PEGASUS_DEBUG_ASSERT(false);
637 }
|
638 r.kieninger 1.1 }
|
639 thilo.boehm 1.3 }
|
640 r.kieninger 1.1
|
641 thilo.boehm 1.3 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
642 {
643 switch (_dataType)
|
644 r.kieninger 1.1 {
|
645 thilo.boehm 1.3 case RESP_INSTNAMES:
646 {
647 for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++)
648 {
649 XmlWriter::appendInstanceNameElement(out,_instanceNames[i]);
650 }
651 break;
652 }
653 case RESP_INSTANCE:
654 {
655 if (_instances.size() > 0)
656 {
|
657 anusha.kandepu 1.6 XmlWriter::appendInstanceElement(
658 out,
659 _instances[0],
660 _includeQualifiers,
661 _includeClassOrigin,
662 _propertyList);
|
663 thilo.boehm 1.3 }
664 break;
665 }
666 case RESP_INSTANCES:
667 {
668 for (Uint32 i = 0, n = _instances.size(); i < n; i++)
669 {
670 XmlWriter::appendValueNamedInstanceElement(
|
671 anusha.kandepu 1.6 out,
672 _instances[i],
673 _includeQualifiers,
674 _includeClassOrigin,
675 _propertyList);
|
676 thilo.boehm 1.3 }
677 break;
678 }
679 case RESP_OBJECTS:
680 {
681 for (Uint32 i = 0; i < _objects.size(); i++)
682 {
683 XmlWriter::appendValueObjectWithPathElement(
684 out,
|
685 anusha.kandepu 1.6 _objects[i],
686 _includeQualifiers,
687 _includeClassOrigin,
688 _propertyList);
|
689 thilo.boehm 1.3 }
690 break;
691 }
692 case RESP_OBJECTPATHS:
693 {
694 for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++)
695 {
696 out << "<OBJECTPATH>\n";
697 XmlWriter::appendValueReferenceElement(
698 out,
699 _instanceNames[i],
700 false);
701 out << "</OBJECTPATH>\n";
702 }
703 break;
704 }
705 default:
706 {
707 PEGASUS_DEBUG_ASSERT(false);
708 }
|
709 r.kieninger 1.1 }
|
710 thilo.boehm 1.3 }
711 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
712 {
713 switch (_dataType)
|
714 r.kieninger 1.1 {
|
715 thilo.boehm 1.3 case RESP_INSTNAMES:
716 {
717 for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++)
718 {
719 SCMOXmlWriter::appendInstanceNameElement(
720 out,
721 _scmoInstances[i]);
|
722 anusha.kandepu 1.6
|
723 thilo.boehm 1.3 }
724 break;
725 }
726 case RESP_INSTANCE:
727 {
728 if (_scmoInstances.size() > 0)
729 {
|
730 anusha.kandepu 1.6 if(_propertyList.isNull())
731 {
732 Array<Uint32> emptyNodes;
733 SCMOXmlWriter::appendInstanceElement(
734 out,
735 _scmoInstances[0],
736 false,
737 emptyNodes);
738 }
739 else
740 {
741 Array<propertyFilterNodesArray_t> propFilterNodesArrays;
742 // This searches for an already created array of nodes,
743 //if not found, creates it inside propFilterNodesArrays
744 const Array<Uint32> & nodes=
745 SCMOXmlWriter::getFilteredNodesArray(
746 propFilterNodesArrays,
747 _scmoInstances[0],
748 _propertyList);
749 SCMOXmlWriter::appendInstanceElement(
750 out,
751 anusha.kandepu 1.6 _scmoInstances[0],
752 true,
753 nodes);
754 }
|
755 thilo.boehm 1.3 }
756 break;
757 }
758 case RESP_INSTANCES:
759 {
|
760 anusha.kandepu 1.6 SCMOXmlWriter::appendValueSCMOInstanceElements(
761 out,
762 _scmoInstances,
763 _propertyList);
|
764 thilo.boehm 1.3 break;
765 }
766 case RESP_OBJECTS:
767 {
|
768 anusha.kandepu 1.6 SCMOXmlWriter::appendValueObjectWithPathElement(
769 out,
770 _scmoInstances,
771 _propertyList);
|
772 thilo.boehm 1.3 break;
773 }
774 case RESP_OBJECTPATHS:
775 {
776 for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++)
777 {
778 out << "<OBJECTPATH>\n";
779 SCMOXmlWriter::appendValueReferenceElement(
780 out,
781 _scmoInstances[i],
782 false);
783 out << "</OBJECTPATH>\n";
784 }
785 break;
786 }
787 default:
788 {
789 PEGASUS_DEBUG_ASSERT(false);
790 }
|
791 r.kieninger 1.1 }
792 }
|
793 thilo.boehm 1.3 }
|
794 r.kieninger 1.1
|
795 thilo.boehm 1.3 // contrary to encodeXmlResponse this function encodes the Xml in a format
796 // not usable by clients
797 void CIMResponseData::encodeInternalXmlResponse(CIMBuffer& out)
798 {
799 PEG_TRACE((TRC_XML, Tracer::LEVEL3,
|
800 r.kieninger 1.4 "CIMResponseData::encodeInternalXmlResponse(encoding=%X,content=%X)",
|
801 thilo.boehm 1.3 _encoding,
802 _dataType));
803 // For mixed (CIM+SCMO) responses, we need to tell the receiver the
804 // total number of instances. The totalSize variable is used to keep track
805 // of this.
806 Uint32 totalSize = 0;
|
807 r.kieninger 1.1
|
808 thilo.boehm 1.3 // already existing Internal XML does not need to be encoded further
809 // binary input is not actually impossible here, but we have an established
810 // fallback
811 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
812 {
813 _resolveBinary();
814 }
815 if ((0 == _encoding) ||
816 (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)))
817 {
818 switch (_dataType)
819 {
820 case RESP_INSTANCE:
821 {
822 if (0 == _instances.size())
823 {
824 _instances.append(CIMInstance());
|
825 anusha.kandepu 1.6 CIMInternalXmlEncoder::_putXMLInstance(
826 out,
827 _instances[0]);
828 break;
|
829 thilo.boehm 1.3 }
|
830 anusha.kandepu 1.6 CIMInternalXmlEncoder::_putXMLInstance(
831 out,
832 _instances[0],
833 _includeQualifiers,
834 _includeClassOrigin,
835 _propertyList);
|
836 thilo.boehm 1.3 break;
837 }
838 case RESP_INSTANCES:
839 {
840 Uint32 n = _instances.size();
841 totalSize = n + _scmoInstances.size();
842 out.putUint32(totalSize);
843 for (Uint32 i = 0; i < n; i++)
844 {
845 CIMInternalXmlEncoder::_putXMLNamedInstance(
846 out,
|
847 anusha.kandepu 1.6 _instances[i],
848 _includeQualifiers,
849 _includeClassOrigin,
850 _propertyList);
|
851 thilo.boehm 1.3 }
852 break;
853 }
854 case RESP_OBJECTS:
855 {
856 Uint32 n = _objects.size();
857 totalSize = n + _scmoInstances.size();
858 out.putUint32(totalSize);
859 for (Uint32 i = 0; i < n; i++)
860 {
|
861 anusha.kandepu 1.6 CIMInternalXmlEncoder::_putXMLObject(
862 out,
863 _objects[i],
864 _includeQualifiers,
865 _includeClassOrigin,
866 _propertyList);
|
867 thilo.boehm 1.3 }
868 break;
869 }
870 // internal xml encoding of instance names and object paths not
871 // done today
872 case RESP_INSTNAMES:
873 case RESP_OBJECTPATHS:
874 default:
875 {
876 PEGASUS_DEBUG_ASSERT(false);
877 }
878 }
879 }
880 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
881 {
882 switch (_dataType)
883 {
884 case RESP_INSTANCE:
885 {
886 if (0 == _scmoInstances.size())
887 {
888 thilo.boehm 1.3 _scmoInstances.append(SCMOInstance());
889 }
|
890 anusha.kandepu 1.6 SCMOInternalXmlEncoder::_putXMLInstance(
891 out,
892 _scmoInstances[0],
893 _propertyList);
|
894 thilo.boehm 1.3 break;
895 }
896 case RESP_INSTANCES:
897 {
898 Uint32 n = _scmoInstances.size();
899 // Only put the size when not already done above
900 if (0==totalSize)
901 {
902 out.putUint32(n);
903 }
|
904 anusha.kandepu 1.6 SCMOInternalXmlEncoder::_putXMLNamedInstance(
905 out,
906 _scmoInstances,
907 _propertyList);
|
908 thilo.boehm 1.3 break;
909 }
910 case RESP_OBJECTS:
911 {
912 Uint32 n = _scmoInstances.size();
913 // Only put the size when not already done above
914 if (0==totalSize)
915 {
916 out.putUint32(n);
917 }
|
918 anusha.kandepu 1.6 SCMOInternalXmlEncoder::_putXMLObject(
919 out,
920 _scmoInstances,
921 _propertyList);
|
922 thilo.boehm 1.3 break;
923 }
924 // internal xml encoding of instance names and object paths not
925 // done today
926 case RESP_INSTNAMES:
927 case RESP_OBJECTPATHS:
928 default:
929 {
930 PEGASUS_DEBUG_ASSERT(false);
931 }
932 }
933 }
|
934 anusha.kandepu 1.6
|
935 thilo.boehm 1.3 }
|
936 r.kieninger 1.1
|
937 thilo.boehm 1.3 void CIMResponseData::_resolveToCIM()
|
938 r.kieninger 1.1 {
|
939 r.kieninger 1.4 PEG_TRACE((TRC_XML, Tracer::LEVEL3,
940 "CIMResponseData::_resolveToCIM(encoding=%X,content=%X)",
|
941 thilo.boehm 1.3 _encoding,
942 _dataType));
|
943 r.kieninger 1.1
|
944 thilo.boehm 1.3 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
945 {
946 _resolveXmlToCIM();
947 }
948 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
|
949 r.kieninger 1.1 {
|
950 thilo.boehm 1.3 _resolveBinary();
|
951 r.kieninger 1.1 }
|
952 thilo.boehm 1.3 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
|
953 r.kieninger 1.1 {
|
954 thilo.boehm 1.3 _resolveSCMOToCIM();
|
955 r.kieninger 1.1 }
|
956 thilo.boehm 1.3
957 PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_CIM || _encoding == 0);
|
958 r.kieninger 1.1 }
959
|
960 thilo.boehm 1.3 void CIMResponseData::_resolveToSCMO()
|
961 r.kieninger 1.1 {
|
962 r.kieninger 1.4 PEG_TRACE((TRC_XML, Tracer::LEVEL3,
963 "CIMResponseData::_resolveToSCMO(encoding=%X,content=%X)",
|
964 thilo.boehm 1.3 _encoding,
965 _dataType));
|
966 r.kieninger 1.1
|
967 thilo.boehm 1.3 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
968 {
969 _resolveXmlToSCMO();
970 }
971 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
|
972 r.kieninger 1.1 {
|
973 thilo.boehm 1.3 _resolveBinary();
|
974 r.kieninger 1.1 }
|
975 thilo.boehm 1.3 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
|
976 r.kieninger 1.1 {
|
977 thilo.boehm 1.3 _resolveCIMToSCMO();
|
978 r.kieninger 1.1 }
|
979 thilo.boehm 1.3 PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_SCMO || _encoding == 0);
|
980 r.kieninger 1.1 }
981
|
982 thilo.boehm 1.3 // helper functions to transform different formats into one-another
983 // functions work on the internal data and calling of them should be
984 // avoided whenever possible
985 void CIMResponseData::_resolveBinary()
|
986 r.kieninger 1.1 {
987 PEG_METHOD_ENTER(TRC_DISPATCHER,
|
988 thilo.boehm 1.3 "CIMResponseData::_resolveBinary");
|
989 r.kieninger 1.1
|
990 thilo.boehm 1.3 CIMBuffer in((char*)_binaryData.getData(), _binaryData.size());
|
991 r.kieninger 1.1
|
992 r.kieninger 1.2 while (in.more())
|
993 r.kieninger 1.1 {
|
994 thilo.boehm 1.3 Uint32 binaryTypeMarker=0;
995 if(!in.getTypeMarker(binaryTypeMarker))
|
996 r.kieninger 1.2 {
997 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
|
998 thilo.boehm 1.3 "Failed to get type marker for binary objects!");
|
999 r.kieninger 1.2 PEG_METHOD_EXIT();
|
1000 thilo.boehm 1.3 in.release();
1001 return;
1002 }
1003
1004 if (BIN_TYPE_MARKER_SCMO==binaryTypeMarker)
1005 {
1006 if (!in.getSCMOInstanceA(_scmoInstances))
1007 {
1008 _encoding &=(~RESP_ENC_BINARY);
1009 in.release();
1010 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1011 "Failed to resolve binary SCMOInstances!");
1012 PEG_METHOD_EXIT();
1013 return;
1014 }
1015
1016 _encoding |= RESP_ENC_SCMO;
|
1017 r.kieninger 1.2 }
|
1018 thilo.boehm 1.3 else
1019 {
1020 switch (_dataType)
1021 {
1022 case RESP_INSTNAMES:
1023 case RESP_OBJECTPATHS:
1024 {
1025 if (!in.getObjectPathA(_instanceNames))
1026 {
1027 _encoding &=(~RESP_ENC_BINARY);
1028 in.release();
1029 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1030 "Failed to resolve binary CIMObjectPaths!");
1031 PEG_METHOD_EXIT();
1032 return;
1033 }
1034 break;
1035 }
1036 case RESP_INSTANCE:
1037 {
1038 CIMInstance instance;
1039 thilo.boehm 1.3 if (!in.getInstance(instance))
1040 {
1041 _encoding &=(~RESP_ENC_BINARY);
1042 _encoding |= RESP_ENC_CIM;
1043 _instances.append(instance);
1044 in.release();
1045 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1046 "Failed to resolve binary instance!");
1047 PEG_METHOD_EXIT();
1048 return;
1049 }
1050
1051 _instances.append(instance);
1052 break;
1053 }
1054 case RESP_INSTANCES:
1055 {
1056 if (!in.getInstanceA(_instances))
1057 {
1058 _encoding &=(~RESP_ENC_BINARY);
1059 in.release();
1060 thilo.boehm 1.3 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1061 "Failed to resolve binary CIMInstances!");
1062 PEG_METHOD_EXIT();
1063 return;
1064 }
1065 break;
1066 }
1067 case RESP_OBJECTS:
1068 {
1069 if (!in.getObjectA(_objects))
1070 {
1071 in.release();
1072 _encoding &=(~RESP_ENC_BINARY);
1073 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1074 "Failed to resolve binary CIMObjects!");
1075 PEG_METHOD_EXIT();
1076 return;
1077 }
1078 break;
1079 }
1080 default:
1081 thilo.boehm 1.3 {
1082 PEGASUS_DEBUG_ASSERT(false);
1083 }
1084 } // switch
1085 _encoding |= RESP_ENC_CIM;
1086 } // else SCMO
1087 }
1088 _encoding &=(~RESP_ENC_BINARY);
1089 // fix up the hostname and namespace for objects if defaults
1090 // were set
1091 if (_defaultHostname.size() > 0 && !_defaultNamespace.isNull())
1092 {
1093 completeHostNameAndNamespace(_defaultHostname, _defaultNamespace);
|
1094 r.kieninger 1.1 }
1095 in.release();
1096 PEG_METHOD_EXIT();
1097 }
1098
|
1099 thilo.boehm 1.11
1100 void CIMResponseData::_deserializeObject(Uint32 idx,CIMObject& cimObject)
1101 {
1102 // Only start the parser when instance data is present.
1103 if (0 != _instanceData[idx].size())
1104 {
1105 CIMInstance cimInstance;
1106 CIMClass cimClass;
1107
1108 XmlParser parser((char*)_instanceData[idx].getData());
1109
1110 if (XmlReader::getInstanceElement(parser, cimInstance))
1111 {
1112 cimObject = CIMObject(cimInstance);
1113 return;
1114 }
1115
1116 if (XmlReader::getClassElement(parser, cimClass))
1117 {
1118 cimObject = CIMObject(cimClass);
1119 return;
1120 thilo.boehm 1.11 }
1121 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1122 "Failed to resolve XML object data, parser error!");
1123 }
1124 }
1125
1126 void CIMResponseData::_deserializeInstance(Uint32 idx,CIMInstance& cimInstance)
1127 {
1128 // Only start the parser when instance data is present.
1129 if (0 != _instanceData[idx].size())
1130 {
1131 XmlParser parser((char*)_instanceData[idx].getData());
1132 if (XmlReader::getInstanceElement(parser, cimInstance))
1133 {
1134 return;
1135 }
1136 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1137 "Failed to resolve XML instance, parser error!");
1138 }
1139 // reset instance when parsing may not be successfull or
1140 // no instance is present.
1141 thilo.boehm 1.11 cimInstance = CIMInstance();
1142 }
1143
1144 Boolean CIMResponseData::_deserializeReference(
1145 Uint32 idx,
1146 CIMObjectPath& cimObjectPath)
1147 {
1148 // Only start the parser when reference data is present.
1149 if (0 != _referencesData[idx].size())
1150 {
1151 XmlParser parser((char*)_referencesData[idx].getData());
1152 if (XmlReader::getValueReferenceElement(parser, cimObjectPath))
1153 {
1154 if (_hostsData[idx].size())
1155 {
1156 cimObjectPath.setHost(_hostsData[idx]);
1157 }
1158 if (!_nameSpacesData[idx].isNull())
1159 {
1160 cimObjectPath.setNameSpace(_nameSpacesData[idx]);
1161 }
1162 thilo.boehm 1.11 return true;
1163 }
1164 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1165 "Failed to resolve XML reference, parser error!");
1166
1167 }
1168 return false;
1169 }
1170
1171 Boolean CIMResponseData::_deserializeInstanceName(
1172 Uint32 idx,
1173 CIMObjectPath& cimObjectPath)
1174 {
1175 // Only start the parser when instance name data is present.
1176 if (0 != _referencesData[idx].size())
1177 {
1178 XmlParser parser((char*)_referencesData[idx].getData());
1179 if (XmlReader::getInstanceNameElement(parser, cimObjectPath))
1180 {
1181 if (_hostsData[idx].size())
1182 {
1183 thilo.boehm 1.11 cimObjectPath.setHost(_hostsData[idx]);
1184 }
1185 if (!_nameSpacesData[idx].isNull())
1186 {
1187 cimObjectPath.setNameSpace(_nameSpacesData[idx]);
1188 }
1189 return true;
1190 }
1191 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1192 "Failed to resolve XML instance name, parser error!");
1193
1194 }
1195 return false;
1196 }
1197
|
1198 thilo.boehm 1.3 void CIMResponseData::_resolveXmlToCIM()
|
1199 r.kieninger 1.1 {
|
1200 thilo.boehm 1.3 switch (_dataType)
|
1201 r.kieninger 1.1 {
|
1202 thilo.boehm 1.3 // Xml encoding for instance names and object paths not used
1203 case RESP_OBJECTPATHS:
1204 case RESP_INSTNAMES:
1205 {
1206 break;
1207 }
1208 case RESP_INSTANCE:
|
1209 r.kieninger 1.1 {
|
1210 thilo.boehm 1.3 CIMInstance cimInstance;
|
1211 thilo.boehm 1.11 CIMObjectPath cimObjectPath;
|
1212 r.kieninger 1.1
|
1213 thilo.boehm 1.11 _deserializeInstance(0,cimInstance);
1214 if (_deserializeReference(0,cimObjectPath))
|
1215 r.kieninger 1.1 {
|
1216 thilo.boehm 1.11 cimInstance.setPath(cimObjectPath);
1217 // A single CIMInstance has to have an objectpath.
1218 // So only add it when an objectpath exists.
1219 _instances.append(cimInstance);
|
1220 r.kieninger 1.1 }
|
1221 thilo.boehm 1.3 break;
|
1222 r.kieninger 1.1 }
|
1223 thilo.boehm 1.3 case RESP_INSTANCES:
1224 {
1225 for (Uint32 i = 0; i < _instanceData.size(); i++)
1226 {
1227 CIMInstance cimInstance;
|
1228 thilo.boehm 1.11 CIMObjectPath cimObjectPath;
|
1229 thilo.boehm 1.3
|
1230 thilo.boehm 1.11 _deserializeInstance(i,cimInstance);
1231 if (_deserializeInstanceName(i,cimObjectPath))
|
1232 thilo.boehm 1.3 {
|
1233 thilo.boehm 1.11 cimInstance.setPath(cimObjectPath);
|
1234 thilo.boehm 1.3 }
|
1235 thilo.boehm 1.11 // enumarate instances can be without name
|
1236 thilo.boehm 1.3 _instances.append(cimInstance);
1237 }
1238 break;
1239 }
1240 case RESP_OBJECTS:
|
1241 r.kieninger 1.1 {
|
1242 thilo.boehm 1.3 for (Uint32 i=0, n=_instanceData.size(); i<n; i++)
|
1243 r.kieninger 1.1 {
|
1244 thilo.boehm 1.3 CIMObject cimObject;
|
1245 thilo.boehm 1.11 CIMObjectPath cimObjectPath;
|
1246 r.kieninger 1.1
|
1247 thilo.boehm 1.11 _deserializeObject(i,cimObject);
1248 if (_deserializeReference(i,cimObjectPath))
|
1249 thilo.boehm 1.3 {
|
1250 thilo.boehm 1.11 cimObject.setPath(cimObjectPath);
|
1251 thilo.boehm 1.3 }
1252 _objects.append(cimObject);
|
1253 r.kieninger 1.1 }
|
1254 thilo.boehm 1.3 break;
1255 }
1256 default:
1257 {
1258 PEGASUS_DEBUG_ASSERT(false);
|
1259 r.kieninger 1.1 }
1260 }
|
1261 thilo.boehm 1.3 // Xml was resolved, release Xml content now
1262 _referencesData.clear();
1263 _hostsData.clear();
1264 _nameSpacesData.clear();
1265 _instanceData.clear();
1266 // remove Xml Encoding flag
1267 _encoding &=(~RESP_ENC_XML);
1268 // add CIM Encoding flag
1269 _encoding |=RESP_ENC_CIM;
1270 }
|
1271 r.kieninger 1.1
|
1272 thilo.boehm 1.3 void CIMResponseData::_resolveXmlToSCMO()
1273 {
1274 // Not optimal, can probably be improved
1275 // but on the other hand, since using the binary format this case should
1276 // actually not ever happen.
1277 _resolveXmlToCIM();
1278 _resolveCIMToSCMO();
|
1279 r.kieninger 1.1 }
1280
|
1281 thilo.boehm 1.3 void CIMResponseData::_resolveSCMOToCIM()
|
1282 r.kieninger 1.1 {
|
1283 thilo.boehm 1.3 switch(_dataType)
|
1284 r.kieninger 1.2 {
|
1285 thilo.boehm 1.3 case RESP_INSTNAMES:
1286 case RESP_OBJECTPATHS:
|
1287 r.kieninger 1.2 {
|
1288 thilo.boehm 1.3 for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
1289 {
1290 CIMObjectPath newObjectPath;
1291 _scmoInstances[x].getCIMObjectPath(newObjectPath);
1292 _instanceNames.append(newObjectPath);
1293 }
1294 break;
|
1295 r.kieninger 1.2 }
|
1296 thilo.boehm 1.3 case RESP_INSTANCE:
|
1297 r.kieninger 1.1 {
|
1298 thilo.boehm 1.3 if (_scmoInstances.size() > 0)
1299 {
1300 CIMInstance newInstance;
1301 _scmoInstances[0].getCIMInstance(newInstance);
1302 _instances.append(newInstance);
1303 }
1304 break;
|
1305 r.kieninger 1.1 }
|
1306 thilo.boehm 1.3 case RESP_INSTANCES:
|
1307 r.kieninger 1.1 {
|
1308 thilo.boehm 1.3 for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
1309 {
1310 CIMInstance newInstance;
1311 _scmoInstances[x].getCIMInstance(newInstance);
1312 _instances.append(newInstance);
1313 }
1314 break;
|
1315 r.kieninger 1.1 }
|
1316 thilo.boehm 1.3 case RESP_OBJECTS:
|
1317 r.kieninger 1.1 {
|
1318 thilo.boehm 1.3 for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
1319 {
1320 CIMInstance newInstance;
1321 _scmoInstances[x].getCIMInstance(newInstance);
1322 _objects.append(CIMObject(newInstance));
1323 }
1324 break;
|
1325 r.kieninger 1.1 }
|
1326 thilo.boehm 1.3 default:
|
1327 r.kieninger 1.1 {
|
1328 thilo.boehm 1.3 PEGASUS_DEBUG_ASSERT(false);
|
1329 r.kieninger 1.1 }
1330 }
|
1331 thilo.boehm 1.3 _scmoInstances.clear();
1332 // remove CIM Encoding flag
1333 _encoding &=(~RESP_ENC_SCMO);
1334 // add SCMO Encoding flag
1335 _encoding |=RESP_ENC_CIM;
|
1336 r.kieninger 1.1 }
1337
|
1338 thilo.boehm 1.3 void CIMResponseData::_resolveCIMToSCMO()
|
1339 r.kieninger 1.1 {
|
1340 thilo.boehm 1.3 CString nsCString=_defaultNamespace.getString().getCString();
1341 const char* _defNamespace = nsCString;
1342 Uint32 _defNamespaceLen;
1343 if (_defaultNamespace.isNull())
|
1344 r.kieninger 1.1 {
|
1345 thilo.boehm 1.3 _defNamespaceLen=0;
|
1346 r.kieninger 1.1 }
1347 else
1348 {
|
1349 thilo.boehm 1.3 _defNamespaceLen=strlen(_defNamespace);
|
1350 r.kieninger 1.1 }
|
1351 thilo.boehm 1.3 switch (_dataType)
|
1352 r.kieninger 1.1 {
|
1353 thilo.boehm 1.3 case RESP_INSTNAMES:
|
1354 r.kieninger 1.1 {
|
1355 thilo.boehm 1.3 for (Uint32 i=0,n=_instanceNames.size();i<n;i++)
1356 {
1357 SCMOInstance addme(
1358 _instanceNames[i],
1359 _defNamespace,
1360 _defNamespaceLen);
1361 _scmoInstances.append(addme);
1362 }
1363 _instanceNames.clear();
1364 break;
|
1365 r.kieninger 1.1 }
|
1366 thilo.boehm 1.3 case RESP_INSTANCE:
|
1367 r.kieninger 1.2 {
|
1368 thilo.boehm 1.3 if (_instances.size() > 0)
1369 {
1370 SCMOInstance addme(
1371 _instances[0],
1372 _defNamespace,
1373 _defNamespaceLen);
1374 _scmoInstances.clear();
1375 _scmoInstances.append(addme);
1376 _instances.clear();
1377 }
1378 break;
|
1379 r.kieninger 1.2 }
|
1380 thilo.boehm 1.3 case RESP_INSTANCES:
|
1381 r.kieninger 1.1 {
|
1382 thilo.boehm 1.3 for (Uint32 i=0,n=_instances.size();i<n;i++)
|
1383 r.kieninger 1.1 {
|
1384 thilo.boehm 1.3 SCMOInstance addme(
1385 _instances[i],
1386 _defNamespace,
1387 _defNamespaceLen);
1388 _scmoInstances.append(addme);
|
1389 r.kieninger 1.1 }
|
1390 thilo.boehm 1.3 _instances.clear();
1391 break;
1392 }
1393 case RESP_OBJECTS:
1394 {
1395 for (Uint32 i=0,n=_objects.size();i<n;i++)
|
1396 r.kieninger 1.1 {
|
1397 thilo.boehm 1.3 SCMOInstance addme(
1398 _objects[i],
1399 _defNamespace,
1400 _defNamespaceLen);
1401 _scmoInstances.append(addme);
|
1402 r.kieninger 1.1 }
|
1403 thilo.boehm 1.3 _objects.clear();
1404 break;
1405 }
1406 case RESP_OBJECTPATHS:
1407 {
1408 for (Uint32 i=0,n=_instanceNames.size();i<n;i++)
|
1409 r.kieninger 1.1 {
|
1410 thilo.boehm 1.3 SCMOInstance addme(
1411 _instanceNames[i],
1412 _defNamespace,
1413 _defNamespaceLen);
1414 // TODO: More description about this.
1415 if (0 == _instanceNames[i].getKeyBindings().size())
1416 {
1417 // if there is no keybinding, this is a class
1418 addme.setIsClassOnly(true);
1419 }
1420 _scmoInstances.append(addme);
|
1421 r.kieninger 1.1 }
|
1422 thilo.boehm 1.3 _instanceNames.clear();
1423 break;
|
1424 r.kieninger 1.1 }
|
1425 thilo.boehm 1.3 default:
|
1426 r.kieninger 1.1 {
|
1427 thilo.boehm 1.3 PEGASUS_DEBUG_ASSERT(false);
|
1428 r.kieninger 1.1 }
1429 }
1430
|
1431 thilo.boehm 1.3 // remove CIM Encoding flag
1432 _encoding &=(~RESP_ENC_CIM);
1433 // add SCMO Encoding flag
1434 _encoding |=RESP_ENC_SCMO;
|
1435 r.kieninger 1.1 }
1436
|
1437 anusha.kandepu 1.6 void CIMResponseData::setRequestProperties(
1438 const Boolean includeQualifiers,
1439 const Boolean includeClassOrigin,
1440 const CIMPropertyList& propertyList)
1441 {
1442 _includeQualifiers = includeQualifiers;
1443 _includeClassOrigin = includeClassOrigin;
1444 _propertyList = propertyList;
1445 }
1446
|
1447 r.kieninger 1.1 PEGASUS_NAMESPACE_END
|