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