(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                             try
173                             {
174                                 CachedClassDefinitionContainer container =
175                                     request->operationContext.get(CachedClassDefinitionContainer::NAME);
176                     
177                                 CIMClass cimClass = container.getClass();
178                     
179                                 _normalizer =
180                                     ObjectNormalizer(
181                                         cimClass,
182                                         request->localOnly,
183                                         request->includeQualifiers,
184                                         request->includeClassOrigin);
185                             }
186                             catch(Exception &)
187                             {
188                                 // Do nothing. Container is missing, which implies normalization is disabled
189 chip           1.14             // for this operation.
190                             }
191                             #endif
192                         }
193                     
194                         /*
195                         #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
196                         virtual void deliver(const CIMInstance & cimInstance)
197                         {
198                             // Normalize (if seeded, otherwise do nothing) and pass to subclass method for delivery.
199                             SimpleInstanceResponseHandler::deliver(_normalizer.processInstance(cimInstance));
200 chip           1.11     }
201 chip           1.14     #endif
202                         */
203 schuur         1.1  
204 chip           1.11     virtual String getClass(void) const
205                         {
206                             return(String("GetInstanceResponseHandler"));
207                         }
208                     
209                         virtual void transfer(void)
210                         {
211                             if(size() > 0)
212                             {
213                                 CIMGetInstanceResponseMessage & msg =
214                                     *static_cast<CIMGetInstanceResponseMessage *>(getResponse());
215                     
216                                 msg.cimInstance = getObjects()[0];
217                             }
218                         }
219                     
220                         virtual void validate(void)
221                         {
222                             if(getResponseObjectTotal() == 0)
223                             {
224                                 // error? provider claims success,
225 chip           1.11             // but did not deliver an instance.
226                                 setStatus(CIM_ERR_NOT_FOUND);
227                             }
228                         }
229 chip           1.14 
230                     private:
231                         ObjectNormalizer _normalizer;
232                     
233 schuur         1.1  };
234                     
235                     class EnumerateInstancesResponseHandler : public OperationResponseHandler, public SimpleInstanceResponseHandler
236                     {
237                     public:
238 chip           1.11     EnumerateInstancesResponseHandler(
239                             CIMEnumerateInstancesRequestMessage * request,
240                             CIMEnumerateInstancesResponseMessage * response)
241                         : OperationResponseHandler(request, response)
242                         {
243 chip           1.14         #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
244                             // Attempt to get the cached class definition used to validate results of this
245                             // operation. If it does not exist, then this feature is disabled for this
246                             // operation.
247                             try
248                             {
249                                 CachedClassDefinitionContainer container =
250                                     request->operationContext.get(CachedClassDefinitionContainer::NAME);
251                     
252                                 CIMClass cimClass = container.getClass();
253                     
254                                 _normalizer =
255                                     ObjectNormalizer(
256                                         cimClass,
257                                         request->localOnly,
258                                         request->includeQualifiers,
259                                         request->includeClassOrigin);
260                             }
261                             catch(Exception &)
262                             {
263                                 // Do nothing. Container is missing, which implies normalization is disabled
264 chip           1.14             // for this operation.
265                             }
266                             #endif
267                         }
268                     
269                         /*
270                         #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
271                         virtual void deliver(const CIMInstance & cimInstance)
272                         {
273                             // Normalize (if seeded, otherwise do nothing) and pass to subclass method for delivery.
274                             SimpleInstanceResponseHandler::deliver(_normalizer.processInstance(cimInstance));
275 chip           1.11     }
276 chip           1.14     #endif
277                         */
278 schuur         1.1  
279 chip           1.11     virtual String getClass(void) const
280                         {
281                             return(String("EnumerateInstancesResponseHandler"));
282                         }
283                     
284                         virtual void transfer(void)
285                         {
286                             CIMEnumerateInstancesResponseMessage & msg =
287                                 *static_cast<CIMEnumerateInstancesResponseMessage *>(getResponse());
288                     
289                             msg.cimNamedInstances = getObjects();
290                         }
291 chip           1.14 
292                     private:
293                         ObjectNormalizer _normalizer;
294                     
295 schuur         1.1  };
296                     
297                     class EnumerateInstanceNamesResponseHandler : public OperationResponseHandler, public SimpleObjectPathResponseHandler
298                     {
299                     public:
300 chip           1.11     EnumerateInstanceNamesResponseHandler(
301                             CIMEnumerateInstanceNamesRequestMessage * request,
302                             CIMEnumerateInstanceNamesResponseMessage * response)
303                         : OperationResponseHandler(request, response)
304                         {
305 chip           1.14         #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
306                             // Attempt to get the cached class definition used to validate results of this
307                             // operation. If it does not exist, then this feature is disabled for this
308                             // operation.
309                             try
310                             {
311                                 CachedClassDefinitionContainer container =
312                                     request->operationContext.get(CachedClassDefinitionContainer::NAME);
313                     
314                                 CIMClass cimClass = container.getClass();
315                     
316                                 _normalizer =
317                                     ObjectNormalizer(
318                                         cimClass,
319                                         false,
320                                         false,
321                                         false);
322                             }
323                             catch(Exception &)
324                             {
325                                 // Do nothing. Container is missing, which implies normalization is disabled
326 chip           1.14             // for this operation.
327                             }
328                             #endif
329                         }
330                     
331                         /*
332                         #ifdef PEGASUS_ENABLE_OBJECT_NORMALIZATION
333                         virtual void deliver(const CIMObjectPath & cimObjectPath)
334                         {
335                             // Normalize (if seeded, otherwise do nothing) and pass to subclass method for delivery.
336                             SimpleObjectPathResponseHandler::deliver(_normalizer.processInstanceObjectPath(cimObjectPath));
337 chip           1.11     }
338 chip           1.14     #endif
339                         */
340 chip           1.11 
341                         virtual String getClass(void) const
342                         {
343                             return(String("EnumerateInstanceNamesResponseHandler"));
344                         }
345                     
346                         virtual void transfer(void)
347                         {
348                             CIMEnumerateInstanceNamesResponseMessage & msg =
349                                 *static_cast<CIMEnumerateInstanceNamesResponseMessage *>(getResponse());
350                     
351                             msg.instanceNames = getObjects();
352                         }
353 chip           1.14 
354                     private:
355                         ObjectNormalizer _normalizer;
356                     
357 schuur         1.1  };
358                     
359                     class CreateInstanceResponseHandler : public OperationResponseHandler, public SimpleObjectPathResponseHandler
360                     {
361                     public:
362 chip           1.11     CreateInstanceResponseHandler(
363                             CIMCreateInstanceRequestMessage * request,
364                             CIMCreateInstanceResponseMessage * response)
365                         : OperationResponseHandler(request, response)
366                         {
367                         }
368                     
369                         virtual String getClass(void) const
370                         {
371                             return(String("CreateInstanceResponseHandler"));
372                         }
373                     
374 brian.campbell 1.9  #if 0
375 chip           1.11     // ATTN: is it an error to not return instance name?
376                         virtual void validate(void)
377                         {
378                             if(getResponseObjectTotal() == 0)
379                             {
380                                 setStatus(CIM_ERR_NOT_FOUND);
381                             }
382                         }
383 brian.campbell 1.9  #endif
384 schuur         1.1  
385 chip           1.11     virtual void transfer(void)
386                         {
387                             if(size() > 0)
388                             {
389                                 CIMCreateInstanceResponseMessage & msg =
390                                     *static_cast<CIMCreateInstanceResponseMessage *>(getResponse());
391                     
392                                 msg.instanceName = getObjects()[0];
393                             }
394                         }
395 schuur         1.1  };
396                     
397                     class ModifyInstanceResponseHandler : public OperationResponseHandler, public SimpleResponseHandler
398                     {
399                     public:
400 chip           1.11     ModifyInstanceResponseHandler(
401                             CIMModifyInstanceRequestMessage * request,
402                             CIMModifyInstanceResponseMessage * response)
403                         : OperationResponseHandler(request, response)
404                         {
405                         }
406                     
407                         virtual String getClass(void) const
408                         {
409                             return(String("ModifyInstanceResponseHandler"));
410                         }
411                     
412 schuur         1.1  };
413                     
414                     class DeleteInstanceResponseHandler : public OperationResponseHandler, public SimpleResponseHandler
415                     {
416                     public:
417 chip           1.11     DeleteInstanceResponseHandler(
418                             CIMDeleteInstanceRequestMessage * request,
419                             CIMDeleteInstanceResponseMessage * response)
420                         : OperationResponseHandler(request, response)
421                         {
422                         }
423                     
424                         virtual String getClass(void) const
425                         {
426                             return(String("DeleteInstanceResponseHandler"));
427                         }
428                     
429 schuur         1.1  };
430                     
431                     class GetPropertyResponseHandler : public OperationResponseHandler, public SimpleValueResponseHandler
432                     {
433                     public:
434 chip           1.11     GetPropertyResponseHandler(
435                             CIMGetPropertyRequestMessage * request,
436                             CIMGetPropertyResponseMessage * response)
437                         : OperationResponseHandler(request, response)
438                         {
439                         }
440                     
441                         virtual String getClass(void) const
442                         {
443                             return(String("GetPropertyResponseHandler"));
444                         }
445 schuur         1.1  
446 chip           1.11     virtual void transfer(void)
447                         {
448                             if(size() > 0)
449                             {
450                                 CIMGetPropertyResponseMessage & msg =
451                                     *static_cast<CIMGetPropertyResponseMessage *>(getResponse());
452                     
453                                 msg.value = getObjects()[0];
454                             }
455                         }
456                     
457                         virtual void validate(void)
458                         {
459                             // error? provider claims success,
460                             // but did not deliver an instance.
461                             if(getResponseObjectTotal() == 0)
462                             {
463                                 setStatus(CIM_ERR_NOT_FOUND);
464                             }
465                         }
466 schuur         1.1  };
467                     
468                     class SetPropertyResponseHandler : public OperationResponseHandler, public SimpleResponseHandler
469                     {
470                     public:
471 chip           1.11     SetPropertyResponseHandler(
472                             CIMSetPropertyRequestMessage * request,
473                             CIMSetPropertyResponseMessage * response)
474                         : OperationResponseHandler(request, response)
475                         {
476                         }
477                     
478                         virtual String getClass(void) const
479                         {
480                             return(String("SetPropertyResponseHandler"));
481                         }
482                     
483 schuur         1.1  };
484                     
485                     class ExecQueryResponseHandler : public OperationResponseHandler, public SimpleInstance2ObjectResponseHandler
486                     {
487                     public:
488 chip           1.11     ExecQueryResponseHandler(
489                             CIMExecQueryRequestMessage * request,
490                             CIMExecQueryResponseMessage * response)
491                         : OperationResponseHandler(request, response)
492                         {
493                         }
494 schuur         1.1  
495 chip           1.11     virtual String getClass(void) const
496                         {
497                             return(String("ExecQueryResponseHandler"));
498                         }
499 schuur         1.1  
500 chip           1.11     virtual void transfer(void)
501                         {
502                             CIMExecQueryResponseMessage & msg =
503                                 *static_cast<CIMExecQueryResponseMessage *>(getResponse());
504                     
505                             msg.cimObjects = getObjects();
506                         }
507                     
508                         // this handler will not send async
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                         // this handler will not send async
664                         virtual Boolean isAsync(void) const
665                         {
666 chip           1.11         return(false);
667                         }
668                     
669                         virtual void deliver(const CIMIndication & cimIndication)
670                         {
671                             OperationContext context;
672                     
673                             Array<CIMObjectPath> subscriptionInstanceNames;
674                     
675                             context.insert(SubscriptionInstanceNamesContainer(subscriptionInstanceNames));
676                     
677                             deliver(context, cimIndication);
678                         }
679                     
680                         virtual void deliver(const OperationContext & context, const CIMIndication & cimIndication)
681                         {
682                             // ATTN: temporarily convert indication to instance
683                             CIMInstance cimInstance(cimIndication);
684                     
685                             //  Get list of subscription instance names from context
686                             Array<CIMObjectPath> subscriptionInstanceNames;
687 chip           1.11 
688                             try
689                             {
690                                 SubscriptionInstanceNamesContainer container =
691                                     context.get(SubscriptionInstanceNamesContainer::NAME);
692                     
693                                 subscriptionInstanceNames = container.getInstanceNames();
694                             }
695                             catch(Exception &)
696                             {
697                                 subscriptionInstanceNames.clear();
698                             }
699                     
700                             // l10n
701                             ContentLanguages contentLangs;
702                     
703                             try
704                             {
705                                 // Get the Content-Language for this indication.  The provider
706                                 // does not have to add specify a language for the indication.
707                                 ContentLanguageListContainer langContainer =
708 chip           1.11                 context.get(ContentLanguageListContainer::NAME);
709                     
710                                 contentLangs = langContainer.getLanguages();
711                             }
712                             catch(Exception &)
713                             {
714                                 // The provider did not explicitly set a Content-Language for
715                                 // the indication.  Fall back to the lang set in this object.
716                                 contentLangs = getLanguages();
717                             }
718                             // l10n -end
719                     
720                             // create message
721                             // l10n
722                             CIMProcessIndicationRequestMessage * request =
723                                 new CIMProcessIndicationRequestMessage(
724                                 XmlWriter::getNextMessageId(),
725                                 cimInstance.getPath().getNameSpace(),
726                                 cimInstance,
727                                 subscriptionInstanceNames,
728                                 _provider,
729 chip           1.11             QueueIdStack());  // Must be filled in by the callback function
730                     
731                             request->operationContext = context;
732                     
733                             try
734                             {
735                                 request->operationContext.set(ContentLanguageListContainer(contentLangs));
736                             }
737                             catch(Exception &)
738                             {
739                                 request->operationContext.insert(ContentLanguageListContainer(contentLangs));
740                             }
741                     
742                             _indicationCallback(request);
743                         }
744                     
745                         virtual void deliver(const Array<CIMIndication> & cimIndications)
746                         {
747                             OperationContext context;
748                     
749                             deliver(context, cimIndications);
750 chip           1.11     }
751                     
752                         virtual void deliver(const OperationContext & context, const Array<CIMIndication> & cimIndications)
753                         {
754                             for(Uint32 i = 0, n = cimIndications.size(); i < n; i++)
755                             {
756                                 deliver(context, cimIndications[i]);
757                             }
758                         }
759 brian.campbell 1.9  
760                     private:
761 chip           1.11     CIMEnableIndicationsRequestMessage _request_copy;
762                         CIMEnableIndicationsResponseMessage _response_copy;
763                         PEGASUS_INDICATION_CALLBACK _indicationCallback;
764 schuur         1.1  
765 brian.campbell 1.9  };
766 schuur         1.1  
767                     PEGASUS_NAMESPACE_END
768                     
769                     #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2