1 martin 1.50 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.51 //
|
3 martin 1.50 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.51 //
|
10 martin 1.50 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.51 //
|
17 martin 1.50 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.51 //
|
20 martin 1.50 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.51 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.50 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.51 //
|
28 martin 1.50 //////////////////////////////////////////////////////////////////////////
|
29 schuur 1.1 //
30 //%/////////////////////////////////////////////////////////////////////////////
|
31 venkat.puvvada 1.39
|
32 schuur 1.6 #include "CMPI_Version.h"
|
33 schuur 1.3
|
34 schuur 1.1 #include "CMPI_Broker.h"
35 #include "CMPI_Object.h"
36 #include "CMPI_ContextArgs.h"
37 #include "CMPI_Enumeration.h"
38 #include "CMPI_Value.h"
39 #include "CMPIProviderManager.h"
|
40 schuur 1.9 #include "CMPI_String.h"
|
41 marek 1.43 #include <Pegasus/ProviderManager2/CMPI/CMPIClassCache.h>
|
42 schuur 1.1
43 #include <Pegasus/Common/CIMName.h>
44 #include <Pegasus/Common/CIMPropertyList.h>
45 #include <Pegasus/Provider/CIMOMHandle.h>
46 #include <Pegasus/Common/CIMValue.h>
47 #include <Pegasus/Common/CIMType.h>
|
48 r.kieninger 1.53.2.2 #include "CMPISCMOUtilities.h"
|
49 schuur 1.1
50
51 PEGASUS_USING_STD;
52 PEGASUS_NAMESPACE_BEGIN
53
|
54 venkat.puvvada 1.36 static const CMPIUint32 MB_CAPABILITIES =
|
55 venkat.puvvada 1.39 # ifdef CMPI_VER_200
56 CMPI_MB_Supports_Extended_Error |
57 # endif
|
58 venkat.puvvada 1.36 CMPI_MB_BasicRead | CMPI_MB_BasicWrite | CMPI_MB_InstanceManipulation |
59 CMPI_MB_AssociationTraversal | CMPI_MB_QueryNormalization |
60 CMPI_MB_Indications | CMPI_MB_BasicQualifierSupport |
61 CMPI_MB_OSEncapsulationSupport
|
62 venkat.puvvada 1.39 # ifndef PEGASUS_DISABLE_EXECQUERY
|
63 venkat.puvvada 1.36 | CMPI_MB_QueryExecution
64 # endif
65 ;
66
|
67 marek 1.45 #define HandlerCatchSetStatus(rc, returnvalue) \
68 catch (const CIMException &e) \
69 { \
|
70 thilo.boehm 1.48 PEG_TRACE(( \
|
71 marek 1.45 TRC_CMPIPROVIDERINTERFACE, \
|
72 thilo.boehm 1.48 Tracer::LEVEL1, \
73 "CIMException: %s",(const char*)e.getMessage().getCString())); \
|
74 marek 1.45 CMSetStatusWithString( \
75 rc, \
76 (CMPIrc)e.getCode(), \
77 (CMPIString*)string2CMPIString(e.getMessage())); \
78 PEG_METHOD_EXIT(); \
79 return returnvalue; \
80 } \
81 catch (const Exception &e) \
82 { \
83 PEG_TRACE(( \
84 TRC_CMPIPROVIDERINTERFACE, \
85 Tracer::LEVEL2, \
86 "Exception: %s", (const char *)e.getMessage().getCString())); \
87 CMSetStatusWithString( \
88 rc, \
89 (CMPIrc)CMPI_RC_ERROR_SYSTEM, \
90 (CMPIString*)string2CMPIString(e.getMessage())); \
91 PEG_METHOD_EXIT(); \
92 return returnvalue; \
93 } \
94 catch (...) \
95 marek 1.45 { \
96 PEG_TRACE(( \
97 TRC_CMPIPROVIDERINTERFACE, \
98 Tracer::LEVEL2, \
99 "Unknown exception")); \
100 CMSetStatusWithString( \
101 rc, \
102 (CMPIrc)CMPI_RC_ERROR_SYSTEM, \
103 (CMPIString*)string2CMPIString("Unknown exception")); \
104 PEG_METHOD_EXIT(); \
105 return returnvalue; \
106 }
107
108 #define HandlerCatchReturnStatus() \
109 catch (const CIMException &e) \
110 { \
|
111 thilo.boehm 1.48 PEG_TRACE(( \
|
112 marek 1.45 TRC_CMPIPROVIDERINTERFACE, \
113 Tracer::LEVEL2, \
|
114 thilo.boehm 1.48 "CIMException: %s",(const char*)e.getMessage().getCString())); \
|
115 marek 1.45 PEG_METHOD_EXIT(); \
116 CMReturnWithString( \
117 (CMPIrc)e.getCode(), \
118 (CMPIString*)string2CMPIString(e.getMessage())); \
119 } \
120 catch (const Exception &e) \
121 { \
122 PEG_TRACE(( \
123 TRC_CMPIPROVIDERINTERFACE, \
124 Tracer::LEVEL2, \
125 "Exception: %s", (const char *)e.getMessage().getCString())); \
126 PEG_METHOD_EXIT(); \
127 CMReturnWithString( \
128 (CMPIrc)CMPI_RC_ERROR_SYSTEM, \
129 (CMPIString*)string2CMPIString(e.getMessage())); \
130 } \
131 catch (...) \
132 { \
133 PEG_TRACE(( \
134 TRC_CMPIPROVIDERINTERFACE, \
135 Tracer::LEVEL2, \
136 marek 1.45 "Unknown exception")); \
137 PEG_METHOD_EXIT(); \
138 CMReturnWithString( \
139 (CMPIrc)CMPI_RC_ERROR_SYSTEM, \
140 (CMPIString*)string2CMPIString("Unknown exception")); \
141 }
142
|
143 venkat.puvvada 1.39 static CIMPropertyList getList(const char** l)
144 {
145 CIMPropertyList pl;
146 if (l)
147 {
148 Array<CIMName> n;
149 while (*l)
150 {
151 n.append(*l++);
152 }
153 pl.set(n);
154 }
155 return pl;
|
156 schuur 1.1 }
157
|
158 venkat.puvvada 1.39 CIMClass* mbGetClass(const CMPIBroker *mb, const CIMObjectPath &cop)
159 {
|
160 ms.aruran 1.42 PEG_METHOD_ENTER(TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbGetClass()");
161
162 mb=CM_BROKER;
163 CMPI_Broker *xBroker=(CMPI_Broker*)mb;
|
164 marek 1.43 CIMClass * ccp = xBroker->classCache.getClass(xBroker, cop);
|
165 ms.aruran 1.42 PEG_METHOD_EXIT();
|
166 marek 1.43 return ccp;
|
167 schuur 1.1 }
168
|
169 r.kieninger 1.53.2.2 SCMOClass* mbGetSCMOClass(
170 const CMPIBroker *mb,
171 const char* nameSpace,
172 const char* cls)
|
173 r.kieninger 1.53.2.1 {
174 PEG_METHOD_ENTER(TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbGetSCMOClass()");
175
176 mb=CM_BROKER;
177 CMPI_Broker *xBroker=(CMPI_Broker*)mb;
|
178 r.kieninger 1.53.2.2
179 const char* ns=nameSpace;
180 if (0==ns || 0==*ns)
181 {
182 //If we don't have a namespace here, we use the initnamespace from
183 // the thread context, since we need one to be able to lookup the class
184 const CMPIContext* ctx = CMPI_ThreadContext::getContext();
185 if (0!=ctx)
186 {
187 CMPIStatus rc;
188 CMPIData nsCtxData = CMGetContextEntry(ctx, CMPIInitNameSpace,&rc);
189 if (rc.rc == CMPI_RC_OK)
190 {
191 ns = CMGetCharsPtr(nsCtxData.value.string, 0);
192 }
193 }
194
195 }
196
197
|
198 r.kieninger 1.53.2.1 SCMOClass* scmoCls = xBroker->classCache.getSCMOClass(xBroker, ns, cls);
|
199 r.kieninger 1.53.2.2
|
200 r.kieninger 1.53.2.1 PEG_METHOD_EXIT();
201 return scmoCls;
202 }
203
|
204 venkat.puvvada 1.39 extern "C"
205 {
|
206 schuur 1.1
|
207 venkat.puvvada 1.39 static CMPIInstance* mbGetInstance(
208 const CMPIBroker *mb,
209 const CMPIContext *ctx,
210 const CMPIObjectPath *cop,
211 const char **properties,
212 CMPIStatus *rc)
213 {
|
214 ms.aruran 1.42 PEG_METHOD_ENTER(
215 TRC_CMPIPROVIDERINTERFACE,
216 "CMPI_Broker:mbGetInstance()");
217
|
218 venkat.puvvada 1.39 mb = CM_BROKER;
219 CMPIFlags flgs =
220 ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
221 const CIMPropertyList props = getList(properties);
|
222 r.kieninger 1.53.2.2
223 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
224 CIMObjectPath qop;
|
225 venkat.puvvada 1.39 try
226 {
|
227 r.kieninger 1.53.2.4 scmoObjPath->getCIMObjectPath(qop);
228
229 CIMResponseData resData = CM_CIMOM(mb)->getInstance(
|
230 marek 1.53 *CM_Context(ctx),
|
231 r.kieninger 1.53.2.2 scmoObjPath->getNameSpace(),
232 qop,
|
233 venkat.puvvada 1.39 CM_IncludeQualifiers(flgs),
234 CM_ClassOrigin(flgs),
235 props);
236
|
237 r.kieninger 1.53.2.4 SCMOInstance& scmoOrgInst = resData.getSCMO()[0];
238
239 SCMOInstance* scmoInst = new SCMOInstance(scmoOrgInst);
240
241 // Rebuild the objectPath
242 if (0==scmoInst->getNameSpace())
243 {
244 scmoInst->setNameSpace(scmoObjPath->getNameSpace());
245 }
246 if (0==scmoInst->getClassName())
247 {
248 scmoInst->setClassName(scmoObjPath->getClassName());
249 }
250 scmoInst->buildKeyBindingsFromProperties();
251
|
252 ms.aruran 1.42 CMPIInstance* cmpiInst = reinterpret_cast<CMPIInstance*>(
|
253 r.kieninger 1.53.2.4 new CMPI_Object(scmoInst,CMPI_Object::ObjectTypeInstance));
254
255 CMSetStatus(rc,CMPI_RC_OK);
|
256 ms.aruran 1.42 PEG_METHOD_EXIT();
257 return cmpiInst;
|
258 venkat.puvvada 1.39 }
|
259 marek 1.45 HandlerCatchSetStatus(rc, NULL);
260
|
261 venkat.puvvada 1.39 // Code flow should never get here.
262 }
263
264 static CMPIObjectPath* mbCreateInstance(
265 const CMPIBroker *mb,
266 const CMPIContext *ctx,
267 const CMPIObjectPath *cop,
268 const CMPIInstance *ci,
269 CMPIStatus *rc)
270 {
|
271 ms.aruran 1.42 PEG_METHOD_ENTER(
272 TRC_CMPIPROVIDERINTERFACE,
273 "CMPI_Broker:mbCreateInstance()");
274
|
275 venkat.puvvada 1.39 mb = CM_BROKER;
276
|
277 r.kieninger 1.53.2.2 SCMOInstance* scmoInst = SCMO_Instance(ci);
278 CIMInstance inst;
|
279 venkat.puvvada 1.39 try
280 {
|
281 r.kieninger 1.53.2.4 scmoInst->getCIMInstance(inst);
282
|
283 venkat.puvvada 1.39 CIMObjectPath ncop = CM_CIMOM(mb)->createInstance(
|
284 marek 1.53 *CM_Context(ctx),
|
285 r.kieninger 1.53.2.2 scmoInst->getNameSpace(),
286 inst);
287
288 SCMOInstance* newScmoInst=
289 CMPISCMOUtilities::getSCMOFromCIMObjectPath(
|
290 marek 1.53.2.3 ncop,
|
291 r.kieninger 1.53.2.2 scmoInst->getNameSpace());
292
|
293 ms.aruran 1.42 CMPIObjectPath* cmpiObjPath = reinterpret_cast<CMPIObjectPath*>(
|
294 r.kieninger 1.53.2.4 new CMPI_Object(newScmoInst,CMPI_Object::ObjectTypeObjectPath));
295
296 CMSetStatus(rc,CMPI_RC_OK);
|
297 ms.aruran 1.42 PEG_METHOD_EXIT();
298 return cmpiObjPath;
|
299 venkat.puvvada 1.39 }
|
300 marek 1.45 HandlerCatchSetStatus(rc, NULL);
301
|
302 venkat.puvvada 1.39 // Code flow should never get here.
303 }
304
305 static CMPIStatus mbModifyInstance(
306 const CMPIBroker *mb,
307 const CMPIContext *ctx,
308 const CMPIObjectPath *cop,
309 const CMPIInstance *ci,
310 const char ** properties)
311 {
|
312 ms.aruran 1.42 PEG_METHOD_ENTER(
313 TRC_CMPIPROVIDERINTERFACE,
314 "CMPI_Broker:mbModifyInstance()");
|
315 venkat.puvvada 1.39 mb = CM_BROKER;
316 CMPIFlags flgs =
317 ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
318 const CIMPropertyList props = getList(properties);
319
|
320 r.kieninger 1.53.2.2 SCMOInstance* scmoInst = SCMO_Instance(ci);
321 CIMInstance inst;
|
322 venkat.puvvada 1.39 try
323 {
|
324 r.kieninger 1.53.2.4 scmoInst->getCIMInstance(inst);
325
|
326 venkat.puvvada 1.39 CM_CIMOM(mb)->modifyInstance(
|
327 marek 1.53 *CM_Context(ctx),
|
328 r.kieninger 1.53.2.2 SCMO_ObjectPath(cop)->getNameSpace(),
329 inst,
|
330 venkat.puvvada 1.39 CM_IncludeQualifiers(flgs),
331 props);
332 }
|
333 marek 1.45 HandlerCatchReturnStatus();
334
|
335 ms.aruran 1.42 PEG_METHOD_EXIT();
|
336 venkat.puvvada 1.39 CMReturn(CMPI_RC_OK);
337 }
338
339 static CMPIStatus mbDeleteInstance(
340 const CMPIBroker *mb,
341 const CMPIContext *ctx,
342 const CMPIObjectPath *cop)
343 {
|
344 ms.aruran 1.42 PEG_METHOD_ENTER(
345 TRC_CMPIPROVIDERINTERFACE,
346 "CMPI_Broker:mbDeleteInstance()");
|
347 venkat.puvvada 1.39 mb = CM_BROKER;
|
348 r.kieninger 1.53.2.2
349 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
350 CIMObjectPath qop;
|
351 venkat.puvvada 1.39 try
352 {
|
353 r.kieninger 1.53.2.4 scmoObjPath->getCIMObjectPath(qop);
354
|
355 venkat.puvvada 1.39 CM_CIMOM(mb)->deleteInstance(
|
356 marek 1.53 *CM_Context(ctx),
|
357 r.kieninger 1.53.2.2 SCMO_ObjectPath(cop)->getNameSpace(),
358 qop);
|
359 venkat.puvvada 1.39 }
|
360 marek 1.45 HandlerCatchReturnStatus();
361
|
362 ms.aruran 1.42 PEG_METHOD_EXIT();
|
363 venkat.puvvada 1.39 CMReturn(CMPI_RC_OK);
364 }
365
366 static CMPIEnumeration* mbExecQuery(
367 const CMPIBroker *mb,
368 const CMPIContext *ctx,
369 const CMPIObjectPath *cop,
370 const char *query, const char *lang, CMPIStatus *rc)
371 {
|
372 ms.aruran 1.42 PEG_METHOD_ENTER(
373 TRC_CMPIPROVIDERINTERFACE,
374 "CMPI_Broker:mbExecQuery()");
|
375 venkat.puvvada 1.39 mb = CM_BROKER;
376
377 try
378 {
|
379 r.kieninger 1.53.2.4 CIMResponseData resData = CM_CIMOM(mb)->execQuery(
|
380 marek 1.53 *CM_Context(ctx),
|
381 r.kieninger 1.53.2.2 SCMO_ObjectPath(cop)->getNameSpace(),
|
382 venkat.puvvada 1.39 String(lang),
383 String(query));
384
|
385 r.kieninger 1.53.2.2
|
386 r.kieninger 1.53.2.4 Array<SCMOInstance>* aObj =
387 new Array<SCMOInstance>(resData.getSCMO());
388
|
389 r.kieninger 1.53.2.2
390 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
391 new CMPI_Object(new CMPI_ObjEnumeration(aObj)));
392
|
393 r.kieninger 1.53.2.4 CMSetStatus(rc,CMPI_RC_OK);
|
394 ms.aruran 1.42 PEG_METHOD_EXIT();
395 return cmpiEnum;
|
396 venkat.puvvada 1.39 }
|
397 marek 1.45 HandlerCatchSetStatus(rc, NULL);
398
|
399 venkat.puvvada 1.39 // Code flow should never get here.
400 }
401
402 static CMPIEnumeration* mbEnumInstances(
403 const CMPIBroker *mb,
404 const CMPIContext *ctx,
405 const CMPIObjectPath *cop,
406 const char **properties,
407 CMPIStatus *rc)
408 {
|
409 ms.aruran 1.42 PEG_METHOD_ENTER(
410 TRC_CMPIPROVIDERINTERFACE,
411 "CMPI_Broker:mbEnumInstances()");
|
412 venkat.puvvada 1.39 mb = CM_BROKER;
413
414 CMPIFlags flgs =
415 ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
416 const CIMPropertyList props = getList(properties);
417
418 try
419 {
|
420 r.kieninger 1.53.2.4 CIMResponseData resData =
|
421 venkat.puvvada 1.39 CM_CIMOM(mb)->enumerateInstances(
|
422 marek 1.53 *CM_Context(ctx),
|
423 r.kieninger 1.53.2.2 SCMO_ObjectPath(cop)->getNameSpace(),
424 SCMO_ObjectPath(cop)->getClassName(),
|
425 venkat.puvvada 1.39 CM_DeepInheritance(flgs),
426 CM_IncludeQualifiers(flgs),
427 CM_ClassOrigin(flgs),
428 props);
429
430 // When running out of process the returned instances don't contain
|
431 r.kieninger 1.53.2.4 // a namespace.
432 // Add the namespace from the input parameters where neccessary
433 resData.completeNamespace(SCMO_ObjectPath(cop));
|
434 venkat.puvvada 1.39
|
435 r.kieninger 1.53.2.4 Array<SCMOInstance>* aInst =
436 new Array<SCMOInstance>(resData.getSCMO());
|
437 venkat.puvvada 1.39
|
438 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
439 venkat.puvvada 1.39 new CMPI_Object(new CMPI_InstEnumeration(aInst)));
|
440 r.kieninger 1.53.2.4
441 CMSetStatus(rc,CMPI_RC_OK);
|
442 ms.aruran 1.42 PEG_METHOD_EXIT();
443 return cmpiEnum;
|
444 venkat.puvvada 1.39 }
|
445 marek 1.45 HandlerCatchSetStatus(rc, NULL);
446
|
447 venkat.puvvada 1.39 // Code flow should never get here.
448 }
449
450 static CMPIEnumeration* mbEnumInstanceNames(
451 const CMPIBroker *mb,
452 const CMPIContext *ctx,
453 const CMPIObjectPath *cop,
454 CMPIStatus *rc)
455 {
|
456 ms.aruran 1.42 PEG_METHOD_ENTER(
457 TRC_CMPIPROVIDERINTERFACE,
458 "CMPI_Broker:mbEnumInstanceNames()");
|
459 venkat.puvvada 1.39 mb = CM_BROKER;
460
461 try
462 {
|
463 r.kieninger 1.53.2.4 CIMResponseData resData =
|
464 venkat.puvvada 1.39 CM_CIMOM(mb)->enumerateInstanceNames(
|
465 marek 1.53 *CM_Context(ctx),
|
466 r.kieninger 1.53.2.2 SCMO_ObjectPath(cop)->getNameSpace(),
467 SCMO_ObjectPath(cop)->getClassName());
|
468 venkat.puvvada 1.39
469 // When running out of process the returned instances don't contain
|
470 r.kieninger 1.53.2.4 // a namespace.
471 // Add the namespace from the input parameters where neccessary
472 resData.completeNamespace(SCMO_ObjectPath(cop));
473
474 Array<SCMOInstance>* aRef =
475 new Array<SCMOInstance>(resData.getSCMO());
476
477
|
478 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
479 venkat.puvvada 1.49 new CMPI_Object(new CMPI_OpEnumeration(aRef)));
|
480 r.kieninger 1.53.2.4
481 CMSetStatus(rc,CMPI_RC_OK);
|
482 ms.aruran 1.42 PEG_METHOD_EXIT();
483 return cmpiEnum;
|
484 venkat.puvvada 1.39 }
|
485 marek 1.45 HandlerCatchSetStatus(rc, NULL);
486
|
487 venkat.puvvada 1.39 // Code flow should never get here.
488 }
489
490 static CMPIEnumeration* mbAssociators(
491 const CMPIBroker *mb,
492 const CMPIContext *ctx,
493 const CMPIObjectPath *cop,
494 const char *assocClass,
495 const char *resultClass,
496 const char *role,
497 const char *resultRole,
498 const char **properties,
499 CMPIStatus *rc)
500 {
|
501 ms.aruran 1.42 PEG_METHOD_ENTER(
502 TRC_CMPIPROVIDERINTERFACE,
503 "CMPI_Broker:mbAssociators()");
|
504 venkat.puvvada 1.39 mb = CM_BROKER;
|
505 dave.sudlik 1.41 // ATTN-CAKG-P2-20020726: The following condition does not correctly
506 // distinguish instanceNames from classNames in every case
507 // The instanceName of a singleton instance of a keyless class has no
508 // key bindings
|
509 r.kieninger 1.53.2.2 if (!SCMO_ObjectPath(cop)->getKeyBindingCount())
|
510 dave.sudlik 1.41 {
511 CMSetStatus(rc, CMPI_RC_ERR_FAILED);
|
512 ms.aruran 1.42 PEG_METHOD_EXIT();
|
513 dave.sudlik 1.41 return 0;
514 }
|
515 venkat.puvvada 1.39 CMPIFlags flgs =
516 ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
517 const CIMPropertyList props = getList(properties);
|
518 r.kieninger 1.53.2.2
519 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
520 CIMObjectPath qop;
|
521 venkat.puvvada 1.39 try
522 {
|
523 r.kieninger 1.53.2.4 scmoObjPath->getCIMObjectPath(qop);
524
525 CIMResponseData resData =
|
526 venkat.puvvada 1.39 CM_CIMOM(mb)->associators(
|
527 marek 1.53 *CM_Context(ctx),
|
528 r.kieninger 1.53.2.2 SCMO_ObjectPath(cop)->getNameSpace(),
|
529 venkat.puvvada 1.39 qop,
530 assocClass ? CIMName(assocClass) : CIMName(),
531 resultClass ? CIMName(resultClass) : CIMName(),
532 role ? String(role) : String::EMPTY,
533 resultRole ? String(resultRole) : String::EMPTY,
534 CM_IncludeQualifiers(flgs),
535 CM_ClassOrigin(flgs),
536 props);
537
538 // When running out of process the returned instances don't contain
|
539 r.kieninger 1.53.2.4 // a namespace.
540 // Add the namespace from the input parameters where neccessary
541 resData.completeNamespace(scmoObjPath);
542
543 Array<SCMOInstance>* aObj =
544 new Array<SCMOInstance>(resData.getSCMO());
|
545 venkat.puvvada 1.49
|
546 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
547 venkat.puvvada 1.49 new CMPI_Object(new CMPI_ObjEnumeration(aObj)));
|
548 r.kieninger 1.53.2.4
549 CMSetStatus(rc,CMPI_RC_OK);
|
550 ms.aruran 1.42 PEG_METHOD_EXIT();
551 return cmpiEnum;
|
552 venkat.puvvada 1.39 }
|
553 marek 1.45 HandlerCatchSetStatus(rc, NULL);
554
|
555 venkat.puvvada 1.39 // Code flow should never get here.
556 }
557
558 static CMPIEnumeration* mbAssociatorNames(
559 const CMPIBroker *mb,
560 const CMPIContext *ctx,
561 const CMPIObjectPath *cop,
562 const char *assocClass,
563 const char *resultClass,
564 const char *role,
565 const char *resultRole,
566 CMPIStatus *rc)
567 {
|
568 ms.aruran 1.42 PEG_METHOD_ENTER(
569 TRC_CMPIPROVIDERINTERFACE,
570 "CMPI_Broker:mbAssociatorNames()");
|
571 venkat.puvvada 1.39 mb = CM_BROKER;
|
572 dave.sudlik 1.41 // ATTN-CAKG-P2-20020726: The following condition does not correctly
573 // distinguish instanceNames from classNames in every case
574 // The instanceName of a singleton instance of a keyless class has no
575 // key bindings
|
576 r.kieninger 1.53.2.2 if (!SCMO_ObjectPath(cop)->getKeyBindingCount())
|
577 dave.sudlik 1.41 {
578 CMSetStatus(rc, CMPI_RC_ERR_FAILED);
|
579 ms.aruran 1.42 PEG_METHOD_EXIT();
|
580 dave.sudlik 1.41 return 0;
581 }
|
582 r.kieninger 1.53.2.2
583 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
584 CIMObjectPath qop;
|
585 venkat.puvvada 1.39 try
586 {
|
587 r.kieninger 1.53.2.4 scmoObjPath->getCIMObjectPath(qop);
588
589 CIMResponseData resData =
|
590 venkat.puvvada 1.39 CM_CIMOM(mb)->associatorNames(
|
591 marek 1.53 *CM_Context(ctx),
|
592 r.kieninger 1.53.2.2 scmoObjPath->getNameSpace(),
|
593 venkat.puvvada 1.39 qop,
594 assocClass ? CIMName(assocClass) : CIMName(),
595 resultClass ? CIMName(resultClass) : CIMName(),
596 role ? String(role) : String::EMPTY,
597 resultRole ? String(resultRole) : String::EMPTY);
598
599 // When running out of process the returned instances don't contain
|
600 r.kieninger 1.53.2.4 // a namespace.
601 // Add the namespace from the input parameters where neccessary
602 resData.completeNamespace(scmoObjPath);
603
604 Array<SCMOInstance>* aRef =
605 new Array<SCMOInstance>(resData.getSCMO());
606
|
607 venkat.puvvada 1.49
|
608 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
609 venkat.puvvada 1.49 new CMPI_Object(new CMPI_OpEnumeration(aRef)));
|
610 r.kieninger 1.53.2.4
611 CMSetStatus(rc,CMPI_RC_OK);
|
612 ms.aruran 1.42 PEG_METHOD_EXIT();
613 return cmpiEnum;
|
614 venkat.puvvada 1.39 }
|
615 marek 1.45 HandlerCatchSetStatus(rc, NULL);
616
|
617 venkat.puvvada 1.39 // Code flow should never get here.
618 }
619
620 static CMPIEnumeration* mbReferences(
621 const CMPIBroker *mb,
622 const CMPIContext *ctx,
623 const CMPIObjectPath *cop,
624 const char *resultClass,
625 const char *role ,
626 const char **properties,
627 CMPIStatus *rc)
628 {
|
629 ms.aruran 1.42 PEG_METHOD_ENTER(
630 TRC_CMPIPROVIDERINTERFACE,
631 "CMPI_Broker:mbReferences()");
|
632 venkat.puvvada 1.39 mb = CM_BROKER;
|
633 dave.sudlik 1.41 // ATTN-CAKG-P2-20020726: The following condition does not correctly
634 // distinguish instanceNames from classNames in every case
635 // The instanceName of a singleton instance of a keyless class has no
636 // key bindings
|
637 r.kieninger 1.53.2.2 if (!SCMO_ObjectPath(cop)->getKeyBindingCount())
|
638 dave.sudlik 1.41 {
639 CMSetStatus(rc, CMPI_RC_ERR_FAILED);
|
640 ms.aruran 1.42 PEG_METHOD_EXIT();
|
641 dave.sudlik 1.41 return 0;
642 }
|
643 venkat.puvvada 1.39 CMPIFlags flgs =
644 ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
645 CIMPropertyList props = getList(properties);
|
646 r.kieninger 1.53.2.2
647
648 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
649 CIMObjectPath qop;
|
650 venkat.puvvada 1.39 try
651 {
|
652 r.kieninger 1.53.2.4 scmoObjPath->getCIMObjectPath(qop);
653
654 CIMResponseData resData =
|
655 venkat.puvvada 1.39 CM_CIMOM(mb)->references(
|
656 marek 1.53 *CM_Context(ctx),
|
657 r.kieninger 1.53.2.2 scmoObjPath->getNameSpace(),
|
658 venkat.puvvada 1.39 qop,
659 resultClass ? CIMName(resultClass) : CIMName(),
660 role ? String(role) : String::EMPTY,
661 CM_IncludeQualifiers(flgs),
662 CM_ClassOrigin(flgs),
663 props);
664
665 CMSetStatus(rc,CMPI_RC_OK);
|
666 r.kieninger 1.53.2.4
667 // Add the namespace from the input parameters when neccessary
668 resData.completeNamespace(scmoObjPath);
669
670 Array<SCMOInstance>* aObj =
671 new Array<SCMOInstance>(resData.getSCMO());
|
672 venkat.puvvada 1.49
|
673 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
674 venkat.puvvada 1.49 new CMPI_Object(new CMPI_ObjEnumeration(aObj)));
|
675 ms.aruran 1.42 PEG_METHOD_EXIT();
676 return cmpiEnum;
|
677 venkat.puvvada 1.39 }
|
678 marek 1.45 HandlerCatchSetStatus(rc, NULL);
679
|
680 venkat.puvvada 1.39 // Code flow should never get here.
681 }
682
683 static CMPIEnumeration* mbReferenceNames(
684 const CMPIBroker *mb,
685 const CMPIContext *ctx,
686 const CMPIObjectPath *cop,
687 const char *resultClass,
688 const char *role,
689 CMPIStatus *rc)
690 {
|
691 ms.aruran 1.42 PEG_METHOD_ENTER(
692 TRC_CMPIPROVIDERINTERFACE,
693 "CMPI_Broker:mbReferenceNames()");
|
694 venkat.puvvada 1.39 mb = CM_BROKER;
|
695 dave.sudlik 1.41 // ATTN-CAKG-P2-20020726: The following condition does not correctly
696 // distinguish instanceNames from classNames in every case
697 // The instanceName of a singleton instance of a keyless class has no
698 // key bindings
|
699 r.kieninger 1.53.2.2 if (!SCMO_ObjectPath(cop)->getKeyBindingCount())
|
700 dave.sudlik 1.41 {
701 CMSetStatus(rc, CMPI_RC_ERR_FAILED);
|
702 ms.aruran 1.42 PEG_METHOD_EXIT();
|
703 dave.sudlik 1.41 return 0;
704 }
|
705 r.kieninger 1.53.2.2
706 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
707 CIMObjectPath qop;
|
708 venkat.puvvada 1.39 try
709 {
|
710 r.kieninger 1.53.2.4 scmoObjPath->getCIMObjectPath(qop);
711
712 CIMResponseData resData =
|
713 venkat.puvvada 1.39 CM_CIMOM(mb)->referenceNames(
|
714 marek 1.53 *CM_Context(ctx),
|
715 r.kieninger 1.53.2.2 scmoObjPath->getNameSpace(),
|
716 venkat.puvvada 1.39 qop,
717 resultClass ? CIMName(resultClass) : CIMName(),
718 role ? String(role) : String::EMPTY);
719
|
720 r.kieninger 1.53.2.4 // Add the namespace from the input parameters when neccessary
721 resData.completeNamespace(scmoObjPath);
722
723 Array<SCMOInstance>* aRef =
724 new Array<SCMOInstance>(resData.getSCMO());
|
725 venkat.puvvada 1.49
|
726 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
727 venkat.puvvada 1.49 new CMPI_Object(new CMPI_OpEnumeration(aRef)));
|
728 r.kieninger 1.53.2.4 CMSetStatus(rc,CMPI_RC_OK);
|
729 ms.aruran 1.42 PEG_METHOD_EXIT();
730 return cmpiEnum;
|
731 venkat.puvvada 1.39 }
|
732 marek 1.45 HandlerCatchSetStatus(rc, NULL);
733
|
734 venkat.puvvada 1.39 // Code flow should never get here.
735 }
|
736 schuur 1.1
|
737 r.kieninger 1.29 #define CM_Args(args) ((Array<CIMParamValue>*)args->hdl)
738
|
739 venkat.puvvada 1.39 static CMPIData mbInvokeMethod(
740 const CMPIBroker *mb,
741 const CMPIContext *ctx,
742 const CMPIObjectPath *cop,
743 const char *method,
744 const CMPIArgs *in,
745 CMPIArgs *out,
746 CMPIStatus *rc)
747 {
|
748 ms.aruran 1.42 PEG_METHOD_ENTER(
749 TRC_CMPIPROVIDERINTERFACE,
750 "CMPI_Broker:mbInvokeMethod()");
|
751 venkat.puvvada 1.39 CMPIData data = {0,CMPI_nullValue,{0}};
752 mb = CM_BROKER;
|
753 r.kieninger 1.53.2.2
754
755 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
756 CIMObjectPath qop;
|
757 venkat.puvvada 1.39 try
758 {
|
759 r.kieninger 1.53.2.4 scmoObjPath->getCIMObjectPath(qop);
760
|
761 venkat.puvvada 1.39 CIMValue v = CM_CIMOM(mb)->invokeMethod(
|
762 marek 1.53 *CM_Context(ctx),
|
763 r.kieninger 1.53.2.2 SCMO_ObjectPath(cop)->getNameSpace(),
|
764 venkat.puvvada 1.39 qop,
765 method ? String(method) : String::EMPTY,
766 *CM_Args(in),
767 *CM_Args(out));
768 CIMType vType=v.getType();
769 CMPIType t = type2CMPIType(vType,v.isArray());
770 value2CMPIData(v,t,&data);
771 if (rc)
772 {
773 CMSetStatus(rc,CMPI_RC_OK);
774 }
775 }
|
776 marek 1.45 HandlerCatchSetStatus(rc, data);
777
|
778 ms.aruran 1.42 PEG_METHOD_EXIT();
|
779 venkat.puvvada 1.39 return data; // "data" will be valid data or nullValue (in error case)
780 }
781
782 static CMPIStatus mbSetProperty(
783 const CMPIBroker *mb,
784 const CMPIContext *ctx,
785 const CMPIObjectPath *cop,
786 const char *name,
787 const CMPIValue *val,
788 CMPIType type)
789 {
|
790 ms.aruran 1.42 PEG_METHOD_ENTER(
791 TRC_CMPIPROVIDERINTERFACE,
792 "CMPI_Broker:mbSetProperty()");
|
793 venkat.puvvada 1.39 mb = CM_BROKER;
794 CMPIrc rc;
795 CIMValue v = value2CIMValue(val,type,&rc);
796
|
797 r.kieninger 1.53.2.2 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
798 CIMObjectPath qop;
|
799 venkat.puvvada 1.39 try
800 {
|
801 r.kieninger 1.53.2.4 scmoObjPath->getCIMObjectPath(qop);
802
|
803 venkat.puvvada 1.39 CM_CIMOM(mb)->setProperty(
|
804 marek 1.53 *CM_Context(ctx),
|
805 r.kieninger 1.53.2.2 SCMO_ObjectPath(cop)->getNameSpace(),
806 qop,
|
807 venkat.puvvada 1.39 String(name),
808 v);
809 }
|
810 marek 1.45 HandlerCatchReturnStatus();
811
|
812 ms.aruran 1.42 PEG_METHOD_EXIT();
|
813 venkat.puvvada 1.39 CMReturn(CMPI_RC_OK);
814 }
815
816 static CMPIData mbGetProperty(
817 const CMPIBroker *mb,
818 const CMPIContext *ctx,
819 const CMPIObjectPath *cop,
820 const char *name,
821 CMPIStatus *rc)
822 {
|
823 ms.aruran 1.42 PEG_METHOD_ENTER(
824 TRC_CMPIPROVIDERINTERFACE,
825 "CMPI_Broker:mbGetProperty()");
|
826 venkat.puvvada 1.39 mb = CM_BROKER;
827 CMPIData data = {0,CMPI_nullValue,{0}};
828
|
829 r.kieninger 1.53.2.2 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
830 CIMObjectPath qop;
831 scmoObjPath->getCIMObjectPath(qop);
832
|
833 venkat.puvvada 1.39 try
834 {
835 CIMValue v = CM_CIMOM(mb)->getProperty(
|
836 marek 1.53 *CM_Context(ctx),
|
837 r.kieninger 1.53.2.2 SCMO_ObjectPath(cop)->getNameSpace(),
838 qop,
|
839 venkat.puvvada 1.39 String(name));
840 CIMType vType = v.getType();
841 CMPIType t = type2CMPIType(vType,v.isArray());
842 value2CMPIData(v,t,&data);
843 CMSetStatus(rc,CMPI_RC_OK);
844 }
|
845 marek 1.45 HandlerCatchSetStatus(rc, data);
846
|
847 ms.aruran 1.42 PEG_METHOD_EXIT();
|
848 venkat.puvvada 1.39 return data; // "data" will be valid data or nullValue (in error case)
849 }
850
|
851 marek 1.53.2.3 /* With Bug#8541 the CMPI Provider Manager was changed to attach the
|
852 marek 1.53 complete requests operation context to the CMPI thread context.
853 In future, when we have a lot more containers on the operation context,
854 this might lead to an impact on memory usage here, when the entire
855 operation context gets copied to the new thread.
856 */
|
857 venkat.puvvada 1.39 static CMPIContext* mbPrepareAttachThread(
858 const CMPIBroker* mb,
859 const CMPIContext* eCtx)
860 {
|
861 ms.aruran 1.42 PEG_METHOD_ENTER(
862 TRC_CMPIPROVIDERINTERFACE,
863 "CMPI_Broker:mbPrepareAttachThread()");
|
864 venkat.puvvada 1.39 mb = CM_BROKER;
865 OperationContext *ctx = (OperationContext*)((CMPI_Context*)eCtx)->ctx;
866 OperationContext nctx = *ctx;
867 CMPIContext* neCtx = new CMPI_Context(*(new OperationContext(nctx)));
868 CMPIString *name;
869 for (int i=0,s=CMPI_Args_Ftab->getArgCount(
870 reinterpret_cast<const CMPIArgs*>(eCtx),NULL); i<s; i++)
871 {
872 CMPIData data = CMPI_Args_Ftab->getArgAt(
873 reinterpret_cast<const CMPIArgs*>(eCtx),i,&name,NULL);
874 CMPI_Args_Ftab->addArg(
875 reinterpret_cast<CMPIArgs*>(neCtx),
|
876 s.kodali 1.47 CMGetCharsPtr(name,NULL),
|
877 venkat.puvvada 1.39 &data.value,data.type);
878 }
|
879 ms.aruran 1.42 PEG_METHOD_EXIT();
|
880 venkat.puvvada 1.39 return neCtx;
881 }
882
883 static CMPIStatus mbAttachThread(
884 const CMPIBroker* mb,
885 const CMPIContext* eCtx)
886 {
887 ((CMPI_Context*)eCtx)->thr = new CMPI_ThreadContext(mb,eCtx);
888 CMReturn(CMPI_RC_OK);
889 }
890
891 static CMPIStatus mbDetachThread(
892 const CMPIBroker* mb,
893 const CMPIContext* eCtx)
894 {
895 mb = CM_BROKER;
896 CMPI_Context *neCtx = (CMPI_Context *)eCtx;
897 delete neCtx->thr;
898 // Delete also CMPIContext
899 delete neCtx;
900 CMReturn(CMPI_RC_OK);
901 venkat.puvvada 1.39 }
|
902 schuur 1.11
|
903 venkat.puvvada 1.39 static CMPIStatus mbDeliverIndication(
|
904 ms.aruran 1.42 const CMPIBroker* eMb,
905 const CMPIContext* ctx,
906 const char *ns,
907 const CMPIInstance* ind)
908 {
909 PEG_METHOD_ENTER(
910 TRC_CMPIPROVIDERINTERFACE,
911 "CMPI_Broker:mbDeliverIndication()");
|
912 venkat.puvvada 1.39 eMb = CM_BROKER;
913 CMPI_Broker *mb = (CMPI_Broker*)eMb;
914 CMPIProviderManager::indProvRecord *prec;
915 OperationContext* context = CM_Context(ctx);
|
916 r.kieninger 1.53.2.2
917 SCMOInstance* scmoInst = SCMO_Instance(ind);
918 CIMInstance indInst;
919 scmoInst->getCIMInstance(indInst);
920
|
921 venkat.puvvada 1.39 // When an indication to be delivered comes from Remote providers,
922 // the CMPIBroker contains the name of the provider in the form
923 // of physical-name:logical-name. Search using logical-name. -V 5884
924 String provider_name;
925 CMPIUint32 n;
926
927 if ( (n = mb->name.find(':') ) != PEG_NOT_FOUND)
928 {
929 provider_name = mb->name.subString (n + 1);
930 }
931 else
932 {
933 provider_name = mb->name;
934 }
935 ReadLock readLock(CMPIProviderManager::rwSemProvTab);
936 if (CMPIProviderManager::provTab.lookup(provider_name,prec))
937 {
938 if (prec->enabled)
939 {
940 try
941 {
942 venkat.puvvada 1.39 context->get(SubscriptionInstanceNamesContainer::NAME);
943 }
|
944 ms.aruran 1.42 catch (const Exception &e)
|
945 venkat.puvvada 1.39 {
|
946 thilo.boehm 1.48 PEG_TRACE((TRC_CMPIPROVIDERINTERFACE,Tracer::LEVEL1,
947 "Exception: %s",
948 (const char*)e.getMessage().getCString()));
|
949 venkat.puvvada 1.39 Array<CIMObjectPath> subscriptionInstanceNames;
950 context->insert(
951 SubscriptionInstanceNamesContainer(
952 subscriptionInstanceNames));
953 }
|
954 r.kieninger 1.53.2.2 CIMIndication cimIndication(indInst);
|
955 venkat.puvvada 1.39 try
956 {
957 prec->handler->deliver(
958 *context,
959 // OperationContext(*CM_Context(ctx)),
960 cimIndication);
|
961 ms.aruran 1.42 PEG_METHOD_EXIT();
962 CMReturn(CMPI_RC_OK);
|
963 venkat.puvvada 1.39 }
|
964 marek 1.45 HandlerCatchReturnStatus();
|
965 venkat.puvvada 1.39 }
966 }
|
967 ms.aruran 1.42 PEG_METHOD_EXIT();
|
968 venkat.puvvada 1.39 CMReturn(CMPI_RC_ERR_FAILED);
969 }
|
970 schuur 1.11 }
|
971 schuur 1.1
|
972 venkat.puvvada 1.39 static CMPIBrokerFT broker_FT =
973 {
974 MB_CAPABILITIES, // brokerClassification;
975 CMPICurrentVersion,
976 "Pegasus",
977 mbPrepareAttachThread,
978 mbAttachThread,
979 mbDetachThread,
980 mbDeliverIndication,
981 mbEnumInstanceNames,
982 mbGetInstance,
983 mbCreateInstance,
984 mbModifyInstance,
985 mbDeleteInstance,
986 mbExecQuery,
987 mbEnumInstances,
988 mbAssociators,
989 mbAssociatorNames,
990 mbReferences,
991 mbReferenceNames,
992 mbInvokeMethod,
993 venkat.puvvada 1.39 mbSetProperty,
994 mbGetProperty,
|
995 schuur 1.1 };
996
|
997 venkat.puvvada 1.39 CMPIBrokerFT *CMPI_Broker_Ftab = & broker_FT;
|
998 schuur 1.1
999 PEGASUS_NAMESPACE_END
|