1 karl 1.17 //%2005////////////////////////////////////////////////////////////////////////
|
2 schuur 1.1 //
|
3 karl 1.8 // 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.8 // 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.17 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 schuur 1.1 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
|
18 chip 1.18 //
|
19 schuur 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Author: Chip Vincent (cvincent@us.ibm.com)
31 //
|
32 chip 1.11 // Modified By:
33 // Carol Ann Krug Graves, Hewlett-Packard Company (carolann_graves@hp.com)
34 // Dave Rosckes (rosckes@us.ibm.com)
35 // Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
36 // Adrian Schuur (schuur@de.ibm.com)
37 // Seema Gupta (gseema@in.ibm.com) for PEP135
38 // Brian G. Campbell, EMC (campbell_brian@emc.com) - PEP140/phase2
|
39 schuur 1.1 //
40 //%/////////////////////////////////////////////////////////////////////////////
41
42 #ifndef Pegasus_OperationResponseHandler_h
43 #define Pegasus_OperationResponseHandler_h
44
45 #include <Pegasus/Common/Config.h>
46 #include <Pegasus/Server/Linkage.h>
47 #include <Pegasus/Common/CIMMessage.h>
48 #include <Pegasus/Common/MessageQueueService.h>
49 #include <Pegasus/Common/Constants.h>
50 #include <Pegasus/Common/ContentLanguages.h> // l10n
51
52 #include <Pegasus/Common/CIMClass.h>
53 #include <Pegasus/Common/CIMInstance.h>
54 #include <Pegasus/Common/CIMIndication.h>
55 #include <Pegasus/Common/CIMValue.h>
56
|
57 chip 1.14 #include <Pegasus/Common/OperationContext.h>
58 #include <Pegasus/Common/OperationContextInternal.h>
59
60 #include <Pegasus/Common/ObjectNormalizer.h>
|
61 schuur 1.1 #include <Pegasus/Common/ResponseHandler.h>
62 #include <Pegasus/Common/Logger.h>
|
63 kumpf 1.6 #include <Pegasus/Common/XmlWriter.h>
|
64 schuur 1.1
65 #include <Pegasus/ProviderManager2/SimpleResponseHandler.h>
66 #include <Pegasus/ProviderManager2/Linkage.h>
67
68 PEGASUS_NAMESPACE_BEGIN
69
70 class PEGASUS_PPM_LINKAGE OperationResponseHandler
71 {
|
72 chip 1.11 friend class SimpleResponseHandler;
|
73 brian.campbell 1.9
|
74 schuur 1.1 public:
|
75 chip 1.11 OperationResponseHandler(
76 CIMRequestMessage * request,
77 CIMResponseMessage * response);
|
78 schuur 1.1
|
79 brian.campbell 1.9 virtual ~OperationResponseHandler(void);
|
80 chip 1.11
|
81 schuur 1.1 CIMRequestMessage * getRequest(void) const
82 {
83 return(_request);
84 }
85
86 CIMResponseMessage * getResponse(void) const
87 {
88 return(_response);
89 }
90
|
91 chip 1.11 virtual void setStatus(
92 const Uint32 code,
93 const String & message = String::EMPTY)
|
94 schuur 1.1 {
95 _response->cimException = PEGASUS_CIM_EXCEPTION(CIMStatusCode(code), message);
96 }
97
|
98 chip 1.11 virtual void setStatus(
99 const Uint32 code,
100 const ContentLanguages & langs,
101 const String & message = String::EMPTY)
102 {
103 _response->cimException =
104 PEGASUS_CIM_EXCEPTION_LANG(
105 langs,
106 CIMStatusCode(code),
107 message);
|
108 schuur 1.1 }
109
110 protected:
|
111 chip 1.11 // the default for all derived handlers. Some handlers may not apply
112 // async behavior because their callers cannot handle partial responses.
113 virtual Boolean isAsync(void) const
114 {
115 return(true);
116 }
|
117 brian.campbell 1.9
|
118 chip 1.11 // send (deliver) asynchronously
119 virtual void send(Boolean isComplete);
|
120 brian.campbell 1.9
|
121 chip 1.11 // transfer any objects from handler to response. this does not clear()
122 virtual void transfer(void)
123 {
124 }
|
125 brian.campbell 1.9
|
126 chip 1.11 // validate whatever is necessary before the transfer
127 virtual void validate(void)
128 {
129 }
|
130 brian.campbell 1.9
|
131 chip 1.11 virtual String getClass(void) const
132 {
133 return(String("OperationResponseHandler"));
134 }
|
135 brian.campbell 1.9
|
136 chip 1.11 Uint32 getResponseObjectTotal(void) const
137 {
138 return(_responseObjectTotal);
139 }
|
140 brian.campbell 1.9
|
141 chip 1.11 // there can be many objects per message (or none at all - i.e complete())
142 Uint32 getResponseMessageTotal(void) const
143 {
144 return(_responseMessageTotal);
145 }
|
146 brian.campbell 1.9
|
147 chip 1.11 Uint32 getResponseObjectThreshold(void) const
148 {
149 return(_responseObjectThreshold);
150 }
|
151 brian.campbell 1.9
|
152 schuur 1.1 CIMRequestMessage * _request;
153 CIMResponseMessage * _response;
154
|
155 brian.campbell 1.9 private:
|
156 chip 1.11 Uint32 _responseObjectTotal;
157 Uint32 _responseMessageTotal;
158 Uint32 _responseObjectThreshold;
159
|
160 schuur 1.1 };
161
|
162 chip 1.11 class GetInstanceResponseHandler : public OperationResponseHandler, public SimpleInstanceResponseHandler
163 {
164 public:
165 GetInstanceResponseHandler(
166 CIMGetInstanceRequestMessage * request,
167 CIMGetInstanceResponseMessage * response)
168 : OperationResponseHandler(request, response)
169 {
|
170 chip 1.14 #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
171 // Attempt to get the cached class definition used to validate results of this
172 // operation. If it does not exist, then this feature is disabled for this
173 // operation.
|
174 chip 1.15 CIMClass cimClass;
175
|
176 chip 1.14 try
177 {
178 CachedClassDefinitionContainer container =
179 request->operationContext.get(CachedClassDefinitionContainer::NAME);
180
|
181 chip 1.15 cimClass = container.getClass();
|
182 chip 1.14
183 }
184 catch(Exception &)
185 {
186 // Do nothing. Container is missing, which implies normalization is disabled
187 // for this operation.
188 }
|
189 chip 1.15
190 _normalizer =
191 ObjectNormalizer(
192 cimClass,
193 request->includeQualifiers,
194 request->includeClassOrigin);
|
195 chip 1.14 #endif
196 }
197
198 virtual void deliver(const CIMInstance & cimInstance)
199 {
|
200 chip 1.21 if(cimInstance.isUninitialized())
201 {
202 MessageLoaderParms message(
203 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
204 "The object is not initialized.");
205
206 throw CIMException(CIM_ERR_FAILED, message);
207 }
208
209 #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
|
210 chip 1.14 SimpleInstanceResponseHandler::deliver(_normalizer.processInstance(cimInstance));
|
211 chip 1.21 #else
212 SimpleInstanceResponseHandler::deliver(cimInstance);
213 #endif
|
214 chip 1.11 }
|
215 schuur 1.1
|
216 chip 1.18 protected:
|
217 chip 1.11 virtual String getClass(void) const
218 {
219 return(String("GetInstanceResponseHandler"));
220 }
221
222 virtual void transfer(void)
223 {
224 if(size() > 0)
225 {
226 CIMGetInstanceResponseMessage & msg =
227 *static_cast<CIMGetInstanceResponseMessage *>(getResponse());
228
229 msg.cimInstance = getObjects()[0];
230 }
231 }
232
233 virtual void validate(void)
234 {
235 if(getResponseObjectTotal() == 0)
236 {
237 // error? provider claims success,
238 chip 1.11 // but did not deliver an instance.
239 setStatus(CIM_ERR_NOT_FOUND);
240 }
241 }
|
242 chip 1.14
243 private:
244 ObjectNormalizer _normalizer;
245
|
246 schuur 1.1 };
247
248 class EnumerateInstancesResponseHandler : public OperationResponseHandler, public SimpleInstanceResponseHandler
249 {
250 public:
|
251 chip 1.11 EnumerateInstancesResponseHandler(
252 CIMEnumerateInstancesRequestMessage * request,
253 CIMEnumerateInstancesResponseMessage * response)
254 : OperationResponseHandler(request, response)
255 {
|
256 chip 1.14 #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
257 // Attempt to get the cached class definition used to validate results of this
258 // operation. If it does not exist, then this feature is disabled for this
259 // operation.
|
260 chip 1.15 CIMClass cimClass;
261
|
262 chip 1.14 try
263 {
264 CachedClassDefinitionContainer container =
265 request->operationContext.get(CachedClassDefinitionContainer::NAME);
266
|
267 chip 1.15 cimClass = container.getClass();
|
268 chip 1.14 }
269 catch(Exception &)
270 {
271 // Do nothing. Container is missing, which implies normalization is disabled
272 // for this operation.
273 }
|
274 chip 1.15
275 _normalizer =
276 ObjectNormalizer(
277 cimClass,
278 request->includeQualifiers,
279 request->includeClassOrigin);
|
280 chip 1.14 #endif
281 }
282
283 virtual void deliver(const CIMInstance & cimInstance)
284 {
|
285 chip 1.21 if(cimInstance.isUninitialized())
286 {
287 MessageLoaderParms message(
288 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
289 "The object is not initialized.");
290
291 throw CIMException(CIM_ERR_FAILED, message);
292 }
293
294 #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
|
295 chip 1.14 SimpleInstanceResponseHandler::deliver(_normalizer.processInstance(cimInstance));
|
296 chip 1.21 #else
297 SimpleInstanceResponseHandler::deliver(cimInstance);
298 #endif
|
299 chip 1.11 }
|
300 schuur 1.1
|
301 chip 1.18 protected:
|
302 chip 1.11 virtual String getClass(void) const
303 {
304 return(String("EnumerateInstancesResponseHandler"));
305 }
306
307 virtual void transfer(void)
308 {
309 CIMEnumerateInstancesResponseMessage & msg =
310 *static_cast<CIMEnumerateInstancesResponseMessage *>(getResponse());
311
312 msg.cimNamedInstances = getObjects();
313 }
|
314 chip 1.14
315 private:
316 ObjectNormalizer _normalizer;
317
|
318 schuur 1.1 };
319
320 class EnumerateInstanceNamesResponseHandler : public OperationResponseHandler, public SimpleObjectPathResponseHandler
321 {
322 public:
|
323 chip 1.11 EnumerateInstanceNamesResponseHandler(
324 CIMEnumerateInstanceNamesRequestMessage * request,
325 CIMEnumerateInstanceNamesResponseMessage * response)
326 : OperationResponseHandler(request, response)
327 {
|
328 chip 1.14 #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
329 // Attempt to get the cached class definition used to validate results of this
330 // operation. If it does not exist, then this feature is disabled for this
331 // operation.
|
332 chip 1.15 CIMClass cimClass;
333
|
334 chip 1.14 try
335 {
336 CachedClassDefinitionContainer container =
337 request->operationContext.get(CachedClassDefinitionContainer::NAME);
338
|
339 chip 1.15 cimClass = container.getClass();
|
340 chip 1.14 }
341 catch(Exception &)
342 {
343 // Do nothing. Container is missing, which implies normalization is disabled
344 // for this operation.
345 }
|
346 chip 1.15
347 _normalizer =
348 ObjectNormalizer(
349 cimClass,
350 false,
351 false);
|
352 chip 1.14 #endif
353 }
354
355 virtual void deliver(const CIMObjectPath & cimObjectPath)
356 {
|
357 chip 1.21 if(cimObjectPath.getClassName().isNull())
358 {
359 MessageLoaderParms message(
360 "Common.Exception.UNINITIALIZED_OBJECT_EXCEPTION",
361 "The object is not initialized.");
362
363 throw CIMException(CIM_ERR_FAILED, message);
364 }
365
366 #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
|
367 chip 1.14 SimpleObjectPathResponseHandler::deliver(_normalizer.processInstanceObjectPath(cimObjectPath));
|
368 chip 1.21 #else
369 SimpleObjectPathResponseHandler::deliver(cimObjectPath);
370 #endif
|
371 chip 1.11 }
372
|
373 chip 1.18 protected:
|
374 chip 1.11 virtual String getClass(void) const
375 {
376 return(String("EnumerateInstanceNamesResponseHandler"));
377 }
378
379 virtual void transfer(void)
380 {
381 CIMEnumerateInstanceNamesResponseMessage & msg =
382 *static_cast<CIMEnumerateInstanceNamesResponseMessage *>(getResponse());
383
384 msg.instanceNames = getObjects();
385 }
|
386 chip 1.14
387 private:
388 ObjectNormalizer _normalizer;
389
|
390 schuur 1.1 };
391
392 class CreateInstanceResponseHandler : public OperationResponseHandler, public SimpleObjectPathResponseHandler
393 {
394 public:
|
395 chip 1.11 CreateInstanceResponseHandler(
396 CIMCreateInstanceRequestMessage * request,
397 CIMCreateInstanceResponseMessage * response)
398 : OperationResponseHandler(request, response)
399 {
400 }
401
|
402 chip 1.18 protected:
|
403 chip 1.11 virtual String getClass(void) const
404 {
405 return(String("CreateInstanceResponseHandler"));
406 }
407
|
408 chip 1.18 #if 0
|
409 chip 1.11 // ATTN: is it an error to not return instance name?
410 virtual void validate(void)
411 {
412 if(getResponseObjectTotal() == 0)
413 {
414 setStatus(CIM_ERR_NOT_FOUND);
415 }
416 }
|
417 chip 1.18 #endif
|
418 schuur 1.1
|
419 chip 1.11 virtual void transfer(void)
420 {
421 if(size() > 0)
422 {
423 CIMCreateInstanceResponseMessage & msg =
424 *static_cast<CIMCreateInstanceResponseMessage *>(getResponse());
425
426 msg.instanceName = getObjects()[0];
427 }
428 }
|
429 schuur 1.1 };
430
431 class ModifyInstanceResponseHandler : public OperationResponseHandler, public SimpleResponseHandler
432 {
433 public:
|
434 chip 1.11 ModifyInstanceResponseHandler(
435 CIMModifyInstanceRequestMessage * request,
436 CIMModifyInstanceResponseMessage * response)
437 : OperationResponseHandler(request, response)
438 {
439 }
440
|
441 chip 1.18 protected:
|
442 chip 1.11 virtual String getClass(void) const
443 {
444 return(String("ModifyInstanceResponseHandler"));
445 }
|
446 schuur 1.1 };
447
448 class DeleteInstanceResponseHandler : public OperationResponseHandler, public SimpleResponseHandler
449 {
450 public:
|
451 chip 1.11 DeleteInstanceResponseHandler(
452 CIMDeleteInstanceRequestMessage * request,
453 CIMDeleteInstanceResponseMessage * response)
454 : OperationResponseHandler(request, response)
455 {
456 }
457
|
458 chip 1.18 protected:
|
459 chip 1.11 virtual String getClass(void) const
460 {
461 return(String("DeleteInstanceResponseHandler"));
462 }
463
|
464 schuur 1.1 };
465
466 class GetPropertyResponseHandler : public OperationResponseHandler, public SimpleValueResponseHandler
467 {
468 public:
|
469 chip 1.11 GetPropertyResponseHandler(
470 CIMGetPropertyRequestMessage * request,
471 CIMGetPropertyResponseMessage * response)
472 : OperationResponseHandler(request, response)
473 {
474 }
475
|
476 chip 1.18 protected:
|
477 chip 1.11 virtual String getClass(void) const
478 {
479 return(String("GetPropertyResponseHandler"));
480 }
|
481 schuur 1.1
|
482 chip 1.11 virtual void transfer(void)
483 {
484 if(size() > 0)
485 {
486 CIMGetPropertyResponseMessage & msg =
487 *static_cast<CIMGetPropertyResponseMessage *>(getResponse());
488
489 msg.value = getObjects()[0];
490 }
491 }
492
493 virtual void validate(void)
494 {
495 // error? provider claims success,
496 // but did not deliver an instance.
497 if(getResponseObjectTotal() == 0)
498 {
499 setStatus(CIM_ERR_NOT_FOUND);
500 }
501 }
|
502 schuur 1.1 };
503
504 class SetPropertyResponseHandler : public OperationResponseHandler, public SimpleResponseHandler
505 {
506 public:
|
507 chip 1.11 SetPropertyResponseHandler(
508 CIMSetPropertyRequestMessage * request,
509 CIMSetPropertyResponseMessage * response)
510 : OperationResponseHandler(request, response)
511 {
512 }
513
|
514 chip 1.18 protected:
|
515 chip 1.11 virtual String getClass(void) const
516 {
517 return(String("SetPropertyResponseHandler"));
518 }
519
|
520 schuur 1.1 };
521
522 class ExecQueryResponseHandler : public OperationResponseHandler, public SimpleInstance2ObjectResponseHandler
523 {
524 public:
|
525 chip 1.11 ExecQueryResponseHandler(
526 CIMExecQueryRequestMessage * request,
527 CIMExecQueryResponseMessage * response)
528 : OperationResponseHandler(request, response)
529 {
530 }
|
531 schuur 1.1
|
532 chip 1.18 protected:
|
533 chip 1.11 virtual String getClass(void) const
534 {
535 return(String("ExecQueryResponseHandler"));
536 }
|
537 schuur 1.1
|
538 chip 1.11 virtual void transfer(void)
539 {
540 CIMExecQueryResponseMessage & msg =
541 *static_cast<CIMExecQueryResponseMessage *>(getResponse());
542
543 msg.cimObjects = getObjects();
544 }
545
546 virtual Boolean isAsync(void) const
547 {
548 return(false);
549 }
|
550 schuur 1.1 };
551
552 class AssociatorsResponseHandler : public OperationResponseHandler, public SimpleObjectResponseHandler
553 {
554 public:
|
555 chip 1.11 AssociatorsResponseHandler(
556 CIMAssociatorsRequestMessage * request,
557 CIMAssociatorsResponseMessage * response)
558 : OperationResponseHandler(request, response)
559 {
560 }
561
|
562 chip 1.18 protected:
|
563 chip 1.11 virtual String getClass(void) const
564 {
565 return(String("AssociatorsResponseHandler"));
566 }
|
567 schuur 1.1
|
568 chip 1.11 virtual void transfer(void)
569 {
570 CIMAssociatorsResponseMessage & msg =
571 *static_cast<CIMAssociatorsResponseMessage *>(getResponse());
572
573 msg.cimObjects = getObjects();
574 }
|
575 schuur 1.1 };
576
577 class AssociatorNamesResponseHandler : public OperationResponseHandler, public SimpleObjectPathResponseHandler
578 {
579 public:
|
580 chip 1.11 AssociatorNamesResponseHandler(
581 CIMAssociatorNamesRequestMessage * request,
582 CIMAssociatorNamesResponseMessage * response)
583 : OperationResponseHandler(request, response)
584 {
585 }
586
|
587 chip 1.18 protected:
|
588 chip 1.11 virtual String getClass(void) const
589 {
590 return(String("AssociatorNamesResponseHandler"));
591 }
592
593 virtual void transfer(void)
594 {
595 CIMAssociatorNamesResponseMessage & msg =
596 *static_cast<CIMAssociatorNamesResponseMessage *>(getResponse());
597
598 msg.objectNames = getObjects();
599 }
|
600 schuur 1.1 };
601
602 class ReferencesResponseHandler : public OperationResponseHandler, public SimpleObjectResponseHandler
603 {
604 public:
|
605 chip 1.11 ReferencesResponseHandler(
606 CIMReferencesRequestMessage * request,
607 CIMReferencesResponseMessage * response)
608 : OperationResponseHandler(request, response)
609 {
610 }
611
|
612 chip 1.18 protected:
|
613 chip 1.11 virtual String getClass(void) const
614 {
615 return(String("ReferencesResponseHandler"));
616 }
617
618 virtual void transfer(void)
619 {
620 CIMReferencesResponseMessage & msg =
621 *static_cast<CIMReferencesResponseMessage *>(getResponse());
622
623 msg.cimObjects = getObjects();
624 }
|
625 schuur 1.1 };
626
627 class ReferenceNamesResponseHandler : public OperationResponseHandler, public SimpleObjectPathResponseHandler
628 {
629 public:
|
630 chip 1.11 ReferenceNamesResponseHandler(
631 CIMReferenceNamesRequestMessage * request,
632 CIMReferenceNamesResponseMessage * response)
633 : OperationResponseHandler(request, response)
634 {
635 }
636
|
637 chip 1.18 protected:
|
638 chip 1.11 virtual String getClass(void) const
639 {
640 return(String("ReferenceNamesResponseHandler"));
641 }
642
643 virtual void transfer(void)
644 {
645 CIMReferenceNamesResponseMessage & msg =
646 *static_cast<CIMReferenceNamesResponseMessage *>(getResponse());
647
648 msg.objectNames = getObjects();
649 }
|
650 schuur 1.1 };
651
652 class InvokeMethodResponseHandler : public OperationResponseHandler, public SimpleMethodResultResponseHandler
653 {
654 public:
|
655 chip 1.11 InvokeMethodResponseHandler(
656 CIMInvokeMethodRequestMessage * request,
657 CIMInvokeMethodResponseMessage * response)
658 : OperationResponseHandler(request, response)
659 {
660 }
661
|
662 chip 1.18 protected:
|
663 chip 1.11 virtual String getClass(void) const
664 {
665 return(String("InvokeMethodResponseHandler"));
666 }
667
668 virtual void transfer(void)
669 {
670 CIMInvokeMethodResponseMessage & msg =
671 *static_cast<CIMInvokeMethodResponseMessage *>(getResponse());
|
672 schuur 1.1
|
673 chip 1.11 msg.outParameters = getParamValues();
674
675 // ATTN-RK-20020903: Is it legal for the return value to be null?
676 // if not, then the check must be done here since deliver() works off the
677 // virtual size, which refers to out parameters!
678 msg.retValue = getReturnValue();
679 }
|
680 schuur 1.1 };
681
|
682 brian.campbell 1.9 typedef void (*PEGASUS_INDICATION_CALLBACK)(CIMProcessIndicationRequestMessage*);
|
683 kumpf 1.2
|
684 schuur 1.1 class EnableIndicationsResponseHandler : public OperationResponseHandler, public SimpleIndicationResponseHandler
685 {
686 public:
|
687 chip 1.11 EnableIndicationsResponseHandler(
|
688 carolann.graves 1.19 CIMRequestMessage * request,
689 CIMResponseMessage * response,
|
690 chip 1.11 CIMInstance & provider,
691 PEGASUS_INDICATION_CALLBACK indicationCallback)
692 : OperationResponseHandler(request, response),
693 _indicationCallback(indicationCallback)
694 {
695 _provider = provider;
696 }
697
698 virtual void deliver(const CIMIndication & cimIndication)
699 {
700 OperationContext context;
701
702 Array<CIMObjectPath> subscriptionInstanceNames;
703
704 context.insert(SubscriptionInstanceNamesContainer(subscriptionInstanceNames));
705
706 deliver(context, cimIndication);
707 }
708
709 virtual void deliver(const OperationContext & context, const CIMIndication & cimIndication)
710 {
711 chip 1.11 // ATTN: temporarily convert indication to instance
712 CIMInstance cimInstance(cimIndication);
713
714 // Get list of subscription instance names from context
715 Array<CIMObjectPath> subscriptionInstanceNames;
716
717 try
718 {
719 SubscriptionInstanceNamesContainer container =
720 context.get(SubscriptionInstanceNamesContainer::NAME);
721
722 subscriptionInstanceNames = container.getInstanceNames();
723 }
724 catch(Exception &)
725 {
726 subscriptionInstanceNames.clear();
727 }
728
729 // l10n
730 ContentLanguages contentLangs;
731
732 chip 1.11 try
733 {
734 // Get the Content-Language for this indication. The provider
735 // does not have to add specify a language for the indication.
736 ContentLanguageListContainer langContainer =
737 context.get(ContentLanguageListContainer::NAME);
738
739 contentLangs = langContainer.getLanguages();
740 }
741 catch(Exception &)
742 {
743 // The provider did not explicitly set a Content-Language for
744 // the indication. Fall back to the lang set in this object.
745 contentLangs = getLanguages();
746 }
747 // l10n -end
748
749 // create message
750 // l10n
751 CIMProcessIndicationRequestMessage * request =
752 new CIMProcessIndicationRequestMessage(
753 chip 1.11 XmlWriter::getNextMessageId(),
754 cimInstance.getPath().getNameSpace(),
755 cimInstance,
756 subscriptionInstanceNames,
757 _provider,
758 QueueIdStack()); // Must be filled in by the callback function
759
760 request->operationContext = context;
761
762 try
763 {
764 request->operationContext.set(ContentLanguageListContainer(contentLangs));
765 }
766 catch(Exception &)
767 {
768 request->operationContext.insert(ContentLanguageListContainer(contentLangs));
769 }
770
771 _indicationCallback(request);
772 }
773
774 chip 1.11 virtual void deliver(const Array<CIMIndication> & cimIndications)
775 {
776 OperationContext context;
777
778 deliver(context, cimIndications);
779 }
780
781 virtual void deliver(const OperationContext & context, const Array<CIMIndication> & cimIndications)
782 {
783 for(Uint32 i = 0, n = cimIndications.size(); i < n; i++)
784 {
785 deliver(context, cimIndications[i]);
786 }
787 }
|
788 brian.campbell 1.9
|
789 chip 1.18 protected:
790 virtual String getClass(void) const
791 {
792 return(String("EnableIndicationsResponseHandler"));
793 }
794
795 virtual Boolean isAsync(void) const
796 {
797 return(false);
798 }
799
|
800 brian.campbell 1.9 private:
|
801 chip 1.11 PEGASUS_INDICATION_CALLBACK _indicationCallback;
|
802 schuur 1.1
|
803 brian.campbell 1.9 };
|
804 schuur 1.1
805 PEGASUS_NAMESPACE_END
806
807 #endif
|