(file) Return to OperationResponseHandler.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2