1 a.dunfey 1.13.16.1 //%2006////////////////////////////////////////////////////////////////////////
|
2 chip 1.1 //
|
3 karl 1.11 // 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 karl 1.4 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.11 // 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.13 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 a.dunfey 1.13.16.1 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 chip 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 karl 1.4 //
|
21 chip 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: Markus Mueller (sedgewick_de@yahoo.de)
35 // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
36 // Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
37 // Sushma Fernandes, Hewlett-Packard Company
38 // (sushma_fernandes@hp.com)
39 // Mike Day, IBM (mdday@us.ibm.com)
|
40 chip 1.3 // Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
|
41 joyce.j 1.12 // Josephine Eskaline Joyce (jojustin@in.ibm.com) for PEP#101
|
42 chip 1.1 //
43 //%/////////////////////////////////////////////////////////////////////////////
44
45 #include "ProviderFacade.h"
46
47 #include <Pegasus/Common/InternalException.h>
|
48 chip 1.3 #include <Pegasus/Common/MessageLoader.h>
|
49 chip 1.1
|
50 schuur 1.7 #include <Pegasus/ProviderManager2/SimpleResponseHandler.h>
|
51 chip 1.1
52 PEGASUS_NAMESPACE_BEGIN
53
54 class op_counter
55 {
56 public:
57 op_counter(AtomicInt *counter)
58 : _counter(counter)
59 {
60 (*_counter)++;
61 }
62 ~op_counter(void)
63 {
64 (*_counter)--;
65 }
66 private:
67 op_counter(void);
68 AtomicInt *_counter;
69 };
70
71
72 chip 1.1 template<class T>
73 inline T * getInterface(CIMProvider * provider)
74 {
75 T * p = dynamic_cast<T *>(provider);
76
77 if(p == 0)
78 {
79 //l10n
80 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, "Invalid provider interface.");
81 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED, MessageLoaderParms(
82 "ProviderManager.ProviderFacade.INVALID_PROVIDER_INTERFACE",
83 "Invalid provider interface."));
84 }
85
86 return(p);
87 }
88
89 ProviderFacade::ProviderFacade(CIMProvider * provider) : _provider(provider)
90 {
|
91 schuur 1.8 _indications_enabled=false;
|
92 chip 1.1 }
93
94 ProviderFacade::~ProviderFacade(void)
95 {
96 }
97
98 void ProviderFacade::initialize(CIMOMHandle & cimom)
99 {
100 _provider->initialize(cimom);
101 }
102
|
103 kumpf 1.2 #ifdef PEGASUS_PRESERVE_TRYTERMINATE
|
104 chip 1.1 Boolean ProviderFacade::tryTerminate(void)
105 {
106 return(_provider->tryTerminate());
107 }
|
108 kumpf 1.2 #endif
|
109 chip 1.1
110 void ProviderFacade::terminate(void)
111 {
112 _provider->terminate();
113 }
114
115 void ProviderFacade::getInstance(
116 const OperationContext & context,
117 const CIMObjectPath & instanceReference,
118 const Boolean includeQualifiers,
119 const Boolean includeClassOrigin,
120 const CIMPropertyList & propertyList,
121 InstanceResponseHandler & handler)
122 {
123 op_counter ops(&_current_operations);
124
125 CIMInstanceProvider * provider = getInterface<CIMInstanceProvider>(_provider);
126
127 // forward request
128 provider->getInstance(
129 context,
130 chip 1.1 instanceReference,
131 includeQualifiers,
132 includeClassOrigin,
133 propertyList,
134 handler);
135
136 }
137
138 void ProviderFacade::enumerateInstances(
139 const OperationContext & context,
140 const CIMObjectPath & classReference,
141 const Boolean includeQualifiers,
142 const Boolean includeClassOrigin,
143 const CIMPropertyList & propertyList,
144 InstanceResponseHandler & handler)
145 {
146 op_counter ops(&_current_operations);
147 CIMInstanceProvider * provider = getInterface<CIMInstanceProvider>(_provider);
148
149 // forward request
150 provider->enumerateInstances(
151 chip 1.1 context,
152 classReference,
153 includeQualifiers,
154 includeClassOrigin,
155 propertyList,
156 handler);
157
158 // try enumerateInstanceNames and getInstance if not supported
159 }
160
161 void ProviderFacade::enumerateInstanceNames(
162 const OperationContext & context,
163 const CIMObjectPath & classReference,
164 ObjectPathResponseHandler & handler)
165 {
166 op_counter ops(&_current_operations);
167 CIMInstanceProvider * provider = getInterface<CIMInstanceProvider>(_provider);
168
169 // forward request
170 provider->enumerateInstanceNames(
171 context,
172 chip 1.1 classReference,
173 handler);
174
175 // try enumerateInstances if not supported
176 }
177
178 void ProviderFacade::modifyInstance(
179 const OperationContext & context,
180 const CIMObjectPath & instanceReference,
181 const CIMInstance & instanceObject,
182 const Boolean includeQualifiers,
183 const CIMPropertyList & propertyList,
184 ResponseHandler & handler)
185 {
186 op_counter ops(&_current_operations);
187 CIMInstanceProvider * provider = getInterface<CIMInstanceProvider>(_provider);
188
189 // forward request
190 provider->modifyInstance(
191 context,
192 instanceReference,
193 chip 1.1 instanceObject,
194 includeQualifiers,
195 propertyList,
196 handler);
197 }
198
199 void ProviderFacade::createInstance(
200 const OperationContext & context,
201 const CIMObjectPath & instanceReference,
202 const CIMInstance & instanceObject,
203 ObjectPathResponseHandler & handler)
204 {
205 op_counter ops(&_current_operations);
206 CIMInstanceProvider * provider = getInterface<CIMInstanceProvider>(_provider);
207
208 // forward request
209 provider->createInstance(
210 context,
211 instanceReference,
212 instanceObject,
213 handler);
214 chip 1.1 }
215
216 void ProviderFacade::deleteInstance(
217 const OperationContext & context,
218 const CIMObjectPath & instanceReference,
219 ResponseHandler & handler)
220 {
221 op_counter ops(&_current_operations);
222 CIMInstanceProvider * provider = getInterface<CIMInstanceProvider>(_provider);
223
224 // forward request
225 provider->deleteInstance(
226 context,
227 instanceReference,
228 handler);
229 }
230
|
231 schuur 1.5 void ProviderFacade::execQuery(
232 const OperationContext & context,
233 const CIMObjectPath & nameSpaceAndClass,
234 const QueryExpression & query,
235 InstanceResponseHandler & handler)
236 {
237 op_counter ops(&_current_operations);
238 CIMInstanceQueryProvider *provider =
239 getInterface<CIMInstanceQueryProvider>(_provider);
240 // forward request
241 provider->execQuery(
242 context,
243 nameSpaceAndClass,
244 query,
245 handler);
246 }
247
248
|
249 chip 1.1 void ProviderFacade::associators(
250 const OperationContext & context,
251 const CIMObjectPath & objectName,
252 const CIMName & associationClass,
253 const CIMName & resultClass,
254 const String & role,
255 const String & resultRole,
256 const Boolean includeQualifiers,
257 const Boolean includeClassOrigin,
258 const CIMPropertyList & propertyList,
259 ObjectResponseHandler & handler)
260 {
261 op_counter ops(&_current_operations);
262 CIMAssociationProvider * provider = getInterface<CIMAssociationProvider>(_provider);
263
264 // forward request
265 provider->associators(
266 context,
267 objectName,
268 associationClass,
269 resultClass,
270 chip 1.1 role,
271 resultRole,
272 includeQualifiers,
273 includeClassOrigin,
274 propertyList,
275 handler);
276 }
277
278 void ProviderFacade::associatorNames(
279 const OperationContext & context,
280 const CIMObjectPath & objectName,
281 const CIMName & associationClass,
282 const CIMName & resultClass,
283 const String & role,
284 const String & resultRole,
285 ObjectPathResponseHandler & handler)
286 {
287 op_counter ops(&_current_operations);
288 CIMAssociationProvider * provider = getInterface<CIMAssociationProvider>(_provider);
289
290 // forward request
291 chip 1.1 provider->associatorNames(
292 context,
293 objectName,
294 associationClass,
295 resultClass,
296 role,
297 resultRole,
298 handler);
299 }
300
301 void ProviderFacade::references(
302 const OperationContext & context,
303 const CIMObjectPath & objectName,
304 const CIMName & resultClass,
305 const String & role,
306 const Boolean includeQualifiers,
307 const Boolean includeClassOrigin,
308 const CIMPropertyList & propertyList,
309 ObjectResponseHandler & handler)
310 {
311 op_counter ops(&_current_operations);
312 chip 1.1 CIMAssociationProvider * provider = getInterface<CIMAssociationProvider>(_provider);
313
314 // forward request
315 provider->references(
316 context,
317 objectName,
318 resultClass,
319 role,
320 includeQualifiers,
321 includeClassOrigin,
322 propertyList,
323 handler);
324 }
325
326 void ProviderFacade::referenceNames(
327 const OperationContext & context,
328 const CIMObjectPath & objectName,
329 const CIMName & resultClass,
330 const String & role,
331 ObjectPathResponseHandler & handler)
332 {
333 chip 1.1 op_counter ops(&_current_operations);
334 CIMAssociationProvider * provider = getInterface<CIMAssociationProvider>(_provider);
335
336 // forward request
337 provider->referenceNames(
338 context,
339 objectName,
340 resultClass,
341 role,
342 handler);
343 }
344
345 void ProviderFacade::getProperty(
346 const OperationContext & context,
347 const CIMObjectPath & instanceReference,
348 const CIMName & propertyName,
349 ValueResponseHandler & handler)
350 {
351 op_counter ops(&_current_operations);
352
|
353 kumpf 1.9 // NOTE: Use the CIMInstanceProvider interface
|
354 chip 1.1 handler.processing();
355
356 Array<CIMName> propertyList;
357
358 propertyList.append(propertyName);
359
360 SimpleInstanceResponseHandler instanceHandler;
361
362 getInstance(
363 context,
364 instanceReference,
365 false, // includeQualifiers
366 false, // includeClassOrigin
367 propertyList,
368 instanceHandler);
369
370 if(instanceHandler.getObjects().size())
371 {
372 CIMInstance instance = instanceHandler.getObjects()[0];
373
374 Uint32 pos = instance.findProperty(propertyName);
375 chip 1.1
376 if(pos != PEG_NOT_FOUND)
377 {
378 handler.deliver(instance.getProperty(pos).getValue());
379 }
380 // Property not found. Return CIM_ERR_NO_SUCH_PROPERTY.
381 else
382 {
383 handler.complete();
384 throw PEGASUS_CIM_EXCEPTION(
385 CIM_ERR_NO_SUCH_PROPERTY,
386 propertyName.getString());
387 }
388 }
389
390 handler.complete();
391 }
392
393 void ProviderFacade::setProperty(
394 const OperationContext & context,
395 const CIMObjectPath & instanceReference,
396 chip 1.1 const CIMName & propertyName,
397 const CIMValue & newValue,
398 ResponseHandler & handler)
399 {
400 op_counter ops(&_current_operations);
401
|
402 kumpf 1.9 // NOTE: Use the CIMInstanceProvider interface
|
403 chip 1.1 handler.processing();
404
405 CIMInstance instance(instanceReference.getClassName());
406
407 instance.addProperty(CIMProperty(propertyName, newValue));
408
409 Array<CIMName> propertyList;
410
411 propertyList.append(propertyName);
412
413 SimpleInstanceResponseHandler instanceHandler;
414
415 modifyInstance(
416 context,
417 instanceReference,
418 instance,
419 false, // includeQualifiers
420 propertyList,
421 instanceHandler);
422
423 handler.complete();
424 chip 1.1 }
425
426 void ProviderFacade::invokeMethod(
427 const OperationContext & context,
428 const CIMObjectPath & objectReference,
429 const CIMName & methodName,
430 const Array<CIMParamValue> & inParameters,
431 MethodResultResponseHandler & handler)
432 {
433 op_counter ops(&_current_operations);
434 CIMMethodProvider * provider = getInterface<CIMMethodProvider>(_provider);
435
436 // forward request
437 provider->invokeMethod(
438 context,
439 objectReference,
440 methodName,
441 inParameters,
442 handler);
443 }
444
445 chip 1.1 void ProviderFacade::enableIndications(IndicationResponseHandler & handler)
446 {
|
447 schuur 1.6 _indications_enabled = true;
448 // _current_operations++;
449 op_counter ind_ops(&_current_operations);
|
450 chip 1.1
451 CIMIndicationProvider * provider = getInterface<CIMIndicationProvider>(_provider);
452
453 // forward request
454 provider->enableIndications(handler);
455 }
456
457 void ProviderFacade::disableIndications(void)
458 {
459 CIMIndicationProvider * provider = getInterface<CIMIndicationProvider>(_provider);
460
461 // forward request
462 provider->disableIndications();
|
463 schuur 1.6 _indications_enabled = false;
464 // _current_operations--;
|
465 chip 1.1 }
466
467 void ProviderFacade::createSubscription(
468 const OperationContext & context,
469 const CIMObjectPath & subscriptionName,
470 const Array<CIMObjectPath> & classNames,
471 const CIMPropertyList & propertyList,
472 const Uint16 repeatNotificationPolicy)
473 {
474 op_counter ops(&_current_operations);
|
475 schuur 1.6 // op_counter ind_ops(&_current_ind_operations);
|
476 chip 1.1 CIMIndicationProvider * provider = getInterface<CIMIndicationProvider>(_provider);
477
478 // forward request
479 provider->createSubscription(
480 context,
481 subscriptionName,
482 classNames,
483 propertyList,
484 repeatNotificationPolicy);
485 }
486
487 void ProviderFacade::modifySubscription(
488 const OperationContext & context,
489 const CIMObjectPath & subscriptionName,
490 const Array<CIMObjectPath> & classNames,
491 const CIMPropertyList & propertyList,
492 const Uint16 repeatNotificationPolicy)
493 {
494 op_counter ops(&_current_operations);
|
495 schuur 1.6 // op_counter ind_ops(&_current_ind_operations);
|
496 chip 1.1 CIMIndicationProvider * provider = getInterface<CIMIndicationProvider>(_provider);
497
498 // forward request
499 provider->modifySubscription(
500 context,
501 subscriptionName,
502 classNames,
503 propertyList,
504 repeatNotificationPolicy);
505 }
506
507 void ProviderFacade::deleteSubscription(
508 const OperationContext & context,
509 const CIMObjectPath & subscriptionName,
510 const Array<CIMObjectPath> & classNames)
511 {
512 op_counter ops(&_current_operations);
|
513 chip 1.3
|
514 schuur 1.6 // op_counter ind_ops(&_current_ind_operations);
|
515 chip 1.3
|
516 chip 1.1 CIMIndicationProvider * provider = getInterface<CIMIndicationProvider>(_provider);
517
518 // forward request
519 provider->deleteSubscription(
520 context,
521 subscriptionName,
522 classNames);
523 }
524
|
525 chip 1.3 // CIMIndicationConsumerProvider interface
|
526 chip 1.1 void ProviderFacade::consumeIndication(
527 const OperationContext & context,
|
528 chip 1.3 const String & destinationPath,
529 const CIMInstance & indication)
|
530 chip 1.1 {
531 op_counter ops(&_current_operations);
532
|
533 chip 1.3 CIMIndicationConsumerProvider * provider = getInterface<CIMIndicationConsumerProvider>(_provider);
|
534 chip 1.1
|
535 chip 1.3 provider->consumeIndication(
536 context,
537 destinationPath,
538 indication);
|
539 chip 1.1 }
540
541 PEGASUS_NAMESPACE_END
|