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