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