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