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