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