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 thilo.boehm 1.55 #include <Pegasus/ProviderManager2/CMPI/CMPI_ThreadContext.h>
|
43 schuur 1.1
44 #include <Pegasus/Common/CIMName.h>
45 #include <Pegasus/Common/CIMPropertyList.h>
46 #include <Pegasus/Provider/CIMOMHandle.h>
47 #include <Pegasus/Common/CIMValue.h>
48 #include <Pegasus/Common/CIMType.h>
|
49 thilo.boehm 1.55 #include "CMPISCMOUtilities.h"
|
50 schuur 1.1
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 marek 1.45 #define HandlerCatchSetStatus(rc, returnvalue) \
69 catch (const CIMException &e) \
70 { \
|
71 thilo.boehm 1.48 PEG_TRACE(( \
|
72 marek 1.45 TRC_CMPIPROVIDERINTERFACE, \
|
73 thilo.boehm 1.48 Tracer::LEVEL1, \
74 "CIMException: %s",(const char*)e.getMessage().getCString())); \
|
75 marek 1.45 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 rc, \
90 (CMPIrc)CMPI_RC_ERROR_SYSTEM, \
91 (CMPIString*)string2CMPIString(e.getMessage())); \
92 PEG_METHOD_EXIT(); \
93 return returnvalue; \
94 } \
95 catch (...) \
96 marek 1.45 { \
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 catch (const CIMException &e) \
111 { \
|
112 thilo.boehm 1.48 PEG_TRACE(( \
|
113 marek 1.45 TRC_CMPIPROVIDERINTERFACE, \
114 Tracer::LEVEL2, \
|
115 thilo.boehm 1.48 "CIMException: %s",(const char*)e.getMessage().getCString())); \
|
116 marek 1.45 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 } \
132 catch (...) \
133 { \
134 PEG_TRACE(( \
135 TRC_CMPIPROVIDERINTERFACE, \
136 Tracer::LEVEL2, \
137 marek 1.45 "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 thilo.boehm 1.55 SCMOClass* mbGetSCMOClass(
160 const char* nameSpace,
161 Uint32 nsL,
162 const char* cls,
163 Uint32 clsL)
|
164 venkat.puvvada 1.39 {
|
165 thilo.boehm 1.55 PEG_METHOD_ENTER(TRC_CMPIPROVIDERINTERFACE, "CMPI_Broker:mbGetSCMOClass()");
166
167 const CMPIBroker * mb = CMPI_ThreadContext::getBroker();
168 CMPI_Broker *xBroker = (CMPI_Broker*)mb;
169
170 const char* ns=nameSpace;
171 if (0 == nsL)
172 {
173 //If we don't have a namespace here, we use the initnamespace from
174 // the thread context, since we need one to be able to lookup the class
175 const CMPIContext* ctx = CMPI_ThreadContext::getContext();
176 if (0!=ctx)
177 {
178 CMPIStatus rc;
179 CMPIData nsCtxData = CMGetContextEntry(ctx, CMPIInitNameSpace,&rc);
180 if (rc.rc == CMPI_RC_OK)
181 {
182 ns = CMGetCharsPtr(nsCtxData.value.string, 0);
183 nsL = strlen(ns);
184 }
185 }
186 thilo.boehm 1.55
187 }
188
189
190 SCMOClass* scmoCls =
191 xBroker->classCache.getSCMOClass(xBroker, ns, nsL, cls, clsL);
|
192 ms.aruran 1.42
193 PEG_METHOD_EXIT();
|
194 thilo.boehm 1.55 return scmoCls;
|
195 schuur 1.1 }
196
|
197 venkat.puvvada 1.39 extern "C"
198 {
|
199 schuur 1.1
|
200 venkat.puvvada 1.39 static CMPIInstance* mbGetInstance(
201 const CMPIBroker *mb,
202 const CMPIContext *ctx,
203 const CMPIObjectPath *cop,
204 const char **properties,
205 CMPIStatus *rc)
206 {
|
207 ms.aruran 1.42 PEG_METHOD_ENTER(
208 TRC_CMPIPROVIDERINTERFACE,
209 "CMPI_Broker:mbGetInstance()");
210
|
211 venkat.puvvada 1.39 mb = CM_BROKER;
212 CMPIFlags flgs =
213 ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
214 const CIMPropertyList props = getList(properties);
|
215 schuur 1.11
|
216 thilo.boehm 1.55 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
217 CIMObjectPath qop;
|
218 venkat.puvvada 1.39 try
219 {
|
220 thilo.boehm 1.55 scmoObjPath->getCIMObjectPath(qop);
221
222 CIMResponseData resData = CM_CIMOM(mb)->getInstance(
|
223 marek 1.53 *CM_Context(ctx),
|
224 thilo.boehm 1.55 scmoObjPath->getNameSpace(),
225 qop,
|
226 venkat.puvvada 1.39 CM_IncludeQualifiers(flgs),
227 CM_ClassOrigin(flgs),
228 props);
229
|
230 r.kieninger 1.56 // When running out of process the returned instances don't contain
231 // a namespace.
232 // Add the namespace from the input parameters where neccessary
233 resData.completeNamespace(SCMO_ObjectPath(cop));
234
|
235 thilo.boehm 1.55 SCMOInstance& scmoOrgInst = resData.getSCMO()[0];
236
237 SCMOInstance* scmoInst = new SCMOInstance(scmoOrgInst);
238
239 // Rebuild the objectPath
240 scmoInst->buildKeyBindingsFromProperties();
241
242 CMPIInstance* cmpiInst = reinterpret_cast<CMPIInstance*>(
243 new CMPI_Object(scmoInst,CMPI_Object::ObjectTypeInstance));
244
|
245 venkat.puvvada 1.39 CMSetStatus(rc,CMPI_RC_OK);
|
246 ms.aruran 1.42 PEG_METHOD_EXIT();
247 return cmpiInst;
|
248 venkat.puvvada 1.39 }
|
249 marek 1.45 HandlerCatchSetStatus(rc, NULL);
250
|
251 venkat.puvvada 1.39 // Code flow should never get here.
252 }
253
254 static CMPIObjectPath* mbCreateInstance(
255 const CMPIBroker *mb,
256 const CMPIContext *ctx,
257 const CMPIObjectPath *cop,
258 const CMPIInstance *ci,
259 CMPIStatus *rc)
260 {
|
261 ms.aruran 1.42 PEG_METHOD_ENTER(
262 TRC_CMPIPROVIDERINTERFACE,
263 "CMPI_Broker:mbCreateInstance()");
264
|
265 venkat.puvvada 1.39 mb = CM_BROKER;
266
|
267 thilo.boehm 1.55 SCMOInstance* scmoInst = SCMO_Instance(ci);
268 CIMInstance inst;
|
269 venkat.puvvada 1.39 try
270 {
|
271 thilo.boehm 1.55 scmoInst->getCIMInstance(inst);
272
|
273 venkat.puvvada 1.39 CIMObjectPath ncop = CM_CIMOM(mb)->createInstance(
|
274 marek 1.53 *CM_Context(ctx),
|
275 thilo.boehm 1.55 scmoInst->getNameSpace(),
276 inst);
277
278 SCMOInstance* newScmoInst=
279 CMPISCMOUtilities::getSCMOFromCIMObjectPath(
280 ncop,
281 scmoInst->getNameSpace());
282
283 CMPIObjectPath* cmpiObjPath = reinterpret_cast<CMPIObjectPath*>(
284 new CMPI_Object(newScmoInst,CMPI_Object::ObjectTypeObjectPath));
285
|
286 venkat.puvvada 1.39 CMSetStatus(rc,CMPI_RC_OK);
|
287 ms.aruran 1.42 PEG_METHOD_EXIT();
288 return cmpiObjPath;
|
289 venkat.puvvada 1.39 }
|
290 marek 1.45 HandlerCatchSetStatus(rc, NULL);
291
|
292 venkat.puvvada 1.39 // Code flow should never get here.
293 }
294
295 static CMPIStatus mbModifyInstance(
296 const CMPIBroker *mb,
297 const CMPIContext *ctx,
298 const CMPIObjectPath *cop,
299 const CMPIInstance *ci,
300 const char ** properties)
301 {
|
302 ms.aruran 1.42 PEG_METHOD_ENTER(
303 TRC_CMPIPROVIDERINTERFACE,
304 "CMPI_Broker:mbModifyInstance()");
|
305 venkat.puvvada 1.39 mb = CM_BROKER;
306 CMPIFlags flgs =
307 ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
308 const CIMPropertyList props = getList(properties);
309
|
310 thilo.boehm 1.55 SCMOInstance* scmoInst = SCMO_Instance(ci);
311 CIMInstance inst;
|
312 venkat.puvvada 1.39 try
313 {
|
314 thilo.boehm 1.55 scmoInst->getCIMInstance(inst);
315
|
316 venkat.puvvada 1.39 CM_CIMOM(mb)->modifyInstance(
|
317 marek 1.53 *CM_Context(ctx),
|
318 thilo.boehm 1.55 SCMO_ObjectPath(cop)->getNameSpace(),
319 inst,
|
320 venkat.puvvada 1.39 CM_IncludeQualifiers(flgs),
321 props);
322 }
|
323 marek 1.45 HandlerCatchReturnStatus();
324
|
325 ms.aruran 1.42 PEG_METHOD_EXIT();
|
326 venkat.puvvada 1.39 CMReturn(CMPI_RC_OK);
327 }
328
329 static CMPIStatus mbDeleteInstance(
330 const CMPIBroker *mb,
331 const CMPIContext *ctx,
332 const CMPIObjectPath *cop)
333 {
|
334 ms.aruran 1.42 PEG_METHOD_ENTER(
335 TRC_CMPIPROVIDERINTERFACE,
336 "CMPI_Broker:mbDeleteInstance()");
|
337 venkat.puvvada 1.39 mb = CM_BROKER;
|
338 schuur 1.11
|
339 thilo.boehm 1.55 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
340 CIMObjectPath qop;
|
341 venkat.puvvada 1.39 try
342 {
|
343 thilo.boehm 1.55 scmoObjPath->getCIMObjectPath(qop);
344
|
345 venkat.puvvada 1.39 CM_CIMOM(mb)->deleteInstance(
|
346 marek 1.53 *CM_Context(ctx),
|
347 thilo.boehm 1.55 SCMO_ObjectPath(cop)->getNameSpace(),
348 qop);
|
349 venkat.puvvada 1.39 }
|
350 marek 1.45 HandlerCatchReturnStatus();
351
|
352 ms.aruran 1.42 PEG_METHOD_EXIT();
|
353 venkat.puvvada 1.39 CMReturn(CMPI_RC_OK);
354 }
355
356 static CMPIEnumeration* mbExecQuery(
357 const CMPIBroker *mb,
358 const CMPIContext *ctx,
359 const CMPIObjectPath *cop,
360 const char *query, const char *lang, CMPIStatus *rc)
361 {
|
362 ms.aruran 1.42 PEG_METHOD_ENTER(
363 TRC_CMPIPROVIDERINTERFACE,
364 "CMPI_Broker:mbExecQuery()");
|
365 venkat.puvvada 1.39 mb = CM_BROKER;
366
367 try
368 {
|
369 thilo.boehm 1.55 CIMResponseData resData = CM_CIMOM(mb)->execQuery(
|
370 marek 1.53 *CM_Context(ctx),
|
371 thilo.boehm 1.55 SCMO_ObjectPath(cop)->getNameSpace(),
|
372 venkat.puvvada 1.39 String(lang),
373 String(query));
374
|
375 r.kieninger 1.56 // When running out of process the returned instances don't contain
376 // a namespace.
377 // Add the namespace from the input parameters where neccessary
378 resData.completeNamespace(SCMO_ObjectPath(cop));
|
379 thilo.boehm 1.55
380 Array<SCMOInstance>* aObj =
381 new Array<SCMOInstance>(resData.getSCMO());
382
383
384 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
385 new CMPI_Object(new CMPI_ObjEnumeration(aObj)));
386
387 CMSetStatus(rc,CMPI_RC_OK);
|
388 ms.aruran 1.42 PEG_METHOD_EXIT();
389 return cmpiEnum;
|
390 venkat.puvvada 1.39 }
|
391 marek 1.45 HandlerCatchSetStatus(rc, NULL);
392
|
393 venkat.puvvada 1.39 // Code flow should never get here.
394 }
395
396 static CMPIEnumeration* mbEnumInstances(
397 const CMPIBroker *mb,
398 const CMPIContext *ctx,
399 const CMPIObjectPath *cop,
400 const char **properties,
401 CMPIStatus *rc)
402 {
|
403 ms.aruran 1.42 PEG_METHOD_ENTER(
404 TRC_CMPIPROVIDERINTERFACE,
405 "CMPI_Broker:mbEnumInstances()");
|
406 venkat.puvvada 1.39 mb = CM_BROKER;
407
408 CMPIFlags flgs =
409 ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
410 const CIMPropertyList props = getList(properties);
411
412 try
413 {
|
414 thilo.boehm 1.55 CIMResponseData resData =
|
415 venkat.puvvada 1.39 CM_CIMOM(mb)->enumerateInstances(
|
416 marek 1.53 *CM_Context(ctx),
|
417 thilo.boehm 1.55 SCMO_ObjectPath(cop)->getNameSpace(),
418 SCMO_ObjectPath(cop)->getClassName(),
419 true,
|
420 venkat.puvvada 1.39 CM_IncludeQualifiers(flgs),
421 CM_ClassOrigin(flgs),
422 props);
423
424 // When running out of process the returned instances don't contain
|
425 thilo.boehm 1.55 // a namespace.
426 // Add the namespace from the input parameters where neccessary
427 resData.completeNamespace(SCMO_ObjectPath(cop));
|
428 venkat.puvvada 1.39
|
429 thilo.boehm 1.55 Array<SCMOInstance>* aInst =
430 new Array<SCMOInstance>(resData.getSCMO());
|
431 venkat.puvvada 1.39
|
432 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
433 venkat.puvvada 1.39 new CMPI_Object(new CMPI_InstEnumeration(aInst)));
|
434 thilo.boehm 1.55
435 CMSetStatus(rc,CMPI_RC_OK);
|
436 ms.aruran 1.42 PEG_METHOD_EXIT();
437 return cmpiEnum;
|
438 venkat.puvvada 1.39 }
|
439 marek 1.45 HandlerCatchSetStatus(rc, NULL);
440
|
441 venkat.puvvada 1.39 // Code flow should never get here.
442 }
443
444 static CMPIEnumeration* mbEnumInstanceNames(
445 const CMPIBroker *mb,
446 const CMPIContext *ctx,
447 const CMPIObjectPath *cop,
448 CMPIStatus *rc)
449 {
|
450 ms.aruran 1.42 PEG_METHOD_ENTER(
451 TRC_CMPIPROVIDERINTERFACE,
452 "CMPI_Broker:mbEnumInstanceNames()");
|
453 venkat.puvvada 1.39 mb = CM_BROKER;
454
455 try
456 {
|
457 thilo.boehm 1.55 CIMResponseData resData =
|
458 venkat.puvvada 1.39 CM_CIMOM(mb)->enumerateInstanceNames(
|
459 marek 1.53 *CM_Context(ctx),
|
460 thilo.boehm 1.55 SCMO_ObjectPath(cop)->getNameSpace(),
461 SCMO_ObjectPath(cop)->getClassName());
|
462 venkat.puvvada 1.39
463 // When running out of process the returned instances don't contain
|
464 thilo.boehm 1.55 // a namespace.
465 // Add the namespace from the input parameters where neccessary
466 resData.completeNamespace(SCMO_ObjectPath(cop));
467
468 Array<SCMOInstance>* aRef =
469 new Array<SCMOInstance>(resData.getSCMO());
470
471
|
472 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
473 venkat.puvvada 1.49 new CMPI_Object(new CMPI_OpEnumeration(aRef)));
|
474 thilo.boehm 1.55
475 CMSetStatus(rc,CMPI_RC_OK);
|
476 ms.aruran 1.42 PEG_METHOD_EXIT();
477 return cmpiEnum;
|
478 venkat.puvvada 1.39 }
|
479 marek 1.45 HandlerCatchSetStatus(rc, NULL);
480
|
481 venkat.puvvada 1.39 // Code flow should never get here.
482 }
483
484 static CMPIEnumeration* mbAssociators(
485 const CMPIBroker *mb,
486 const CMPIContext *ctx,
487 const CMPIObjectPath *cop,
488 const char *assocClass,
489 const char *resultClass,
490 const char *role,
491 const char *resultRole,
492 const char **properties,
493 CMPIStatus *rc)
494 {
|
495 ms.aruran 1.42 PEG_METHOD_ENTER(
496 TRC_CMPIPROVIDERINTERFACE,
497 "CMPI_Broker:mbAssociators()");
|
498 venkat.puvvada 1.39 mb = CM_BROKER;
|
499 dave.sudlik 1.41 // ATTN-CAKG-P2-20020726: The following condition does not correctly
500 // distinguish instanceNames from classNames in every case
501 // The instanceName of a singleton instance of a keyless class has no
502 // key bindings
|
503 thilo.boehm 1.55 if (!SCMO_ObjectPath(cop)->getKeyBindingCount())
|
504 dave.sudlik 1.41 {
505 CMSetStatus(rc, CMPI_RC_ERR_FAILED);
|
506 ms.aruran 1.42 PEG_METHOD_EXIT();
|
507 dave.sudlik 1.41 return 0;
508 }
|
509 venkat.puvvada 1.39 CMPIFlags flgs =
510 ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
511 const CIMPropertyList props = getList(properties);
|
512 schuur 1.11
|
513 thilo.boehm 1.55 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
514 CIMObjectPath qop;
|
515 venkat.puvvada 1.39 try
516 {
|
517 thilo.boehm 1.55 scmoObjPath->getCIMObjectPath(qop);
518 // For compatibility with previous implementations have empty ns
519 qop.setNameSpace(CIMNamespaceName());
520
521 CIMResponseData resData =
|
522 venkat.puvvada 1.39 CM_CIMOM(mb)->associators(
|
523 marek 1.53 *CM_Context(ctx),
|
524 thilo.boehm 1.55 SCMO_ObjectPath(cop)->getNameSpace(),
|
525 venkat.puvvada 1.39 qop,
526 assocClass ? CIMName(assocClass) : CIMName(),
527 resultClass ? CIMName(resultClass) : CIMName(),
528 role ? String(role) : String::EMPTY,
529 resultRole ? String(resultRole) : String::EMPTY,
530 CM_IncludeQualifiers(flgs),
531 CM_ClassOrigin(flgs),
532 props);
533
|
534 thilo.boehm 1.55 // When running out of process the returned instances don't contain
535 // a namespace.
536 // Add the namespace from the input parameters where neccessary
537 resData.completeNamespace(scmoObjPath);
|
538 venkat.puvvada 1.39
|
539 thilo.boehm 1.55 Array<SCMOInstance>* aObj =
540 new Array<SCMOInstance>(resData.getSCMO());
|
541 venkat.puvvada 1.49
|
542 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
543 venkat.puvvada 1.49 new CMPI_Object(new CMPI_ObjEnumeration(aObj)));
|
544 thilo.boehm 1.55
545 CMSetStatus(rc,CMPI_RC_OK);
|
546 ms.aruran 1.42 PEG_METHOD_EXIT();
547 return cmpiEnum;
|
548 venkat.puvvada 1.39 }
|
549 marek 1.45 HandlerCatchSetStatus(rc, NULL);
550
|
551 venkat.puvvada 1.39 // Code flow should never get here.
552 }
553
554 static CMPIEnumeration* mbAssociatorNames(
555 const CMPIBroker *mb,
556 const CMPIContext *ctx,
557 const CMPIObjectPath *cop,
558 const char *assocClass,
559 const char *resultClass,
560 const char *role,
561 const char *resultRole,
562 CMPIStatus *rc)
563 {
|
564 ms.aruran 1.42 PEG_METHOD_ENTER(
565 TRC_CMPIPROVIDERINTERFACE,
566 "CMPI_Broker:mbAssociatorNames()");
|
567 venkat.puvvada 1.39 mb = CM_BROKER;
|
568 dave.sudlik 1.41 // ATTN-CAKG-P2-20020726: The following condition does not correctly
569 // distinguish instanceNames from classNames in every case
570 // The instanceName of a singleton instance of a keyless class has no
571 // key bindings
|
572 thilo.boehm 1.55 if (!SCMO_ObjectPath(cop)->getKeyBindingCount())
|
573 dave.sudlik 1.41 {
574 CMSetStatus(rc, CMPI_RC_ERR_FAILED);
|
575 ms.aruran 1.42 PEG_METHOD_EXIT();
|
576 dave.sudlik 1.41 return 0;
577 }
|
578 schuur 1.11
|
579 thilo.boehm 1.55 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
580 CIMObjectPath qop;
|
581 venkat.puvvada 1.39 try
582 {
|
583 thilo.boehm 1.55 scmoObjPath->getCIMObjectPath(qop);
584 // For compatibility with previous implementations have empty ns
585 qop.setNameSpace(CIMNamespaceName());
586
587 CIMResponseData resData =
|
588 venkat.puvvada 1.39 CM_CIMOM(mb)->associatorNames(
|
589 marek 1.53 *CM_Context(ctx),
|
590 thilo.boehm 1.55 scmoObjPath->getNameSpace(),
|
591 venkat.puvvada 1.39 qop,
592 assocClass ? CIMName(assocClass) : CIMName(),
593 resultClass ? CIMName(resultClass) : CIMName(),
594 role ? String(role) : String::EMPTY,
595 resultRole ? String(resultRole) : String::EMPTY);
596
597 // When running out of process the returned instances don't contain
|
598 thilo.boehm 1.55 // a namespace.
599 // Add the namespace from the input parameters where neccessary
600 resData.completeNamespace(scmoObjPath);
601
602 Array<SCMOInstance>* aRef =
603 new Array<SCMOInstance>(resData.getSCMO());
604
|
605 venkat.puvvada 1.49
|
606 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
607 venkat.puvvada 1.49 new CMPI_Object(new CMPI_OpEnumeration(aRef)));
|
608 thilo.boehm 1.55
609 CMSetStatus(rc,CMPI_RC_OK);
|
610 ms.aruran 1.42 PEG_METHOD_EXIT();
611 return cmpiEnum;
|
612 venkat.puvvada 1.39 }
|
613 marek 1.45 HandlerCatchSetStatus(rc, NULL);
614
|
615 venkat.puvvada 1.39 // Code flow should never get here.
616 }
617
618 static CMPIEnumeration* mbReferences(
619 const CMPIBroker *mb,
620 const CMPIContext *ctx,
621 const CMPIObjectPath *cop,
622 const char *resultClass,
623 const char *role ,
624 const char **properties,
625 CMPIStatus *rc)
626 {
|
627 ms.aruran 1.42 PEG_METHOD_ENTER(
628 TRC_CMPIPROVIDERINTERFACE,
629 "CMPI_Broker:mbReferences()");
|
630 venkat.puvvada 1.39 mb = CM_BROKER;
|
631 dave.sudlik 1.41 // ATTN-CAKG-P2-20020726: The following condition does not correctly
632 // distinguish instanceNames from classNames in every case
633 // The instanceName of a singleton instance of a keyless class has no
634 // key bindings
|
635 thilo.boehm 1.55 if (!SCMO_ObjectPath(cop)->getKeyBindingCount())
|
636 dave.sudlik 1.41 {
637 CMSetStatus(rc, CMPI_RC_ERR_FAILED);
|
638 ms.aruran 1.42 PEG_METHOD_EXIT();
|
639 dave.sudlik 1.41 return 0;
640 }
|
641 venkat.puvvada 1.39 CMPIFlags flgs =
642 ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
643 CIMPropertyList props = getList(properties);
|
644 schuur 1.11
|
645 thilo.boehm 1.55
646 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
647 CIMObjectPath qop;
|
648 venkat.puvvada 1.39 try
649 {
|
650 thilo.boehm 1.55 scmoObjPath->getCIMObjectPath(qop);
651 // For compatibility with previous implementations have empty ns
652 qop.setNameSpace(CIMNamespaceName());
653
654 CIMResponseData resData =
|
655 venkat.puvvada 1.39 CM_CIMOM(mb)->references(
|
656 marek 1.53 *CM_Context(ctx),
|
657 thilo.boehm 1.55 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 thilo.boehm 1.55
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 thilo.boehm 1.55 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 schuur 1.11
|
706 thilo.boehm 1.55 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
707 CIMObjectPath qop;
|
708 venkat.puvvada 1.39 try
709 {
|
710 thilo.boehm 1.55 scmoObjPath->getCIMObjectPath(qop);
711 // For compatibility with previous implementations have empty ns
712 qop.setNameSpace(CIMNamespaceName());
713
714 CIMResponseData resData =
|
715 venkat.puvvada 1.39 CM_CIMOM(mb)->referenceNames(
|
716 marek 1.53 *CM_Context(ctx),
|
717 thilo.boehm 1.55 scmoObjPath->getNameSpace(),
|
718 venkat.puvvada 1.39 qop,
719 resultClass ? CIMName(resultClass) : CIMName(),
720 role ? String(role) : String::EMPTY);
721
|
722 thilo.boehm 1.55 // Add the namespace from the input parameters when neccessary
723 resData.completeNamespace(scmoObjPath);
724
725 Array<SCMOInstance>* aRef =
726 new Array<SCMOInstance>(resData.getSCMO());
|
727 venkat.puvvada 1.49
|
728 ms.aruran 1.42 CMPIEnumeration* cmpiEnum = reinterpret_cast<CMPIEnumeration*>(
|
729 venkat.puvvada 1.49 new CMPI_Object(new CMPI_OpEnumeration(aRef)));
|
730 thilo.boehm 1.55 CMSetStatus(rc,CMPI_RC_OK);
|
731 ms.aruran 1.42 PEG_METHOD_EXIT();
732 return cmpiEnum;
|
733 venkat.puvvada 1.39 }
|
734 marek 1.45 HandlerCatchSetStatus(rc, NULL);
735
|
736 venkat.puvvada 1.39 // Code flow should never get here.
737 }
|
738 schuur 1.1
|
739 r.kieninger 1.29 #define CM_Args(args) ((Array<CIMParamValue>*)args->hdl)
740
|
741 venkat.puvvada 1.39 static CMPIData mbInvokeMethod(
742 const CMPIBroker *mb,
743 const CMPIContext *ctx,
744 const CMPIObjectPath *cop,
745 const char *method,
746 const CMPIArgs *in,
747 CMPIArgs *out,
748 CMPIStatus *rc)
749 {
|
750 ms.aruran 1.42 PEG_METHOD_ENTER(
751 TRC_CMPIPROVIDERINTERFACE,
752 "CMPI_Broker:mbInvokeMethod()");
|
753 venkat.puvvada 1.39 CMPIData data = {0,CMPI_nullValue,{0}};
754 mb = CM_BROKER;
|
755 r.kieninger 1.29
|
756 thilo.boehm 1.55
757 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
758 CIMObjectPath qop;
|
759 venkat.puvvada 1.39 try
760 {
|
761 thilo.boehm 1.55 scmoObjPath->getCIMObjectPath(qop);
762
|
763 venkat.puvvada 1.39 CIMValue v = CM_CIMOM(mb)->invokeMethod(
|
764 marek 1.53 *CM_Context(ctx),
|
765 thilo.boehm 1.55 SCMO_ObjectPath(cop)->getNameSpace(),
|
766 venkat.puvvada 1.39 qop,
767 method ? String(method) : String::EMPTY,
768 *CM_Args(in),
769 *CM_Args(out));
|
770 thilo.boehm 1.55
771 CIMType vType=v.getType();
772 CMPIType t = type2CMPIType(vType,v.isArray());
773 value2CMPIData(v,t,&data);
774
|
775 venkat.puvvada 1.39 if (rc)
776 {
777 CMSetStatus(rc,CMPI_RC_OK);
778 }
779 }
|
780 marek 1.45 HandlerCatchSetStatus(rc, data);
781
|
782 ms.aruran 1.42 PEG_METHOD_EXIT();
|
783 venkat.puvvada 1.39 return data; // "data" will be valid data or nullValue (in error case)
784 }
785
786 static CMPIStatus mbSetProperty(
787 const CMPIBroker *mb,
788 const CMPIContext *ctx,
789 const CMPIObjectPath *cop,
790 const char *name,
791 const CMPIValue *val,
792 CMPIType type)
793 {
|
794 ms.aruran 1.42 PEG_METHOD_ENTER(
795 TRC_CMPIPROVIDERINTERFACE,
796 "CMPI_Broker:mbSetProperty()");
|
797 venkat.puvvada 1.39 mb = CM_BROKER;
798 CMPIrc rc;
799 CIMValue v = value2CIMValue(val,type,&rc);
800
|
801 thilo.boehm 1.55 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
802 CIMObjectPath qop;
|
803 venkat.puvvada 1.39 try
804 {
|
805 thilo.boehm 1.55 scmoObjPath->getCIMObjectPath(qop);
806
|
807 venkat.puvvada 1.39 CM_CIMOM(mb)->setProperty(
|
808 marek 1.53 *CM_Context(ctx),
|
809 thilo.boehm 1.55 SCMO_ObjectPath(cop)->getNameSpace(),
810 qop,
|
811 venkat.puvvada 1.39 String(name),
812 v);
813 }
|
814 marek 1.45 HandlerCatchReturnStatus();
815
|
816 ms.aruran 1.42 PEG_METHOD_EXIT();
|
817 venkat.puvvada 1.39 CMReturn(CMPI_RC_OK);
818 }
819
820 static CMPIData mbGetProperty(
821 const CMPIBroker *mb,
822 const CMPIContext *ctx,
823 const CMPIObjectPath *cop,
824 const char *name,
825 CMPIStatus *rc)
826 {
|
827 ms.aruran 1.42 PEG_METHOD_ENTER(
828 TRC_CMPIPROVIDERINTERFACE,
829 "CMPI_Broker:mbGetProperty()");
|
830 venkat.puvvada 1.39 mb = CM_BROKER;
831 CMPIData data = {0,CMPI_nullValue,{0}};
832
|
833 thilo.boehm 1.55 SCMOInstance* scmoObjPath = SCMO_ObjectPath(cop);
834 CIMObjectPath qop;
835 scmoObjPath->getCIMObjectPath(qop);
836
|
837 venkat.puvvada 1.39 try
838 {
839 CIMValue v = CM_CIMOM(mb)->getProperty(
|
840 marek 1.53 *CM_Context(ctx),
|
841 thilo.boehm 1.55 SCMO_ObjectPath(cop)->getNameSpace(),
842 qop,
|
843 venkat.puvvada 1.39 String(name));
844 CIMType vType = v.getType();
845 CMPIType t = type2CMPIType(vType,v.isArray());
846 value2CMPIData(v,t,&data);
847 CMSetStatus(rc,CMPI_RC_OK);
848 }
|
849 marek 1.45 HandlerCatchSetStatus(rc, data);
850
|
851 ms.aruran 1.42 PEG_METHOD_EXIT();
|
852 venkat.puvvada 1.39 return data; // "data" will be valid data or nullValue (in error case)
853 }
854
|
855 thilo.boehm 1.55 /* With Bug#8541 the CMPI Provider Manager was changed to attach the
|
856 marek 1.53 complete requests operation context to the CMPI thread context.
857 In future, when we have a lot more containers on the operation context,
858 this might lead to an impact on memory usage here, when the entire
859 operation context gets copied to the new thread.
860 */
|
861 venkat.puvvada 1.39 static CMPIContext* mbPrepareAttachThread(
862 const CMPIBroker* mb,
863 const CMPIContext* eCtx)
864 {
|
865 ms.aruran 1.42 PEG_METHOD_ENTER(
866 TRC_CMPIPROVIDERINTERFACE,
867 "CMPI_Broker:mbPrepareAttachThread()");
|
868 venkat.puvvada 1.39 mb = CM_BROKER;
869 OperationContext *ctx = (OperationContext*)((CMPI_Context*)eCtx)->ctx;
870 OperationContext nctx = *ctx;
871 CMPIContext* neCtx = new CMPI_Context(*(new OperationContext(nctx)));
872 CMPIString *name;
873 for (int i=0,s=CMPI_Args_Ftab->getArgCount(
874 reinterpret_cast<const CMPIArgs*>(eCtx),NULL); i<s; i++)
875 {
876 CMPIData data = CMPI_Args_Ftab->getArgAt(
877 reinterpret_cast<const CMPIArgs*>(eCtx),i,&name,NULL);
878 CMPI_Args_Ftab->addArg(
879 reinterpret_cast<CMPIArgs*>(neCtx),
|
880 s.kodali 1.47 CMGetCharsPtr(name,NULL),
|
881 venkat.puvvada 1.39 &data.value,data.type);
882 }
|
883 ms.aruran 1.42 PEG_METHOD_EXIT();
|
884 venkat.puvvada 1.39 return neCtx;
885 }
886
887 static CMPIStatus mbAttachThread(
888 const CMPIBroker* mb,
889 const CMPIContext* eCtx)
890 {
891 ((CMPI_Context*)eCtx)->thr = new CMPI_ThreadContext(mb,eCtx);
892 CMReturn(CMPI_RC_OK);
893 }
894
895 static CMPIStatus mbDetachThread(
896 const CMPIBroker* mb,
897 const CMPIContext* eCtx)
898 {
899 mb = CM_BROKER;
900 CMPI_Context *neCtx = (CMPI_Context *)eCtx;
901 delete neCtx->thr;
902 // Delete also CMPIContext
903 delete neCtx;
904 CMReturn(CMPI_RC_OK);
905 venkat.puvvada 1.39 }
|
906 schuur 1.11
|
907 venkat.puvvada 1.39 static CMPIStatus mbDeliverIndication(
|
908 ms.aruran 1.42 const CMPIBroker* eMb,
909 const CMPIContext* ctx,
910 const char *ns,
911 const CMPIInstance* ind)
912 {
913 PEG_METHOD_ENTER(
914 TRC_CMPIPROVIDERINTERFACE,
915 "CMPI_Broker:mbDeliverIndication()");
|
916 venkat.puvvada 1.39 eMb = CM_BROKER;
917 CMPI_Broker *mb = (CMPI_Broker*)eMb;
|
918 venkat.puvvada 1.54 IndProvRecord *indProvRec;
|
919 venkat.puvvada 1.39 OperationContext* context = CM_Context(ctx);
|
920 thilo.boehm 1.55
921 SCMOInstance* scmoInst = SCMO_Instance(ind);
922 CIMInstance indInst;
923 scmoInst->getCIMInstance(indInst);
924
|
925 venkat.puvvada 1.39 // When an indication to be delivered comes from Remote providers,
926 // the CMPIBroker contains the name of the provider in the form
927 // of physical-name:logical-name. Search using logical-name. -V 5884
928 String provider_name;
929 CMPIUint32 n;
930
931 if ( (n = mb->name.find(':') ) != PEG_NOT_FOUND)
932 {
933 provider_name = mb->name.subString (n + 1);
934 }
935 else
936 {
937 provider_name = mb->name;
938 }
939 ReadLock readLock(CMPIProviderManager::rwSemProvTab);
|
940 venkat.puvvada 1.54 if (CMPIProviderManager::indProvTab.lookup(provider_name, indProvRec))
|
941 venkat.puvvada 1.39 {
|
942 venkat.puvvada 1.54 if (indProvRec->isEnabled())
|
943 venkat.puvvada 1.39 {
|
944 venkat.puvvada 1.57 if (!context->contains(
945 SubscriptionInstanceNamesContainer::NAME))
|
946 venkat.puvvada 1.39 {
947 Array<CIMObjectPath> subscriptionInstanceNames;
948 context->insert(
949 SubscriptionInstanceNamesContainer(
950 subscriptionInstanceNames));
951 }
|
952 thilo.boehm 1.55 CIMIndication cimIndication(indInst);
|
953 venkat.puvvada 1.39 try
954 {
|
955 venkat.puvvada 1.54 indProvRec->getHandler()->deliver(
|
956 venkat.puvvada 1.39 *context,
957 // OperationContext(*CM_Context(ctx)),
958 cimIndication);
|
959 ms.aruran 1.42 PEG_METHOD_EXIT();
960 CMReturn(CMPI_RC_OK);
|
961 venkat.puvvada 1.39 }
|
962 marek 1.45 HandlerCatchReturnStatus();
|
963 venkat.puvvada 1.39 }
964 }
|
965 ms.aruran 1.42 PEG_METHOD_EXIT();
|
966 venkat.puvvada 1.39 CMReturn(CMPI_RC_ERR_FAILED);
967 }
|
968 schuur 1.11 }
|
969 schuur 1.1
|
970 venkat.puvvada 1.39 static CMPIBrokerFT broker_FT =
971 {
972 MB_CAPABILITIES, // brokerClassification;
973 CMPICurrentVersion,
974 "Pegasus",
975 mbPrepareAttachThread,
976 mbAttachThread,
977 mbDetachThread,
978 mbDeliverIndication,
979 mbEnumInstanceNames,
980 mbGetInstance,
981 mbCreateInstance,
982 mbModifyInstance,
983 mbDeleteInstance,
984 mbExecQuery,
985 mbEnumInstances,
986 mbAssociators,
987 mbAssociatorNames,
988 mbReferences,
989 mbReferenceNames,
990 mbInvokeMethod,
991 venkat.puvvada 1.39 mbSetProperty,
992 mbGetProperty,
|
993 schuur 1.1 };
994
|
995 venkat.puvvada 1.39 CMPIBrokerFT *CMPI_Broker_Ftab = & broker_FT;
|
996 schuur 1.1
997 PEGASUS_NAMESPACE_END
|