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 karl 1.5.2.32 // Insure that _size never goes negative. This is a
551 // diagnostic. KS_TODO remove before release
|
552 karl 1.5.2.13 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.32 //// KS_TODO diagnostic that we should be able to remove before
563 //// release
|
564 karl 1.5.2.2 if (rtnSize != _size)
565 {
566 PEG_TRACE((TRC_XML, Tracer::LEVEL1,
567 "Size calc error _size %u rtnSWize = %u", _size, rtnSize));
568 }
|
569 karl 1.5.2.9 PEG_METHOD_EXIT();
|
570 karl 1.5.2.1 return rtnSize;
571 }
572
|
573 karl 1.5.2.12 Boolean CIMResponseData::hasBinaryData() const
574 {
575 return (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY));
576 }
577 // Sets the _size variable based on the internal size counts.
578 void CIMResponseData::setSize()
579 {
|
580 karl 1.5.2.27 PEGASUS_DEBUG_ASSERT(valid());
|
581 karl 1.5.2.12
582 Uint32 rtnSize = 0;
583 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
584 {
585 switch (_dataType)
586 {
587 case RESP_OBJECTPATHS:
588 case RESP_INSTNAMES:
589 break;
590 case RESP_INSTANCE:
591 rtnSize +=1;
592 break;
593 case RESP_INSTANCES:
594 case RESP_OBJECTS:
595 rtnSize += _instanceData.size();
596 break;
597 }
598 }
599 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
600 {
601 // KS_PULL_TODO
602 karl 1.5.2.12 // Cannot resolve this one without actually processing
603 // the data since it is a stream.
604 rtnSize += 0;
605 }
606
607 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
608 {
609 rtnSize += _scmoInstances.size();
610 }
611
612 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
613 {
614 switch (_dataType)
615 {
616 case RESP_OBJECTPATHS:
617 case RESP_INSTNAMES:
618 rtnSize += _instanceNames.size();
619 break;
620 case RESP_INSTANCE:
621 case RESP_INSTANCES:
622 rtnSize += _instances.size();
623 karl 1.5.2.12 break;
624 case RESP_OBJECTS:
625 rtnSize += _objects.size();
626 break;
627 }
628 }
629 _size = rtnSize;
630 }
|
631 karl 1.5.2.1 //
|
632 karl 1.5.2.25 // Return the number of CIM objects in the CIM Response data object by
633 // aggregating sizes of each of the encodings
634 //
|
635 karl 1.5.2.1 Uint32 CIMResponseData::size()
636 {
637 // If debug mode, add up all the individual size components to
638 // determine overall size of this object. Then compare this with
|
639 karl 1.5.2.25 // the _size variable. This is a check on the completeness of the
|
640 karl 1.5.2.1 // size computations. We should be able to remove this at some point
641 // but there are many sources of size info and we need to be sure we
642 // have covered them all.
|
643 karl 1.5.2.25 #ifdef CIMRESPONSEDATA_DEBUG
644 PEGASUS_DEBUG_ASSERT(valid());
|
645 karl 1.5.2.1
646 Uint32 rtnSize = 0;
|
647 karl 1.5.2.25
|
648 karl 1.5.2.1 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
649 {
650 switch (_dataType)
651 {
652 case RESP_OBJECTPATHS:
653 case RESP_INSTNAMES:
654 break;
655 case RESP_INSTANCE:
656 rtnSize +=1;
657 break;
658 case RESP_INSTANCES:
659 case RESP_OBJECTS:
660 rtnSize += _instanceData.size();
661 break;
662 }
663 }
664 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
665 {
666 // KS_PULL_TODO
667 // Cannot resolve this one without actually processing
668 // the data since it is a stream.
669 karl 1.5.2.1 rtnSize += 0;
670 }
671
672 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
673 {
674 rtnSize += _scmoInstances.size();
675 }
676
677 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
678 {
679 switch (_dataType)
680 {
681 case RESP_OBJECTPATHS:
682 case RESP_INSTNAMES:
683 rtnSize += _instanceNames.size();
684 break;
685 case RESP_INSTANCE:
686 case RESP_INSTANCES:
687 rtnSize += _instances.size();
688 break;
689 case RESP_OBJECTS:
690 karl 1.5.2.1 rtnSize += _objects.size();
691 break;
692 }
693 }
|
694 karl 1.5.2.9 // Test of actual count against _size variable. KS_TODO diagnostic
|
695 karl 1.5.2.22 Uint32 lsize = _size;
696 if (rtnSize != lsize)
|
697 karl 1.5.2.1 {
698 PEG_TRACE((TRC_XML, Tracer::LEVEL1,
699 "CIMResponseData::size ERROR. debug size mismatch."
|
700 karl 1.5.2.22 "Computed = %u. variable = %u inc binary %s",rtnSize, _size,
701 boolToString(RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
702 ));
|
703 karl 1.5.2.1 }
704 #endif
705 return _size;
706 }
707
|
708 thilo.boehm 1.3 // function used by OperationAggregator to aggregate response data in a
|
709 karl 1.5.2.1 // single ResponseData object. Adds all data in the from ResponseData object
710 // input variable to the target ResponseData object
711 // target array
|
712 thilo.boehm 1.3 void CIMResponseData::appendResponseData(const CIMResponseData & x)
713 {
|
714 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
715 "CIMResponseData::appendResponseData");
|
716 karl 1.5.2.28
717 PEGASUS_DEBUG_ASSERT(valid());
718
|
719 karl 1.5.2.1 // Confirm that the CIMResponseData type matches the type
720 // of the data being appended
|
721 karl 1.5.2.28 // A CIMResponseData must represent a single data content type.
722 // ex. Cannot mix objects and instances.
|
723 karl 1.5.2.1
|
724 thilo.boehm 1.3 PEGASUS_DEBUG_ASSERT(_dataType == x._dataType);
725 _encoding |= x._encoding;
726
727 // add all binary data
728 _binaryData.appendArray(x._binaryData);
729
730 // add all the C++ stuff
731 _instanceNames.appendArray(x._instanceNames);
|
732 karl 1.5.2.1 _size += x._instanceNames.size();
|
733 thilo.boehm 1.3 _instances.appendArray(x._instances);
|
734 karl 1.5.2.1 _size += x._instances.size();
|
735 thilo.boehm 1.3 _objects.appendArray(x._objects);
|
736 karl 1.5.2.1 _size += x._objects.size();
|
737 thilo.boehm 1.3
738 // add the SCMO instances
739 _scmoInstances.appendArray(x._scmoInstances);
|
740 karl 1.5.2.1 _size += x._scmoInstances.size();
|
741 thilo.boehm 1.3
742 _referencesData.appendArray(x._referencesData);
743 _instanceData.appendArray(x._instanceData);
744 _hostsData.appendArray(x._hostsData);
745 _nameSpacesData.appendArray(x._nameSpacesData);
|
746 karl 1.5.2.13 _size += x._instanceData.size();
747
|
748 karl 1.5.2.6 // transfer property list
749 _propertyList = x._propertyList;
|
750 karl 1.5.2.11
751 PEG_METHOD_EXIT();
|
752 thilo.boehm 1.3 }
|
753 r.kieninger 1.1
|
754 thilo.boehm 1.3 // Encoding responses into output format
755 void CIMResponseData::encodeBinaryResponse(CIMBuffer& out)
|
756 r.kieninger 1.1 {
757 PEG_METHOD_ENTER(TRC_DISPATCHER,
|
758 thilo.boehm 1.3 "CIMResponseData::encodeBinaryResponse");
|
759 r.kieninger 1.1
|
760 thilo.boehm 1.3 // Need to do a complete job here by transferring all contained data
761 // into binary format and handing it out in the CIMBuffer
|
762 karl 1.5.2.32 // FUTURE. For now we do not handle binary in the pull
763 // operations and therefore convert back to another encoding.
|
764 thilo.boehm 1.3 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
|
765 r.kieninger 1.1 {
|
766 thilo.boehm 1.3 // Binary does NOT need a marker as it consists of C++ and SCMO
|
767 r.kieninger 1.1 const Array<Uint8>& data = _binaryData;
768 out.putBytes(data.getData(), data.size());
769 }
|
770 karl 1.5.2.1
|
771 thilo.boehm 1.3 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
|
772 r.kieninger 1.1 {
|
773 thilo.boehm 1.3 out.putTypeMarker(BIN_TYPE_MARKER_CPPD);
774 switch (_dataType)
775 {
776 case RESP_INSTNAMES:
777 {
778 out.putObjectPathA(_instanceNames);
779 break;
780 }
781 case RESP_INSTANCE:
782 {
783 if (0 == _instances.size())
784 {
785 _instances.append(CIMInstance());
786 }
787 out.putInstance(_instances[0], true, true);
788 break;
789 }
790 case RESP_INSTANCES:
791 {
792 out.putInstanceA(_instances);
793 break;
794 thilo.boehm 1.3 }
795 case RESP_OBJECTS:
796 {
797 out.putObjectA(_objects);
798 break;
799 }
800 case RESP_OBJECTPATHS:
801 {
802 out.putObjectPathA(_instanceNames);
803 break;
804 }
805 default:
806 {
|
807 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
808 thilo.boehm 1.3 }
809 }
|
810 r.kieninger 1.1 }
|
811 thilo.boehm 1.3 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
|
812 r.kieninger 1.1 {
|
813 thilo.boehm 1.3 out.putTypeMarker(BIN_TYPE_MARKER_SCMO);
814 out.putSCMOInstanceA(_scmoInstances);
|
815 r.kieninger 1.1 }
|
816 thilo.boehm 1.3 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
|
817 r.kieninger 1.1 {
|
818 thilo.boehm 1.3 // This actually should not happen following general code logic
|
819 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
820 r.kieninger 1.1 }
|
821 thilo.boehm 1.3
|
822 r.kieninger 1.1 PEG_METHOD_EXIT();
823 }
824
|
825 thilo.boehm 1.3 void CIMResponseData::completeNamespace(const SCMOInstance * x)
|
826 r.kieninger 1.1 {
|
827 thilo.boehm 1.3 const char * ns;
828 Uint32 len;
829 ns = x->getNameSpace_l(len);
830 // Both internal XML as well as binary always contain a namespace
831 // don't have to do anything for those two encodings
832 if ((RESP_ENC_BINARY == (_encoding&RESP_ENC_BINARY)) && (len != 0))
|
833 r.kieninger 1.1 {
|
834 thilo.boehm 1.3 _defaultNamespace = CIMNamespaceName(ns);
|
835 r.kieninger 1.1 }
|
836 thilo.boehm 1.3 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
|
837 r.kieninger 1.1 {
|
838 thilo.boehm 1.3 CIMNamespaceName nsName(ns);
839 switch (_dataType)
|
840 r.kieninger 1.1 {
|
841 thilo.boehm 1.3 case RESP_INSTANCE:
842 {
843 if (_instances.size() > 0)
844 {
845 const CIMInstance& inst = _instances[0];
846 CIMObjectPath& p =
847 const_cast<CIMObjectPath&>(inst.getPath());
848 if (p.getNameSpace().isNull())
849 {
850 p.setNameSpace(nsName);
851 }
852 }
|
853 karl 1.5.2.3 break;
|
854 thilo.boehm 1.3 }
855 case RESP_INSTANCES:
856 {
857 for (Uint32 j = 0, n = _instances.size(); j < n; j++)
858 {
859 const CIMInstance& inst = _instances[j];
860 CIMObjectPath& p =
861 const_cast<CIMObjectPath&>(inst.getPath());
862 if (p.getNameSpace().isNull())
863 {
864 p.setNameSpace(nsName);
865 }
866 }
867 break;
868 }
869 case RESP_OBJECTS:
870 {
871 for (Uint32 j = 0, n = _objects.size(); j < n; j++)
872 {
873 const CIMObject& object = _objects[j];
874 CIMObjectPath& p =
875 thilo.boehm 1.3 const_cast<CIMObjectPath&>(object.getPath());
876 if (p.getNameSpace().isNull())
877 {
878 p.setNameSpace(nsName);
879 }
880 }
881 break;
882 }
883 case RESP_INSTNAMES:
884 case RESP_OBJECTPATHS:
885 {
886 for (Uint32 j = 0, n = _instanceNames.size(); j < n; j++)
887 {
888 CIMObjectPath& p = _instanceNames[j];
889 if (p.getNameSpace().isNull())
890 {
891 p.setNameSpace(nsName);
892 }
893 }
894 break;
895 }
896 thilo.boehm 1.3 default:
897 {
898 PEGASUS_DEBUG_ASSERT(false);
899 }
|
900 r.kieninger 1.1 }
901 }
|
902 karl 1.5.2.11
|
903 thilo.boehm 1.3 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
|
904 r.kieninger 1.1 {
|
905 thilo.boehm 1.3 for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++)
|
906 r.kieninger 1.1 {
|
907 thilo.boehm 1.3 SCMOInstance & scmoInst=_scmoInstances[j];
908 if (0 == scmoInst.getNameSpace())
909 {
910 scmoInst.setNameSpace_l(ns,len);
911 }
|
912 r.kieninger 1.1 }
913 }
914 }
915
|
916 thilo.boehm 1.3 void CIMResponseData::completeHostNameAndNamespace(
917 const String & hn,
|
918 karl 1.5.2.12 const CIMNamespaceName & ns,
919 Boolean isPullOperation)
|
920 r.kieninger 1.1 {
|
921 karl 1.5.2.1 PEG_METHOD_ENTER(TRC_DISPATCHER,
922 "CIMResponseData::completeHostNameAndNamespace");
923
|
924 karl 1.5.2.27 PEGASUS_DEBUG_ASSERT(valid());
|
925 karl 1.5.2.13
|
926 thilo.boehm 1.3 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
927 {
|
928 karl 1.5.2.13 // On binary need to remember hostname and namespace in case someone
929 // builds C++ default objects or Xml types later i.e.
|
930 thilo.boehm 1.3 // -> usage: See resolveBinary()
931 _defaultNamespace=ns;
932 _defaultHostname=hn;
933 }
934 // InternalXml does not support objectPath calls
935 if ((RESP_ENC_XML == (_encoding & RESP_ENC_XML)) &&
936 (RESP_OBJECTS == _dataType))
937 {
938 for (Uint32 j = 0, n = _referencesData.size(); j < n; j++)
939 {
940 if (0 == _hostsData[j].size())
941 {
942 _hostsData[j]=hn;
943 }
944 if (_nameSpacesData[j].isNull())
945 {
946 _nameSpacesData[j]=ns;
947 }
948 }
949 }
|
950 karl 1.5.2.12 // Need to set for Pull Enumeration operations
951 if ((RESP_ENC_XML == (_encoding & RESP_ENC_XML)) &&
952 ((RESP_INSTANCES == _dataType) || isPullOperation))
953 {
954 for (Uint32 j = 0, n = _referencesData.size(); j < n; j++)
955 {
956 if (0 == _hostsData[j].size())
957 {
958 _hostsData[j]=hn;
959 }
960 if (_nameSpacesData[j].isNull())
961 {
962 _nameSpacesData[j]=ns;
963 }
964
|
965 karl 1.5.2.13 // KS_TODO Remove Diagnostic
|
966 karl 1.5.2.12 PEG_TRACE(( TRC_DISPATCHER, Tracer::LEVEL4,
967 "completeHostNameAndNamespace Setting hostName, etc "
968 "host %s ns %s set to _hostData %s _namespaceData %s",
969 (const char *)hn.getCString(),
970 (const char *)ns.getString().getCString(),
971 (const char *)_hostsData[j].getCString(),
972 (const char *)_nameSpacesData[j].getString().getCString() ));
973 }
974 }
975
|
976 thilo.boehm 1.3 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
|
977 r.kieninger 1.1 {
|
978 thilo.boehm 1.3 switch (_dataType)
|
979 r.kieninger 1.2 {
|
980 karl 1.5.2.1 // Instances added to account for namedInstance in Pull operations.
981 case RESP_INSTANCES:
982
983 for (Uint32 j = 0, n = _instances.size(); j < n; j++)
984 {
985 const CIMInstance& instance = _instances[j];
986 CIMObjectPath& p =
987 const_cast<CIMObjectPath&>(instance.getPath());
988 if (p.getHost().size()==0)
989 {
990 p.setHost(hn);
991 }
992 if (p.getNameSpace().isNull())
993 {
994 p.setNameSpace(ns);
995 }
996 }
|
997 thilo.boehm 1.3 case RESP_OBJECTS:
998 {
999 for (Uint32 j = 0, n = _objects.size(); j < n; j++)
1000 {
1001 const CIMObject& object = _objects[j];
1002 CIMObjectPath& p =
1003 const_cast<CIMObjectPath&>(object.getPath());
1004 if (p.getHost().size()==0)
1005 {
1006 p.setHost(hn);
1007 }
1008 if (p.getNameSpace().isNull())
1009 {
1010 p.setNameSpace(ns);
1011 }
1012 }
1013 break;
1014 }
|
1015 karl 1.5.2.1 // INSTNAMES added to account for instance paths in pull name
1016 // operations
1017 case RESP_INSTNAMES:
|
1018 thilo.boehm 1.3 case RESP_OBJECTPATHS:
1019 {
1020 for (Uint32 j = 0, n = _instanceNames.size(); j < n; j++)
1021 {
1022 CIMObjectPath& p = _instanceNames[j];
1023 if (p.getHost().size() == 0)
|
1024 karl 1.5.2.11 {
|
1025 thilo.boehm 1.3 p.setHost(hn);
|
1026 karl 1.5.2.11 }
|
1027 thilo.boehm 1.3 if (p.getNameSpace().isNull())
|
1028 karl 1.5.2.11 {
|
1029 thilo.boehm 1.3 p.setNameSpace(ns);
|
1030 karl 1.5.2.11 }
|
1031 thilo.boehm 1.3 }
1032 break;
1033 }
1034 default:
1035 {
|
1036 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
1037 thilo.boehm 1.3 }
|
1038 r.kieninger 1.2 }
1039 }
|
1040 thilo.boehm 1.3 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
|
1041 r.kieninger 1.2 {
|
1042 thilo.boehm 1.3 CString hnCString=hn.getCString();
1043 const char* hnChars = hnCString;
1044 Uint32 hnLen = strlen(hnChars);
1045 CString nsCString=ns.getString().getCString();
1046 const char* nsChars=nsCString;
1047 Uint32 nsLen = strlen(nsChars);
1048 switch (_dataType)
1049 {
|
1050 karl 1.5.2.1 // KS_PULL add Instances and InstNames to cover pull operations
1051 // KS_PULL - Confirm that this OK.
1052 case RESP_INSTNAMES:
1053 case RESP_INSTANCES:
|
1054 thilo.boehm 1.3 case RESP_OBJECTS:
1055 case RESP_OBJECTPATHS:
1056 {
1057 for (Uint32 j = 0, n = _scmoInstances.size(); j < n; j++)
1058 {
1059 SCMOInstance & scmoInst=_scmoInstances[j];
|
1060 karl 1.5.2.7 scmoInst.completeHostNameAndNamespace(
1061 hnChars,
1062 hnLen,
1063 nsChars,
1064 nsLen);
|
1065 thilo.boehm 1.3 }
1066 break;
1067 }
1068 default:
1069 {
|
1070 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
1071 thilo.boehm 1.3 }
1072 }
|
1073 r.kieninger 1.1 }
|
1074 karl 1.5.2.1 PEG_METHOD_EXIT();
|
1075 thilo.boehm 1.3 }
|
1076 r.kieninger 1.1
|
1077 karl 1.5.2.1 // NOTE: The reason for the isPullResponse variable is that there are
1078 // some variations in ouput to Xml depending on whether the responses
|
1079 karl 1.5.2.7 // are one of the pull responses or not
|
1080 karl 1.5.2.15 void CIMResponseData::encodeXmlResponse(Buffer& out,
1081 Boolean isPullResponse,
1082 Boolean encodeInstanceOnly)
|
1083 r.kieninger 1.1 {
|
1084 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
1085 "CIMResponseData::encodeXmlResponse");
|
1086 karl 1.5.2.6
|
1087 thilo.boehm 1.3 PEG_TRACE((TRC_XML, Tracer::LEVEL3,
|
1088 karl 1.5.2.21 "CIMResponseData::encodeXmlResponse(encoding=%X,dataType=%X, isPull= %s"
1089 " encodeInstanceOnly= %s)",
|
1090 thilo.boehm 1.3 _encoding,
|
1091 karl 1.5.2.11 _dataType,
|
1092 karl 1.5.2.21 boolToString(isPullResponse),
1093 boolToString(encodeInstanceOnly) ));
|
1094 karl 1.5.2.7
|
1095 thilo.boehm 1.3 // already existing Internal XML does not need to be encoded further
1096 // binary input is not actually impossible here, but we have an established
1097 // fallback
1098 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
|
1099 r.kieninger 1.1 {
|
1100 karl 1.5.2.13 _resolveBinaryToSCMO();
|
1101 r.kieninger 1.1 }
|
1102 thilo.boehm 1.3 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
|
1103 r.kieninger 1.1 {
|
1104 thilo.boehm 1.3 switch (_dataType)
|
1105 r.kieninger 1.1 {
|
1106 thilo.boehm 1.3 case RESP_INSTANCE:
1107 {
1108 const Array<ArraySint8>& a = _instanceData;
1109 out.append((char*)a[0].getData(), a[0].size() - 1);
1110 break;
1111 }
1112 case RESP_INSTANCES:
1113 {
1114 const Array<ArraySint8>& a = _instanceData;
1115 const Array<ArraySint8>& b = _referencesData;
|
1116 r.kieninger 1.1
|
1117 thilo.boehm 1.3 for (Uint32 i = 0, n = a.size(); i < n; i++)
1118 {
|
1119 karl 1.5.2.1 if (isPullResponse)
1120 {
|
1121 karl 1.5.2.32 out << STRLIT("<VALUE.INSTANCEWITHPATH>\n"
1122 "<INSTANCEPATH>\n");
|
1123 karl 1.5.2.13 XmlWriter::appendNameSpacePathElement(out,
1124 _hostsData[i],
1125 _nameSpacesData[i]);
1126 out.append((char*)b[i].getData(), b[i].size() - 1);
1127 out << STRLIT("</INSTANCEPATH>\n");
1128 out.append((char *)a[i].getData(), a[i].size() - 1);
|
1129 karl 1.5.2.1 out << STRLIT("</VALUE.INSTANCEWITHPATH>\n");
1130 }
1131 else
1132 {
|
1133 karl 1.5.2.13 out << STRLIT("<VALUE.NAMEDINSTANCE>\n");
1134 out.append((char*)b[i].getData(), b[i].size() - 1);
1135 out.append((char *)a[i].getData(), a[i].size() - 1);
|
1136 karl 1.5.2.1 out << STRLIT("</VALUE.NAMEDINSTANCE>\n");
1137 }
|
1138 thilo.boehm 1.3 }
1139 break;
1140 }
1141 case RESP_OBJECTS:
1142 {
1143 const Array<ArraySint8>& a = _instanceData;
1144 const Array<ArraySint8>& b = _referencesData;
|
1145 karl 1.5.2.13
|
1146 thilo.boehm 1.3 for (Uint32 i = 0, n = a.size(); i < n; i++)
1147 {
|
1148 karl 1.5.2.21 if (isPullResponse)
1149 {
1150 out << STRLIT("<VALUE.INSTANCEWITHPATH>\n");
1151 }
1152 else
1153 {
1154 out << STRLIT("<VALUE.OBJECTWITHPATH>\n");
1155 }
|
1156 thilo.boehm 1.3 out << STRLIT("<INSTANCEPATH>\n");
1157 XmlWriter::appendNameSpacePathElement(
1158 out,
1159 _hostsData[i],
1160 _nameSpacesData[i]);
|
1161 karl 1.5.2.21
1162 if (isPullResponse)
1163 {
1164 out.append((char*)b[i].getData(),b[i].size()-1);
1165 }
1166 else
1167 {
1168 // Leave out the surrounding tags "<VALUE.REFERENCE>\n"
1169 // and "</VALUE.REFERENCE>\n" which are 18 and 19
1170 // characters long
1171 //// KS_TODO Should be able to do this by properly
1172 //// building in the CIMXmlInternalEncoder
1173 out.append(
1174 ((char*)b[i].getData())+18,
1175 b[i].size() - 1 - 18 -19);
1176 }
1177
|
1178 thilo.boehm 1.3 out << STRLIT("</INSTANCEPATH>\n");
1179 // append instance body
1180 out.append((char*)a[i].getData(), a[i].size() - 1);
|
1181 karl 1.5.2.21 if (isPullResponse)
1182 {
1183 out << STRLIT("</VALUE.INSTANCEWITHPATH>\n");
1184 }
1185 else
1186 {
1187 out << STRLIT("</VALUE.OBJECTWITHPATH>\n");
1188 }
|
1189 thilo.boehm 1.3 }
1190 break;
1191 }
1192 // internal xml encoding of instance names and object paths not
1193 // done today
1194 case RESP_INSTNAMES:
1195 case RESP_OBJECTPATHS:
1196 default:
1197 {
|
1198 karl 1.5.2.11 PEGASUS_ASSERT(false);
|
1199 thilo.boehm 1.3 }
|
1200 r.kieninger 1.1 }
|
1201 thilo.boehm 1.3 }
|
1202 r.kieninger 1.1
|
1203 thilo.boehm 1.3 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
1204 {
1205 switch (_dataType)
|
1206 r.kieninger 1.1 {
|
1207 thilo.boehm 1.3 case RESP_INSTNAMES:
1208 {
1209 for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++)
1210 {
|
1211 karl 1.5.2.1 // Element type is different for Pull responses
1212 if (isPullResponse)
1213 {
1214 XmlWriter::appendInstancePathElement(out,
1215 _instanceNames[i]);
1216 }
1217 else
1218 {
1219 XmlWriter::appendInstanceNameElement(out,
1220 _instanceNames[i]);
1221 }
|
1222 thilo.boehm 1.3 }
1223 break;
1224 }
1225 case RESP_INSTANCE:
1226 {
1227 if (_instances.size() > 0)
1228 {
|
1229 karl 1.5.2.3 XmlWriter::appendInstanceElement(
|
1230 karl 1.5.2.7 out,
|
1231 karl 1.5.2.3 _instances[0],
1232 _includeQualifiers,
1233 _includeClassOrigin,
1234 _propertyList);
|
1235 thilo.boehm 1.3 }
1236 break;
1237 }
1238 case RESP_INSTANCES:
1239 {
1240 for (Uint32 i = 0, n = _instances.size(); i < n; i++)
1241 {
|
1242 karl 1.5.2.1 if (isPullResponse)
1243 {
|
1244 karl 1.5.2.15 if (encodeInstanceOnly)
1245 {
1246 XmlWriter::appendInstanceElement(
1247 out,
1248 _instances[i],
|
1249 karl 1.5.2.18 _includeQualifiers,
|
1250 karl 1.5.2.15 _includeClassOrigin,
1251 _propertyList);
1252 }
1253 else
1254 {
1255 XmlWriter::appendValueInstanceWithPathElement(
1256 out,
1257 _instances[i],
|
1258 karl 1.5.2.18 _includeQualifiers,
|
1259 karl 1.5.2.15 _includeClassOrigin,
1260 _propertyList);
1261 }
|
1262 karl 1.5.2.1 }
1263 else
1264 {
1265 XmlWriter::appendValueNamedInstanceElement(
|
1266 karl 1.5.2.3 out,
1267 _instances[i],
1268 _includeQualifiers,
1269 _includeClassOrigin,
1270 _propertyList);
|
1271 karl 1.5.2.1 }
|
1272 thilo.boehm 1.3 }
1273 break;
1274 }
1275 case RESP_OBJECTS:
1276 {
1277 for (Uint32 i = 0; i < _objects.size(); i++)
1278 {
|
1279 karl 1.5.2.1 // If pull, map to instances
1280 if (isPullResponse)
1281 {
|
1282 karl 1.5.2.28
|
1283 karl 1.5.2.1 CIMInstance x = (CIMInstance)_objects[i];
|
1284 karl 1.5.2.28 if (encodeInstanceOnly)
1285 {
1286 XmlWriter::appendInstanceElement(
1287 out,
1288 x,
1289 _includeQualifiers,
1290 _includeClassOrigin,
1291 _propertyList);
1292 }
1293 else
1294 {
1295 XmlWriter::appendValueInstanceWithPathElement(
1296 out,
1297 x,
1298 _includeQualifiers,
1299 _includeClassOrigin,
1300 _propertyList);
1301 }
|
1302 karl 1.5.2.1 }
1303 else
1304 {
1305 XmlWriter::appendValueObjectWithPathElement(
|
1306 karl 1.5.2.3 out,
1307 _objects[i],
1308 _includeQualifiers,
1309 _includeClassOrigin,
|
1310 karl 1.5.2.7 _isClassOperation,
|
1311 karl 1.5.2.3 _propertyList);
|
1312 karl 1.5.2.1 }
|
1313 thilo.boehm 1.3 }
1314 break;
1315 }
1316 case RESP_OBJECTPATHS:
1317 {
1318 for (Uint32 i = 0, n = _instanceNames.size(); i < n; i++)
1319 {
|
1320 karl 1.5.2.1 // ObjectPaths come from providers for pull operations
|
1321 karl 1.5.2.21 // but are encoded as instancePathElements. If pull
1322 // only instances allowed.
|
1323 karl 1.5.2.1 if (isPullResponse)
1324 {
|
1325 karl 1.5.2.21 XmlWriter::appendInstancePathElement(
1326 out,
|
1327 karl 1.5.2.1 _instanceNames[i]);
1328 }
1329 else
1330 {
|
1331 karl 1.5.2.21 //Append The path element (Class or instance)
|
1332 karl 1.5.2.1 out << "<OBJECTPATH>\n";
|
1333 karl 1.5.2.21 XmlWriter::appendClassOrInstancePathElement(
|
1334 karl 1.5.2.1 out,
1335 _instanceNames[i],
|
1336 karl 1.5.2.21 _isClassOperation);
|
1337 karl 1.5.2.1 out << "</OBJECTPATH>\n";
1338 }
|
1339 thilo.boehm 1.3 }
1340 break;
1341 }
1342 default:
1343 {
|
1344 karl 1.5.2.11 PEGASUS_ASSERT(false);
|
1345 thilo.boehm 1.3 }
|
1346 r.kieninger 1.1 }
|
1347 thilo.boehm 1.3 }
1348 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
1349 {
1350 switch (_dataType)
|
1351 r.kieninger 1.1 {
|
1352 thilo.boehm 1.3 case RESP_INSTNAMES:
1353 {
|
1354 karl 1.5.2.15 for (Uint32 i = 0, n = _scmoInstances.size();i < n; i++)
|
1355 thilo.boehm 1.3 {
|
1356 karl 1.5.2.15 if (isPullResponse)
|
1357 karl 1.5.2.6 {
1358 SCMOXmlWriter::appendInstancePathElement(
|
1359 karl 1.5.2.15 out,
1360 _scmoInstances[i]);
|
1361 karl 1.5.2.6 }
|
1362 karl 1.5.2.15 else
|
1363 karl 1.5.2.6 {
1364 SCMOXmlWriter::appendInstanceNameElement(
1365 out,
1366 _scmoInstances[i]);
1367 }
|
1368 thilo.boehm 1.3 }
1369 break;
1370 }
1371 case RESP_INSTANCE:
1372 {
1373 if (_scmoInstances.size() > 0)
1374 {
|
1375 karl 1.5.2.15 _appendInstanceElement(out, _scmoInstances[0]);
|
1376 thilo.boehm 1.3 }
1377 break;
1378 }
1379 case RESP_INSTANCES:
1380 {
|
1381 karl 1.5.2.3 if (isPullResponse)
|
1382 thilo.boehm 1.3 {
|
1383 karl 1.5.2.15 // pull and encodeInstanceOnly (i.e. response to
1384 // OpenQueryInstances and pullInstances
1385 if (encodeInstanceOnly)
1386 {
|
1387 karl 1.5.2.32 // KS_FUTURE move this to SCMOXmlWriter
|
1388 karl 1.5.2.15 for (Uint32 i = 0, n = _scmoInstances.size();i < n; i++)
1389 {
1390 _appendInstanceElement(out, _scmoInstances[i]);
1391 }
1392 }
1393 else
1394 {
1395 SCMOXmlWriter::appendValueSCMOInstanceWithPathElements(
1396 out, _scmoInstances, _propertyList);
1397 }
|
1398 thilo.boehm 1.3 }
|
1399 karl 1.5.2.3 else
1400 {
1401 SCMOXmlWriter::appendValueSCMOInstanceElements(
1402 out, _scmoInstances, _propertyList);
1403 }
|
1404 thilo.boehm 1.3 break;
1405 }
1406 case RESP_OBJECTS:
1407 {
|
1408 karl 1.5.2.3 if (isPullResponse)
|
1409 thilo.boehm 1.3 {
|
1410 karl 1.5.2.28 // if encodeInstanceOnly flag, encode objects as instances
1411 // Used by OpenQueryInstances and pullInstances.
1412 if (encodeInstanceOnly)
1413 {
1414 for (Uint32 i = 0, n = _scmoInstances.size();i < n; i++)
1415 {
1416 _appendInstanceElement(out, _scmoInstances[i]);
1417 }
1418 }
1419 else
1420 {
1421 SCMOXmlWriter::appendValueSCMOInstanceWithPathElements(
1422 out,_scmoInstances, _propertyList);
1423 }
|
1424 karl 1.5.2.3 }
1425 else
1426 {
1427 // KS_TODO why is this one named element rather than
1428 // elements
1429 SCMOXmlWriter::appendValueObjectWithPathElement(
1430 out, _scmoInstances, _propertyList);
|
1431 thilo.boehm 1.3 }
1432 break;
1433 }
1434 case RESP_OBJECTPATHS:
1435 {
1436 for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++)
1437 {
|
1438 karl 1.5.2.1 if (isPullResponse)
1439 {
1440 SCMOXmlWriter::appendInstancePathElement(out,
1441 _scmoInstances[i]);
1442 }
1443 else
1444 {
1445 out << "<OBJECTPATH>\n";
|
1446 karl 1.5.2.21 SCMOXmlWriter::appendClassOrInstancePathElement(
1447 out, _scmoInstances[i]);
|
1448 karl 1.5.2.1 out << "</OBJECTPATH>\n";
1449 }
|
1450 thilo.boehm 1.3 }
1451 break;
1452 }
1453 default:
1454 {
|
1455 karl 1.5.2.11 PEGASUS_ASSERT(false);
|
1456 thilo.boehm 1.3 }
|
1457 r.kieninger 1.1 }
1458 }
|
1459 karl 1.5.2.11 PEG_METHOD_EXIT();
|
1460 thilo.boehm 1.3 }
|
1461 r.kieninger 1.1
|
1462 thilo.boehm 1.3 // contrary to encodeXmlResponse this function encodes the Xml in a format
1463 // not usable by clients
|
1464 karl 1.5.2.21 void CIMResponseData::encodeInternalXmlResponse(CIMBuffer& out,
1465 Boolean isPullOperation)
|
1466 thilo.boehm 1.3 {
|
1467 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
1468 "CIMResponseData::encodeInternalXmlResponse");
1469
|
1470 thilo.boehm 1.3 PEG_TRACE((TRC_XML, Tracer::LEVEL3,
|
1471 karl 1.5.2.21 "CIMResponseData::encodeInternalXmlResponse(encoding=%X,content=%X"
1472 " isPullOperation=%s)",
|
1473 thilo.boehm 1.3 _encoding,
|
1474 karl 1.5.2.21 _dataType,
1475 boolToString(isPullOperation)));
1476
|
1477 thilo.boehm 1.3 // For mixed (CIM+SCMO) responses, we need to tell the receiver the
1478 // total number of instances. The totalSize variable is used to keep track
1479 // of this.
1480 Uint32 totalSize = 0;
|
1481 r.kieninger 1.1
|
1482 thilo.boehm 1.3 // already existing Internal XML does not need to be encoded further
1483 // binary input is not actually impossible here, but we have an established
1484 // fallback
1485 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
1486 {
|
1487 karl 1.5.2.13 _resolveBinaryToSCMO();
|
1488 thilo.boehm 1.3 }
1489 if ((0 == _encoding) ||
1490 (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)))
1491 {
1492 switch (_dataType)
1493 {
1494 case RESP_INSTANCE:
1495 {
1496 if (0 == _instances.size())
1497 {
1498 _instances.append(CIMInstance());
|
1499 karl 1.5.2.3 CIMInternalXmlEncoder::_putXMLInstance(
1500 out,
1501 _instances[0]);
1502 break;
|
1503 thilo.boehm 1.3 }
|
1504 karl 1.5.2.3 CIMInternalXmlEncoder::_putXMLInstance(
1505 out,
1506 _instances[0],
1507 _includeQualifiers,
1508 _includeClassOrigin,
1509 _propertyList);
|
1510 thilo.boehm 1.3 break;
1511 }
1512 case RESP_INSTANCES:
1513 {
1514 Uint32 n = _instances.size();
1515 totalSize = n + _scmoInstances.size();
1516 out.putUint32(totalSize);
1517 for (Uint32 i = 0; i < n; i++)
1518 {
1519 CIMInternalXmlEncoder::_putXMLNamedInstance(
1520 out,
|
1521 karl 1.5.2.3 _instances[i],
1522 _includeQualifiers,
1523 _includeClassOrigin,
1524 _propertyList);
|
1525 thilo.boehm 1.3 }
1526 break;
1527 }
1528 case RESP_OBJECTS:
1529 {
1530 Uint32 n = _objects.size();
1531 totalSize = n + _scmoInstances.size();
1532 out.putUint32(totalSize);
1533 for (Uint32 i = 0; i < n; i++)
1534 {
|
1535 karl 1.5.2.21 // if is pull map to instances.
1536 if (isPullOperation)
1537 {
1538 CIMInternalXmlEncoder::_putXMLNamedInstance(
1539 out,
1540 (CIMInstance)_objects[i],
1541 _includeQualifiers,
1542 _includeClassOrigin,
1543 _propertyList);
1544 }
1545 else
1546 {
1547 CIMInternalXmlEncoder::_putXMLObject(
1548 out,
1549 _objects[i],
1550 _includeQualifiers,
1551 _includeClassOrigin,
1552 _propertyList);
1553 }
|
1554 thilo.boehm 1.3 }
1555 break;
1556 }
1557 // internal xml encoding of instance names and object paths not
1558 // done today
1559 case RESP_INSTNAMES:
1560 case RESP_OBJECTPATHS:
1561 default:
1562 {
|
1563 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
1564 thilo.boehm 1.3 }
1565 }
1566 }
1567 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
1568 {
1569 switch (_dataType)
1570 {
1571 case RESP_INSTANCE:
1572 {
1573 if (0 == _scmoInstances.size())
1574 {
1575 _scmoInstances.append(SCMOInstance());
1576 }
|
1577 karl 1.5.2.3 SCMOInternalXmlEncoder::_putXMLInstance(
|
1578 karl 1.5.2.7 out,
|
1579 karl 1.5.2.3 _scmoInstances[0],
1580 _propertyList);
|
1581 thilo.boehm 1.3 break;
1582 }
1583 case RESP_INSTANCES:
1584 {
1585 Uint32 n = _scmoInstances.size();
1586 // Only put the size when not already done above
1587 if (0==totalSize)
1588 {
1589 out.putUint32(n);
1590 }
|
1591 karl 1.5.2.3 SCMOInternalXmlEncoder::_putXMLNamedInstance(
1592 out,
1593 _scmoInstances,
1594 _propertyList);
|
1595 thilo.boehm 1.3 break;
1596 }
1597 case RESP_OBJECTS:
1598 {
1599 Uint32 n = _scmoInstances.size();
1600 // Only put the size when not already done above
1601 if (0==totalSize)
1602 {
1603 out.putUint32(n);
1604 }
|
1605 karl 1.5.2.21 // if is pull map to instances.
1606 if (isPullOperation)
1607 {
1608 SCMOInternalXmlEncoder::_putXMLNamedInstance(
1609 out,
1610 _scmoInstances,
1611 _propertyList);
1612 }
1613 else
1614 {
1615 SCMOInternalXmlEncoder::_putXMLObject(
1616 out,
1617 _scmoInstances,
1618 _propertyList);
1619 }
|
1620 thilo.boehm 1.3 break;
1621 }
1622 // internal xml encoding of instance names and object paths not
1623 // done today
1624 case RESP_INSTNAMES:
1625 case RESP_OBJECTPATHS:
1626 default:
1627 {
|
1628 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
1629 thilo.boehm 1.3 }
1630 }
1631 }
|
1632 karl 1.5.2.11 PEG_METHOD_EXIT();
|
1633 thilo.boehm 1.3 }
|
1634 r.kieninger 1.1
|
1635 thilo.boehm 1.3 void CIMResponseData::_resolveToCIM()
|
1636 r.kieninger 1.1 {
|
1637 r.kieninger 1.4 PEG_TRACE((TRC_XML, Tracer::LEVEL3,
1638 "CIMResponseData::_resolveToCIM(encoding=%X,content=%X)",
|
1639 thilo.boehm 1.3 _encoding,
1640 _dataType));
|
1641 r.kieninger 1.1
|
1642 thilo.boehm 1.3 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
1643 {
1644 _resolveXmlToCIM();
1645 }
1646 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
|
1647 r.kieninger 1.1 {
|
1648 karl 1.5.2.13 _resolveBinaryToSCMO();
|
1649 r.kieninger 1.1 }
|
1650 thilo.boehm 1.3 if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO))
|
1651 r.kieninger 1.1 {
|
1652 thilo.boehm 1.3 _resolveSCMOToCIM();
|
1653 r.kieninger 1.1 }
|
1654 thilo.boehm 1.3
1655 PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_CIM || _encoding == 0);
|
1656 r.kieninger 1.1 }
1657
|
1658 karl 1.5.2.13 // Resolve any binary data to SCMO. This externalfunction added because we
1659 // cannot do a move on Binary data so convert it a to movable format
1660 void CIMResponseData::resolveBinaryToSCMO()
1661 {
1662 PEG_METHOD_ENTER(TRC_DISPATCHER,
1663 "CIMResponseData::resolveBinaryToSCMO");
1664 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
1665 {
1666 _resolveBinaryToSCMO();
1667 }
1668 PEG_METHOD_EXIT();
1669 }
1670
|
1671 thilo.boehm 1.3 void CIMResponseData::_resolveToSCMO()
|
1672 r.kieninger 1.1 {
|
1673 r.kieninger 1.4 PEG_TRACE((TRC_XML, Tracer::LEVEL3,
1674 "CIMResponseData::_resolveToSCMO(encoding=%X,content=%X)",
|
1675 thilo.boehm 1.3 _encoding,
1676 _dataType));
|
1677 r.kieninger 1.1
|
1678 thilo.boehm 1.3 if (RESP_ENC_XML == (_encoding & RESP_ENC_XML))
1679 {
1680 _resolveXmlToSCMO();
1681 }
1682 if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY))
|
1683 r.kieninger 1.1 {
|
1684 karl 1.5.2.13 _resolveBinaryToSCMO();
|
1685 r.kieninger 1.1 }
|
1686 thilo.boehm 1.3 if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM))
|
1687 r.kieninger 1.1 {
|
1688 thilo.boehm 1.3 _resolveCIMToSCMO();
|
1689 r.kieninger 1.1 }
|
1690 thilo.boehm 1.3 PEGASUS_DEBUG_ASSERT(_encoding == RESP_ENC_SCMO || _encoding == 0);
|
1691 r.kieninger 1.1 }
1692
|
1693 thilo.boehm 1.3 // helper functions to transform different formats into one-another
1694 // functions work on the internal data and calling of them should be
1695 // avoided whenever possible
|
1696 karl 1.5.2.13 void CIMResponseData::_resolveBinaryToSCMO()
|
1697 r.kieninger 1.1 {
1698 PEG_METHOD_ENTER(TRC_DISPATCHER,
|
1699 karl 1.5.2.13 "CIMResponseData::_resolveBinaryToSCMO");
|
1700 r.kieninger 1.1
|
1701 thilo.boehm 1.3 CIMBuffer in((char*)_binaryData.getData(), _binaryData.size());
|
1702 r.kieninger 1.1
|
1703 r.kieninger 1.2 while (in.more())
|
1704 r.kieninger 1.1 {
|
1705 thilo.boehm 1.3 Uint32 binaryTypeMarker=0;
1706 if(!in.getTypeMarker(binaryTypeMarker))
|
1707 r.kieninger 1.2 {
1708 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
|
1709 thilo.boehm 1.3 "Failed to get type marker for binary objects!");
|
1710 r.kieninger 1.2 PEG_METHOD_EXIT();
|
1711 thilo.boehm 1.3 in.release();
1712 return;
1713 }
1714
1715 if (BIN_TYPE_MARKER_SCMO==binaryTypeMarker)
1716 {
1717 if (!in.getSCMOInstanceA(_scmoInstances))
1718 {
1719 _encoding &=(~RESP_ENC_BINARY);
1720 in.release();
1721 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1722 "Failed to resolve binary SCMOInstances!");
1723 PEG_METHOD_EXIT();
1724 return;
1725 }
1726
1727 _encoding |= RESP_ENC_SCMO;
|
1728 r.kieninger 1.2 }
|
1729 thilo.boehm 1.3 else
1730 {
1731 switch (_dataType)
1732 {
1733 case RESP_INSTNAMES:
1734 case RESP_OBJECTPATHS:
1735 {
1736 if (!in.getObjectPathA(_instanceNames))
1737 {
1738 _encoding &=(~RESP_ENC_BINARY);
1739 in.release();
1740 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1741 "Failed to resolve binary CIMObjectPaths!");
1742 PEG_METHOD_EXIT();
1743 return;
1744 }
1745 break;
1746 }
1747 case RESP_INSTANCE:
1748 {
1749 CIMInstance instance;
1750 thilo.boehm 1.3 if (!in.getInstance(instance))
1751 {
1752 _encoding &=(~RESP_ENC_BINARY);
1753 _encoding |= RESP_ENC_CIM;
1754 _instances.append(instance);
1755 in.release();
1756 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1757 "Failed to resolve binary instance!");
1758 PEG_METHOD_EXIT();
1759 return;
1760 }
1761
1762 _instances.append(instance);
1763 break;
1764 }
1765 case RESP_INSTANCES:
1766 {
1767 if (!in.getInstanceA(_instances))
1768 {
1769 _encoding &=(~RESP_ENC_BINARY);
1770 in.release();
1771 thilo.boehm 1.3 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1772 "Failed to resolve binary CIMInstances!");
1773 PEG_METHOD_EXIT();
1774 return;
1775 }
1776 break;
1777 }
1778 case RESP_OBJECTS:
1779 {
1780 if (!in.getObjectA(_objects))
1781 {
1782 in.release();
1783 _encoding &=(~RESP_ENC_BINARY);
1784 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1785 "Failed to resolve binary CIMObjects!");
1786 PEG_METHOD_EXIT();
1787 return;
1788 }
1789 break;
1790 }
1791 default:
1792 thilo.boehm 1.3 {
|
1793 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
1794 thilo.boehm 1.3 }
1795 } // switch
1796 _encoding |= RESP_ENC_CIM;
1797 } // else SCMO
1798 }
1799 _encoding &=(~RESP_ENC_BINARY);
1800 // fix up the hostname and namespace for objects if defaults
1801 // were set
1802 if (_defaultHostname.size() > 0 && !_defaultNamespace.isNull())
1803 {
1804 completeHostNameAndNamespace(_defaultHostname, _defaultNamespace);
|
1805 r.kieninger 1.1 }
1806 in.release();
1807 PEG_METHOD_EXIT();
1808 }
1809
|
1810 karl 1.5.2.7
1811 void CIMResponseData::_deserializeObject(Uint32 idx,CIMObject& cimObject)
1812 {
|
1813 karl 1.5.2.11
1814 PEG_METHOD_ENTER(TRC_DISPATCHER,
1815 "CIMResponseData::_deserializeObject");
|
1816 karl 1.5.2.7 // Only start the parser when instance data is present.
1817 if (0 != _instanceData[idx].size())
1818 {
1819 CIMInstance cimInstance;
1820 CIMClass cimClass;
1821
1822 XmlParser parser((char*)_instanceData[idx].getData());
1823
1824 if (XmlReader::getInstanceElement(parser, cimInstance))
1825 {
1826 cimObject = CIMObject(cimInstance);
1827 return;
1828 }
1829
1830 if (XmlReader::getClassElement(parser, cimClass))
1831 {
1832 cimObject = CIMObject(cimClass);
1833 return;
1834 }
1835 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1836 "Failed to resolve XML object data, parser error!");
1837 karl 1.5.2.7 }
|
1838 karl 1.5.2.11 PEG_METHOD_EXIT();
|
1839 karl 1.5.2.7 }
1840
1841 void CIMResponseData::_deserializeInstance(Uint32 idx,CIMInstance& cimInstance)
1842 {
|
1843 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
1844 "CIMResponseData::_deserializeInstance");
|
1845 karl 1.5.2.7 // Only start the parser when instance data is present.
1846 if (0 != _instanceData[idx].size())
1847 {
1848 XmlParser parser((char*)_instanceData[idx].getData());
1849 if (XmlReader::getInstanceElement(parser, cimInstance))
1850 {
1851 return;
1852 }
1853 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1854 "Failed to resolve XML instance, parser error!");
1855 }
1856 // reset instance when parsing may not be successfull or
1857 // no instance is present.
1858 cimInstance = CIMInstance();
|
1859 karl 1.5.2.11
1860 PEG_METHOD_EXIT();
|
1861 karl 1.5.2.7 }
1862
1863 Boolean CIMResponseData::_deserializeReference(
1864 Uint32 idx,
1865 CIMObjectPath& cimObjectPath)
1866 {
1867 // Only start the parser when reference data is present.
1868 if (0 != _referencesData[idx].size())
1869 {
1870 XmlParser parser((char*)_referencesData[idx].getData());
1871 if (XmlReader::getValueReferenceElement(parser, cimObjectPath))
1872 {
1873 if (_hostsData[idx].size())
1874 {
1875 cimObjectPath.setHost(_hostsData[idx]);
1876 }
1877 if (!_nameSpacesData[idx].isNull())
1878 {
1879 cimObjectPath.setNameSpace(_nameSpacesData[idx]);
1880 }
1881 return true;
1882 karl 1.5.2.7 }
1883 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1884 "Failed to resolve XML reference, parser error!");
1885
1886 }
1887 return false;
1888 }
1889
1890 Boolean CIMResponseData::_deserializeInstanceName(
1891 Uint32 idx,
1892 CIMObjectPath& cimObjectPath)
1893 {
1894 // Only start the parser when instance name data is present.
1895 if (0 != _referencesData[idx].size())
1896 {
1897 XmlParser parser((char*)_referencesData[idx].getData());
1898 if (XmlReader::getInstanceNameElement(parser, cimObjectPath))
1899 {
1900 if (_hostsData[idx].size())
1901 {
1902 cimObjectPath.setHost(_hostsData[idx]);
1903 karl 1.5.2.7 }
1904 if (!_nameSpacesData[idx].isNull())
1905 {
1906 cimObjectPath.setNameSpace(_nameSpacesData[idx]);
1907 }
1908 return true;
1909 }
1910 PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL1,
1911 "Failed to resolve XML instance name, parser error!");
1912
1913 }
1914 return false;
1915 }
1916
|
1917 thilo.boehm 1.3 void CIMResponseData::_resolveXmlToCIM()
|
1918 r.kieninger 1.1 {
|
1919 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
1920 "CIMResponseData::_resolveXmlToCIM");
1921
|
1922 thilo.boehm 1.3 switch (_dataType)
|
1923 r.kieninger 1.1 {
|
1924 thilo.boehm 1.3 // Xml encoding for instance names and object paths not used
1925 case RESP_OBJECTPATHS:
1926 case RESP_INSTNAMES:
1927 {
1928 break;
1929 }
1930 case RESP_INSTANCE:
|
1931 r.kieninger 1.1 {
|
1932 thilo.boehm 1.3 CIMInstance cimInstance;
|
1933 karl 1.5.2.7 CIMObjectPath cimObjectPath;
|
1934 r.kieninger 1.1
|
1935 karl 1.5.2.7 _deserializeInstance(0,cimInstance);
1936 if (_deserializeReference(0,cimObjectPath))
|
1937 r.kieninger 1.1 {
|
1938 karl 1.5.2.7 cimInstance.setPath(cimObjectPath);
1939 // A single CIMInstance has to have an objectpath.
1940 // So only add it when an objectpath exists.
1941 _instances.append(cimInstance);
|
1942 r.kieninger 1.1 }
|
1943 thilo.boehm 1.3 break;
|
1944 r.kieninger 1.1 }
|
1945 thilo.boehm 1.3 case RESP_INSTANCES:
1946 {
1947 for (Uint32 i = 0; i < _instanceData.size(); i++)
1948 {
1949 CIMInstance cimInstance;
|
1950 karl 1.5.2.7 CIMObjectPath cimObjectPath;
|
1951 thilo.boehm 1.3
|
1952 karl 1.5.2.7 _deserializeInstance(i,cimInstance);
1953 if (_deserializeInstanceName(i,cimObjectPath))
|
1954 thilo.boehm 1.3 {
|
1955 karl 1.5.2.7 cimInstance.setPath(cimObjectPath);
|
1956 thilo.boehm 1.3 }
|
1957 karl 1.5.2.7 // enumarate instances can be without name
|
1958 thilo.boehm 1.3 _instances.append(cimInstance);
1959 }
1960 break;
1961 }
1962 case RESP_OBJECTS:
|
1963 r.kieninger 1.1 {
|
1964 thilo.boehm 1.3 for (Uint32 i=0, n=_instanceData.size(); i<n; i++)
|
1965 r.kieninger 1.1 {
|
1966 thilo.boehm 1.3 CIMObject cimObject;
|
1967 karl 1.5.2.7 CIMObjectPath cimObjectPath;
|
1968 r.kieninger 1.1
|
1969 karl 1.5.2.7 _deserializeObject(i,cimObject);
1970 if (_deserializeReference(i,cimObjectPath))
|
1971 thilo.boehm 1.3 {
|
1972 karl 1.5.2.7 cimObject.setPath(cimObjectPath);
|
1973 thilo.boehm 1.3 }
1974 _objects.append(cimObject);
|
1975 r.kieninger 1.1 }
|
1976 thilo.boehm 1.3 break;
1977 }
1978 default:
1979 {
|
1980 karl 1.5.2.11 PEGASUS_ASSERT(false);
|
1981 r.kieninger 1.1 }
1982 }
|
1983 thilo.boehm 1.3 // Xml was resolved, release Xml content now
1984 _referencesData.clear();
1985 _hostsData.clear();
1986 _nameSpacesData.clear();
1987 _instanceData.clear();
1988 // remove Xml Encoding flag
1989 _encoding &=(~RESP_ENC_XML);
1990 // add CIM Encoding flag
1991 _encoding |=RESP_ENC_CIM;
|
1992 karl 1.5.2.11
1993 PEG_METHOD_EXIT();
|
1994 thilo.boehm 1.3 }
|
1995 r.kieninger 1.1
|
1996 thilo.boehm 1.3 void CIMResponseData::_resolveXmlToSCMO()
1997 {
|
1998 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
1999 "CIMResponseData::_resolveXmlToSCMO");
|
2000 thilo.boehm 1.3 // Not optimal, can probably be improved
2001 // but on the other hand, since using the binary format this case should
2002 // actually not ever happen.
2003 _resolveXmlToCIM();
2004 _resolveCIMToSCMO();
|
2005 karl 1.5.2.11
2006 PEG_METHOD_EXIT();
|
2007 r.kieninger 1.1 }
2008
|
2009 thilo.boehm 1.3 void CIMResponseData::_resolveSCMOToCIM()
|
2010 r.kieninger 1.1 {
|
2011 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
2012 "CIMResponseData::_resolveSCMOToCIM");
|
2013 thilo.boehm 1.3 switch(_dataType)
|
2014 r.kieninger 1.2 {
|
2015 thilo.boehm 1.3 case RESP_INSTNAMES:
2016 case RESP_OBJECTPATHS:
|
2017 r.kieninger 1.2 {
|
2018 thilo.boehm 1.3 for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
2019 {
2020 CIMObjectPath newObjectPath;
2021 _scmoInstances[x].getCIMObjectPath(newObjectPath);
2022 _instanceNames.append(newObjectPath);
2023 }
2024 break;
|
2025 r.kieninger 1.2 }
|
2026 thilo.boehm 1.3 case RESP_INSTANCE:
|
2027 r.kieninger 1.1 {
|
2028 thilo.boehm 1.3 if (_scmoInstances.size() > 0)
2029 {
2030 CIMInstance newInstance;
2031 _scmoInstances[0].getCIMInstance(newInstance);
2032 _instances.append(newInstance);
2033 }
2034 break;
|
2035 r.kieninger 1.1 }
|
2036 thilo.boehm 1.3 case RESP_INSTANCES:
|
2037 r.kieninger 1.1 {
|
2038 thilo.boehm 1.3 for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
2039 {
2040 CIMInstance newInstance;
2041 _scmoInstances[x].getCIMInstance(newInstance);
2042 _instances.append(newInstance);
2043 }
2044 break;
|
2045 r.kieninger 1.1 }
|
2046 thilo.boehm 1.3 case RESP_OBJECTS:
|
2047 r.kieninger 1.1 {
|
2048 thilo.boehm 1.3 for (Uint32 x=0, n=_scmoInstances.size(); x < n; x++)
2049 {
2050 CIMInstance newInstance;
2051 _scmoInstances[x].getCIMInstance(newInstance);
2052 _objects.append(CIMObject(newInstance));
2053 }
2054 break;
|
2055 r.kieninger 1.1 }
|
2056 thilo.boehm 1.3 default:
|
2057 r.kieninger 1.1 {
|
2058 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
2059 r.kieninger 1.1 }
2060 }
|
2061 thilo.boehm 1.3 _scmoInstances.clear();
2062 // remove CIM Encoding flag
2063 _encoding &=(~RESP_ENC_SCMO);
2064 // add SCMO Encoding flag
2065 _encoding |=RESP_ENC_CIM;
|
2066 karl 1.5.2.11
2067 PEG_METHOD_EXIT();
|
2068 r.kieninger 1.1 }
2069
|
2070 thilo.boehm 1.3 void CIMResponseData::_resolveCIMToSCMO()
|
2071 r.kieninger 1.1 {
|
2072 karl 1.5.2.11 PEG_METHOD_ENTER(TRC_DISPATCHER,
2073 "CIMResponseData::_resolveCIMToSCMO");
|
2074 thilo.boehm 1.3 CString nsCString=_defaultNamespace.getString().getCString();
2075 const char* _defNamespace = nsCString;
2076 Uint32 _defNamespaceLen;
2077 if (_defaultNamespace.isNull())
|
2078 r.kieninger 1.1 {
|
2079 thilo.boehm 1.3 _defNamespaceLen=0;
|
2080 r.kieninger 1.1 }
2081 else
2082 {
|
2083 thilo.boehm 1.3 _defNamespaceLen=strlen(_defNamespace);
|
2084 r.kieninger 1.1 }
|
2085 thilo.boehm 1.3 switch (_dataType)
|
2086 r.kieninger 1.1 {
|
2087 thilo.boehm 1.3 case RESP_INSTNAMES:
|
2088 r.kieninger 1.1 {
|
2089 thilo.boehm 1.3 for (Uint32 i=0,n=_instanceNames.size();i<n;i++)
2090 {
2091 SCMOInstance addme(
2092 _instanceNames[i],
2093 _defNamespace,
2094 _defNamespaceLen);
2095 _scmoInstances.append(addme);
2096 }
2097 _instanceNames.clear();
2098 break;
|
2099 r.kieninger 1.1 }
|
2100 thilo.boehm 1.3 case RESP_INSTANCE:
|
2101 r.kieninger 1.2 {
|
2102 thilo.boehm 1.3 if (_instances.size() > 0)
2103 {
2104 SCMOInstance addme(
2105 _instances[0],
2106 _defNamespace,
2107 _defNamespaceLen);
2108 _scmoInstances.clear();
2109 _scmoInstances.append(addme);
2110 _instances.clear();
2111 }
2112 break;
|
2113 r.kieninger 1.2 }
|
2114 thilo.boehm 1.3 case RESP_INSTANCES:
|
2115 r.kieninger 1.1 {
|
2116 thilo.boehm 1.3 for (Uint32 i=0,n=_instances.size();i<n;i++)
|
2117 r.kieninger 1.1 {
|
2118 thilo.boehm 1.3 SCMOInstance addme(
2119 _instances[i],
2120 _defNamespace,
2121 _defNamespaceLen);
2122 _scmoInstances.append(addme);
|
2123 r.kieninger 1.1 }
|
2124 thilo.boehm 1.3 _instances.clear();
2125 break;
2126 }
2127 case RESP_OBJECTS:
2128 {
2129 for (Uint32 i=0,n=_objects.size();i<n;i++)
|
2130 r.kieninger 1.1 {
|
2131 thilo.boehm 1.3 SCMOInstance addme(
2132 _objects[i],
2133 _defNamespace,
2134 _defNamespaceLen);
2135 _scmoInstances.append(addme);
|
2136 r.kieninger 1.1 }
|
2137 thilo.boehm 1.3 _objects.clear();
2138 break;
2139 }
2140 case RESP_OBJECTPATHS:
2141 {
2142 for (Uint32 i=0,n=_instanceNames.size();i<n;i++)
|
2143 r.kieninger 1.1 {
|
2144 thilo.boehm 1.3 SCMOInstance addme(
2145 _instanceNames[i],
2146 _defNamespace,
2147 _defNamespaceLen);
|
2148 karl 1.5.2.7 if (_isClassOperation)
|
2149 thilo.boehm 1.3 {
2150 addme.setIsClassOnly(true);
2151 }
2152 _scmoInstances.append(addme);
|
2153 r.kieninger 1.1 }
|
2154 thilo.boehm 1.3 _instanceNames.clear();
2155 break;
|
2156 r.kieninger 1.1 }
|
2157 thilo.boehm 1.3 default:
|
2158 r.kieninger 1.1 {
|
2159 karl 1.5.2.16 PEGASUS_DEBUG_ASSERT(false);
|
2160 r.kieninger 1.1 }
2161 }
2162
|
2163 thilo.boehm 1.3 // remove CIM Encoding flag
2164 _encoding &=(~RESP_ENC_CIM);
2165 // add SCMO Encoding flag
2166 _encoding |=RESP_ENC_SCMO;
|
2167 karl 1.5.2.11
2168 PEG_METHOD_EXIT();
|
2169 r.kieninger 1.1 }
2170
|
2171 karl 1.5.2.1 /**
2172 * Validate the magic object for this CIMResponseData. This
2173 * compiles only in debug mode and can be use to validate the
2174 * CIMResponseData object
2175 *
2176 * @return Boolean True if valid object.
2177 */
|
2178 karl 1.5.2.10 Boolean CIMResponseData::valid() const
|
2179 karl 1.5.2.1 {
2180 return _magic;
2181 }
2182
|
2183 karl 1.5.2.3 void CIMResponseData::setRequestProperties(
2184 const Boolean includeQualifiers,
2185 const Boolean includeClassOrigin,
2186 const CIMPropertyList& propertyList)
2187 {
2188 _includeQualifiers = includeQualifiers;
2189 _includeClassOrigin = includeClassOrigin;
|
2190 karl 1.5.2.7 _propertyList = propertyList;
2191 }
2192
2193 void CIMResponseData::setIsClassOperation(Boolean b)
2194 {
2195 _isClassOperation = b;
|
2196 karl 1.5.2.3 }
2197
|
2198 karl 1.5.2.26 // Clear all of the input encodings by clearing their arrays and
2199 // unsetting the encoding flag.
2200 void CIMResponseData::clear()
2201 {
2202 // Clear the xml data area
2203 _referencesData.clear();
2204 _hostsData.clear();
2205 _nameSpacesData.clear();
2206 _instanceData.clear();
2207
2208 // Clear the binary data area
2209 _binaryData.clear();
2210
2211 // Clear the SCMO data
2212 _scmoInstances.clear();
2213
2214 //Clear the C++ Data areaa
2215 _instanceNames.clear();
2216 _instances.clear();
2217 _objects.clear();
2218
2219 karl 1.5.2.26 _encoding = 0;
2220 _size = 0;
2221 }
2222
|
2223 karl 1.5.2.28 // The following are debugging support only
|
2224 karl 1.5.2.30 //// FUTURE: Make this conditional compile
|
2225 karl 1.5.2.28 void CIMResponseData::traceResponseData() const
|
2226 karl 1.5.2.12 {
2227 PEG_TRACE((TRC_XML, Tracer::LEVEL3,
|
2228 karl 1.5.2.21 "%s", (const char*)toStringTraceResponseData().getCString() ));
2229 }
|
2230 karl 1.5.2.28
2231 String CIMResponseData::toStringTraceResponseData() const
|
2232 karl 1.5.2.21 {
|
2233 karl 1.5.2.29 String rtnStr;
2234 rtnStr.appendPrintf(
|
2235 karl 1.5.2.12 "CIMResponseData::traceResponseData(encoding=%X,dataType=%X "
|
2236 karl 1.5.2.13 " size=%u C++instNamecount=%u c++Instances=%u c++Objects=%u "
2237 "scomInstances=%u XMLInstData=%u binaryData=%u "
2238 "xmlref=%u xmlinst=%u, xmlhost=%u xmlns=%u",
|
2239 karl 1.5.2.12 _encoding,_dataType, _size,
2240 _instanceNames.size(),_instances.size(), _objects.size(),
2241 _scmoInstances.size(),_instanceData.size(),_binaryData.size(),
2242 _referencesData.size(), _instanceData.size(), _hostsData.size(),
|
2243 karl 1.5.2.21 _nameSpacesData.size());
2244
2245 return(rtnStr);
|
2246 karl 1.5.2.12 }
|
2247 karl 1.5.2.30
|
2248 karl 1.5.2.12
|
2249 karl 1.5.2.21
|
2250 r.kieninger 1.1 PEGASUS_NAMESPACE_END
|