1 karl 1.13 //%2006////////////////////////////////////////////////////////////////////////
|
2 schuur 1.1 //
|
3 karl 1.2 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 schuur 1.1 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.2 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.5 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.13 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 schuur 1.1 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 venkat.puvvada 1.21 //
|
21 schuur 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 #include "OperationResponseHandler.h"
|
35 a.dunfey 1.15 #include "CIMOMHandleContext.h"
|
36 chip 1.7
|
37 marek 1.25 #include <Pegasus/Common/Tracer.h>
|
38 dave.sudlik 1.24 #include <Pegasus/Common/SharedPtr.h>
|
39 a.dunfey 1.15 #include <Pegasus/Provider/CIMOMHandle.h>
|
40 chip 1.7
|
41 schuur 1.1 PEGASUS_NAMESPACE_BEGIN
42
|
43 chip 1.7 //
44 // OperationResponseHandler
45 //
46
47 OperationResponseHandler::OperationResponseHandler(
|
48 kumpf 1.23 CIMRequestMessage* request,
49 CIMResponseMessage* response,
|
50 kumpf 1.14 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
|
51 chip 1.7 : _request(request),
52 _response(response),
|
53 kumpf 1.14 _responseChunkCallback(responseChunkCallback),
|
54 chip 1.8 _responseObjectTotal(0),
|
55 chip 1.7 _responseMessageTotal(0),
|
56 kumpf 1.14 _responseObjectThreshold(0)
|
57 brian.campbell 1.3 {
58 #ifndef PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD
|
59 kumpf 1.23 # define PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD 100
|
60 brian.campbell 1.3 #elif PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD == 0
|
61 kumpf 1.23 # undef PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD
62 # define PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD ~0
|
63 brian.campbell 1.3 #endif
64
|
65 kumpf 1.14 if (!request)
|
66 a.dunfey 1.4 {
67 _responseObjectThreshold = ~0;
68 }
|
69 kumpf 1.23 else
|
70 a.dunfey 1.4 {
71 _responseObjectThreshold = PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD;
|
72 brian.campbell 1.3
73 #ifdef PEGASUS_DEBUG
|
74 kumpf 1.23 static const char* responseObjectThreshold =
75 getenv("PEGASUS_RESPONSE_OBJECT_COUNT_THRESHOLD");
|
76 chip 1.7
77 if (responseObjectThreshold)
|
78 kumpf 1.23 {
79 Uint32 i = (Uint32)atoi(responseObjectThreshold);
|
80 chip 1.7
81 if (i > 0)
82 {
83 _responseObjectThreshold = i;
84 }
|
85 kumpf 1.23 }
|
86 brian.campbell 1.3 #endif
|
87 a.dunfey 1.4 }
|
88 brian.campbell 1.3 }
89
90 OperationResponseHandler::~OperationResponseHandler()
91 {
|
92 kumpf 1.23 _request = 0;
93 _response = 0;
|
94 brian.campbell 1.3 }
95
|
96 kumpf 1.23 CIMRequestMessage* OperationResponseHandler::getRequest() const
|
97 chip 1.7 {
|
98 kumpf 1.23 return _request;
|
99 chip 1.7 }
100
|
101 kumpf 1.23 CIMResponseMessage* OperationResponseHandler::getResponse() const
|
102 chip 1.7 {
|
103 kumpf 1.23 return _response;
|
104 chip 1.7 }
105
106 void OperationResponseHandler::setStatus(
107 const Uint32 code,
|
108 kumpf 1.23 const String& message)
|
109 chip 1.7 {
|
110 kumpf 1.23 _response->cimException =
111 PEGASUS_CIM_EXCEPTION(CIMStatusCode(code), message);
|
112 chip 1.7 }
113
114 void OperationResponseHandler::setStatus(
115 const Uint32 code,
|
116 kumpf 1.23 const ContentLanguageList& langs,
117 const String& message)
|
118 chip 1.7 {
119 _response->cimException =
120 PEGASUS_CIM_EXCEPTION_LANG(
121 langs,
122 CIMStatusCode(code),
123 message);
124 }
125
|
126 mike 1.22 void OperationResponseHandler::setCIMException(
127 const CIMException& cimException)
128 {
129 // Assign the cimException argument to _response->cimException. Note that
130 // there is no need to use the PEGASUS_CIM_EXCEPTION_LANG() macro to create
131 // a TraceableCIMException since both _response->cimException and
132 // cimException are of type CIMException and the TraceableCIMException
133 // constructor has no side effects.
134 _response->cimException = cimException;
135 }
136
|
137 kumpf 1.23 Boolean OperationResponseHandler::isAsync() const
|
138 chip 1.7 {
|
139 kumpf 1.17 return _responseChunkCallback != 0;
|
140 chip 1.7 }
141
|
142 brian.campbell 1.3 // This is only called from SimpleResponseHandler.deliver() but lives in this
143 // class because all asyncronous response must have a "response" pointer
144 // to go through. Only operation classes have a response pointer
145 void OperationResponseHandler::send(Boolean isComplete)
146 {
|
147 kumpf 1.20 // It is possible to instantiate this class directly (not a derived
148 // class, which would also inherit from SimpleResponseHandler).
149 // The caller would do this only if the operation does not have any
150 // data to be returned.
151
152 SimpleResponseHandler* simpleP =
153 dynamic_cast<SimpleResponseHandler*>(this);
154 if (simpleP == 0)
155 {
156 // if there is no data to be returned, then the message should NEVER be
157 // incomplete (even on an error)
158 PEGASUS_ASSERT(isComplete);
|
159 chip 1.7 return;
|
160 kumpf 1.20 }
|
161 kumpf 1.19
|
162 kumpf 1.20 // some handlers do not send async because their callers cannot handle
163 // partial responses. If this is the case, stop here.
|
164 brian.campbell 1.3
|
165 kumpf 1.20 if (!isAsync())
166 {
167 // preserve traditional behavior
168 if (isComplete)
|
169 chip 1.7 {
|
170 kumpf 1.20 if (_response != 0)
171 {
172 _response->operationContext.set(
173 ContentLanguageListContainer(simpleP->getLanguages()));
174 }
175 transfer();
|
176 chip 1.7 }
177
178 return;
|
179 kumpf 1.20 }
|
180 brian.campbell 1.3
|
181 kumpf 1.23 SimpleResponseHandler& simple = *simpleP;
182 PEGASUS_ASSERT(_response);
183 Uint32 objectCount = simple.size();
|
184 brian.campbell 1.3
|
185 kumpf 1.23 // have not reached threshold yet
186 if ((isComplete == false) && (objectCount < _responseObjectThreshold))
|
187 chip 1.7 {
188 return;
189 }
|
190 brian.campbell 1.3
|
191 kumpf 1.23 CIMResponseMessage* response = _response;
|
192 brian.campbell 1.3
|
193 kumpf 1.23 // for complete responses, just use the one handed down from caller
194 // otherwise, create our own that the caller never sees but is
195 // utilized for async responses underneath
|
196 brian.campbell 1.3
|
197 kumpf 1.23 if (isComplete == false)
|
198 chip 1.7 {
199 _response = _request->buildResponse();
200 }
|
201 brian.campbell 1.3
|
202 kumpf 1.23 _response->setComplete(isComplete);
203 _responseObjectTotal += objectCount;
|
204 brian.campbell 1.3
|
205 kumpf 1.23 // since we are reusing response for every chunk, keep track of original
206 // count
207 _response->setIndex(_responseMessageTotal++);
208
209 // set the originally allocated response to one more than the current.
210 // The reason for doing this is proactive in case of an exception. This
211 // allows the last response to be set as it may not re-enter this code.
|
212 brian.campbell 1.3
|
213 kumpf 1.23 if (isComplete == false)
|
214 chip 1.7 {
215 response->setIndex(_responseMessageTotal);
216 }
|
217 brian.campbell 1.3
|
218 kumpf 1.23 validate();
|
219 brian.campbell 1.3
|
220 kumpf 1.23 if (_response->cimException.getCode() != CIM_ERR_SUCCESS)
|
221 chip 1.7 {
222 simple.clear();
223 }
224
|
225 marek 1.25 PEG_TRACE((
226 TRC_PROVIDERMANAGER,
227 Tracer::LEVEL4,
228 "%s::transfer",
229 (const char*) getClass().getCString()));
|
230 chip 1.7
|
231 kumpf 1.23 transfer();
232 simple.clear();
|
233 brian.campbell 1.3
|
234 kumpf 1.23 _response->operationContext.set(
235 ContentLanguageListContainer(simple.getLanguages()));
|
236 brian.campbell 1.3
|
237 kumpf 1.23 // call thru ProviderManager to get externally declared entry point
|
238 brian.campbell 1.3
|
239 kumpf 1.23 if (isComplete == false)
240 {
241 _responseChunkCallback(_request, _response);
242 }
|
243 brian.campbell 1.3
|
244 kumpf 1.23 // put caller's allocated response back in place. Note that _response
245 // is INVALID after sending because it has been deleted externally
|
246 brian.campbell 1.3
|
247 kumpf 1.23 _response = response;
|
248 brian.campbell 1.3 }
249
|
250 kumpf 1.23 void OperationResponseHandler::transfer()
|
251 chip 1.7 {
252 }
253
|
254 kumpf 1.23 void OperationResponseHandler::validate()
|
255 chip 1.7 {
256 }
257
|
258 kumpf 1.23 String OperationResponseHandler::getClass() const
|
259 chip 1.7 {
|
260 kumpf 1.23 return String("OperationResponseHandler");
|
261 chip 1.7 }
262
|
263 kumpf 1.23 Uint32 OperationResponseHandler::getResponseObjectTotal() const
|
264 chip 1.7 {
|
265 kumpf 1.23 return _responseObjectTotal;
|
266 chip 1.7 }
267
|
268 kumpf 1.23 Uint32 OperationResponseHandler::getResponseMessageTotal() const
|
269 chip 1.7 {
|
270 kumpf 1.23 return _responseMessageTotal;
|
271 chip 1.7 }
272
|
273 kumpf 1.23 Uint32 OperationResponseHandler::getResponseObjectThreshold() const
|
274 chip 1.7 {
|
275 kumpf 1.23 return _responseObjectThreshold;
|
276 chip 1.7 }
277
278 //
279 // GetInstanceResponseHandler
280 //
281
282 GetInstanceResponseHandler::GetInstanceResponseHandler(
|
283 kumpf 1.14 CIMGetInstanceRequestMessage* request,
284 CIMGetInstanceResponseMessage* response,
285 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
286 : OperationResponseHandler(request, response, responseChunkCallback)
|
287 chip 1.7 {
|
288 kumpf 1.23 #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
289 // Attempt to get the cached class definition used to validate results of
290 // this operation. If it does not exist, then this feature is disabled
291 // for this operation.
|
292 chip 1.7 CIMClass cimClass;
293
|
294 kumpf 1.23 if (request->operationContext.contains(
295 CachedClassDefinitionContainer::NAME))
|
296 chip 1.7 {
297 CachedClassDefinitionContainer container =
|
298 a.dunfey 1.16 request->operationContext.get(
299 CachedClassDefinitionContainer::NAME);
|
300 chip 1.7
301 cimClass = container.getClass();
302 }
303
|
304 dave.sudlik 1.24 SharedPtr<NormalizerContext> tmpContext(new CIMOMHandleContext());
|
305 a.dunfey 1.15 ObjectNormalizer tmpNormalizer(
306 cimClass,
307 request->includeQualifiers,
308 request->includeClassOrigin,
309 request->nameSpace,
310 tmpContext);
311 _normalizer = tmpNormalizer;
|
312 kumpf 1.23 #endif
|
313 chip 1.7 }
314
|
315 kumpf 1.23 void GetInstanceResponseHandler::deliver(const CIMInstance& cimInstance)
|
316 chip 1.7 {
|
317 kumpf 1.23 if (cimInstance.isUninitialized())
|
318 chip 1.7 {
319 MessageLoaderParms message(
320 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
321 "The object is not initialized.");
322
323 throw CIMException(CIM_ERR_FAILED, message);
324 }
325
|
326 kumpf 1.23 if (SimpleInstanceResponseHandler::size() != 0)
|
327 chip 1.9 {
328 MessageLoaderParms message(
329 "Server.OperationResponseHandler.TOO_MANY_OBJECTS_DELIVERED",
330 "Too many objects delivered.");
331
332 throw CIMException(CIM_ERR_FAILED, message);
333 }
334
|
335 kumpf 1.23 #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
|
336 chip 1.7 // The normalizer expects an object path embedded in instances even
337 // though it is not required by this operation. Use the requested
338 // object path is missing from the instance.
339 CIMInstance localInstance(cimInstance);
340
|
341 kumpf 1.23 if (localInstance.getPath().getKeyBindings().size() == 0)
|
342 chip 1.7 {
343 // ATTN: should clone before modification
|
344 kumpf 1.23 localInstance.setPath(static_cast<CIMGetInstanceRequestMessage*>(
345 getRequest())->instanceName);
|
346 chip 1.7 }
347
|
348 kumpf 1.23 SimpleInstanceResponseHandler::deliver(
349 _normalizer.processInstance(localInstance));
350 #else
|
351 chip 1.7 SimpleInstanceResponseHandler::deliver(cimInstance);
|
352 kumpf 1.23 #endif
|
353 chip 1.7 }
354
|
355 kumpf 1.23 void GetInstanceResponseHandler::complete()
|
356 chip 1.9 {
|
357 kumpf 1.23 if (SimpleInstanceResponseHandler::size() == 0)
|
358 chip 1.9 {
359 MessageLoaderParms message(
360 "Server.OperationResponseHandler.TOO_FEW_OBJECTS_DELIVERED",
361 "Too few objects delivered.");
|
362 venkat.puvvada 1.21 // Provider claims success, no instances returned. -V see Bug #4104
363 setStatus(CIM_ERR_NOT_FOUND);
|
364 chip 1.9 throw CIMException(CIM_ERR_FAILED, message);
365 }
366
367 SimpleInstanceResponseHandler::complete();
368 }
369
|
370 kumpf 1.23 String GetInstanceResponseHandler::getClass() const
|
371 chip 1.7 {
|
372 kumpf 1.23 return String("GetInstanceResponseHandler");
|
373 chip 1.7 }
374
|
375 kumpf 1.23 void GetInstanceResponseHandler::transfer()
|
376 chip 1.7 {
|
377 kumpf 1.23 if (size() > 0)
|
378 chip 1.7 {
|
379 kumpf 1.23 CIMGetInstanceResponseMessage& msg =
380 *static_cast<CIMGetInstanceResponseMessage*>(getResponse());
|
381 chip 1.7
382 msg.cimInstance = getObjects()[0];
383 }
384 }
385
|
386 kumpf 1.23 void GetInstanceResponseHandler::validate()
|
387 chip 1.7 {
|
388 kumpf 1.23 if (getResponseObjectTotal() == 0)
|
389 chip 1.7 {
390 // error? provider claims success,
391 // but did not deliver an instance.
392 setStatus(CIM_ERR_NOT_FOUND);
393 }
394 }
395
396 //
397 // EnumerateInstancesResponseHandler
398 //
399
400 EnumerateInstancesResponseHandler::EnumerateInstancesResponseHandler(
|
401 kumpf 1.14 CIMEnumerateInstancesRequestMessage* request,
402 CIMEnumerateInstancesResponseMessage* response,
403 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
404 : OperationResponseHandler(request, response, responseChunkCallback)
|
405 chip 1.7 {
|
406 kumpf 1.23 #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
407 // Attempt to get the cached class definition used to validate results of
408 // this operation. If it does not exist, then this feature is disabled
409 // for this operation.
|
410 chip 1.7 CIMClass cimClass;
411
|
412 kumpf 1.23 if (request->operationContext.contains(
413 CachedClassDefinitionContainer::NAME))
|
414 chip 1.7 {
415 CachedClassDefinitionContainer container =
|
416 a.dunfey 1.16 request->operationContext.get(
417 CachedClassDefinitionContainer::NAME);
|
418 chip 1.7 cimClass = container.getClass();
419 }
420
|
421 dave.sudlik 1.24 SharedPtr<NormalizerContext> tmpContext(new CIMOMHandleContext());
|
422 a.dunfey 1.15 ObjectNormalizer tmpNormalizer(
423 cimClass,
424 request->includeQualifiers,
425 request->includeClassOrigin,
426 request->nameSpace,
427 tmpContext);
428 _normalizer = tmpNormalizer;
429 #endif
|
430 chip 1.7 }
431
|
432 kumpf 1.23 void EnumerateInstancesResponseHandler::deliver(const CIMInstance& cimInstance)
|
433 chip 1.7 {
|
434 kumpf 1.23 if (cimInstance.isUninitialized())
|
435 chip 1.7 {
436 MessageLoaderParms message(
437 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
438 "The object is not initialized.");
439
440 throw CIMException(CIM_ERR_FAILED, message);
441 }
442
|
443 kumpf 1.23 #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
444 SimpleInstanceResponseHandler::deliver(
445 _normalizer.processInstance(cimInstance));
446 #else
|
447 chip 1.7 SimpleInstanceResponseHandler::deliver(cimInstance);
|
448 kumpf 1.23 #endif
|
449 chip 1.7 }
450
|
451 kumpf 1.23 String EnumerateInstancesResponseHandler::getClass() const
|
452 chip 1.7 {
|
453 kumpf 1.23 return String("EnumerateInstancesResponseHandler");
|
454 chip 1.7 }
455
|
456 kumpf 1.23 void EnumerateInstancesResponseHandler::transfer()
|
457 chip 1.7 {
|
458 kumpf 1.23 CIMEnumerateInstancesResponseMessage& msg =
459 *static_cast<CIMEnumerateInstancesResponseMessage*>(getResponse());
|
460 chip 1.7
461 msg.cimNamedInstances = getObjects();
462 }
463
464 //
465 // EnumerateInstanceNamesResponseHandler
466 //
467
468 EnumerateInstanceNamesResponseHandler::EnumerateInstanceNamesResponseHandler(
|
469 kumpf 1.14 CIMEnumerateInstanceNamesRequestMessage* request,
470 CIMEnumerateInstanceNamesResponseMessage* response,
471 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
472 : OperationResponseHandler(request, response, responseChunkCallback)
|
473 chip 1.7 {
|
474 kumpf 1.23 #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
475 // Attempt to get the cached class definition used to validate results of
476 // this operation. If it does not exist, then this feature is disabled
477 // for this operation.
|
478 chip 1.7 CIMClass cimClass;
479
|
480 kumpf 1.23 if (request->operationContext.contains(
481 CachedClassDefinitionContainer::NAME))
|
482 chip 1.7 {
483 CachedClassDefinitionContainer container =
|
484 a.dunfey 1.16 request->operationContext.get(
485 CachedClassDefinitionContainer::NAME);
|
486 chip 1.7
487 cimClass = container.getClass();
488 }
489
|
490 dave.sudlik 1.24 SharedPtr<NormalizerContext> tmpContext(new CIMOMHandleContext());
|
491 a.dunfey 1.15 ObjectNormalizer tmpNormalizer(
492 cimClass,
493 false,
494 false,
495 request->nameSpace,
496 tmpContext);
497 _normalizer = tmpNormalizer;
498 #endif
|
499 chip 1.7 }
500
|
501 kumpf 1.23 void EnumerateInstanceNamesResponseHandler::deliver(
502 const CIMObjectPath& cimObjectPath)
|
503 chip 1.7 {
|
504 kumpf 1.23 if (cimObjectPath.getClassName().isNull())
|
505 chip 1.7 {
506 MessageLoaderParms message(
507 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
508 "The object is not initialized.");
509
510 throw CIMException(CIM_ERR_FAILED, message);
511 }
512
|
513 kumpf 1.23 #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
514 SimpleObjectPathResponseHandler::deliver(
515 _normalizer.processInstanceObjectPath(cimObjectPath));
516 #else
|
517 chip 1.7 SimpleObjectPathResponseHandler::deliver(cimObjectPath);
|
518 kumpf 1.23 #endif
|
519 chip 1.7 }
520
|
521 kumpf 1.23 String EnumerateInstanceNamesResponseHandler::getClass() const
|
522 chip 1.7 {
|
523 kumpf 1.23 return String("EnumerateInstanceNamesResponseHandler");
|
524 chip 1.7 }
525
|
526 kumpf 1.23 void EnumerateInstanceNamesResponseHandler::transfer()
|
527 chip 1.7 {
|
528 kumpf 1.23 CIMEnumerateInstanceNamesResponseMessage& msg =
529 *static_cast<CIMEnumerateInstanceNamesResponseMessage*>(getResponse());
|
530 chip 1.7
531 msg.instanceNames = getObjects();
532 }
533
534 //
535 // CreateInstanceResponseHandler
536 //
537
538 CreateInstanceResponseHandler::CreateInstanceResponseHandler(
|
539 kumpf 1.14 CIMCreateInstanceRequestMessage* request,
540 CIMCreateInstanceResponseMessage* response,
541 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
542 : OperationResponseHandler(request, response, responseChunkCallback)
|
543 chip 1.7 {
544 }
545
|
546 kumpf 1.23 void CreateInstanceResponseHandler::deliver(const CIMObjectPath& cimObjectPath)
|
547 chip 1.7 {
|
548 kumpf 1.23 if (cimObjectPath.getClassName().isNull())
|
549 chip 1.7 {
550 MessageLoaderParms message(
551 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
552 "The object is not initialized.");
553
554 throw CIMException(CIM_ERR_FAILED, message);
555 }
556
|
557 kumpf 1.23 if (SimpleObjectPathResponseHandler::size() != 0)
|
558 chip 1.11 {
559 MessageLoaderParms message(
560 "Server.OperationResponseHandler.TOO_MANY_OBJECTS_DELIVERED",
561 "Too many objects delivered.");
562
563 throw CIMException(CIM_ERR_FAILED, message);
564 }
565
|
566 chip 1.7 SimpleObjectPathResponseHandler::deliver(cimObjectPath);
567 }
568
|
569 kumpf 1.23 void CreateInstanceResponseHandler::complete()
|
570 chip 1.9 {
|
571 kumpf 1.23 if (SimpleObjectPathResponseHandler::size() == 0)
|
572 chip 1.9 {
573 MessageLoaderParms message(
574 "Server.OperationResponseHandler.TOO_FEW_OBJECTS_DELIVERED",
575 "Too few objects delivered.");
576
577 throw CIMException(CIM_ERR_FAILED, message);
578 }
579
580 SimpleObjectPathResponseHandler::complete();
581 }
582
|
583 kumpf 1.23 String CreateInstanceResponseHandler::getClass() const
|
584 chip 1.7 {
|
585 kumpf 1.23 return String("CreateInstanceResponseHandler");
|
586 chip 1.7 }
587
588 #if 0
589 // ATTN: is it an error to not return instance name?
|
590 kumpf 1.23 void CreateInstanceResponseHandler::validate()
|
591 chip 1.7 {
|
592 kumpf 1.23 if (getResponseObjectTotal() == 0)
|
593 chip 1.7 {
594 setStatus(CIM_ERR_NOT_FOUND);
595 }
596 }
597 #endif
598
|
599 kumpf 1.23 void CreateInstanceResponseHandler::transfer()
|
600 chip 1.7 {
|
601 kumpf 1.23 if (size() > 0)
|
602 chip 1.7 {
|
603 kumpf 1.23 CIMCreateInstanceResponseMessage& msg =
604 *static_cast<CIMCreateInstanceResponseMessage*>(getResponse());
|
605 chip 1.7
606 msg.instanceName = getObjects()[0];
607 }
608 }
609
610 //
611 // ModifyInstanceResponseHandler
612 //
613
614 ModifyInstanceResponseHandler::ModifyInstanceResponseHandler(
|
615 kumpf 1.14 CIMModifyInstanceRequestMessage* request,
616 CIMModifyInstanceResponseMessage* response,
617 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
618 : OperationResponseHandler(request, response, responseChunkCallback)
|
619 chip 1.7 {
620 }
621
|
622 kumpf 1.23 String ModifyInstanceResponseHandler::getClass() const
|
623 chip 1.7 {
|
624 kumpf 1.23 return String("ModifyInstanceResponseHandler");
|
625 chip 1.7 }
626
627 //
628 // DeleteInstanceResponseHandler
629 //
630
631 DeleteInstanceResponseHandler::DeleteInstanceResponseHandler(
|
632 kumpf 1.14 CIMDeleteInstanceRequestMessage* request,
633 CIMDeleteInstanceResponseMessage* response,
634 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
635 : OperationResponseHandler(request, response, responseChunkCallback)
|
636 chip 1.7 {
637 }
638
|
639 kumpf 1.23 String DeleteInstanceResponseHandler::getClass() const
|
640 chip 1.7 {
|
641 kumpf 1.23 return String("DeleteInstanceResponseHandler");
|
642 chip 1.7 }
643
644 //
645 // GetPropertyResponseHandler
646 //
647
648 GetPropertyResponseHandler::GetPropertyResponseHandler(
|
649 kumpf 1.14 CIMGetPropertyRequestMessage* request,
650 CIMGetPropertyResponseMessage* response,
651 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
652 : OperationResponseHandler(request, response, responseChunkCallback)
|
653 chip 1.7 {
654 }
655
|
656 kumpf 1.23 void GetPropertyResponseHandler::deliver(const CIMValue& cimValue)
|
657 chip 1.7 {
|
658 kumpf 1.23 if (cimValue.isNull())
|
659 chip 1.7 {
660 MessageLoaderParms message(
661 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
662 "The object is not initialized.");
663
664 throw CIMException(CIM_ERR_FAILED, message);
665 }
666
667 SimpleValueResponseHandler::deliver(cimValue);
668 }
669
|
670 kumpf 1.23 String GetPropertyResponseHandler::getClass() const
|
671 chip 1.7 {
|
672 kumpf 1.23 return String("GetPropertyResponseHandler");
|
673 chip 1.7 }
674
|
675 kumpf 1.23 void GetPropertyResponseHandler::transfer()
|
676 chip 1.7 {
|
677 kumpf 1.23 if (size() > 0)
|
678 chip 1.7 {
|
679 kumpf 1.23 CIMGetPropertyResponseMessage& msg =
680 *static_cast<CIMGetPropertyResponseMessage*>(getResponse());
|
681 chip 1.7
682 msg.value = getObjects()[0];
683 }
684 }
685
|
686 kumpf 1.23 void GetPropertyResponseHandler::validate()
|
687 chip 1.7 {
688 // error? provider claims success,
689 // but did not deliver an instance.
|
690 kumpf 1.23 if (getResponseObjectTotal() == 0)
|
691 chip 1.7 {
692 setStatus(CIM_ERR_NOT_FOUND);
693 }
694 }
695
696 //
697 // SetPropertyResponseHandler
698 //
699
700 SetPropertyResponseHandler::SetPropertyResponseHandler(
|
701 kumpf 1.14 CIMSetPropertyRequestMessage* request,
702 CIMSetPropertyResponseMessage* response,
703 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
704 : OperationResponseHandler(request, response, responseChunkCallback)
|
705 chip 1.7 {
706 }
707
|
708 kumpf 1.23 String SetPropertyResponseHandler::getClass() const
|
709 chip 1.7 {
|
710 kumpf 1.23 return String("SetPropertyResponseHandler");
|
711 chip 1.7 }
712
713 //
714 // ExecQueryResponseHandler
715 //
716
717 ExecQueryResponseHandler::ExecQueryResponseHandler(
|
718 kumpf 1.14 CIMExecQueryRequestMessage* request,
719 CIMExecQueryResponseMessage* response,
720 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
721 : OperationResponseHandler(request, response, responseChunkCallback)
|
722 chip 1.7 {
723 }
724
|
725 kumpf 1.23 void ExecQueryResponseHandler::deliver(const CIMInstance& cimInstance)
|
726 chip 1.7 {
|
727 kumpf 1.23 if (cimInstance.isUninitialized())
|
728 chip 1.7 {
729 MessageLoaderParms message(
730 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
731 "The object is not initialized.");
732
733 throw CIMException(CIM_ERR_FAILED, message);
734 }
735
736 SimpleInstance2ObjectResponseHandler::deliver(cimInstance);
737 }
738
|
739 kumpf 1.23 String ExecQueryResponseHandler::getClass() const
|
740 chip 1.7 {
|
741 kumpf 1.23 return String("ExecQueryResponseHandler");
|
742 chip 1.7 }
743
|
744 kumpf 1.23 void ExecQueryResponseHandler::transfer()
|
745 chip 1.7 {
|
746 kumpf 1.23 CIMExecQueryResponseMessage& msg =
747 *static_cast<CIMExecQueryResponseMessage*>(getResponse());
|
748 chip 1.7
749 msg.cimObjects = getObjects();
750 }
751
|
752 kumpf 1.23 Boolean ExecQueryResponseHandler::isAsync() const
|
753 chip 1.7 {
|
754 kumpf 1.23 return false;
|
755 chip 1.7 }
756
757 //
758 // AssociatorsResponseHandler
759 //
760
761 AssociatorsResponseHandler::AssociatorsResponseHandler(
|
762 kumpf 1.14 CIMAssociatorsRequestMessage* request,
763 CIMAssociatorsResponseMessage* response,
764 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
765 : OperationResponseHandler(request, response, responseChunkCallback)
|
766 chip 1.7 {
767 }
768
|
769 kumpf 1.23 void AssociatorsResponseHandler::deliver(const CIMObject& cimObject)
|
770 chip 1.7 {
|
771 kumpf 1.23 if (cimObject.isUninitialized())
|
772 chip 1.7 {
773 MessageLoaderParms message(
774 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
775 "The object is not initialized.");
776
777 throw CIMException(CIM_ERR_FAILED, message);
778 }
779
780 SimpleObjectResponseHandler::deliver(cimObject);
781 }
782
|
783 kumpf 1.23 String AssociatorsResponseHandler::getClass() const
|
784 chip 1.7 {
|
785 kumpf 1.23 return String("AssociatorsResponseHandler");
|
786 chip 1.7 }
787
|
788 kumpf 1.23 void AssociatorsResponseHandler::transfer()
|
789 chip 1.7 {
|
790 kumpf 1.23 CIMAssociatorsResponseMessage& msg =
791 *static_cast<CIMAssociatorsResponseMessage*>(getResponse());
|
792 chip 1.7
793 msg.cimObjects = getObjects();
794 }
795
796 //
797 // AssociatorNamesResponseHandler
798 //
799
800 AssociatorNamesResponseHandler::AssociatorNamesResponseHandler(
|
801 kumpf 1.14 CIMAssociatorNamesRequestMessage* request,
802 CIMAssociatorNamesResponseMessage* response,
803 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
804 : OperationResponseHandler(request, response, responseChunkCallback)
|
805 chip 1.7 {
806 }
807
|
808 kumpf 1.23 void AssociatorNamesResponseHandler::deliver(const CIMObjectPath& cimObjectPath)
|
809 chip 1.7 {
|
810 kumpf 1.23 if (cimObjectPath.getClassName().isNull())
|
811 chip 1.7 {
812 MessageLoaderParms message(
813 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
814 "The object is not initialized.");
815
816 throw CIMException(CIM_ERR_FAILED, message);
817 }
818
819 SimpleObjectPathResponseHandler::deliver(cimObjectPath);
820 }
821
|
822 kumpf 1.23 String AssociatorNamesResponseHandler::getClass() const
|
823 chip 1.7 {
|
824 kumpf 1.23 return String("AssociatorNamesResponseHandler");
|
825 chip 1.7 }
826
|
827 kumpf 1.23 void AssociatorNamesResponseHandler::transfer()
|
828 chip 1.7 {
|
829 kumpf 1.23 CIMAssociatorNamesResponseMessage& msg =
830 *static_cast<CIMAssociatorNamesResponseMessage*>(getResponse());
|
831 chip 1.7
832 msg.objectNames = getObjects();
833 }
834
835 //
836 // ReferencesResponseHandler
837 //
838
839 ReferencesResponseHandler::ReferencesResponseHandler(
|
840 kumpf 1.14 CIMReferencesRequestMessage* request,
841 CIMReferencesResponseMessage* response,
842 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
843 : OperationResponseHandler(request, response, responseChunkCallback)
|
844 chip 1.7 {
845 }
846
|
847 kumpf 1.23 void ReferencesResponseHandler::deliver(const CIMObject& cimObject)
|
848 chip 1.7 {
|
849 kumpf 1.23 if (cimObject.isUninitialized())
|
850 chip 1.7 {
851 MessageLoaderParms message(
852 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
853 "The object is not initialized.");
854
855 throw CIMException(CIM_ERR_FAILED, message);
856 }
857
858 SimpleObjectResponseHandler::deliver(cimObject);
859 }
860
|
861 kumpf 1.23 String ReferencesResponseHandler::getClass() const
|
862 chip 1.7 {
|
863 kumpf 1.23 return String("ReferencesResponseHandler");
|
864 chip 1.7 }
865
|
866 kumpf 1.23 void ReferencesResponseHandler::transfer()
|
867 chip 1.7 {
|
868 kumpf 1.23 CIMReferencesResponseMessage& msg =
869 *static_cast<CIMReferencesResponseMessage*>(getResponse());
|
870 chip 1.7
871 msg.cimObjects = getObjects();
872 }
873
874 //
875 // ReferenceNamesResponseHandler
876 //
877
878 ReferenceNamesResponseHandler::ReferenceNamesResponseHandler(
|
879 kumpf 1.14 CIMReferenceNamesRequestMessage* request,
880 CIMReferenceNamesResponseMessage* response,
881 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
882 : OperationResponseHandler(request, response, responseChunkCallback)
|
883 chip 1.7 {
884 }
885
|
886 kumpf 1.23 void ReferenceNamesResponseHandler::deliver(const CIMObjectPath& cimObjectPath)
|
887 chip 1.7 {
|
888 kumpf 1.23 if (cimObjectPath.getClassName().isNull())
|
889 chip 1.7 {
890 MessageLoaderParms message(
891 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
892 "The object is not initialized.");
893
894 throw CIMException(CIM_ERR_FAILED, message);
895 }
896
897 SimpleObjectPathResponseHandler::deliver(cimObjectPath);
898 }
899
|
900 kumpf 1.23 String ReferenceNamesResponseHandler::getClass() const
|
901 chip 1.7 {
|
902 kumpf 1.23 return String("ReferenceNamesResponseHandler");
|
903 chip 1.7 }
904
|
905 kumpf 1.23 void ReferenceNamesResponseHandler::transfer()
|
906 chip 1.7 {
|
907 kumpf 1.23 CIMReferenceNamesResponseMessage& msg =
908 *static_cast<CIMReferenceNamesResponseMessage*>(getResponse());
|
909 chip 1.7
910 msg.objectNames = getObjects();
911 }
912
913 //
914 // InvokeMethodResponseHandler
915 //
916
917 InvokeMethodResponseHandler::InvokeMethodResponseHandler(
|
918 kumpf 1.14 CIMInvokeMethodRequestMessage* request,
919 CIMInvokeMethodResponseMessage* response,
920 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
921 : OperationResponseHandler(request, response, responseChunkCallback)
|
922 chip 1.7 {
923 }
924
|
925 kumpf 1.23 void InvokeMethodResponseHandler::deliverParamValue(
926 const CIMParamValue& cimParamValue)
|
927 chip 1.7 {
|
928 kumpf 1.23 if (cimParamValue.isUninitialized())
|
929 chip 1.7 {
930 MessageLoaderParms message(
931 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
932 "The object is not initialized.");
933
934 throw CIMException(CIM_ERR_FAILED, message);
935 }
936
937 SimpleMethodResultResponseHandler::deliverParamValue(cimParamValue);
938 }
939
|
940 kumpf 1.23 void InvokeMethodResponseHandler::deliver(const CIMValue& cimValue)
|
941 chip 1.7 {
|
942 kumpf 1.23 if (cimValue.isNull())
|
943 chip 1.7 {
944 MessageLoaderParms message(
945 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
946 "The object is not initialized.");
947
948 throw CIMException(CIM_ERR_FAILED, message);
949 }
950
951 SimpleMethodResultResponseHandler::deliver(cimValue);
952 }
953
|
954 kumpf 1.23 String InvokeMethodResponseHandler::getClass() const
|
955 chip 1.7 {
|
956 kumpf 1.23 return String("InvokeMethodResponseHandler");
|
957 chip 1.7 }
958
|
959 kumpf 1.23 void InvokeMethodResponseHandler::transfer()
|
960 chip 1.7 {
|
961 kumpf 1.23 CIMInvokeMethodResponseMessage& msg =
962 *static_cast<CIMInvokeMethodResponseMessage*>(getResponse());
|
963 chip 1.7
964 msg.outParameters = getParamValues();
965
966 // ATTN-RK-20020903: Is it legal for the return value to be null?
967 // if not, then the check must be done here since deliver() works off the
968 // virtual size, which refers to out parameters!
969 msg.retValue = getReturnValue();
970 }
971
972 //
973 // EnableIndicationsResponseHandler
974 //
975
976 EnableIndicationsResponseHandler::EnableIndicationsResponseHandler(
|
977 kumpf 1.14 CIMRequestMessage* request,
978 CIMResponseMessage* response,
|
979 kumpf 1.17 const CIMInstance& provider,
|
980 kumpf 1.14 PEGASUS_INDICATION_CALLBACK_T indicationCallback,
981 PEGASUS_RESPONSE_CHUNK_CALLBACK_T responseChunkCallback)
982 : OperationResponseHandler(request, response, responseChunkCallback),
983 _indicationCallback(indicationCallback)
|
984 chip 1.7 {
985 _provider = provider;
986 }
987
|
988 kumpf 1.23 void EnableIndicationsResponseHandler::deliver(
989 const CIMIndication& cimIndication)
|
990 chip 1.7 {
991 OperationContext context;
992
993 Array<CIMObjectPath> subscriptionInstanceNames;
994
|
995 kumpf 1.23 context.insert(
996 SubscriptionInstanceNamesContainer(subscriptionInstanceNames));
|
997 chip 1.7
998 deliver(context, cimIndication);
999 }
1000
|
1001 kumpf 1.23 void EnableIndicationsResponseHandler::deliver(
1002 const OperationContext& context,
1003 const CIMIndication& cimIndication)
|
1004 chip 1.7 {
|
1005 kumpf 1.23 if (cimIndication.isUninitialized())
|
1006 chip 1.7 {
1007 MessageLoaderParms message(
1008 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
1009 "The object is not initialized.");
1010
1011 throw CIMException(CIM_ERR_FAILED, message);
1012 }
1013
1014 // ATTN: temporarily convert indication to instance
1015 CIMInstance cimInstance(cimIndication);
1016
1017 // Get list of subscription instance names from context
1018 Array<CIMObjectPath> subscriptionInstanceNames;
1019
|
1020 kumpf 1.23 if (context.contains(SubscriptionInstanceNamesContainer::NAME))
|
1021 chip 1.7 {
1022 SubscriptionInstanceNamesContainer container =
1023 context.get(SubscriptionInstanceNamesContainer::NAME);
1024
1025 subscriptionInstanceNames = container.getInstanceNames();
1026 }
|
1027 a.dunfey 1.16 else
|
1028 chip 1.7 {
1029 subscriptionInstanceNames.clear();
1030 }
1031
|
1032 kumpf 1.12 ContentLanguageList contentLangs;
|
1033 chip 1.7
|
1034 kumpf 1.23 if (context.contains(ContentLanguageListContainer::NAME))
|
1035 chip 1.7 {
1036 // Get the Content-Language for this indication. The provider
1037 // does not have to add specify a language for the indication.
1038 ContentLanguageListContainer langContainer =
1039 context.get(ContentLanguageListContainer::NAME);
1040
1041 contentLangs = langContainer.getLanguages();
1042 }
|
1043 a.dunfey 1.16 else
|
1044 chip 1.7 {
1045 // The provider did not explicitly set a Content-Language for
1046 // the indication. Fall back to the lang set in this object.
1047 contentLangs = getLanguages();
1048 }
1049
1050 // create message
|
1051 kumpf 1.23 CIMProcessIndicationRequestMessage* request =
|
1052 chip 1.7 new CIMProcessIndicationRequestMessage(
1053 XmlWriter::getNextMessageId(),
1054 cimInstance.getPath().getNameSpace(),
1055 cimInstance,
1056 subscriptionInstanceNames,
1057 _provider,
1058 QueueIdStack()); // Must be filled in by the callback function
1059
1060 request->operationContext = context;
1061
|
1062 kumpf 1.23 if (request->operationContext.contains(ContentLanguageListContainer::NAME))
|
1063 chip 1.7 {
|
1064 kumpf 1.23 request->operationContext.set(
1065 ContentLanguageListContainer(contentLangs));
|
1066 chip 1.7 }
|
1067 a.dunfey 1.16 else
|
1068 chip 1.7 {
|
1069 kumpf 1.23 request->operationContext.insert(
1070 ContentLanguageListContainer(contentLangs));
|
1071 chip 1.7 }
1072
1073 _indicationCallback(request);
1074 }
1075
|
1076 kumpf 1.23 void EnableIndicationsResponseHandler::deliver(
1077 const Array<CIMIndication>& cimIndications)
|
1078 chip 1.7 {
1079 OperationContext context;
1080
1081 deliver(context, cimIndications);
1082 }
1083
|
1084 kumpf 1.23 void EnableIndicationsResponseHandler::deliver(
1085 const OperationContext& context,
1086 const Array<CIMIndication>& cimIndications)
|
1087 chip 1.7 {
|
1088 kumpf 1.23 for (Uint32 i = 0, n = cimIndications.size(); i < n; i++)
|
1089 chip 1.7 {
1090 deliver(context, cimIndications[i]);
1091 }
1092 }
1093
|
1094 kumpf 1.23 String EnableIndicationsResponseHandler::getClass() const
|
1095 chip 1.7 {
|
1096 kumpf 1.23 return String("EnableIndicationsResponseHandler");
|
1097 chip 1.7 }
1098
|
1099 kumpf 1.23 Boolean EnableIndicationsResponseHandler::isAsync() const
|
1100 chip 1.7 {
|
1101 kumpf 1.23 return false;
|
1102 chip 1.7 }
1103
|
1104 schuur 1.1 PEGASUS_NAMESPACE_END
|