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 karl 1.5.2.7 // Class CIMResponseData encapsulates the possible types of response data
31 // representations and supplies conversion methods between these types.
32 // PEP#348 - The CMPI infrastructure using SCMO (Single Chunk Memory Objects)
33 // describes its usage in the server flow.
34 // The design document can be found on the OpenPegasus website openpegasus.org
35 // at https://collaboration.opengroup.org/pegasus/pp/documents/21210/PEP_348.pdf
36 //
|
37 r.kieninger 1.1 //%/////////////////////////////////////////////////////////////////////////////
38
39 #include "CIMResponseData.h"
|
40 thilo.boehm 1.3 #include <Pegasus/Common/Tracer.h>
41 #include <Pegasus/Common/XmlWriter.h>
42 #include <Pegasus/Common/SCMOXmlWriter.h>
43 #include <Pegasus/Common/XmlReader.h>
44 #include <Pegasus/Common/CIMInternalXmlEncoder.h>
45 #include <Pegasus/Common/SCMOInternalXmlEncoder.h>
|
46 r.kieninger 1.1
|
47 karl 1.5.2.5
|
48 r.kieninger 1.1 PEGASUS_USING_STD;
49
50 PEGASUS_NAMESPACE_BEGIN
51
|
52 karl 1.5.2.11 // Defines debug code in CIMResponseData. This under this
53 // special compile flag so that it can be compiled independent of
54 // PEGASUS_DEBUG flags.
|
55 karl 1.5.2.25 // #define CIMRESPONSEDATA_DEBUG
|
56 karl 1.5.2.11
|
57 karl 1.5.2.1 #define LOCAL_MIN(a, b) ((a < b) ? a : b)
|
58 karl 1.5.2.15
59 /*
60 Append an InstanceElement to the Buffer. This function accounts
61 for the existence of a propertyList.
62 */
63 void CIMResponseData::_appendInstanceElement(
64 Buffer& out,
65 SCMOInstance _scmoInstance)
66 {
67 if(_propertyList.isNull())
68 {
69 Array<Uint32> emptyNodes;
70 SCMOXmlWriter::appendInstanceElement(
71 out,
72 _scmoInstance,
73 false,
74 emptyNodes);
75 }
76 else
77 {
78 Array<propertyFilterNodesArray_t> propFilterNodesArrays;
79 karl 1.5.2.15 // This searches for an already created array of nodes,
80 //if not found, creates it inside propFilterNodesArrays
81 const Array<Uint32> & nodes=
82 SCMOXmlWriter::getFilteredNodesArray(
83 propFilterNodesArrays,
84 _scmoInstance,
85 _propertyList);
86 SCMOXmlWriter::appendInstanceElement(
87 out,
88 _scmoInstance,
89 true,
90 nodes);
91 }
92 }
93
|
94 thilo.boehm 1.3 // Instance Names handling
95 Array<CIMObjectPath>& CIMResponseData::getInstanceNames()
96 {
97 PEGASUS_DEBUG_ASSERT(
98 (_dataType==RESP_INSTNAMES || _dataType==RESP_OBJECTPATHS));
99 _resolveToCIM();
100 PEGASUS_DEBUG_ASSERT(_encoding==RESP_ENC_CIM || _encoding == 0);
101 return _instanceNames;
102 }
103
|
104 karl 1.5.2.1 // Get a single instance as a CIM instance.
105 // This converts all of the objects in the response data to
106 // CIM form as part of the conversion.
107 // If there are no instances in the object, returns CIMInstance(),
108 // an empty instance.
|
109 thilo.boehm 1.3 CIMInstance& CIMResponseData::getInstance()
110 {
111 PEGASUS_DEBUG_ASSERT(_dataType == RESP_INSTANCE);
112 _resolveToCIM();
113 if (0 == _instances.size())
114 {
115 _instances.append(CIMInstance());
116 }
117 return _instances[0];
118 }
119
120 // Instances handling
121 Array<CIMInstance>& CIMResponseData::getInstances()
122 {
123 PEGASUS_DEBUG_ASSERT(_dataType == RESP_INSTANCES);
124 _resolveToCIM();
125 return _instances;
126 }
127
|
128 karl 1.5.2.1 // Instances handling specifically for the client where the call may
129 // get either instances or objects and must convert them to instances
130 // NOTE: This is a temporary solution to satisfy the BinaryCodec passing
131 // of data to the client where the data could be either instances or
132 // objects. The correct solution is to convert back when the provider, etc.
133 // returns the data to the server. We must convert to that solution but
134 // this keeps it working for the moment.
135 Array<CIMInstance>& CIMResponseData::getInstancesFromInstancesOrObjects()
136 {
137 if (_dataType == RESP_INSTANCES)
138 {
139 _resolveToCIM();
140 return _instances;
141 }
142 else if (_dataType == RESP_OBJECTS)
143 {
144 _resolveToCIM();
145 for (Uint32 i = 0 ; i < _objects.size() ; i++)
146 {
147 _instances.append((CIMInstance)_objects[i]);
148 }
149 karl 1.5.2.1 return _instances;
150
151 }
|
152 karl 1.5.2.11 PEGASUS_ASSERT(false);
|
153 karl 1.5.2.1 }
154
|
155 thilo.boehm 1.3 // Objects handling
156 Array<CIMObject>& CIMResponseData::getObjects()
157 {
|
158 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::getObjects");
|
159 thilo.boehm 1.3 PEGASUS_DEBUG_ASSERT(_dataType == RESP_OBJECTS);
160 _resolveToCIM();
|
161 karl 1.5.2.11 PEG_METHOD_EXIT();
|
162 thilo.boehm 1.3 return _objects;
163 }
164
165 // SCMO representation, single instance stored as one element array
166 // object paths are represented as SCMOInstance
|
167 karl 1.5.2.7 // Resolve all of the information in the CIMResponseData container to
168 // SCMO and return all scmoInstances.
169 // Note that since the SCMO representation,
170 // a is single instance stored as one element array and object paths are
171 // represented as SCMOInstance this returns array of SCMOInstance.
|
172 thilo.boehm 1.3 Array<SCMOInstance>& CIMResponseData::getSCMO()
173 {
|
174 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::getSCMO");
|
175 karl 1.5.2.7 // This function resolves to instances and so cannot handle responses to
176 // the associators,etc.requests that return classes (input object path with
177 // no keys). That issue is resolved however, since CIMResponseData uses the
178 // _isClassOperation variable (set by the request) to determine whether
179 // the responses are classpaths or instancepaths and the default is
180 // false(instancePaths) so that this should always produce instance paths.
181
|
182 thilo.boehm 1.3 _resolveToSCMO();
|
183 karl 1.5.2.11 PEG_METHOD_EXIT();
|
184 thilo.boehm 1.3 return _scmoInstances;
185 }
186
|
187 karl 1.5.2.1 // set an array of SCMOInstances into the response data object
|
188 thilo.boehm 1.3 void CIMResponseData::setSCMO(const Array<SCMOInstance>& x)
189 {
|
190 karl 1.5.2.11
191 PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setSCMO");
|
192 thilo.boehm 1.3 _scmoInstances=x;
193 _encoding |= RESP_ENC_SCMO;
|
194 karl 1.5.2.1 _size += x.size();
|
195 karl 1.5.2.11 PEG_METHOD_EXIT();
|
196 thilo.boehm 1.3 }
197
198 // Binary data is just a data stream
199 Array<Uint8>& CIMResponseData::getBinary()
200 {
201 PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_BINARY || _encoding == 0);
202 return _binaryData;
203 }
204
|
205 karl 1.5 bool CIMResponseData::setBinary(CIMBuffer& in)
|
206 r.kieninger 1.1 {
|
207 karl 1.5 PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setBinary");
|
208 r.kieninger 1.1
|
209 karl 1.5 // Append all serial data from the CIMBuffer to the local data store.
210 // Returns error if input not a serialized Uint8A
211 if (!in.getUint8A(_binaryData))
212 {
213 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
214 "Failed to get binary input data!");
215 PEG_METHOD_EXIT();
216 return false;
|
217 r.kieninger 1.1 }
|
218 karl 1.5 _encoding |= RESP_ENC_BINARY;
219 PEG_METHOD_EXIT();
220 return true;
221 }
222
223 bool CIMResponseData::setRemainingBinaryData(CIMBuffer& in)
224 {
225 PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setRemainingBinaryData");
226
227 // Append any data that has not been deserialized already from
228 // the CIMBuffer.
229 size_t remainingDataLength = in.remainingDataLength();
230 _binaryData.append((Uint8*)in.getPtr(), remainingDataLength);
231
|
232 thilo.boehm 1.3 _encoding |= RESP_ENC_BINARY;
|
233 r.kieninger 1.1 PEG_METHOD_EXIT();
234 return true;
|
235 thilo.boehm 1.3 }
|
236 r.kieninger 1.1
|
237 thilo.boehm 1.3 bool CIMResponseData::setXml(CIMBuffer& in)
|
238 r.kieninger 1.1 {
|
239 karl 1.5.2.12 PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::setXml");
240
|
241 thilo.boehm 1.3 switch (_dataType)
|
242 r.kieninger 1.1 {
|
243 thilo.boehm 1.3 case RESP_INSTANCE:
244 {
245 Array<Sint8> inst;
246 Array<Sint8> ref;
247 CIMNamespaceName ns;
248 String host;
249 if (!in.getSint8A(inst))
250 {
251 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
252 "Failed to get XML instance data!");
253 return false;
254 }
255 _instanceData.insert(0,inst);
256 if (!in.getSint8A(ref))
257 {
258 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
259 "Failed to get XML instance data (reference)!");
260 return false;
261 }
262 _referencesData.insert(0,ref);
263 if (!in.getString(host))
264 thilo.boehm 1.3 {
265 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
266 "Failed to get XML instance data (host)!");
267 return false;
268 }
269 _hostsData.insert(0,host);
270 if (!in.getNamespaceName(ns))
271 {
272 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
273 "Failed to get XML instance data (namespace)!");
274 return false;
275 }
276 _nameSpacesData.insert(0,ns);
|
277 karl 1.5.2.1 _size++;
|
278 thilo.boehm 1.3 break;
279 }
280 case RESP_INSTANCES:
281 {
282 Uint32 count;
283 if (!in.getUint32(count))
284 {
285 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
286 "Failed to get XML instance data (number of instance)!");
287 return false;
288 }
289 for (Uint32 i = 0; i < count; i++)
290 {
291 Array<Sint8> inst;
292 Array<Sint8> ref;
293 CIMNamespaceName ns;
294 String host;
295 if (!in.getSint8A(inst))
296 {
297 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
298 "Failed to get XML instance data (instances)!");
299 thilo.boehm 1.3 return false;
300 }
301 if (!in.getSint8A(ref))
302 {
303 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
304 "Failed to get XML instance data (references)!");
305 return false;
306 }
307 if (!in.getString(host))
308 {
309 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
310 "Failed to get XML instance data (host)!");
311 return false;
312 }
313 if (!in.getNamespaceName(ns))
314 {
315 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
316 "Failed to get XML instance data (namespace)!");
317 return false;
318 }
319 _instanceData.append(inst);
320 thilo.boehm 1.3 _referencesData.append(ref);
321 _hostsData.append(host);
322 _nameSpacesData.append(ns);
323 }
|
324 karl 1.5.2.1 _size += count;
|
325 thilo.boehm 1.3 break;
326 }
327 case RESP_OBJECTS:
328 {
329 Uint32 count;
330 if (!in.getUint32(count))
331 {
332 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
333 "Failed to get XML object data (number of objects)!");
334 return false;
335 }
336 for (Uint32 i = 0; i < count; i++)
337 {
338 Array<Sint8> obj;
339 Array<Sint8> ref;
340 CIMNamespaceName ns;
341 String host;
342 if (!in.getSint8A(obj))
343 {
344 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
345 "Failed to get XML object data (object)!");
346 thilo.boehm 1.3 return false;
347 }
348 if (!in.getSint8A(ref))
349 {
350 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
351 "Failed to get XML object data (reference)!");
352 return false;
353 }
354 if (!in.getString(host))
355 {
356 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
357 "Failed to get XML object data (host)!");
358 return false;
359 }
360 if (!in.getNamespaceName(ns))
361 {
362 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
363 "Failed to get XML object data (namespace)!");
364 return false;
365 }
366 _instanceData.append(obj);
367 thilo.boehm 1.3 _referencesData.append(ref);
368 _hostsData.append(host);
369 _nameSpacesData.append(ns);
370 }
|
371 karl 1.5.2.1 _size += count;
|
372 thilo.boehm 1.3 break;
373 }
374 // internal xml encoding of instance names and object paths not
375 // done today
376 case RESP_INSTNAMES:
377 case RESP_OBJECTPATHS:
378 default:
379 {
|
380 karl 1.5.2.11 PEGASUS_ASSERT(false);
|
381 thilo.boehm 1.3 }
|
382 r.kieninger 1.1 }
|
383 thilo.boehm 1.3 _encoding |= RESP_ENC_XML;
|
384 karl 1.5.2.12
385 PEG_METHOD_EXIT();
|
386 thilo.boehm 1.3 return true;
387 }
|
388 r.kieninger 1.1
|
389 karl 1.5.2.1 // Move the number of objects defined by the input parameter from
390 // one CIMResponse Object to another CIMResponse Object.
|
391 karl 1.5.2.8 // Returns the new size of the CIMResponseData object.
392 // NOTE: This is not protected by a mutex so the user must be certain
393 // that the from object is not used during the move.
|
394 karl 1.5.2.1 Uint32 CIMResponseData::moveObjects(CIMResponseData & from, Uint32 count)
395 {
|
396 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER, "CIMResponseData::moveObjects");
397
|
398 karl 1.5.2.1 PEG_TRACE((TRC_XML, Tracer::LEVEL3,
399 "CIMResponseData::move(%u)", count));
400
|
401 karl 1.5.2.11 PEGASUS_DEBUG_ASSERT(valid()); // KS_TEMP
402 PEGASUS_DEBUG_ASSERT(_size == 0); // Validate size == 0 or fix below
|
403 karl 1.5.2.1 PEGASUS_DEBUG_ASSERT(_dataType == from._dataType);
|
404 karl 1.5.2.11
|
405 karl 1.5.2.1 Uint32 rtnSize = 0;
406 Uint32 toMove = count;
407
408 if (RESP_ENC_XML == (from._encoding & RESP_ENC_XML))
409 {
410 switch (_dataType)
411 {
412 case RESP_OBJECTPATHS:
413 case RESP_INSTNAMES:
414 break;
415 case RESP_INSTANCE:
416 {
417 if (from._instanceData.size() > 0)
418 {
419 // temp test to assure all sizes are the same.
|
420 karl 1.5.2.11 PEGASUS_DEBUG_ASSERT(from._hostsData.size() ==
|
421 karl 1.5.2.1 from._instanceData.size());
|
422 karl 1.5.2.11 PEGASUS_DEBUG_ASSERT(from._referencesData.size() ==
|
423 karl 1.5.2.1 from._instanceData.size());
|
424 karl 1.5.2.11 PEGASUS_DEBUG_ASSERT(from._nameSpacesData.size() ==
|
425 karl 1.5.2.1 from._instanceData.size());
426 _instanceData.append(from._instanceData.getData(),1);
427 from._instanceData.remove(0, 1);
428 _referencesData.append(
429 from._referencesData.getData(),1);
430 from._referencesData.remove(0, 1);
431 if (_hostsData.size())
432 {
433 _hostsData.append(from._hostsData.getData(),1);
434 from._hostsData.remove(0, 1);
435 }
436 if (_nameSpacesData.size())
437 {
438 _nameSpacesData.append(
439 from._nameSpacesData.getData(),1);
440 from._nameSpacesData.remove(0, 1);
441 }
442 rtnSize += 1;
443 toMove--;
444 _encoding |= RESP_ENC_XML;
445 }
446 karl 1.5.2.1 }
447 break;
448
|
449 karl 1.5.2.31 // KS-FUTURE The above could probably be folded into the following.
|
450 karl 1.5.2.1 // Need something like an assert if there is ever more than
451 // one instance in _instanceData for type RESP_INSTANCE
452 case RESP_INSTANCES:
453 case RESP_OBJECTS:
454 {
455 Uint32 moveCount = LOCAL_MIN(toMove,
456 from._instanceData.size());
457
|
458 karl 1.5.2.11 PEGASUS_DEBUG_ASSERT(from._referencesData.size() ==
|
459 karl 1.5.2.1 from._instanceData.size());
460 _instanceData.append(from._instanceData.getData(),
461 moveCount);
462 from._instanceData.remove(0, moveCount);
463 _referencesData.append(from._referencesData.getData(),
464 moveCount);
465 from._referencesData.remove(0, moveCount);
|
466 karl 1.5.2.12 _hostsData.append(from._hostsData.getData(),
467 moveCount);
468 from._hostsData.remove(0, moveCount);
469 _nameSpacesData.append(from._nameSpacesData.getData(),
470 moveCount);
471 from._nameSpacesData.remove(0, moveCount);
|
472 karl 1.5.2.1 rtnSize += moveCount;
473 toMove -= moveCount;
474 _encoding |= RESP_ENC_XML;
475 }
476 break;
477 }
478 }
479 if (RESP_ENC_BINARY == (from._encoding & RESP_ENC_BINARY))
480 {
481 // Cannot resolve this one without actually processing
|
482 karl 1.5.2.11 // the data since it is a stream. Concluded that we do not
483 // want to do that since cost higher than gain. Therefore we do
484 // not allow this option. Should only mean that provider agent
485 // cannot generate binary for pull operations.
|
486 karl 1.5.2.1 rtnSize += 0;
487 PEGASUS_ASSERT(false);
488 }
489
490 if (RESP_ENC_SCMO == (from._encoding & RESP_ENC_SCMO))
491 {
492 Uint32 moveCount = LOCAL_MIN(toMove, from._scmoInstances.size());
493
494 _scmoInstances.append(from._scmoInstances.getData(), moveCount);
495 from._scmoInstances.remove(0, moveCount);
496 rtnSize += moveCount;
497 toMove -= moveCount;
498 _encoding |= RESP_ENC_SCMO;
499 }
500
501 if (RESP_ENC_CIM == (from._encoding & RESP_ENC_CIM))
502 {
503 switch (_dataType)
504 {
505 case RESP_OBJECTPATHS:
506 case RESP_INSTNAMES:
507 karl 1.5.2.1 {
508 Uint32 moveCount = LOCAL_MIN(toMove,
509 from._instanceNames.size());
510
511 _instanceNames.append(
512 from._instanceNames.getData(), moveCount);
513 from._instanceNames.remove(0, moveCount);
514 rtnSize += moveCount;
515 toMove -= moveCount;
516 _encoding |= RESP_ENC_CIM;
517 }
518 break;
519 case RESP_INSTANCE:
520 case RESP_INSTANCES:
521 {
522
523 Uint32 moveCount = LOCAL_MIN(toMove,
524 from._instances.size());
525
526 _instances.append(from._instances.getData(), moveCount);
527 from._instances.remove(0, moveCount);
528 karl 1.5.2.1 rtnSize += moveCount;
529 toMove -= moveCount;
530 _encoding |= RESP_ENC_CIM;
531 }
532 break;
533 case RESP_OBJECTS:
534 {
535 Uint32 moveCount = LOCAL_MIN(toMove,
536 from._objects.size());
537 _objects.append(from._objects.getData(), moveCount);
538 from._objects.remove(0, moveCount);
539 rtnSize += moveCount;
540 toMove -= moveCount;
541 _encoding |= RESP_ENC_CIM;
542 }
543 break;
544 }
545 }
546 PEGASUS_ASSERT(rtnSize == (count - toMove));
547
548 _size += rtnSize;
|
549 karl 1.5.2.13
550 // insure that _size never goes negative. This is probably a
551 // diagnostics KS_TODO remove before release
552 if (from._size >= rtnSize)
553 {
554
555 from._size -= rtnSize;
556 }
557 else
558 {
559 from._size = 0;
560 }
|
561 karl 1.5.2.2
|
562 karl 1.5.2.11 //// KS_TODO diagnostic that we should be able to remove
|
563 karl 1.5.2.2 if (rtnSize != _size)
564 {
565 PEG_TRACE((TRC_XML, Tracer::LEVEL1,
566 "Size calc error _size %u rtnSWize = %u", _size, rtnSize));
567 }
|
568 karl 1.5.2.9 PEG_METHOD_EXIT();
|
569 karl 1.5.2.1 return rtnSize;
570 }
571
|
572 karl 1.5.2.12 Boolean CIMResponseData::hasBinaryData() const
573 {
574 return (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY));
575 }
576 // Sets the _size variable based on the internal size counts.
577 void CIMResponseData::setSize()
578 {
|
579 karl 1.5.2.27 PEGASUS_DEBUG_ASSERT(valid());
|
580 karl 1.5.2.12
581 Uint32 rtnSize = 0;
582 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
583 {
584 switch (_dataType)
585 {
586 case RESP_OBJECTPATHS:
587 case RESP_INSTNAMES:
588 break;
589 case RESP_INSTANCE:
590 rtnSize +=1;
591 break;
592 case RESP_INSTANCES:
593 case RESP_OBJECTS:
594 rtnSize += _instanceData.size();
595 break;
596 }
597 }
598 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
599 {
600 // KS_PULL_TODO
601 karl 1.5.2.12 // Cannot resolve this one without actually processing
602 // the data since it is a stream.
603 rtnSize += 0;
604 }
605
606 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
607 {
608 rtnSize += _scmoInstances.size();
609 }
610
611 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
612 {
613 switch (_dataType)
614 {
615 case RESP_OBJECTPATHS:
616 case RESP_INSTNAMES:
617 rtnSize += _instanceNames.size();
618 break;
619 case RESP_INSTANCE:
620 case RESP_INSTANCES:
621 rtnSize += _instances.size();
622 karl 1.5.2.12 break;
623 case RESP_OBJECTS:
624 rtnSize += _objects.size();
625 break;
626 }
627 }
628 _size = rtnSize;
629 }
|
630 karl 1.5.2.1 //
|
631 karl 1.5.2.25 // Return the number of CIM objects in the CIM Response data object by
632 // aggregating sizes of each of the encodings
633 //
|
634 karl 1.5.2.1 Uint32 CIMResponseData::size()
635 {
636 // If debug mode, add up all the individual size components to
637 // determine overall size of this object. Then compare this with
|
638 karl 1.5.2.25 // the _size variable. This is a check on the completeness of the
|
639 karl 1.5.2.1 // size computations. We should be able to remove this at some point
640 // but there are many sources of size info and we need to be sure we
641 // have covered them all.
|
642 karl 1.5.2.25 #ifdef CIMRESPONSEDATA_DEBUG
643 PEGASUS_DEBUG_ASSERT(valid());
|
644 karl 1.5.2.1
645 Uint32 rtnSize = 0;
|
646 karl 1.5.2.25
|
647 karl 1.5.2.1 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
648 {
649 switch (_dataType)
650 {
651 case RESP_OBJECTPATHS:
652 case RESP_INSTNAMES:
653 break;
654 case RESP_INSTANCE:
655 rtnSize +=1;
656 break;
657 case RESP_INSTANCES:
658 case RESP_OBJECTS:
659 rtnSize += _instanceData.size();
660 break;
661 }
662 }
663 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
664 {
665 // KS_PULL_TODO
666 // Cannot resolve this one without actually processing
667 // the data since it is a stream.
668 karl 1.5.2.1 rtnSize += 0;
669 }
670
671 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
672 {
673 rtnSize += _scmoInstances.size();
674 }
675
676 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
677 {
678 switch (_dataType)
679 {
680 case RESP_OBJECTPATHS:
681 case RESP_INSTNAMES:
682 rtnSize += _instanceNames.size();
683 break;
684 case RESP_INSTANCE:
685 case RESP_INSTANCES:
686 rtnSize += _instances.size();
687 break;
688 case RESP_OBJECTS:
689 karl 1.5.2.1 rtnSize += _objects.size();
690 break;
691 }
692 }
|
693 karl 1.5.2.9 // Test of actual count against _size variable. KS_TODO diagnostic
|
694 karl 1.5.2.22 Uint32 lsize = _size;
695 if (rtnSize != lsize)
|
696 karl 1.5.2.1 {
697 PEG_TRACE((TRC_XML, Tracer::LEVEL1,
698 "CIMResponseData::size ERROR. debug size mismatch."
|
699 karl 1.5.2.22 "Computed = %u. variable = %u inc binary %s",rtnSize, _size,
700 boolToString(RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
701 ));
|
702 karl 1.5.2.1 }
703 #endif
704 return _size;
705 }
706
|
707 thilo.boehm 1.3 // function used by OperationAggregator to aggregate response data in a
|
708 karl 1.5.2.1 // single ResponseData object. Adds all data in the from ResponseData object
709 // input variable to the target ResponseData object
710 // target array
|
711 thilo.boehm 1.3 void CIMResponseData::appendResponseData(const CIMResponseData & x)
712 {
|
713 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
714 "CIMResponseData::appendResponseData");
|
715 karl 1.5.2.28
716 PEGASUS_DEBUG_ASSERT(valid());
717
|
718 karl 1.5.2.1 // Confirm that the CIMResponseData type matches the type
719 // of the data being appended
|
720 karl 1.5.2.28 // A CIMResponseData must represent a single data content type.
721 // ex. Cannot mix objects and instances.
|
722 karl 1.5.2.1
|
723 thilo.boehm 1.3 PEGASUS_DEBUG_ASSERT(_dataType == x._dataType);
724 _encoding |= x._encoding;
725
726 // add all binary data
727 _binaryData.appendArray(x._binaryData);
728
729 // add all the C++ stuff
730 _instanceNames.appendArray(x._instanceNames);
|
731 karl 1.5.2.1 _size += x._instanceNames.size();
|
732 thilo.boehm 1.3 _instances.appendArray(x._instances);
|
733 karl 1.5.2.1 _size += x._instances.size();
|
734 thilo.boehm 1.3 _objects.appendArray(x._objects);
|
735 karl 1.5.2.1 _size += x._objects.size();
|
736 thilo.boehm 1.3
737 // add the SCMO instances
738 _scmoInstances.appendArray(x._scmoInstances);
|
739 karl 1.5.2.1 _size += x._scmoInstances.size();
|
740 thilo.boehm 1.3
741 _referencesData.appendArray(x._referencesData);
742 _instanceData.appendArray(x._instanceData);
743 _hostsData.appendArray(x._hostsData);
744 _nameSpacesData.appendArray(x._nameSpacesData);
|
745 karl 1.5.2.13 _size += x._instanceData.size();
746
|
747 karl 1.5.2.6 // transfer property list
748 _propertyList = x._propertyList;
|
749 karl 1.5.2.11
750 PEG_METHOD_EXIT();
|
751 thilo.boehm 1.3 }
|
752 r.kieninger 1.1
|
753 thilo.boehm 1.3 // Encoding responses into output format
754 void CIMResponseData::encodeBinaryResponse(CIMBuffer& out)
|
755 r.kieninger 1.1 {
756 PEG_METHOD_ENTER(TRC_DISPATCHER,
|
757 thilo.boehm 1.3 "CIMResponseData::encodeBinaryResponse");
|
758 r.kieninger 1.1
|
759 thilo.boehm 1.3 // Need to do a complete job here by transferring all contained data
760 // into binary format and handing it out in the CIMBuffer
|
761 karl 1.5.2.1 // KS_TODO
|
762 thilo.boehm 1.3 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
|
763 r.kieninger 1.1 {
|
764 thilo.boehm 1.3 // Binary does NOT need a marker as it consists of C++ and SCMO
|
765 r.kieninger 1.1 const Array<Uint8>& data = _binaryData;
766 out.putBytes(data.getData(), data.size());
767 }
|
768 karl 1.5.2.1
|
769 thilo.boehm 1.3 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
|
770 r.kieninger 1.1 {
|
771 thilo.boehm 1.3 out.putTypeMarker(BIN_TYPE_MARKER_CPPD);
772 switch (_dataType)
773 {
774 case RESP_INSTNAMES:
775 {
776 out.putObjectPathA(_instanceNames);
777 break;
778 }
779 case RESP_INSTANCE:
780 {
781 if (0 == _instances.size())
782 {
783 _instances.append(CIMInstance());
784 }
785 out.putInstance(_instances[0], true, true);
786 break;
787 }
788 case RESP_INSTANCES:
789 {
790 out.putInstanceA(_instances);
791 break;
792 thilo.boehm 1.3 }
793 case RESP_OBJECTS:
794 {
795 out.putObjectA(_objects);
796 break;
797 }
798 case RESP_OBJECTPATHS:
799 {
800 out.putObjectPathA(_instanceNames);
801 break;
802 }
803 default:
804 {
|
805 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
806 thilo.boehm 1.3 }
807 }
|
808 r.kieninger 1.1 }
|
809 thilo.boehm 1.3 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
|
810 r.kieninger 1.1 {
|
811 thilo.boehm 1.3 out.putTypeMarker(BIN_TYPE_MARKER_SCMO);
812 out.putSCMOInstanceA(_scmoInstances);
|
813 r.kieninger 1.1 }
|
814 thilo.boehm 1.3 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
|
815 r.kieninger 1.1 {
|
816 thilo.boehm 1.3 // This actually should not happen following general code logic
|
817 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
818 r.kieninger 1.1 }
|
819 thilo.boehm 1.3
|
820 r.kieninger 1.1 PEG_METHOD_EXIT();
821 }
822
|
823 thilo.boehm 1.3 void CIMResponseData::completeNamespace(const SCMOInstance * x)
|
824 r.kieninger 1.1 {
|
825 thilo.boehm 1.3 const char * ns;
826 Uint32 len;
827 ns = x->getNameSpace_l(len);
828 // Both internal XML as well as binary always contain a namespace
829 // don't have to do anything for those two encodings
830 if ((RESP_ENC_BINARY == (_encoding&RESP_ENC_BINARY)) && (len != 0))
|
831 r.kieninger 1.1 {
|
832 thilo.boehm 1.3 _defaultNamespace = CIMNamespaceName(ns);
|
833 r.kieninger 1.1 }
|
834 thilo.boehm 1.3 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
|
835 r.kieninger 1.1 {
|
836 thilo.boehm 1.3 CIMNamespaceName nsName(ns);
837 switch (_dataType)
|
838 r.kieninger 1.1 {
|
839 thilo.boehm 1.3 case RESP_INSTANCE:
840 {
841 if (_instances.size() > 0)
842 {
843 const CIMInstance& inst = _instances[0];
844 CIMObjectPath& p =
845 const_cast<CIMObjectPath&>(inst.getPath());
846 if (p.getNameSpace().isNull())
847 {
848 p.setNameSpace(nsName);
849 }
850 }
|
851 karl 1.5.2.3 break;
|
852 thilo.boehm 1.3 }
853 case RESP_INSTANCES:
854 {
855 for (Uint32 j = 0, n = _instances.size(); j < n; j++)
856 {
857 const CIMInstance& inst = _instances[j];
858 CIMObjectPath& p =
859 const_cast<CIMObjectPath&>(inst.getPath());
860 if (p.getNameSpace().isNull())
861 {
862 p.setNameSpace(nsName);
863 }
864 }
865 break;
866 }
867 case RESP_OBJECTS:
868 {
869 for (Uint32 j = 0, n = _objects.size(); j < n; j++)
870 {
871 const CIMObject& object = _objects[j];
872 CIMObjectPath& p =
873 thilo.boehm 1.3 const_cast<CIMObjectPath&>(object.getPath());
874 if (p.getNameSpace().isNull())
875 {
876 p.setNameSpace(nsName);
877 }
878 }
879 break;
880 }
881 case RESP_INSTNAMES:
882 case RESP_OBJECTPATHS:
883 {
884 for (Uint32 j = 0, n = _instanceNames.size(); j < n; j++)
885 {
886 CIMObjectPath& p = _instanceNames[j];
887 if (p.getNameSpace().isNull())
888 {
889 p.setNameSpace(nsName);
890 }
891 }
892 break;
893 }
894 thilo.boehm 1.3 default:
895 {
896 PEGASUS_DEBUG_ASSERT(false);
897 }
|
898 r.kieninger 1.1 }
899 }
|
900 karl 1.5.2.11
|
901 thilo.boehm 1.3 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
|
902 r.kieninger 1.1 {
|
903 thilo.boehm 1.3 for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++)
|
904 r.kieninger 1.1 {
|
905 thilo.boehm 1.3 SCMOInstance & scmoInst=_scmoInstances[j];
906 if (0 == scmoInst.getNameSpace())
907 {
908 scmoInst.setNameSpace_l(ns,len);
909 }
|
910 r.kieninger 1.1 }
911 }
912 }
913
|
914 thilo.boehm 1.3 void CIMResponseData::completeHostNameAndNamespace(
915 const String & hn,
|
916 karl 1.5.2.12 const CIMNamespaceName & ns,
917 Boolean isPullOperation)
|
918 r.kieninger 1.1 {
|
919 karl 1.5.2.1 PEG_METHOD_ENTER(TRC_DISPATCHER,
920 "CIMResponseData::completeHostNameAndNamespace");
921
|
922 karl 1.5.2.27 PEGASUS_DEBUG_ASSERT(valid());
|
923 karl 1.5.2.13
|
924 thilo.boehm 1.3 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
925 {
|
926 karl 1.5.2.13 // On binary need to remember hostname and namespace in case someone
927 // builds C++ default objects or Xml types later i.e.
|
928 thilo.boehm 1.3 // -> usage: See resolveBinary()
929 _defaultNamespace=ns;
930 _defaultHostname=hn;
931 }
932 // InternalXml does not support objectPath calls
933 if ((RESP_ENC_XML == (_encoding & RESP_ENC_XML)) &&
934 (RESP_OBJECTS == _dataType))
935 {
936 for (Uint32 j = 0, n = _referencesData.size(); j < n; j++)
937 {
938 if (0 == _hostsData[j].size())
939 {
940 _hostsData[j]=hn;
941 }
942 if (_nameSpacesData[j].isNull())
943 {
944 _nameSpacesData[j]=ns;
945 }
946 }
947 }
|
948 karl 1.5.2.12 // Need to set for Pull Enumeration operations
949 if ((RESP_ENC_XML == (_encoding & RESP_ENC_XML)) &&
950 ((RESP_INSTANCES == _dataType) || isPullOperation))
951 {
952 for (Uint32 j = 0, n = _referencesData.size(); j < n; j++)
953 {
954 if (0 == _hostsData[j].size())
955 {
956 _hostsData[j]=hn;
957 }
958 if (_nameSpacesData[j].isNull())
959 {
960 _nameSpacesData[j]=ns;
961 }
962
|
963 karl 1.5.2.13 // KS_TODO Remove Diagnostic
|
964 karl 1.5.2.12 PEG_TRACE(( TRC_DISPATCHER, Tracer::LEVEL4,
965 "completeHostNameAndNamespace Setting hostName, etc "
966 "host %s ns %s set to _hostData %s _namespaceData %s",
967 (const char *)hn.getCString(),
968 (const char *)ns.getString().getCString(),
969 (const char *)_hostsData[j].getCString(),
970 (const char *)_nameSpacesData[j].getString().getCString() ));
971 }
972 }
973
|
974 thilo.boehm 1.3 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
|
975 r.kieninger 1.1 {
|
976 thilo.boehm 1.3 switch (_dataType)
|
977 r.kieninger 1.2 {
|
978 karl 1.5.2.1 // Instances added to account for namedInstance in Pull operations.
979 case RESP_INSTANCES:
980
981 for (Uint32 j = 0, n = _instances.size(); j < n; j++)
982 {
983 const CIMInstance& instance = _instances[j];
984 CIMObjectPath& p =
985 const_cast<CIMObjectPath&>(instance.getPath());
986 if (p.getHost().size()==0)
987 {
988 p.setHost(hn);
989 }
990 if (p.getNameSpace().isNull())
991 {
992 p.setNameSpace(ns);
993 }
994 }
|
995 thilo.boehm 1.3 case RESP_OBJECTS:
996 {
997 for (Uint32 j = 0, n = _objects.size(); j < n; j++)
998 {
999 const CIMObject& object = _objects[j];
1000 CIMObjectPath& p =
1001 const_cast<CIMObjectPath&>(object.getPath());
1002 if (p.getHost().size()==0)
1003 {
1004 p.setHost(hn);
1005 }
1006 if (p.getNameSpace().isNull())
1007 {
1008 p.setNameSpace(ns);
1009 }
1010 }
1011 break;
1012 }
|
1013 karl 1.5.2.1 // INSTNAMES added to account for instance paths in pull name
1014 // operations
1015 case RESP_INSTNAMES:
|
1016 thilo.boehm 1.3 case RESP_OBJECTPATHS:
1017 {
1018 for (Uint32 j = 0, n = _instanceNames.size(); j < n; j++)
1019 {
1020 CIMObjectPath& p = _instanceNames[j];
1021 if (p.getHost().size() == 0)
|
1022 karl 1.5.2.11 {
|
1023 thilo.boehm 1.3 p.setHost(hn);
|
1024 karl 1.5.2.11 }
|
1025 thilo.boehm 1.3 if (p.getNameSpace().isNull())
|
1026 karl 1.5.2.11 {
|
1027 thilo.boehm 1.3 p.setNameSpace(ns);
|
1028 karl 1.5.2.11 }
|
1029 thilo.boehm 1.3 }
1030 break;
1031 }
1032 default:
1033 {
|
1034 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
1035 thilo.boehm 1.3 }
|
1036 r.kieninger 1.2 }
1037 }
|
1038 thilo.boehm 1.3 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
|
1039 r.kieninger 1.2 {
|
1040 thilo.boehm 1.3 CString hnCString=hn.getCString();
1041 const char* hnChars = hnCString;
1042 Uint32 hnLen = strlen(hnChars);
1043 CString nsCString=ns.getString().getCString();
1044 const char* nsChars=nsCString;
1045 Uint32 nsLen = strlen(nsChars);
1046 switch (_dataType)
1047 {
|
1048 karl 1.5.2.1 // KS_PULL add Instances and InstNames to cover pull operations
1049 // KS_PULL - Confirm that this OK.
1050 case RESP_INSTNAMES:
1051 case RESP_INSTANCES:
|
1052 thilo.boehm 1.3 case RESP_OBJECTS:
1053 case RESP_OBJECTPATHS:
1054 {
1055 for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++)
1056 {
1057 SCMOInstance & scmoInst=_scmoInstances[j];
|
1058 karl 1.5.2.7 scmoInst.completeHostNameAndNamespace(
1059 hnChars,
1060 hnLen,
1061 nsChars,
1062 nsLen);
|
1063 thilo.boehm 1.3 }
1064 break;
1065 }
1066 default:
1067 {
|
1068 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
1069 thilo.boehm 1.3 }
1070 }
|
1071 r.kieninger 1.1 }
|
1072 karl 1.5.2.1 PEG_METHOD_EXIT();
|
1073 thilo.boehm 1.3 }
|
1074 r.kieninger 1.1
|
1075 karl 1.5.2.1 // NOTE: The reason for the isPullResponse variable is that there are
1076 // some variations in ouput to Xml depending on whether the responses
|
1077 karl 1.5.2.7 // are one of the pull responses or not
|
1078 karl 1.5.2.15 void CIMResponseData::encodeXmlResponse(Buffer& out,
1079 Boolean isPullResponse,
1080 Boolean encodeInstanceOnly)
|
1081 r.kieninger 1.1 {
|
1082 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
1083 "CIMResponseData::encodeXmlResponse");
|
1084 karl 1.5.2.6
|
1085 thilo.boehm 1.3 PEG_TRACE((TRC_XML, Tracer::LEVEL3,
|
1086 karl 1.5.2.21 "CIMResponseData::encodeXmlResponse(encoding=%X,dataType=%X, isPull= %s"
1087 " encodeInstanceOnly= %s)",
|
1088 thilo.boehm 1.3 _encoding,
|
1089 karl 1.5.2.11 _dataType,
|
1090 karl 1.5.2.21 boolToString(isPullResponse),
1091 boolToString(encodeInstanceOnly) ));
|
1092 karl 1.5.2.7
|
1093 thilo.boehm 1.3 // already existing Internal XML does not need to be encoded further
1094 // binary input is not actually impossible here, but we have an established
1095 // fallback
1096 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
|
1097 r.kieninger 1.1 {
|
1098 karl 1.5.2.13 _resolveBinaryToSCMO();
|
1099 r.kieninger 1.1 }
|
1100 thilo.boehm 1.3 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
|
1101 r.kieninger 1.1 {
|
1102 thilo.boehm 1.3 switch (_dataType)
|
1103 r.kieninger 1.1 {
|
1104 thilo.boehm 1.3 case RESP_INSTANCE:
1105 {
1106 const Array<ArraySint8>& a = _instanceData;
1107 out.append((char*)a[0].getData(), a[0].size() - 1);
1108 break;
1109 }
1110 case RESP_INSTANCES:
1111 {
1112 const Array<ArraySint8>& a = _instanceData;
1113 const Array<ArraySint8>& b = _referencesData;
|
1114 r.kieninger 1.1
|
1115 thilo.boehm 1.3 for (Uint32 i = 0, n = a.size(); i < n; i++)
1116 {
|
1117 karl 1.5.2.1 if (isPullResponse)
1118 {
1119 out << STRLIT("<VALUE.INSTANCEWITHPATH>\n");
|
1120 karl 1.5.2.13 out << STRLIT("<INSTANCEPATH>\n");
1121 XmlWriter::appendNameSpacePathElement(out,
1122 _hostsData[i],
1123 _nameSpacesData[i]);
1124 out.append((char*)b[i].getData(), b[i].size() - 1);
1125 out << STRLIT("</INSTANCEPATH>\n");
1126 out.append((char *)a[i].getData(), a[i].size() - 1);
|
1127 karl 1.5.2.1 out << STRLIT("</VALUE.INSTANCEWITHPATH>\n");
1128 }
1129 else
1130 {
|
1131 karl 1.5.2.13 out << STRLIT("<VALUE.NAMEDINSTANCE>\n");
1132 out.append((char*)b[i].getData(), b[i].size() - 1);
1133 out.append((char *)a[i].getData(), a[i].size() - 1);
|
1134 karl 1.5.2.1 out << STRLIT("</VALUE.NAMEDINSTANCE>\n");
1135 }
|
1136 thilo.boehm 1.3 }
1137 break;
1138 }
1139 case RESP_OBJECTS:
1140 {
1141 const Array<ArraySint8>& a = _instanceData;
1142 const Array<ArraySint8>& b = _referencesData;
|
1143 karl 1.5.2.13
|
1144 thilo.boehm 1.3 for (Uint32 i = 0, n = a.size(); i < n; i++)
1145 {
|
1146 karl 1.5.2.21 if (isPullResponse)
1147 {
1148 out << STRLIT("<VALUE.INSTANCEWITHPATH>\n");
1149 }
1150 else
1151 {
1152 out << STRLIT("<VALUE.OBJECTWITHPATH>\n");
1153 }
|
1154 thilo.boehm 1.3 out << STRLIT("<INSTANCEPATH>\n");
1155 XmlWriter::appendNameSpacePathElement(
1156 out,
1157 _hostsData[i],
1158 _nameSpacesData[i]);
|
1159 karl 1.5.2.21
1160 if (isPullResponse)
1161 {
1162 out.append((char*)b[i].getData(),b[i].size()-1);
1163 }
1164 else
1165 {
1166 // Leave out the surrounding tags "<VALUE.REFERENCE>\n"
1167 // and "</VALUE.REFERENCE>\n" which are 18 and 19
1168 // characters long
1169 //// KS_TODO Should be able to do this by properly
1170 //// building in the CIMXmlInternalEncoder
1171 out.append(
1172 ((char*)b[i].getData())+18,
1173 b[i].size() - 1 - 18 -19);
1174 }
1175
|
1176 thilo.boehm 1.3 out << STRLIT("</INSTANCEPATH>\n");
1177 // append instance body
1178 out.append((char*)a[i].getData(), a[i].size() - 1);
|
1179 karl 1.5.2.21 if (isPullResponse)
1180 {
1181 out << STRLIT("</VALUE.INSTANCEWITHPATH>\n");
1182 }
1183 else
1184 {
1185 out << STRLIT("</VALUE.OBJECTWITHPATH>\n");
1186 }
|
1187 thilo.boehm 1.3 }
1188 break;
1189 }
1190 // internal xml encoding of instance names and object paths not
1191 // done today
1192 case RESP_INSTNAMES:
1193 case RESP_OBJECTPATHS:
1194 default:
1195 {
|
1196 karl 1.5.2.11 PEGASUS_ASSERT(false);
|
1197 thilo.boehm 1.3 }
|
1198 r.kieninger 1.1 }
|
1199 thilo.boehm 1.3 }
|
1200 r.kieninger 1.1
|
1201 thilo.boehm 1.3 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
1202 {
1203 switch (_dataType)
|
1204 r.kieninger 1.1 {
|
1205 thilo.boehm 1.3 case RESP_INSTNAMES:
1206 {
1207 for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++)
1208 {
|
1209 karl 1.5.2.1 // Element type is different for Pull responses
1210 if (isPullResponse)
1211 {
1212 XmlWriter::appendInstancePathElement(out,
1213 _instanceNames[i]);
1214 }
1215 else
1216 {
1217 XmlWriter::appendInstanceNameElement(out,
1218 _instanceNames[i]);
1219 }
|
1220 thilo.boehm 1.3 }
1221 break;
1222 }
1223 case RESP_INSTANCE:
1224 {
1225 if (_instances.size() > 0)
1226 {
|
1227 karl 1.5.2.3 XmlWriter::appendInstanceElement(
|
1228 karl 1.5.2.7 out,
|
1229 karl 1.5.2.3 _instances[0],
1230 _includeQualifiers,
1231 _includeClassOrigin,
1232 _propertyList);
|
1233 thilo.boehm 1.3 }
1234 break;
1235 }
1236 case RESP_INSTANCES:
1237 {
1238 for (Uint32 i = 0, n = _instances.size(); i < n; i++)
1239 {
|
1240 karl 1.5.2.1 if (isPullResponse)
1241 {
|
1242 karl 1.5.2.15 if (encodeInstanceOnly)
1243 {
1244 XmlWriter::appendInstanceElement(
1245 out,
1246 _instances[i],
|
1247 karl 1.5.2.18 _includeQualifiers,
|
1248 karl 1.5.2.15 _includeClassOrigin,
1249 _propertyList);
1250 }
1251 else
1252 {
1253 XmlWriter::appendValueInstanceWithPathElement(
1254 out,
1255 _instances[i],
|
1256 karl 1.5.2.18 _includeQualifiers,
|
1257 karl 1.5.2.15 _includeClassOrigin,
1258 _propertyList);
1259 }
|
1260 karl 1.5.2.1 }
1261 else
1262 {
1263 XmlWriter::appendValueNamedInstanceElement(
|
1264 karl 1.5.2.3 out,
1265 _instances[i],
1266 _includeQualifiers,
1267 _includeClassOrigin,
1268 _propertyList);
|
1269 karl 1.5.2.1 }
|
1270 thilo.boehm 1.3 }
1271 break;
1272 }
1273 case RESP_OBJECTS:
1274 {
1275 for (Uint32 i = 0; i < _objects.size(); i++)
1276 {
|
1277 karl 1.5.2.1 // If pull, map to instances
1278 if (isPullResponse)
1279 {
|
1280 karl 1.5.2.28
|
1281 karl 1.5.2.1 CIMInstance x = (CIMInstance)_objects[i];
|
1282 karl 1.5.2.28 if (encodeInstanceOnly)
1283 {
1284 XmlWriter::appendInstanceElement(
1285 out,
1286 x,
1287 _includeQualifiers,
1288 _includeClassOrigin,
1289 _propertyList);
1290 }
1291 else
1292 {
1293 XmlWriter::appendValueInstanceWithPathElement(
1294 out,
1295 x,
1296 _includeQualifiers,
1297 _includeClassOrigin,
1298 _propertyList);
1299 }
|
1300 karl 1.5.2.1 }
1301 else
1302 {
1303 XmlWriter::appendValueObjectWithPathElement(
|
1304 karl 1.5.2.3 out,
1305 _objects[i],
1306 _includeQualifiers,
1307 _includeClassOrigin,
|
1308 karl 1.5.2.7 _isClassOperation,
|
1309 karl 1.5.2.3 _propertyList);
|
1310 karl 1.5.2.1 }
|
1311 thilo.boehm 1.3 }
1312 break;
1313 }
1314 case RESP_OBJECTPATHS:
1315 {
1316 for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++)
1317 {
|
1318 karl 1.5.2.1 // ObjectPaths come from providers for pull operations
|
1319 karl 1.5.2.21 // but are encoded as instancePathElements. If pull
1320 // only instances allowed.
|
1321 karl 1.5.2.1 if (isPullResponse)
1322 {
|
1323 karl 1.5.2.21 XmlWriter::appendInstancePathElement(
1324 out,
|
1325 karl 1.5.2.1 _instanceNames[i]);
1326 }
1327 else
1328 {
|
1329 karl 1.5.2.21 //Append The path element (Class or instance)
|
1330 karl 1.5.2.1 out << "<OBJECTPATH>\n";
|
1331 karl 1.5.2.21 XmlWriter::appendClassOrInstancePathElement(
|
1332 karl 1.5.2.1 out,
1333 _instanceNames[i],
|
1334 karl 1.5.2.21 _isClassOperation);
|
1335 karl 1.5.2.1 out << "</OBJECTPATH>\n";
1336 }
|
1337 thilo.boehm 1.3 }
1338 break;
1339 }
1340 default:
1341 {
|
1342 karl 1.5.2.11 PEGASUS_ASSERT(false);
|
1343 thilo.boehm 1.3 }
|
1344 r.kieninger 1.1 }
|
1345 thilo.boehm 1.3 }
1346 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
1347 {
1348 switch (_dataType)
|
1349 r.kieninger 1.1 {
|
1350 thilo.boehm 1.3 case RESP_INSTNAMES:
1351 {
|
1352 karl 1.5.2.15 for (Uint32 i = 0, n = _scmoInstances.size();i < n; i++)
|
1353 thilo.boehm 1.3 {
|
1354 karl 1.5.2.15 if (isPullResponse)
|
1355 karl 1.5.2.6 {
1356 SCMOXmlWriter::appendInstancePathElement(
|
1357 karl 1.5.2.15 out,
1358 _scmoInstances[i]);
|
1359 karl 1.5.2.6 }
|
1360 karl 1.5.2.15 else
|
1361 karl 1.5.2.6 {
1362 SCMOXmlWriter::appendInstanceNameElement(
1363 out,
1364 _scmoInstances[i]);
1365 }
|
1366 thilo.boehm 1.3 }
1367 break;
1368 }
1369 case RESP_INSTANCE:
1370 {
1371 if (_scmoInstances.size() > 0)
1372 {
|
1373 karl 1.5.2.15 _appendInstanceElement(out, _scmoInstances[0]);
|
1374 thilo.boehm 1.3 }
1375 break;
1376 }
1377 case RESP_INSTANCES:
1378 {
|
1379 karl 1.5.2.3 if (isPullResponse)
|
1380 thilo.boehm 1.3 {
|
1381 karl 1.5.2.15 // pull and encodeInstanceOnly (i.e. response to
1382 // OpenQueryInstances and pullInstances
1383 if (encodeInstanceOnly)
1384 {
|
1385 karl 1.5.2.28 // KS_TODO move this to SCMOXmlWriter
|
1386 karl 1.5.2.15 for (Uint32 i = 0, n = _scmoInstances.size();i < n; i++)
1387 {
1388 _appendInstanceElement(out, _scmoInstances[i]);
1389 }
1390 }
1391 else
1392 {
1393 SCMOXmlWriter::appendValueSCMOInstanceWithPathElements(
1394 out, _scmoInstances, _propertyList);
1395 }
|
1396 thilo.boehm 1.3 }
|
1397 karl 1.5.2.3 else
1398 {
1399 SCMOXmlWriter::appendValueSCMOInstanceElements(
1400 out, _scmoInstances, _propertyList);
1401 }
|
1402 thilo.boehm 1.3 break;
1403 }
1404 case RESP_OBJECTS:
1405 {
|
1406 karl 1.5.2.3 if (isPullResponse)
|
1407 thilo.boehm 1.3 {
|
1408 karl 1.5.2.28 // if encodeInstanceOnly flag, encode objects as instances
1409 // Used by OpenQueryInstances and pullInstances.
1410 if (encodeInstanceOnly)
1411 {
1412 for (Uint32 i = 0, n = _scmoInstances.size();i < n; i++)
1413 {
1414 _appendInstanceElement(out, _scmoInstances[i]);
1415 }
1416 }
1417 else
1418 {
1419 SCMOXmlWriter::appendValueSCMOInstanceWithPathElements(
1420 out,_scmoInstances, _propertyList);
1421 }
|
1422 karl 1.5.2.3 }
1423 else
1424 {
1425 // KS_TODO why is this one named element rather than
1426 // elements
1427 SCMOXmlWriter::appendValueObjectWithPathElement(
1428 out, _scmoInstances, _propertyList);
|
1429 thilo.boehm 1.3 }
1430 break;
1431 }
1432 case RESP_OBJECTPATHS:
1433 {
1434 for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++)
1435 {
|
1436 karl 1.5.2.1 if (isPullResponse)
1437 {
1438 SCMOXmlWriter::appendInstancePathElement(out,
1439 _scmoInstances[i]);
1440 }
1441 else
1442 {
1443 out << "<OBJECTPATH>\n";
|
1444 karl 1.5.2.21 SCMOXmlWriter::appendClassOrInstancePathElement(
1445 out, _scmoInstances[i]);
|
1446 karl 1.5.2.1 out << "</OBJECTPATH>\n";
1447 }
|
1448 thilo.boehm 1.3 }
1449 break;
1450 }
1451 default:
1452 {
|
1453 karl 1.5.2.11 PEGASUS_ASSERT(false);
|
1454 thilo.boehm 1.3 }
|
1455 r.kieninger 1.1 }
1456 }
|
1457 karl 1.5.2.11 PEG_METHOD_EXIT();
|
1458 thilo.boehm 1.3 }
|
1459 r.kieninger 1.1
|
1460 thilo.boehm 1.3 // contrary to encodeXmlResponse this function encodes the Xml in a format
1461 // not usable by clients
|
1462 karl 1.5.2.21 void CIMResponseData::encodeInternalXmlResponse(CIMBuffer& out,
1463 Boolean isPullOperation)
|
1464 thilo.boehm 1.3 {
|
1465 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
1466 "CIMResponseData::encodeInternalXmlResponse");
1467
|
1468 thilo.boehm 1.3 PEG_TRACE((TRC_XML, Tracer::LEVEL3,
|
1469 karl 1.5.2.21 "CIMResponseData::encodeInternalXmlResponse(encoding=%X,content=%X"
1470 " isPullOperation=%s)",
|
1471 thilo.boehm 1.3 _encoding,
|
1472 karl 1.5.2.21 _dataType,
1473 boolToString(isPullOperation)));
1474
|
1475 thilo.boehm 1.3 // For mixed (CIM+SCMO) responses, we need to tell the receiver the
1476 // total number of instances. The totalSize variable is used to keep track
1477 // of this.
1478 Uint32 totalSize = 0;
|
1479 r.kieninger 1.1
|
1480 thilo.boehm 1.3 // already existing Internal XML does not need to be encoded further
1481 // binary input is not actually impossible here, but we have an established
1482 // fallback
1483 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
1484 {
|
1485 karl 1.5.2.13 _resolveBinaryToSCMO();
|
1486 thilo.boehm 1.3 }
1487 if ((0 == _encoding) ||
1488 (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)))
1489 {
1490 switch (_dataType)
1491 {
1492 case RESP_INSTANCE:
1493 {
1494 if (0 == _instances.size())
1495 {
1496 _instances.append(CIMInstance());
|
1497 karl 1.5.2.3 CIMInternalXmlEncoder::_putXMLInstance(
1498 out,
1499 _instances[0]);
1500 break;
|
1501 thilo.boehm 1.3 }
|
1502 karl 1.5.2.3 CIMInternalXmlEncoder::_putXMLInstance(
1503 out,
1504 _instances[0],
1505 _includeQualifiers,
1506 _includeClassOrigin,
1507 _propertyList);
|
1508 thilo.boehm 1.3 break;
1509 }
1510 case RESP_INSTANCES:
1511 {
1512 Uint32 n = _instances.size();
1513 totalSize = n + _scmoInstances.size();
1514 out.putUint32(totalSize);
1515 for (Uint32 i = 0; i < n; i++)
1516 {
1517 CIMInternalXmlEncoder::_putXMLNamedInstance(
1518 out,
|
1519 karl 1.5.2.3 _instances[i],
1520 _includeQualifiers,
1521 _includeClassOrigin,
1522 _propertyList);
|
1523 thilo.boehm 1.3 }
1524 break;
1525 }
1526 case RESP_OBJECTS:
1527 {
1528 Uint32 n = _objects.size();
1529 totalSize = n + _scmoInstances.size();
1530 out.putUint32(totalSize);
1531 for (Uint32 i = 0; i < n; i++)
1532 {
|
1533 karl 1.5.2.21 // if is pull map to instances.
1534 if (isPullOperation)
1535 {
1536 CIMInternalXmlEncoder::_putXMLNamedInstance(
1537 out,
1538 (CIMInstance)_objects[i],
1539 _includeQualifiers,
1540 _includeClassOrigin,
1541 _propertyList);
1542 }
1543 else
1544 {
1545 CIMInternalXmlEncoder::_putXMLObject(
1546 out,
1547 _objects[i],
1548 _includeQualifiers,
1549 _includeClassOrigin,
1550 _propertyList);
1551 }
|
1552 thilo.boehm 1.3 }
1553 break;
1554 }
1555 // internal xml encoding of instance names and object paths not
1556 // done today
1557 case RESP_INSTNAMES:
1558 case RESP_OBJECTPATHS:
1559 default:
1560 {
|
1561 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
1562 thilo.boehm 1.3 }
1563 }
1564 }
1565 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
1566 {
1567 switch (_dataType)
1568 {
1569 case RESP_INSTANCE:
1570 {
1571 if (0 == _scmoInstances.size())
1572 {
1573 _scmoInstances.append(SCMOInstance());
1574 }
|
1575 karl 1.5.2.3 SCMOInternalXmlEncoder::_putXMLInstance(
|
1576 karl 1.5.2.7 out,
|
1577 karl 1.5.2.3 _scmoInstances[0],
1578 _propertyList);
|
1579 thilo.boehm 1.3 break;
1580 }
1581 case RESP_INSTANCES:
1582 {
1583 Uint32 n = _scmoInstances.size();
1584 // Only put the size when not already done above
1585 if (0==totalSize)
1586 {
1587 out.putUint32(n);
1588 }
|
1589 karl 1.5.2.3 SCMOInternalXmlEncoder::_putXMLNamedInstance(
1590 out,
1591 _scmoInstances,
1592 _propertyList);
|
1593 thilo.boehm 1.3 break;
1594 }
1595 case RESP_OBJECTS:
1596 {
1597 Uint32 n = _scmoInstances.size();
1598 // Only put the size when not already done above
1599 if (0==totalSize)
1600 {
1601 out.putUint32(n);
1602 }
|
1603 karl 1.5.2.21 // if is pull map to instances.
1604 if (isPullOperation)
1605 {
1606 SCMOInternalXmlEncoder::_putXMLNamedInstance(
1607 out,
1608 _scmoInstances,
1609 _propertyList);
1610 }
1611 else
1612 {
1613 SCMOInternalXmlEncoder::_putXMLObject(
1614 out,
1615 _scmoInstances,
1616 _propertyList);
1617 }
|
1618 thilo.boehm 1.3 break;
1619 }
1620 // internal xml encoding of instance names and object paths not
1621 // done today
1622 case RESP_INSTNAMES:
1623 case RESP_OBJECTPATHS:
1624 default:
1625 {
|
1626 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
1627 thilo.boehm 1.3 }
1628 }
1629 }
|
1630 karl 1.5.2.11 PEG_METHOD_EXIT();
|
1631 thilo.boehm 1.3 }
|
1632 r.kieninger 1.1
|
1633 thilo.boehm 1.3 void CIMResponseData::_resolveToCIM()
|
1634 r.kieninger 1.1 {
|
1635 r.kieninger 1.4 PEG_TRACE((TRC_XML, Tracer::LEVEL3,
1636 "CIMResponseData::_resolveToCIM(encoding=%X,content=%X)",
|
1637 thilo.boehm 1.3 _encoding,
1638 _dataType));
|
1639 r.kieninger 1.1
|
1640 thilo.boehm 1.3 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
1641 {
1642 _resolveXmlToCIM();
1643 }
1644 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
|
1645 r.kieninger 1.1 {
|
1646 karl 1.5.2.13 _resolveBinaryToSCMO();
|
1647 r.kieninger 1.1 }
|
1648 thilo.boehm 1.3 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
|
1649 r.kieninger 1.1 {
|
1650 thilo.boehm 1.3 _resolveSCMOToCIM();
|
1651 r.kieninger 1.1 }
|
1652 thilo.boehm 1.3
1653 PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_CIM || _encoding == 0);
|
1654 r.kieninger 1.1 }
1655
|
1656 karl 1.5.2.13 // Resolve any binary data to SCMO. This externalfunction added because we
1657 // cannot do a move on Binary data so convert it a to movable format
1658 void CIMResponseData::resolveBinaryToSCMO()
1659 {
1660 PEG_METHOD_ENTER(TRC_DISPATCHER,
1661 "CIMResponseData::resolveBinaryToSCMO");
1662 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
1663 {
1664 _resolveBinaryToSCMO();
1665 }
1666 PEG_METHOD_EXIT();
1667 }
1668
|
1669 thilo.boehm 1.3 void CIMResponseData::_resolveToSCMO()
|
1670 r.kieninger 1.1 {
|
1671 r.kieninger 1.4 PEG_TRACE((TRC_XML, Tracer::LEVEL3,
1672 "CIMResponseData::_resolveToSCMO(encoding=%X,content=%X)",
|
1673 thilo.boehm 1.3 _encoding,
1674 _dataType));
|
1675 r.kieninger 1.1
|
1676 thilo.boehm 1.3 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
1677 {
1678 _resolveXmlToSCMO();
1679 }
1680 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
|
1681 r.kieninger 1.1 {
|
1682 karl 1.5.2.13 _resolveBinaryToSCMO();
|
1683 r.kieninger 1.1 }
|
1684 thilo.boehm 1.3 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
|
1685 r.kieninger 1.1 {
|
1686 thilo.boehm 1.3 _resolveCIMToSCMO();
|
1687 r.kieninger 1.1 }
|
1688 thilo.boehm 1.3 PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_SCMO || _encoding == 0);
|
1689 r.kieninger 1.1 }
1690
|
1691 thilo.boehm 1.3 // helper functions to transform different formats into one-another
1692 // functions work on the internal data and calling of them should be
1693 // avoided whenever possible
|
1694 karl 1.5.2.13 void CIMResponseData::_resolveBinaryToSCMO()
|
1695 r.kieninger 1.1 {
1696 PEG_METHOD_ENTER(TRC_DISPATCHER,
|
1697 karl 1.5.2.13 "CIMResponseData::_resolveBinaryToSCMO");
|
1698 r.kieninger 1.1
|
1699 thilo.boehm 1.3 CIMBuffer in((char*)_binaryData.getData(), _binaryData.size());
|
1700 r.kieninger 1.1
|
1701 r.kieninger 1.2 while (in.more())
|
1702 r.kieninger 1.1 {
|
1703 thilo.boehm 1.3 Uint32 binaryTypeMarker=0;
1704 if(!in.getTypeMarker(binaryTypeMarker))
|
1705 r.kieninger 1.2 {
1706 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
|
1707 thilo.boehm 1.3 "Failed to get type marker for binary objects!");
|
1708 r.kieninger 1.2 PEG_METHOD_EXIT();
|
1709 thilo.boehm 1.3 in.release();
1710 return;
1711 }
1712
1713 if (BIN_TYPE_MARKER_SCMO==binaryTypeMarker)
1714 {
1715 if (!in.getSCMOInstanceA(_scmoInstances))
1716 {
1717 _encoding &=(~RESP_ENC_BINARY);
1718 in.release();
1719 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1720 "Failed to resolve binary SCMOInstances!");
1721 PEG_METHOD_EXIT();
1722 return;
1723 }
1724
1725 _encoding |= RESP_ENC_SCMO;
|
1726 r.kieninger 1.2 }
|
1727 thilo.boehm 1.3 else
1728 {
1729 switch (_dataType)
1730 {
1731 case RESP_INSTNAMES:
1732 case RESP_OBJECTPATHS:
1733 {
1734 if (!in.getObjectPathA(_instanceNames))
1735 {
1736 _encoding &=(~RESP_ENC_BINARY);
1737 in.release();
1738 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1739 "Failed to resolve binary CIMObjectPaths!");
1740 PEG_METHOD_EXIT();
1741 return;
1742 }
1743 break;
1744 }
1745 case RESP_INSTANCE:
1746 {
1747 CIMInstance instance;
1748 thilo.boehm 1.3 if (!in.getInstance(instance))
1749 {
1750 _encoding &=(~RESP_ENC_BINARY);
1751 _encoding |= RESP_ENC_CIM;
1752 _instances.append(instance);
1753 in.release();
1754 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1755 "Failed to resolve binary instance!");
1756 PEG_METHOD_EXIT();
1757 return;
1758 }
1759
1760 _instances.append(instance);
1761 break;
1762 }
1763 case RESP_INSTANCES:
1764 {
1765 if (!in.getInstanceA(_instances))
1766 {
1767 _encoding &=(~RESP_ENC_BINARY);
1768 in.release();
1769 thilo.boehm 1.3 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1770 "Failed to resolve binary CIMInstances!");
1771 PEG_METHOD_EXIT();
1772 return;
1773 }
1774 break;
1775 }
1776 case RESP_OBJECTS:
1777 {
1778 if (!in.getObjectA(_objects))
1779 {
1780 in.release();
1781 _encoding &=(~RESP_ENC_BINARY);
1782 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1783 "Failed to resolve binary CIMObjects!");
1784 PEG_METHOD_EXIT();
1785 return;
1786 }
1787 break;
1788 }
1789 default:
1790 thilo.boehm 1.3 {
|
1791 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
1792 thilo.boehm 1.3 }
1793 } // switch
1794 _encoding |= RESP_ENC_CIM;
1795 } // else SCMO
1796 }
1797 _encoding &=(~RESP_ENC_BINARY);
1798 // fix up the hostname and namespace for objects if defaults
1799 // were set
1800 if (_defaultHostname.size() > 0 && !_defaultNamespace.isNull())
1801 {
1802 completeHostNameAndNamespace(_defaultHostname, _defaultNamespace);
|
1803 r.kieninger 1.1 }
1804 in.release();
1805 PEG_METHOD_EXIT();
1806 }
1807
|
1808 karl 1.5.2.7
1809 void CIMResponseData::_deserializeObject(Uint32 idx,CIMObject& cimObject)
1810 {
|
1811 karl 1.5.2.11
1812 PEG_METHOD_ENTER(TRC_DISPATCHER,
1813 "CIMResponseData::_deserializeObject");
|
1814 karl 1.5.2.7 // Only start the parser when instance data is present.
1815 if (0 != _instanceData[idx].size())
1816 {
1817 CIMInstance cimInstance;
1818 CIMClass cimClass;
1819
1820 XmlParser parser((char*)_instanceData[idx].getData());
1821
1822 if (XmlReader::getInstanceElement(parser, cimInstance))
1823 {
1824 cimObject = CIMObject(cimInstance);
1825 return;
1826 }
1827
1828 if (XmlReader::getClassElement(parser, cimClass))
1829 {
1830 cimObject = CIMObject(cimClass);
1831 return;
1832 }
1833 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1834 "Failed to resolve XML object data, parser error!");
1835 karl 1.5.2.7 }
|
1836 karl 1.5.2.11 PEG_METHOD_EXIT();
|
1837 karl 1.5.2.7 }
1838
1839 void CIMResponseData::_deserializeInstance(Uint32 idx,CIMInstance& cimInstance)
1840 {
|
1841 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
1842 "CIMResponseData::_deserializeInstance");
|
1843 karl 1.5.2.7 // Only start the parser when instance data is present.
1844 if (0 != _instanceData[idx].size())
1845 {
1846 XmlParser parser((char*)_instanceData[idx].getData());
1847 if (XmlReader::getInstanceElement(parser, cimInstance))
1848 {
1849 return;
1850 }
1851 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1852 "Failed to resolve XML instance, parser error!");
1853 }
1854 // reset instance when parsing may not be successfull or
1855 // no instance is present.
1856 cimInstance = CIMInstance();
|
1857 karl 1.5.2.11
1858 PEG_METHOD_EXIT();
|
1859 karl 1.5.2.7 }
1860
1861 Boolean CIMResponseData::_deserializeReference(
1862 Uint32 idx,
1863 CIMObjectPath& cimObjectPath)
1864 {
1865 // Only start the parser when reference data is present.
1866 if (0 != _referencesData[idx].size())
1867 {
1868 XmlParser parser((char*)_referencesData[idx].getData());
1869 if (XmlReader::getValueReferenceElement(parser, cimObjectPath))
1870 {
1871 if (_hostsData[idx].size())
1872 {
1873 cimObjectPath.setHost(_hostsData[idx]);
1874 }
1875 if (!_nameSpacesData[idx].isNull())
1876 {
1877 cimObjectPath.setNameSpace(_nameSpacesData[idx]);
1878 }
1879 return true;
1880 karl 1.5.2.7 }
1881 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1882 "Failed to resolve XML reference, parser error!");
1883
1884 }
1885 return false;
1886 }
1887
1888 Boolean CIMResponseData::_deserializeInstanceName(
1889 Uint32 idx,
1890 CIMObjectPath& cimObjectPath)
1891 {
1892 // Only start the parser when instance name data is present.
1893 if (0 != _referencesData[idx].size())
1894 {
1895 XmlParser parser((char*)_referencesData[idx].getData());
1896 if (XmlReader::getInstanceNameElement(parser, cimObjectPath))
1897 {
1898 if (_hostsData[idx].size())
1899 {
1900 cimObjectPath.setHost(_hostsData[idx]);
1901 karl 1.5.2.7 }
1902 if (!_nameSpacesData[idx].isNull())
1903 {
1904 cimObjectPath.setNameSpace(_nameSpacesData[idx]);
1905 }
1906 return true;
1907 }
1908 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1909 "Failed to resolve XML instance name, parser error!");
1910
1911 }
1912 return false;
1913 }
1914
|
1915 thilo.boehm 1.3 void CIMResponseData::_resolveXmlToCIM()
|
1916 r.kieninger 1.1 {
|
1917 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
1918 "CIMResponseData::_resolveXmlToCIM");
1919
|
1920 thilo.boehm 1.3 switch (_dataType)
|
1921 r.kieninger 1.1 {
|
1922 thilo.boehm 1.3 // Xml encoding for instance names and object paths not used
1923 case RESP_OBJECTPATHS:
1924 case RESP_INSTNAMES:
1925 {
1926 break;
1927 }
1928 case RESP_INSTANCE:
|
1929 r.kieninger 1.1 {
|
1930 thilo.boehm 1.3 CIMInstance cimInstance;
|
1931 karl 1.5.2.7 CIMObjectPath cimObjectPath;
|
1932 r.kieninger 1.1
|
1933 karl 1.5.2.7 _deserializeInstance(0,cimInstance);
1934 if (_deserializeReference(0,cimObjectPath))
|
1935 r.kieninger 1.1 {
|
1936 karl 1.5.2.7 cimInstance.setPath(cimObjectPath);
1937 // A single CIMInstance has to have an objectpath.
1938 // So only add it when an objectpath exists.
1939 _instances.append(cimInstance);
|
1940 r.kieninger 1.1 }
|
1941 thilo.boehm 1.3 break;
|
1942 r.kieninger 1.1 }
|
1943 thilo.boehm 1.3 case RESP_INSTANCES:
1944 {
1945 for (Uint32 i = 0; i < _instanceData.size(); i++)
1946 {
1947 CIMInstance cimInstance;
|
1948 karl 1.5.2.7 CIMObjectPath cimObjectPath;
|
1949 thilo.boehm 1.3
|
1950 karl 1.5.2.7 _deserializeInstance(i,cimInstance);
1951 if (_deserializeInstanceName(i,cimObjectPath))
|
1952 thilo.boehm 1.3 {
|
1953 karl 1.5.2.7 cimInstance.setPath(cimObjectPath);
|
1954 thilo.boehm 1.3 }
|
1955 karl 1.5.2.7 // enumarate instances can be without name
|
1956 thilo.boehm 1.3 _instances.append(cimInstance);
1957 }
1958 break;
1959 }
1960 case RESP_OBJECTS:
|
1961 r.kieninger 1.1 {
|
1962 thilo.boehm 1.3 for (Uint32 i=0, n=_instanceData.size(); i<n; i++)
|
1963 r.kieninger 1.1 {
|
1964 thilo.boehm 1.3 CIMObject cimObject;
|
1965 karl 1.5.2.7 CIMObjectPath cimObjectPath;
|
1966 r.kieninger 1.1
|
1967 karl 1.5.2.7 _deserializeObject(i,cimObject);
1968 if (_deserializeReference(i,cimObjectPath))
|
1969 thilo.boehm 1.3 {
|
1970 karl 1.5.2.7 cimObject.setPath(cimObjectPath);
|
1971 thilo.boehm 1.3 }
1972 _objects.append(cimObject);
|
1973 r.kieninger 1.1 }
|
1974 thilo.boehm 1.3 break;
1975 }
1976 default:
1977 {
|
1978 karl 1.5.2.11 PEGASUS_ASSERT(false);
|
1979 r.kieninger 1.1 }
1980 }
|
1981 thilo.boehm 1.3 // Xml was resolved, release Xml content now
1982 _referencesData.clear();
1983 _hostsData.clear();
1984 _nameSpacesData.clear();
1985 _instanceData.clear();
1986 // remove Xml Encoding flag
1987 _encoding &=(~RESP_ENC_XML);
1988 // add CIM Encoding flag
1989 _encoding |=RESP_ENC_CIM;
|
1990 karl 1.5.2.11
1991 PEG_METHOD_EXIT();
|
1992 thilo.boehm 1.3 }
|
1993 r.kieninger 1.1
|
1994 thilo.boehm 1.3 void CIMResponseData::_resolveXmlToSCMO()
1995 {
|
1996 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
1997 "CIMResponseData::_resolveXmlToSCMO");
|
1998 thilo.boehm 1.3 // Not optimal, can probably be improved
1999 // but on the other hand, since using the binary format this case should
2000 // actually not ever happen.
2001 _resolveXmlToCIM();
2002 _resolveCIMToSCMO();
|
2003 karl 1.5.2.11
2004 PEG_METHOD_EXIT();
|
2005 r.kieninger 1.1 }
2006
|
2007 thilo.boehm 1.3 void CIMResponseData::_resolveSCMOToCIM()
|
2008 r.kieninger 1.1 {
|
2009 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
2010 "CIMResponseData::_resolveSCMOToCIM");
|
2011 thilo.boehm 1.3 switch(_dataType)
|
2012 r.kieninger 1.2 {
|
2013 thilo.boehm 1.3 case RESP_INSTNAMES:
2014 case RESP_OBJECTPATHS:
|
2015 r.kieninger 1.2 {
|
2016 thilo.boehm 1.3 for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
2017 {
2018 CIMObjectPath newObjectPath;
2019 _scmoInstances[x].getCIMObjectPath(newObjectPath);
2020 _instanceNames.append(newObjectPath);
2021 }
2022 break;
|
2023 r.kieninger 1.2 }
|
2024 thilo.boehm 1.3 case RESP_INSTANCE:
|
2025 r.kieninger 1.1 {
|
2026 thilo.boehm 1.3 if (_scmoInstances.size() > 0)
2027 {
2028 CIMInstance newInstance;
2029 _scmoInstances[0].getCIMInstance(newInstance);
2030 _instances.append(newInstance);
2031 }
2032 break;
|
2033 r.kieninger 1.1 }
|
2034 thilo.boehm 1.3 case RESP_INSTANCES:
|
2035 r.kieninger 1.1 {
|
2036 thilo.boehm 1.3 for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
2037 {
2038 CIMInstance newInstance;
2039 _scmoInstances[x].getCIMInstance(newInstance);
2040 _instances.append(newInstance);
2041 }
2042 break;
|
2043 r.kieninger 1.1 }
|
2044 thilo.boehm 1.3 case RESP_OBJECTS:
|
2045 r.kieninger 1.1 {
|
2046 thilo.boehm 1.3 for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
2047 {
2048 CIMInstance newInstance;
2049 _scmoInstances[x].getCIMInstance(newInstance);
2050 _objects.append(CIMObject(newInstance));
2051 }
2052 break;
|
2053 r.kieninger 1.1 }
|
2054 thilo.boehm 1.3 default:
|
2055 r.kieninger 1.1 {
|
2056 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
2057 r.kieninger 1.1 }
2058 }
|
2059 thilo.boehm 1.3 _scmoInstances.clear();
2060 // remove CIM Encoding flag
2061 _encoding &=(~RESP_ENC_SCMO);
2062 // add SCMO Encoding flag
2063 _encoding |=RESP_ENC_CIM;
|
2064 karl 1.5.2.11
2065 PEG_METHOD_EXIT();
|
2066 r.kieninger 1.1 }
2067
|
2068 thilo.boehm 1.3 void CIMResponseData::_resolveCIMToSCMO()
|
2069 r.kieninger 1.1 {
|
2070 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
2071 "CIMResponseData::_resolveCIMToSCMO");
|
2072 thilo.boehm 1.3 CString nsCString=_defaultNamespace.getString().getCString();
2073 const char* _defNamespace = nsCString;
2074 Uint32 _defNamespaceLen;
2075 if (_defaultNamespace.isNull())
|
2076 r.kieninger 1.1 {
|
2077 thilo.boehm 1.3 _defNamespaceLen=0;
|
2078 r.kieninger 1.1 }
2079 else
2080 {
|
2081 thilo.boehm 1.3 _defNamespaceLen=strlen(_defNamespace);
|
2082 r.kieninger 1.1 }
|
2083 thilo.boehm 1.3 switch (_dataType)
|
2084 r.kieninger 1.1 {
|
2085 thilo.boehm 1.3 case RESP_INSTNAMES:
|
2086 r.kieninger 1.1 {
|
2087 thilo.boehm 1.3 for (Uint32 i=0,n=_instanceNames.size();i<n;i++)
2088 {
2089 SCMOInstance addme(
2090 _instanceNames[i],
2091 _defNamespace,
2092 _defNamespaceLen);
2093 _scmoInstances.append(addme);
2094 }
2095 _instanceNames.clear();
2096 break;
|
2097 r.kieninger 1.1 }
|
2098 thilo.boehm 1.3 case RESP_INSTANCE:
|
2099 r.kieninger 1.2 {
|
2100 thilo.boehm 1.3 if (_instances.size() > 0)
2101 {
2102 SCMOInstance addme(
2103 _instances[0],
2104 _defNamespace,
2105 _defNamespaceLen);
2106 _scmoInstances.clear();
2107 _scmoInstances.append(addme);
2108 _instances.clear();
2109 }
2110 break;
|
2111 r.kieninger 1.2 }
|
2112 thilo.boehm 1.3 case RESP_INSTANCES:
|
2113 r.kieninger 1.1 {
|
2114 thilo.boehm 1.3 for (Uint32 i=0,n=_instances.size();i<n;i++)
|
2115 r.kieninger 1.1 {
|
2116 thilo.boehm 1.3 SCMOInstance addme(
2117 _instances[i],
2118 _defNamespace,
2119 _defNamespaceLen);
2120 _scmoInstances.append(addme);
|
2121 r.kieninger 1.1 }
|
2122 thilo.boehm 1.3 _instances.clear();
2123 break;
2124 }
2125 case RESP_OBJECTS:
2126 {
2127 for (Uint32 i=0,n=_objects.size();i<n;i++)
|
2128 r.kieninger 1.1 {
|
2129 thilo.boehm 1.3 SCMOInstance addme(
2130 _objects[i],
2131 _defNamespace,
2132 _defNamespaceLen);
2133 _scmoInstances.append(addme);
|
2134 r.kieninger 1.1 }
|
2135 thilo.boehm 1.3 _objects.clear();
2136 break;
2137 }
2138 case RESP_OBJECTPATHS:
2139 {
2140 for (Uint32 i=0,n=_instanceNames.size();i<n;i++)
|
2141 r.kieninger 1.1 {
|
2142 thilo.boehm 1.3 SCMOInstance addme(
2143 _instanceNames[i],
2144 _defNamespace,
2145 _defNamespaceLen);
|
2146 karl 1.5.2.7 if (_isClassOperation)
|
2147 thilo.boehm 1.3 {
2148 addme.setIsClassOnly(true);
2149 }
2150 _scmoInstances.append(addme);
|
2151 r.kieninger 1.1 }
|
2152 thilo.boehm 1.3 _instanceNames.clear();
2153 break;
|
2154 r.kieninger 1.1 }
|
2155 thilo.boehm 1.3 default:
|
2156 r.kieninger 1.1 {
|
2157 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
2158 r.kieninger 1.1 }
2159 }
2160
|
2161 thilo.boehm 1.3 // remove CIM Encoding flag
2162 _encoding &=(~RESP_ENC_CIM);
2163 // add SCMO Encoding flag
2164 _encoding |=RESP_ENC_SCMO;
|
2165 karl 1.5.2.11
2166 PEG_METHOD_EXIT();
|
2167 r.kieninger 1.1 }
2168
|
2169 karl 1.5.2.1 /**
2170 * Validate the magic object for this CIMResponseData. This
2171 * compiles only in debug mode and can be use to validate the
2172 * CIMResponseData object
2173 *
2174 * @return Boolean True if valid object.
2175 */
|
2176 karl 1.5.2.10 Boolean CIMResponseData::valid() const
|
2177 karl 1.5.2.1 {
2178 return _magic;
2179 }
2180
|
2181 karl 1.5.2.3 void CIMResponseData::setRequestProperties(
2182 const Boolean includeQualifiers,
2183 const Boolean includeClassOrigin,
2184 const CIMPropertyList& propertyList)
2185 {
2186 _includeQualifiers = includeQualifiers;
2187 _includeClassOrigin = includeClassOrigin;
|
2188 karl 1.5.2.7 _propertyList = propertyList;
2189 }
2190
2191 void CIMResponseData::setIsClassOperation(Boolean b)
2192 {
2193 _isClassOperation = b;
|
2194 karl 1.5.2.3 }
2195
|
2196 karl 1.5.2.26 // Clear all of the input encodings by clearing their arrays and
2197 // unsetting the encoding flag.
2198 void CIMResponseData::clear()
2199 {
2200 // Clear the xml data area
2201 _referencesData.clear();
2202 _hostsData.clear();
2203 _nameSpacesData.clear();
2204 _instanceData.clear();
2205
2206 // Clear the binary data area
2207 _binaryData.clear();
2208
2209 // Clear the SCMO data
2210 _scmoInstances.clear();
2211
2212 //Clear the C++ Data areaa
2213 _instanceNames.clear();
2214 _instances.clear();
2215 _objects.clear();
2216
2217 karl 1.5.2.26 _encoding = 0;
2218 _size = 0;
2219 }
2220
|
2221 karl 1.5.2.28 // The following are debugging support only
|
2222 karl 1.5.2.30 //// FUTURE: Make this conditional compile
|
2223 karl 1.5.2.28 void CIMResponseData::traceResponseData() const
|
2224 karl 1.5.2.12 {
2225 PEG_TRACE((TRC_XML, Tracer::LEVEL3,
|
2226 karl 1.5.2.21 "%s", (const char*)toStringTraceResponseData().getCString() ));
2227 }
|
2228 karl 1.5.2.28
2229 String CIMResponseData::toStringTraceResponseData() const
|
2230 karl 1.5.2.21 {
|
2231 karl 1.5.2.29 String rtnStr;
2232 rtnStr.appendPrintf(
|
2233 karl 1.5.2.12 "CIMResponseData::traceResponseData(encoding=%X,dataType=%X "
|
2234 karl 1.5.2.13 " size=%u C++instNamecount=%u c++Instances=%u c++Objects=%u "
2235 "scomInstances=%u XMLInstData=%u binaryData=%u "
2236 "xmlref=%u xmlinst=%u, xmlhost=%u xmlns=%u",
|
2237 karl 1.5.2.12 _encoding,_dataType, _size,
2238 _instanceNames.size(),_instances.size(), _objects.size(),
2239 _scmoInstances.size(),_instanceData.size(),_binaryData.size(),
2240 _referencesData.size(), _instanceData.size(), _hostsData.size(),
|
2241 karl 1.5.2.21 _nameSpacesData.size());
2242
2243 return(rtnStr);
|
2244 karl 1.5.2.12 }
|
2245 karl 1.5.2.30
|
2246 karl 1.5.2.12
|
2247 karl 1.5.2.21
|
2248 r.kieninger 1.1 PEGASUS_NAMESPACE_END
|