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