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