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