1 karl 1.27 //%2006////////////////////////////////////////////////////////////////////////
|
2 schuur 1.1 //
|
3 karl 1.12 // 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.12 // 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.15 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.27 // 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 r.kieninger 1.29 //
|
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 venkat.puvvada 1.39
|
34 schuur 1.6 #include "CMPI_Version.h"
|
35 schuur 1.3
|
36 schuur 1.1 #include "CMPI_Broker.h"
37 #include "CMPI_Object.h"
38 #include "CMPI_ContextArgs.h"
39 #include "CMPI_Enumeration.h"
40 #include "CMPI_Value.h"
41 #include "CMPIProviderManager.h"
|
42 schuur 1.9 #include "CMPI_String.h"
|
43 marek 1.43 #include <Pegasus/ProviderManager2/CMPI/CMPIClassCache.h>
|
44 schuur 1.1
45 #include <Pegasus/Common/CIMName.h>
46 #include <Pegasus/Common/CIMPropertyList.h>
47 #include <Pegasus/Provider/CIMOMHandle.h>
48 #include <Pegasus/Common/CIMValue.h>
49 #include <Pegasus/Common/CIMType.h>
50
51
52 PEGASUS_USING_STD;
53 PEGASUS_NAMESPACE_BEGIN
54
|
55 venkat.puvvada 1.36 static const CMPIUint32 MB_CAPABILITIES =
|
56 venkat.puvvada 1.39 # ifdef CMPI_VER_200
57 CMPI_MB_Supports_Extended_Error |
58 # endif
|
59 venkat.puvvada 1.36 CMPI_MB_BasicRead | CMPI_MB_BasicWrite | CMPI_MB_InstanceManipulation |
60 CMPI_MB_AssociationTraversal | CMPI_MB_QueryNormalization |
61 CMPI_MB_Indications | CMPI_MB_BasicQualifierSupport |
62 CMPI_MB_OSEncapsulationSupport
|
63 venkat.puvvada 1.39 # ifndef PEGASUS_DISABLE_EXECQUERY
|
64 venkat.puvvada 1.36 | CMPI_MB_QueryExecution
65 # endif
66 ;
67
|
68 mike 1.44.4.1 #define HandlerCatchSetStatus(rc, returnvalue) \
69 catch (const CIMException &e) \
70 { \
71 PEG_TRACE_STRING( \
72 TRC_CMPIPROVIDERINTERFACE, \
73 Tracer::LEVEL2, \
74 "CIMException: " + e.getMessage()); \
75 CMSetStatusWithString( \
76 rc, \
77 (CMPIrc)e.getCode(), \
78 (CMPIString*)string2CMPIString(e.getMessage())); \
79 PEG_METHOD_EXIT(); \
80 return returnvalue; \
81 } \
82 catch (const Exception &e) \
83 { \
84 PEG_TRACE(( \
85 TRC_CMPIPROVIDERINTERFACE, \
86 Tracer::LEVEL2, \
87 "Exception: %s", (const char *)e.getMessage().getCString())); \
88 CMSetStatusWithString( \
89 mike 1.44.4.1 rc, \
90 (CMPIrc)CMPI_RC_ERROR_SYSTEM, \
91 (CMPIString*)string2CMPIString(e.getMessage())); \
92 PEG_METHOD_EXIT(); \
93 return returnvalue; \
94 } \
95 catch (...) \
96 { \
97 PEG_TRACE(( \
98 TRC_CMPIPROVIDERINTERFACE, \
99 Tracer::LEVEL2, \
100 "Unknown exception")); \
101 CMSetStatusWithString( \
102 rc, \
103 (CMPIrc)CMPI_RC_ERROR_SYSTEM, \
104 (CMPIString*)string2CMPIString("Unknown exception")); \
105 PEG_METHOD_EXIT(); \
106 return returnvalue; \
107 }
108
109 #define HandlerCatchReturnStatus() \
110 mike 1.44.4.1 catch (const CIMException &e) \
111 { \
112 PEG_TRACE_STRING( \
113 TRC_CMPIPROVIDERINTERFACE, \
114 Tracer::LEVEL2, \
115 "CIMException: " + e.getMessage()); \
116 PEG_METHOD_EXIT(); \
117 CMReturnWithString( \
118 (CMPIrc)e.getCode(), \
119 (CMPIString*)string2CMPIString(e.getMessage())); \
120 } \
121 catch (const Exception &e) \
122 { \
123 PEG_TRACE(( \
124 TRC_CMPIPROVIDERINTERFACE, \
125 Tracer::LEVEL2, \
126 "Exception: %s", (const char *)e.getMessage().getCString())); \
127 PEG_METHOD_EXIT(); \
128 CMReturnWithString( \
129 (CMPIrc)CMPI_RC_ERROR_SYSTEM, \
130 (CMPIString*)string2CMPIString(e.getMessage())); \
131 mike 1.44.4.1 } \
132 catch (...) \
133 { \
134 PEG_TRACE(( \
135 TRC_CMPIPROVIDERINTERFACE, \
136 Tracer::LEVEL2, \
137 "Unknown exception")); \
138 PEG_METHOD_EXIT(); \
139 CMReturnWithString( \
140 (CMPIrc)CMPI_RC_ERROR_SYSTEM, \
141 (CMPIString*)string2CMPIString("Unknown exception")); \
142 }
143
|
144 venkat.puvvada 1.39 static CIMPropertyList getList(const char** l)
145 {
146 CIMPropertyList pl;
147 if (l)
148 {
149 Array<CIMName> n;
150 while (*l)
151 {
152 n.append(*l++);
153 }
154 pl.set(n);
155 }
156 return pl;
|
157 schuur 1.1 }
158
|
159 venkat.puvvada 1.39 CIMClass* mbGetClass(const CMPIBroker *mb, const CIMObjectPath &cop)
160 {
|
161 ms.aruran 1.42 PEG_METHOD_ENTER(TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbGetClass()");
162
163 mb=CM_BROKER;
164 CMPI_Broker *xBroker=(CMPI_Broker*)mb;
|
165 marek 1.43 CIMClass * ccp = xBroker->classCache.getClass(xBroker, cop);
|
166 ms.aruran 1.42 PEG_METHOD_EXIT();
|
167 marek 1.43 return ccp;
|
168 schuur 1.1 }
169
|
170 venkat.puvvada 1.39 extern "C"
171 {
|
172 schuur 1.1
|
173 venkat.puvvada 1.39 static CMPIInstance* mbGetInstance(
174 const CMPIBroker *mb,
175 const CMPIContext *ctx,
176 const CMPIObjectPath *cop,
177 const char **properties,
178 CMPIStatus *rc)
179 {
|
180 ms.aruran 1.42 PEG_METHOD_ENTER(
181 TRC_CMPIPROVIDERINTERFACE,
182 "CMPI_Broker:mbGetInstance()");
183
|
184 venkat.puvvada 1.39 mb = CM_BROKER;
185 CMPIFlags flgs =
186 ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
187 const CIMPropertyList props = getList(properties);
188 CIMObjectPath qop(
189 String::EMPTY,
190 CIMNamespaceName(),
191 CM_ObjectPath(cop)->getClassName(),
|
192 schuur 1.11 CM_ObjectPath(cop)->getKeyBindings());
193
|
194 venkat.puvvada 1.39 try
195 {
196 CIMInstance ci = CM_CIMOM(mb)->getInstance(
197 OperationContext(*CM_Context(ctx)),
198 CM_ObjectPath(cop)->getNameSpace(),
199 qop, //*CM_ObjectPath(cop),
|
200 venkat.puvvada 1.44 false, // Use of localOnly is deprecated by DMTF.
|
201 venkat.puvvada 1.39 CM_IncludeQualifiers(flgs),
202 CM_ClassOrigin(flgs),
203 props);
204
205 ci.setPath(*CM_ObjectPath(cop));
206 CMSetStatus(rc,CMPI_RC_OK);
|
207 ms.aruran 1.42 CMPIInstance* cmpiInst = reinterpret_cast<CMPIInstance*>(
|
208 venkat.puvvada 1.39 new CMPI_Object(new CIMInstance(ci)));
|
209 ms.aruran 1.42 PEG_METHOD_EXIT();
210 return cmpiInst;
|
211 venkat.puvvada 1.39 }
|
212 mike 1.44.4.1 HandlerCatchSetStatus(rc, NULL);
213
|
214 venkat.puvvada 1.39 // Code flow should never get here.
215 }
216
217 static CMPIObjectPath* mbCreateInstance(
218 const CMPIBroker *mb,
219 const CMPIContext *ctx,
220 const CMPIObjectPath *cop,
221 const CMPIInstance *ci,
222 CMPIStatus *rc)
223 {
|
224 ms.aruran 1.42 PEG_METHOD_ENTER(
225 TRC_CMPIPROVIDERINTERFACE,
226 "CMPI_Broker:mbCreateInstance()");
227
|
228 venkat.puvvada 1.39 mb = CM_BROKER;
229
230 try
231 {
232 CIMObjectPath ncop = CM_CIMOM(mb)->createInstance(
233 OperationContext(*CM_Context(ctx)),
234 CM_ObjectPath(cop)->getNameSpace(),
235 *CM_Instance(ci));
236 CMSetStatus(rc,CMPI_RC_OK);
|
237 ms.aruran 1.42 CMPIObjectPath* cmpiObjPath = reinterpret_cast<CMPIObjectPath*>(
|
238 venkat.puvvada 1.39 new CMPI_Object(new CIMObjectPath(ncop)));
|
239 ms.aruran 1.42 PEG_METHOD_EXIT();
240 return cmpiObjPath;
|
241 venkat.puvvada 1.39 }
|
242 mike 1.44.4.1 HandlerCatchSetStatus(rc, NULL);
243
|
244 venkat.puvvada 1.39 // Code flow should never get here.
245 }
246
247 static CMPIStatus mbModifyInstance(
248 const CMPIBroker *mb,
249 const CMPIContext *ctx,
250 const CMPIObjectPath *cop,
251 const CMPIInstance *ci,
252 const char ** properties)
253 {
|
254 ms.aruran 1.42 PEG_METHOD_ENTER(
255 TRC_CMPIPROVIDERINTERFACE,
256 "CMPI_Broker:mbModifyInstance()");
|
257 venkat.puvvada 1.39 mb = CM_BROKER;
258 CMPIFlags flgs =
259 ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
260 const CIMPropertyList props = getList(properties);
261
262 try
263 {
264 CIMInstance cmi(*CM_Instance(ci));
265 cmi.setPath(*CM_ObjectPath(cop));
266 CM_CIMOM(mb)->modifyInstance(
267 OperationContext(*CM_Context(ctx)),
268 CM_ObjectPath(cop)->getNameSpace(),
269 cmi,
270 CM_IncludeQualifiers(flgs),
271 props);
272 }
|
273 mike 1.44.4.1 HandlerCatchReturnStatus();
274
|
275 ms.aruran 1.42 PEG_METHOD_EXIT();
|
276 venkat.puvvada 1.39 CMReturn(CMPI_RC_OK);
277 }
278
279 static CMPIStatus mbDeleteInstance(
280 const CMPIBroker *mb,
281 const CMPIContext *ctx,
282 const CMPIObjectPath *cop)
283 {
|
284 ms.aruran 1.42 PEG_METHOD_ENTER(
285 TRC_CMPIPROVIDERINTERFACE,
286 "CMPI_Broker:mbDeleteInstance()");
|
287 venkat.puvvada 1.39 mb = CM_BROKER;
288 CIMObjectPath qop(
289 String::EMPTY,CIMNamespaceName(),
290 CM_ObjectPath(cop)->getClassName(),
|
291 schuur 1.11 CM_ObjectPath(cop)->getKeyBindings());
292
|
293 venkat.puvvada 1.39 try
294 {
295 CM_CIMOM(mb)->deleteInstance(
296 OperationContext(*CM_Context(ctx)),
297 CM_ObjectPath(cop)->getNameSpace(),
298 qop); //*CM_ObjectPath(cop));
299 }
|
300 mike 1.44.4.1 HandlerCatchReturnStatus();
301
|
302 ms.aruran 1.42 PEG_METHOD_EXIT();
|
303 venkat.puvvada 1.39 CMReturn(CMPI_RC_OK);
304 }
305
306 static CMPIEnumeration* mbExecQuery(
307 const CMPIBroker *mb,
308 const CMPIContext *ctx,
309 const CMPIObjectPath *cop,
310 const char *query, const char *lang, CMPIStatus *rc)
311 {
|
312 ms.aruran 1.42 PEG_METHOD_ENTER(
313 TRC_CMPIPROVIDERINTERFACE,
314 "CMPI_Broker:mbExecQuery()");
|
315 venkat.puvvada 1.39 mb = CM_BROKER;
316
317 try
318 {
319 Array<CIMObject> const &en = CM_CIMOM(mb)->execQuery(
320 OperationContext(*CM_Context(ctx)),
321 CM_ObjectPath(cop)->getNameSpace(),
322 String(lang),
323 String(query));
324 CMSetStatus(rc,CMPI_RC_OK);
325
|
326 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*> (
|
327 venkat.puvvada 1.39 new CMPI_Object(
|
328 ms.aruran 1.42 new CMPI_ObjEnumeration(new Array<CIMObject>(en))));
329 PEG_METHOD_EXIT();
330 return cmpiEnum;
|
331 venkat.puvvada 1.39 }
|
332 mike 1.44.4.1 HandlerCatchSetStatus(rc, NULL);
333
|
334 venkat.puvvada 1.39 // Code flow should never get here.
335 }
336
337 static CMPIEnumeration* mbEnumInstances(
338 const CMPIBroker *mb,
339 const CMPIContext *ctx,
340 const CMPIObjectPath *cop,
341 const char **properties,
342 CMPIStatus *rc)
343 {
|
344 ms.aruran 1.42 PEG_METHOD_ENTER(
345 TRC_CMPIPROVIDERINTERFACE,
346 "CMPI_Broker:mbEnumInstances()");
|
347 venkat.puvvada 1.39 mb = CM_BROKER;
348
349 CMPIFlags flgs =
350 ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
351 const CIMPropertyList props = getList(properties);
352
353 try
354 {
355 Array<CIMInstance> const &en =
356 CM_CIMOM(mb)->enumerateInstances(
357 OperationContext(*CM_Context(ctx)),
358 CM_ObjectPath(cop)->getNameSpace(),
359 CM_ObjectPath(cop)->getClassName(),
360 CM_DeepInheritance(flgs),
|
361 venkat.puvvada 1.44 false, //Use of localOnly is deprecated by DMTF.
|
362 venkat.puvvada 1.39 CM_IncludeQualifiers(flgs),
363 CM_ClassOrigin(flgs),
364 props);
365
366 CMSetStatus(rc,CMPI_RC_OK);
367
368 // Workaround for bugzilla 4677
369 // When running out of process the returned instances don't contain
370 // a name space. Create a writable copy of the array and add the
371 // namespace from the input parameters.
372
373 Array<CIMInstance> * aInst = new Array<CIMInstance>(en);
374 for (unsigned int index=0; index < aInst->size(); index++)
375 {
376 CIMInstance& myInst = (*aInst)[index];
377 CIMObjectPath orgCop = myInst.getPath();
378 orgCop.setNameSpace(CM_ObjectPath(cop)->getNameSpace());
379 (*aInst)[index].setPath(orgCop);
380 }
381
|
382 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
383 venkat.puvvada 1.39 new CMPI_Object(new CMPI_InstEnumeration(aInst)));
|
384 ms.aruran 1.42 PEG_METHOD_EXIT();
385 return cmpiEnum;
|
386 venkat.puvvada 1.39 }
|
387 mike 1.44.4.1 HandlerCatchSetStatus(rc, NULL);
388
|
389 venkat.puvvada 1.39 // Code flow should never get here.
390 }
391
392 static CMPIEnumeration* mbEnumInstanceNames(
393 const CMPIBroker *mb,
394 const CMPIContext *ctx,
395 const CMPIObjectPath *cop,
396 CMPIStatus *rc)
397 {
|
398 ms.aruran 1.42 PEG_METHOD_ENTER(
399 TRC_CMPIPROVIDERINTERFACE,
400 "CMPI_Broker:mbEnumInstanceNames()");
|
401 venkat.puvvada 1.39 mb = CM_BROKER;
402
403 try
404 {
405 Array<CIMObjectPath> const &en =
406 CM_CIMOM(mb)->enumerateInstanceNames(
407 OperationContext(*CM_Context(ctx)),
408 CM_ObjectPath(cop)->getNameSpace(),
409 CM_ObjectPath(cop)->getClassName());
410 CMSetStatus(rc,CMPI_RC_OK);
411
412 // When running out of process the returned instances don't contain
413 // a name space. Create a writable copy of the array and add the
414 // namespace from the input parameters.
415 Array<CIMObjectPath> * aObj = new Array<CIMObjectPath>(en);
416 for (unsigned int index=0; index < aObj->size(); index++)
417 {
418 (*aObj)[index].setNameSpace(
419 CM_ObjectPath(cop)->getNameSpace());
420 }
|
421 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
422 venkat.puvvada 1.39 new CMPI_Object(new CMPI_OpEnumeration(aObj)));
|
423 ms.aruran 1.42 PEG_METHOD_EXIT();
424 return cmpiEnum;
|
425 venkat.puvvada 1.39 }
|
426 mike 1.44.4.1 HandlerCatchSetStatus(rc, NULL);
427
|
428 venkat.puvvada 1.39 // Code flow should never get here.
429 }
430
431 static CMPIEnumeration* mbAssociators(
432 const CMPIBroker *mb,
433 const CMPIContext *ctx,
434 const CMPIObjectPath *cop,
435 const char *assocClass,
436 const char *resultClass,
437 const char *role,
438 const char *resultRole,
439 const char **properties,
440 CMPIStatus *rc)
441 {
|
442 ms.aruran 1.42 PEG_METHOD_ENTER(
443 TRC_CMPIPROVIDERINTERFACE,
444 "CMPI_Broker:mbAssociators()");
|
445 venkat.puvvada 1.39 mb = CM_BROKER;
|
446 dave.sudlik 1.41 // ATTN-CAKG-P2-20020726: The following condition does not correctly
447 // distinguish instanceNames from classNames in every case
448 // The instanceName of a singleton instance of a keyless class has no
449 // key bindings
450 if (!CM_ObjectPath(cop)->getKeyBindings().size())
451 {
452 CMSetStatus(rc, CMPI_RC_ERR_FAILED);
|
453 ms.aruran 1.42 PEG_METHOD_EXIT();
|
454 dave.sudlik 1.41 return 0;
455 }
|
456 venkat.puvvada 1.39 CMPIFlags flgs =
457 ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
458 const CIMPropertyList props = getList(properties);
459 CIMObjectPath qop(
460 String::EMPTY,CIMNamespaceName(),
461 CM_ObjectPath(cop)->getClassName(),
|
462 schuur 1.11 CM_ObjectPath(cop)->getKeyBindings());
463
|
464 venkat.puvvada 1.39 try
465 {
466 Array<CIMObject> const &en =
467 CM_CIMOM(mb)->associators(
468 OperationContext(*CM_Context(ctx)),
469 CM_ObjectPath(cop)->getNameSpace(),
470 qop,
471 assocClass ? CIMName(assocClass) : CIMName(),
472 resultClass ? CIMName(resultClass) : CIMName(),
473 role ? String(role) : String::EMPTY,
474 resultRole ? String(resultRole) : String::EMPTY,
475 CM_IncludeQualifiers(flgs),
476 CM_ClassOrigin(flgs),
477 props);
478
479 CMSetStatus(rc,CMPI_RC_OK);
480
481 // Workaround for bugzilla 4677
482 // When running out of process the returned instances don't contain
483 // a name space. Create a writable copy of the array and add the
484 // namespace from the input parameters.
485 venkat.puvvada 1.39 Array<CIMObject> * aInst = new Array<CIMObject>(en);
486 for (unsigned int index=0; index < aInst->size(); index++)
487 {
488 CIMObject& myInst = (*aInst)[index];
489 CIMObjectPath orgCop = myInst.getPath();
490 orgCop.setNameSpace(CM_ObjectPath(cop)->getNameSpace());
491 (*aInst)[index].setPath(orgCop);
492 }
|
493 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
494 venkat.puvvada 1.39 new CMPI_Object(new CMPI_ObjEnumeration(aInst)));
|
495 ms.aruran 1.42 PEG_METHOD_EXIT();
496 return cmpiEnum;
|
497 venkat.puvvada 1.39 }
|
498 mike 1.44.4.1 HandlerCatchSetStatus(rc, NULL);
499
|
500 venkat.puvvada 1.39 // Code flow should never get here.
501 }
502
503 static CMPIEnumeration* mbAssociatorNames(
504 const CMPIBroker *mb,
505 const CMPIContext *ctx,
506 const CMPIObjectPath *cop,
507 const char *assocClass,
508 const char *resultClass,
509 const char *role,
510 const char *resultRole,
511 CMPIStatus *rc)
512 {
|
513 ms.aruran 1.42 PEG_METHOD_ENTER(
514 TRC_CMPIPROVIDERINTERFACE,
515 "CMPI_Broker:mbAssociatorNames()");
|
516 venkat.puvvada 1.39 mb = CM_BROKER;
|
517 dave.sudlik 1.41 // ATTN-CAKG-P2-20020726: The following condition does not correctly
518 // distinguish instanceNames from classNames in every case
519 // The instanceName of a singleton instance of a keyless class has no
520 // key bindings
521 if (!CM_ObjectPath(cop)->getKeyBindings().size())
522 {
523 CMSetStatus(rc, CMPI_RC_ERR_FAILED);
|
524 ms.aruran 1.42 PEG_METHOD_EXIT();
|
525 dave.sudlik 1.41 return 0;
526 }
|
527 venkat.puvvada 1.39 CIMObjectPath qop(
528 String::EMPTY,CIMNamespaceName(),
529 CM_ObjectPath(cop)->getClassName(),
|
530 schuur 1.11 CM_ObjectPath(cop)->getKeyBindings());
531
|
532 venkat.puvvada 1.39 try
533 {
534 Array<CIMObjectPath> const &en =
535 CM_CIMOM(mb)->associatorNames(
536 OperationContext(*CM_Context(ctx)),
537 CM_ObjectPath(cop)->getNameSpace(),
538 qop,
539 assocClass ? CIMName(assocClass) : CIMName(),
540 resultClass ? CIMName(resultClass) : CIMName(),
541 role ? String(role) : String::EMPTY,
542 resultRole ? String(resultRole) : String::EMPTY);
543 CMSetStatus(rc,CMPI_RC_OK);
544
545 // When running out of process the returned instances don't contain
546 // a name space. Create a writable copy of the array and add the
547 // namespace from the input parameters.
548 Array<CIMObjectPath> * aObj = new Array<CIMObjectPath>(en);
549 for (unsigned int index=0; index < aObj->size(); index++)
550 {
551 (*aObj)[index].setNameSpace(
552 CM_ObjectPath(cop)->getNameSpace());
553 venkat.puvvada 1.39 }
|
554 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
555 venkat.puvvada 1.39 new CMPI_Object(new CMPI_OpEnumeration(aObj)));
|
556 ms.aruran 1.42 PEG_METHOD_EXIT();
557 return cmpiEnum;
|
558 venkat.puvvada 1.39 }
|
559 mike 1.44.4.1 HandlerCatchSetStatus(rc, NULL);
560
|
561 venkat.puvvada 1.39 // Code flow should never get here.
562 }
563
564 static CMPIEnumeration* mbReferences(
565 const CMPIBroker *mb,
566 const CMPIContext *ctx,
567 const CMPIObjectPath *cop,
568 const char *resultClass,
569 const char *role ,
570 const char **properties,
571 CMPIStatus *rc)
572 {
|
573 ms.aruran 1.42 PEG_METHOD_ENTER(
574 TRC_CMPIPROVIDERINTERFACE,
575 "CMPI_Broker:mbReferences()");
|
576 venkat.puvvada 1.39 mb = CM_BROKER;
|
577 dave.sudlik 1.41 // ATTN-CAKG-P2-20020726: The following condition does not correctly
578 // distinguish instanceNames from classNames in every case
579 // The instanceName of a singleton instance of a keyless class has no
580 // key bindings
581 if (!CM_ObjectPath(cop)->getKeyBindings().size())
582 {
583 CMSetStatus(rc, CMPI_RC_ERR_FAILED);
|
584 ms.aruran 1.42 PEG_METHOD_EXIT();
|
585 dave.sudlik 1.41 return 0;
586 }
|
587 venkat.puvvada 1.39 CMPIFlags flgs =
588 ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
589 CIMPropertyList props = getList(properties);
590 CIMObjectPath qop(
591 String::EMPTY,
592 CIMNamespaceName(),
593 CM_ObjectPath(cop)->getClassName(),
|
594 schuur 1.11 CM_ObjectPath(cop)->getKeyBindings());
595
|
596 venkat.puvvada 1.39 try
597 {
598 Array<CIMObject> const &en =
599 CM_CIMOM(mb)->references(
600 OperationContext(*CM_Context(ctx)),
601 CM_ObjectPath(cop)->getNameSpace(),
602 qop,
603 resultClass ? CIMName(resultClass) : CIMName(),
604 role ? String(role) : String::EMPTY,
605 CM_IncludeQualifiers(flgs),
606 CM_ClassOrigin(flgs),
607 props);
608
609 CMSetStatus(rc,CMPI_RC_OK);
610 // Workaround for bugzilla 4677
611 // When running out of process the returned instances don't contain
612 // a name space. Create a writable copy of the array and add the
613 // namespace from the input parameters.
614 Array<CIMObject> * aInst = new Array<CIMObject>(en);
615 for (unsigned int index=0; index < aInst->size(); index++)
616 {
617 venkat.puvvada 1.39 CIMObject& myInst = (*aInst)[index];
618 CIMObjectPath orgCop = myInst.getPath();
619 orgCop.setNameSpace(CM_ObjectPath(cop)->getNameSpace());
620 (*aInst)[index].setPath(orgCop);
621 }
|
622 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
623 venkat.puvvada 1.39 new CMPI_Object(new CMPI_ObjEnumeration(aInst)));
|
624 ms.aruran 1.42 PEG_METHOD_EXIT();
625 return cmpiEnum;
|
626 venkat.puvvada 1.39 }
|
627 mike 1.44.4.1 HandlerCatchSetStatus(rc, NULL);
628
|
629 venkat.puvvada 1.39 // Code flow should never get here.
630 }
631
632 static CMPIEnumeration* mbReferenceNames(
633 const CMPIBroker *mb,
634 const CMPIContext *ctx,
635 const CMPIObjectPath *cop,
636 const char *resultClass,
637 const char *role,
638 CMPIStatus *rc)
639 {
|
640 ms.aruran 1.42 PEG_METHOD_ENTER(
641 TRC_CMPIPROVIDERINTERFACE,
642 "CMPI_Broker:mbReferenceNames()");
|
643 venkat.puvvada 1.39 mb = CM_BROKER;
|
644 dave.sudlik 1.41 // ATTN-CAKG-P2-20020726: The following condition does not correctly
645 // distinguish instanceNames from classNames in every case
646 // The instanceName of a singleton instance of a keyless class has no
647 // key bindings
648 if (!CM_ObjectPath(cop)->getKeyBindings().size())
649 {
650 CMSetStatus(rc, CMPI_RC_ERR_FAILED);
|
651 ms.aruran 1.42 PEG_METHOD_EXIT();
|
652 dave.sudlik 1.41 return 0;
653 }
|
654 venkat.puvvada 1.39 CIMObjectPath qop(
655 String::EMPTY,
656 CIMNamespaceName(),
657 CM_ObjectPath(cop)->getClassName(),
|
658 schuur 1.11 CM_ObjectPath(cop)->getKeyBindings());
659
|
660 venkat.puvvada 1.39 try
661 {
662 Array<CIMObjectPath> const &en =
663 CM_CIMOM(mb)->referenceNames(
664 OperationContext(*CM_Context(ctx)),
665 CM_ObjectPath(cop)->getNameSpace(),
666 qop,
667 resultClass ? CIMName(resultClass) : CIMName(),
668 role ? String(role) : String::EMPTY);
669 CMSetStatus(rc,CMPI_RC_OK);
670
671 // When running out of process the returned instances don't contain
672 // a name space. Create a writable copy of the array and add the
673 // namespace from the input parameters.
674 Array<CIMObjectPath> * aObj = new Array<CIMObjectPath>(en);
675 for (unsigned int index=0; index < aObj->size(); index++)
676 {
677 (*aObj)[index].setNameSpace(
678 CM_ObjectPath(cop)->getNameSpace());
679 }
|
680 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
681 venkat.puvvada 1.39 new CMPI_Object(new CMPI_OpEnumeration(aObj)));
|
682 ms.aruran 1.42 PEG_METHOD_EXIT();
683 return cmpiEnum;
|
684 venkat.puvvada 1.39 }
|
685 mike 1.44.4.1 HandlerCatchSetStatus(rc, NULL);
686
|
687 venkat.puvvada 1.39 // Code flow should never get here.
688 }
|
689 schuur 1.1
|
690 r.kieninger 1.29 #define CM_Args(args) ((Array<CIMParamValue>*)args->hdl)
691
|
692 venkat.puvvada 1.39 static CMPIData mbInvokeMethod(
693 const CMPIBroker *mb,
694 const CMPIContext *ctx,
695 const CMPIObjectPath *cop,
696 const char *method,
697 const CMPIArgs *in,
698 CMPIArgs *out,
699 CMPIStatus *rc)
700 {
|
701 ms.aruran 1.42 PEG_METHOD_ENTER(
702 TRC_CMPIPROVIDERINTERFACE,
703 "CMPI_Broker:mbInvokeMethod()");
|
704 venkat.puvvada 1.39 CMPIData data = {0,CMPI_nullValue,{0}};
705 mb = CM_BROKER;
706 CIMObjectPath qop(
707 String::EMPTY,CIMNamespaceName(),
|
708 r.kieninger 1.29 CM_ObjectPath(cop)->getClassName(),
709 CM_ObjectPath(cop)->getKeyBindings());
710
|
711 venkat.puvvada 1.39 try
712 {
713 CIMValue v = CM_CIMOM(mb)->invokeMethod(
714 OperationContext(*CM_Context(ctx)),
715 CM_ObjectPath(cop)->getNameSpace(),
716 qop,
717 method ? String(method) : String::EMPTY,
718 *CM_Args(in),
719 *CM_Args(out));
720 CIMType vType=v.getType();
721 CMPIType t = type2CMPIType(vType,v.isArray());
722 value2CMPIData(v,t,&data);
723 if (rc)
724 {
725 CMSetStatus(rc,CMPI_RC_OK);
726 }
727 }
|
728 mike 1.44.4.1 HandlerCatchSetStatus(rc, data);
729
|
730 ms.aruran 1.42 PEG_METHOD_EXIT();
|
731 venkat.puvvada 1.39 return data; // "data" will be valid data or nullValue (in error case)
732 }
733
734 static CMPIStatus mbSetProperty(
735 const CMPIBroker *mb,
736 const CMPIContext *ctx,
737 const CMPIObjectPath *cop,
738 const char *name,
739 const CMPIValue *val,
740 CMPIType type)
741 {
|
742 ms.aruran 1.42 PEG_METHOD_ENTER(
743 TRC_CMPIPROVIDERINTERFACE,
744 "CMPI_Broker:mbSetProperty()");
|
745 venkat.puvvada 1.39 mb = CM_BROKER;
746 CMPIrc rc;
747 CIMValue v = value2CIMValue(val,type,&rc);
748
749 try
750 {
751 CM_CIMOM(mb)->setProperty(
752 OperationContext(*CM_Context(ctx)),
753 CM_ObjectPath(cop)->getNameSpace(),
754 *CM_ObjectPath(cop),
755 String(name),
756 v);
757 }
|
758 mike 1.44.4.1 HandlerCatchReturnStatus();
759
|
760 ms.aruran 1.42 PEG_METHOD_EXIT();
|
761 venkat.puvvada 1.39 CMReturn(CMPI_RC_OK);
762 }
763
764 static CMPIData mbGetProperty(
765 const CMPIBroker *mb,
766 const CMPIContext *ctx,
767 const CMPIObjectPath *cop,
768 const char *name,
769 CMPIStatus *rc)
770 {
|
771 ms.aruran 1.42 PEG_METHOD_ENTER(
772 TRC_CMPIPROVIDERINTERFACE,
773 "CMPI_Broker:mbGetProperty()");
|
774 venkat.puvvada 1.39 mb = CM_BROKER;
775 CMPIData data = {0,CMPI_nullValue,{0}};
776
777 try
778 {
779 CIMValue v = CM_CIMOM(mb)->getProperty(
780 OperationContext(*CM_Context(ctx)),
781 CM_ObjectPath(cop)->getNameSpace(),
782 *CM_ObjectPath(cop),
783 String(name));
784 CIMType vType = v.getType();
785 CMPIType t = type2CMPIType(vType,v.isArray());
786 value2CMPIData(v,t,&data);
787 CMSetStatus(rc,CMPI_RC_OK);
788 }
|
789 mike 1.44.4.1 HandlerCatchSetStatus(rc, data);
790
|
791 ms.aruran 1.42 PEG_METHOD_EXIT();
|
792 venkat.puvvada 1.39 return data; // "data" will be valid data or nullValue (in error case)
793 }
794
795 static CMPIContext* mbPrepareAttachThread(
796 const CMPIBroker* mb,
797 const CMPIContext* eCtx)
798 {
|
799 ms.aruran 1.42 PEG_METHOD_ENTER(
800 TRC_CMPIPROVIDERINTERFACE,
801 "CMPI_Broker:mbPrepareAttachThread()");
|
802 venkat.puvvada 1.39 mb = CM_BROKER;
803 OperationContext *ctx = (OperationContext*)((CMPI_Context*)eCtx)->ctx;
804 OperationContext nctx = *ctx;
805 CMPIContext* neCtx = new CMPI_Context(*(new OperationContext(nctx)));
806 CMPIString *name;
807 for (int i=0,s=CMPI_Args_Ftab->getArgCount(
808 reinterpret_cast<const CMPIArgs*>(eCtx),NULL); i<s; i++)
809 {
810 CMPIData data = CMPI_Args_Ftab->getArgAt(
811 reinterpret_cast<const CMPIArgs*>(eCtx),i,&name,NULL);
812 CMPI_Args_Ftab->addArg(
813 reinterpret_cast<CMPIArgs*>(neCtx),
814 CMGetCharPtr(name),
815 &data.value,data.type);
816 }
|
817 ms.aruran 1.42 PEG_METHOD_EXIT();
|
818 venkat.puvvada 1.39 return neCtx;
819 }
820
821 static CMPIStatus mbAttachThread(
822 const CMPIBroker* mb,
823 const CMPIContext* eCtx)
824 {
825 ((CMPI_Context*)eCtx)->thr = new CMPI_ThreadContext(mb,eCtx);
826 CMReturn(CMPI_RC_OK);
827 }
828
829 static CMPIStatus mbDetachThread(
830 const CMPIBroker* mb,
831 const CMPIContext* eCtx)
832 {
833 mb = CM_BROKER;
834 CMPI_Context *neCtx = (CMPI_Context *)eCtx;
835 delete neCtx->thr;
836 // Delete also CMPIContext
837 delete neCtx;
838 CMReturn(CMPI_RC_OK);
839 venkat.puvvada 1.39 }
|
840 schuur 1.11
|
841 venkat.puvvada 1.39 static CMPIStatus mbDeliverIndication(
|
842 ms.aruran 1.42 const CMPIBroker* eMb,
843 const CMPIContext* ctx,
844 const char *ns,
845 const CMPIInstance* ind)
846 {
847 PEG_METHOD_ENTER(
848 TRC_CMPIPROVIDERINTERFACE,
849 "CMPI_Broker:mbDeliverIndication()");
|
850 venkat.puvvada 1.39 eMb = CM_BROKER;
851 CMPI_Broker *mb = (CMPI_Broker*)eMb;
852 CMPIProviderManager::indProvRecord *prec;
853 OperationContext* context = CM_Context(ctx);
854 // When an indication to be delivered comes from Remote providers,
855 // the CMPIBroker contains the name of the provider in the form
856 // of physical-name:logical-name. Search using logical-name. -V 5884
857 String provider_name;
858 CMPIUint32 n;
859
860 if ( (n = mb->name.find(':') ) != PEG_NOT_FOUND)
861 {
862 provider_name = mb->name.subString (n + 1);
863 }
864 else
865 {
866 provider_name = mb->name;
867 }
868 ReadLock readLock(CMPIProviderManager::rwSemProvTab);
869 if (CMPIProviderManager::provTab.lookup(provider_name,prec))
870 {
871 venkat.puvvada 1.39 if (prec->enabled)
872 {
873 try
874 {
875 context->get(SubscriptionInstanceNamesContainer::NAME);
876 }
|
877 ms.aruran 1.42 catch (const Exception &e)
|
878 venkat.puvvada 1.39 {
|
879 ms.aruran 1.42 PEG_TRACE_STRING(
880 TRC_CMPIPROVIDERINTERFACE,
|
881 mike 1.44.4.1 Tracer::LEVEL1,
|
882 ms.aruran 1.42 "Exception: " + e.getMessage());
|
883 venkat.puvvada 1.39 Array<CIMObjectPath> subscriptionInstanceNames;
884 context->insert(
885 SubscriptionInstanceNamesContainer(
886 subscriptionInstanceNames));
887 }
888 CIMIndication cimIndication(*CM_Instance(ind));
889 try
890 {
891 prec->handler->deliver(
892 *context,
893 // OperationContext(*CM_Context(ctx)),
894 cimIndication);
|
895 ms.aruran 1.42 PEG_METHOD_EXIT();
896 CMReturn(CMPI_RC_OK);
|
897 venkat.puvvada 1.39 }
|
898 mike 1.44.4.1 HandlerCatchReturnStatus();
|
899 venkat.puvvada 1.39 }
900 }
|
901 ms.aruran 1.42 PEG_METHOD_EXIT();
|
902 venkat.puvvada 1.39 CMReturn(CMPI_RC_ERR_FAILED);
903 }
|
904 schuur 1.11 }
|
905 schuur 1.1
|
906 venkat.puvvada 1.39 static CMPIBrokerFT broker_FT =
907 {
908 MB_CAPABILITIES, // brokerClassification;
909 CMPICurrentVersion,
910 "Pegasus",
911 mbPrepareAttachThread,
912 mbAttachThread,
913 mbDetachThread,
914 mbDeliverIndication,
915 mbEnumInstanceNames,
916 mbGetInstance,
917 mbCreateInstance,
918 mbModifyInstance,
919 mbDeleteInstance,
920 mbExecQuery,
921 mbEnumInstances,
922 mbAssociators,
923 mbAssociatorNames,
924 mbReferences,
925 mbReferenceNames,
926 mbInvokeMethod,
927 venkat.puvvada 1.39 mbSetProperty,
928 mbGetProperty,
|
929 schuur 1.1 };
930
|
931 venkat.puvvada 1.39 CMPIBrokerFT *CMPI_Broker_Ftab = & broker_FT;
|
932 schuur 1.1
933 PEGASUS_NAMESPACE_END
|