1 martin 1.51 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.52 //
|
3 martin 1.51 // 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.52 //
|
10 martin 1.51 // 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.52 //
|
17 martin 1.51 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.52 //
|
20 martin 1.51 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.52 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.51 // 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.52 //
|
28 martin 1.51 //////////////////////////////////////////////////////////////////////////
|
29 schuur 1.1 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
|
32 mike 1.29 #include <Pegasus/Common/AutoPtr.h>
|
33 schuur 1.4 #include "CMPI_Version.h"
|
34 schuur 1.2
|
35 schuur 1.1 #include "CMPI_Instance.h"
36 #include "CMPI_Broker.h"
37 #include "CMPI_Value.h"
38 #include "CMPI_String.h"
|
39 r.kieninger 1.54.2.1 #include "CMPISCMOUtilities.h"
|
40 schuur 1.1
|
41 kumpf 1.50 #include <Pegasus/Common/CIMNameCast.h>
|
42 schuur 1.1 #include <Pegasus/Common/InternalException.h>
|
43 konrad.r 1.18 #include <Pegasus/Common/System.h>
|
44 mike 1.29 #include <Pegasus/Common/Mutex.h>
|
45 schuur 1.1 #include <string.h>
|
46 dave.sudlik 1.23 #include <new>
|
47 ms.aruran 1.39 #include <Pegasus/Common/Tracer.h>
|
48 r.kieninger 1.54.2.1 #include <Pegasus/Common/SCMODump.h>
|
49 schuur 1.1
50 PEGASUS_USING_STD;
51 PEGASUS_NAMESPACE_BEGIN
52
|
53 kumpf 1.53 extern "C"
|
54 venkat.puvvada 1.37 {
|
55 schuur 1.12
|
56 venkat.puvvada 1.37 static CMPIStatus instRelease(CMPIInstance* eInst)
57 {
|
58 r.kieninger 1.54.2.1 SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
|
59 venkat.puvvada 1.37 if (inst)
60 {
61 delete inst;
62 (reinterpret_cast<CMPI_Object*>(eInst))->unlinkAndDelete();
63 CMReturn(CMPI_RC_OK);
64 }
65 else
66 {
67 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
68 }
69 }
70
71 static CMPIStatus instReleaseNop(CMPIInstance* eInst)
72 {
73 CMReturn(CMPI_RC_OK);
74 }
75
|
76 kumpf 1.53 static CMPIInstance* instClone(const CMPIInstance* eInst, CMPIStatus* rc)
|
77 venkat.puvvada 1.37 {
|
78 ms.aruran 1.39 PEG_METHOD_ENTER(
79 TRC_CMPIPROVIDERINTERFACE,
80 "CMPI_Instance:instClone()");
|
81 r.kieninger 1.54.2.1 SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
|
82 venkat.puvvada 1.37 if (!inst)
83 {
84 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
|
85 ms.aruran 1.39 PEG_METHOD_EXIT();
|
86 venkat.puvvada 1.37 return NULL;
87 }
88 try
89 {
|
90 r.kieninger 1.54.2.10 AutoPtr<SCMOInstance> cInst(new SCMOInstance(inst->clone()));
91 AutoPtr<CMPI_Object> obj(
92 new CMPI_Object(cInst.get(),CMPI_Object::ObjectTypeInstance));
93 cInst.release();
94 obj->unlink();
|
95 kumpf 1.53 CMPIInstance* cmpiInstance =
|
96 r.kieninger 1.54.2.10 reinterpret_cast<CMPIInstance *>(obj.release());
|
97 r.kieninger 1.54.2.1 CMSetStatus(rc,CMPI_RC_OK);
|
98 ms.aruran 1.39 PEG_METHOD_EXIT();
99 return cmpiInstance;
|
100 venkat.puvvada 1.37 }
101 catch (const PEGASUS_STD(bad_alloc)&)
102 {
103 CMSetStatus(rc, CMPI_RC_ERROR_SYSTEM);
|
104 ms.aruran 1.39 PEG_METHOD_EXIT();
|
105 venkat.puvvada 1.37 return NULL;
106 }
107 }
108
109 static CMPIData instGetPropertyAt(
110 const CMPIInstance* eInst, CMPICount pos, CMPIString** name,
111 CMPIStatus* rc)
112 {
|
113 r.kieninger 1.54.2.1 CMPIData data={0,CMPI_badValue,{0}};
|
114 venkat.puvvada 1.37
|
115 r.kieninger 1.54.2.1 SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
|
116 venkat.puvvada 1.37 if (!inst)
117 {
118 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
119 return data;
120 }
121
|
122 r.kieninger 1.54.2.2 const SCMBUnion* value = 0;
|
123 r.kieninger 1.54.2.1 Boolean isArray = 0;
124 Uint32 size = 0;
125 CIMType type = (CIMType)0;
126 const char* pName=0;
127
128 SCMO_RC src = inst->getPropertyAt((Uint32)pos,
129 &pName,
130 type,
131 &value,
132 isArray,
133 size);
|
134 r.kieninger 1.54.2.7 switch(src)
|
135 r.kieninger 1.54.2.1 {
|
136 r.kieninger 1.54.2.7 case SCMO_OK:
|
137 r.kieninger 1.54.2.1 {
|
138 r.kieninger 1.54.2.7 CMPIType ct=type2CMPIType(type, isArray);
139 CMPISCMOUtilities::scmoValue2CMPIData( value, ct, &data );
140 if ((ct&~CMPI_ARRAY) == CMPI_string)
|
141 r.kieninger 1.54.2.1 {
|
142 r.kieninger 1.54.2.7 // We always receive strings as an array of pointers
143 // with at least one element, which needs to be released
144 // after it was converted to CMPIData
145 free((void*)value);
|
146 r.kieninger 1.54.2.1 }
147 break;
|
148 r.kieninger 1.54.2.7 }
149 case SCMO_INDEX_OUT_OF_BOUND:
150 {
151 CMSetStatus(rc, CMPI_RC_ERR_NO_SUCH_PROPERTY);
152 CMPIData rdata={0,CMPI_nullValue|CMPI_notFound,{0}};
153 return rdata;
154 break;
155 }
|
156 r.kieninger 1.54.2.1
157 case SCMO_NULL_VALUE:
|
158 r.kieninger 1.54.2.7 {
159 // A NullValue does not indicate an error, but simply that
160 // no value has been set for the property.
161 data.type = type2CMPIType(type, isArray);
162 data.state = CMPI_nullValue;
163 data.value.uint64 = 0;
|
164 r.kieninger 1.54.2.1 break;
|
165 r.kieninger 1.54.2.7 }
|
166 r.kieninger 1.54.2.1
167 default:
|
168 r.kieninger 1.54.2.3 {
|
169 r.kieninger 1.54.2.7 // Other return codes should not appear here, but are possible
170 // code wise (i.e. SCMO_NOT_FOUND etc.)
171 PEG_TRACE((
172 TRC_CMPIPROVIDERINTERFACE,
173 Tracer::LEVEL2,
174 "Unexpected RC from SCMOInstance.instGetPropertyAt: %d",
175 src));
176 CMSetStatus(rc, CMPI_RC_ERR_FAILED);
177 return data;
|
178 r.kieninger 1.54.2.3 }
|
179 r.kieninger 1.54.2.7 break;
|
180 r.kieninger 1.54.2.1 }
|
181 venkat.puvvada 1.37
182
|
183 r.kieninger 1.54.2.1 // Returning the property name as CMPI String
|
184 venkat.puvvada 1.37 if (name)
185 {
|
186 r.kieninger 1.54.2.1 *name=string2CMPIString(pName);
|
187 venkat.puvvada 1.37 }
188
189 CMSetStatus(rc,CMPI_RC_OK);
190 return data;
191 }
192
|
193 kumpf 1.53 static CMPIData instGetProperty(const CMPIInstance* eInst,
194 const char *name, CMPIStatus* rc)
|
195 venkat.puvvada 1.37 {
|
196 r.kieninger 1.54.2.1 CMPIData data={0,CMPI_badValue,{0}};
|
197 venkat.puvvada 1.37
|
198 r.kieninger 1.54.2.1 SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
199 if (!inst)
|
200 venkat.puvvada 1.37 {
201 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
202 return data;
203 }
|
204 r.kieninger 1.54.2.1
|
205 venkat.puvvada 1.37 if (!name)
206 {
207 CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
208 return data;
209 }
210
|
211 r.kieninger 1.54.2.2 const SCMBUnion* value = 0;
|
212 r.kieninger 1.54.2.1 Boolean isArray = 0;
213 Uint32 size = 0;
214 CIMType type = (CIMType)0;
215
216 SCMO_RC src = inst->getProperty(name, type, &value, isArray, size);
217 if (src != SCMO_OK)
|
218 venkat.puvvada 1.37 {
|
219 r.kieninger 1.54.2.1 switch(src)
220 {
221 case SCMO_NOT_FOUND:
222 {
223 CMSetStatus(rc, CMPI_RC_ERR_NO_SUCH_PROPERTY);
224 return data;
225 }
226 break;
227
228 case SCMO_NULL_VALUE:
229 {
230 // A NullValue does not indicate an error, but simply that
231 // no value has been set for the property.
|
232 r.kieninger 1.54.2.8
|
233 marek 1.54.2.9 // TBD: Though the CMPI specification mandates to return a
234 // nullvalue when a property exists on an instance but has
235 // not yet been assigned a value, for compatibility with
236 // previous versions we return CMPI_RC_ERR_NO_SUCH_PROPERTY
|
237 r.kieninger 1.54.2.8 // in this case.
238 // If SCMO would distinguish between nullvalues and values
239 // that have not been set at all on an instance, we could
240 // be more precise here.
241 /*
242 // Correct code for nullvalues
243 data.type = type2CMPIType(type, isArray);
244 data.state = CMPI_nullValue;
245 data.value.uint64 = 0;
246 */
247 // Code for properties that have not been set
248 CMSetStatus(rc, CMPI_RC_ERR_NO_SUCH_PROPERTY);
249 return data;
250
|
251 r.kieninger 1.54.2.1 }
252 break;
253
254 default:
255 {
256 PEG_TRACE((
257 TRC_CMPIPROVIDERINTERFACE,
258 Tracer::LEVEL1,
259 "Unexpected RC from SCMOInstance.instGetPropertyAt: %d",
260 src));
261 CMSetStatus(rc, CMPI_RC_ERR_FAILED);
262 return data;
263 }
264 break;
265 }
266 }
267 else
268 {
269 CMPIType ct=type2CMPIType(type, isArray);
|
270 r.kieninger 1.54.2.3 CMPISCMOUtilities::scmoValue2CMPIData(value, ct, &data, size);
271 if ((ct&~CMPI_ARRAY) == CMPI_string)
272 {
273 // We always receive strings as an array of pointers
274 // with at least one element, which needs to be released
275 // after it was converted to CMPIData
276 free((void*)value);
277 }
|
278 venkat.puvvada 1.37 }
|
279 r.kieninger 1.54.2.1
280
281 CMSetStatus(rc,CMPI_RC_OK);
|
282 venkat.puvvada 1.37 return data;
283 }
284
285
|
286 kumpf 1.53 static CMPICount instGetPropertyCount(const CMPIInstance* eInst,
287 CMPIStatus* rc)
|
288 venkat.puvvada 1.37 {
|
289 r.kieninger 1.54.2.1 SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
|
290 venkat.puvvada 1.37 if (!inst)
291 {
292 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
293 return 0;
294 }
295 CMSetStatus(rc,CMPI_RC_OK);
296 return inst->getPropertyCount();
297 }
298
|
299 r.kieninger 1.54.2.2 static CMPIStatus instSetPropertyWithOrigin(
300 const CMPIInstance* eInst,
|
301 marek 1.54.2.9 const char* name,
302 const CMPIValue* data,
|
303 r.kieninger 1.54.2.2 const CMPIType type,
|
304 venkat.puvvada 1.37 const char* origin)
305 {
|
306 ms.aruran 1.39 PEG_METHOD_ENTER(
307 TRC_CMPIPROVIDERINTERFACE,
308 "CMPI_Instance:instSetPropertyWithOrigin()");
|
309 r.kieninger 1.54.2.1
310 SCMOInstance *inst=(SCMOInstance*)eInst->hdl;
|
311 venkat.puvvada 1.37 if (!inst)
312 {
|
313 ms.aruran 1.39 PEG_METHOD_EXIT();
|
314 venkat.puvvada 1.37 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
315 }
316
|
317 r.kieninger 1.54.2.1 CMPIStatus cmpiRC = {CMPI_RC_OK,0};
318 SCMO_RC rc;
|
319 venkat.puvvada 1.37
|
320 r.kieninger 1.54.2.1 if (!(type&CMPI_ARRAY))
321 {
|
322 r.kieninger 1.54.2.2 CIMType cimType=type2CIMType(type);
323 SCMBUnion scmoData = value2SCMOValue(data, type);
|
324 venkat.puvvada 1.37
|
325 r.kieninger 1.54.2.1 rc = inst->setPropertyWithOrigin(name,
326 cimType,
|
327 r.kieninger 1.54.2.2 &scmoData,
|
328 r.kieninger 1.54.2.1 false, // isArray
329 0, // arraySize
330 origin);
331 }
332 else
333 {
|
334 r.kieninger 1.54.2.2 //Get the type of the elements in the array
335 CMPIType aType=type&~CMPI_ARRAY;
336 CIMType cimType=type2CIMType(aType);
337
|
338 r.kieninger 1.54.2.5 if( data == NULL || data->array == NULL )
|
339 r.kieninger 1.54.2.2 {
|
340 r.kieninger 1.54.2.5 // In this case just set a NULL Value
341 rc = inst->setPropertyWithOrigin(name,cimType,0,true,0,origin);
|
342 r.kieninger 1.54.2.2 }
|
343 r.kieninger 1.54.2.5 else
344 {
345 // When data is not NULL and data->array is also set
346 CMPI_Array* ar = (CMPI_Array*)data->array->hdl;
347 CMPIData* arrData = (CMPIData*)ar->hdl;
348
349
350 Uint32 arraySize = arrData->value.uint32;
351
|
352 r.kieninger 1.54.2.2
|
353 r.kieninger 1.54.2.5 // Convert the array of CMPIData to an array of SCMBUnion
354 SCMBUnion scmbArray[arraySize];
355 for (unsigned int x=0; x<arraySize; x++)
356 {
|
357 r.kieninger 1.54.2.12 // Note, aType is the single array element type
358 scmbArray[x] = value2SCMOValue(&(arrData[x].value), aType);
|
359 r.kieninger 1.54.2.5 }
360
361 rc = inst->setPropertyWithOrigin(name,
362 cimType,
363 &(scmbArray[0]),
364 true, // isArray
365 arraySize,
366 origin);
367 }
|
368 venkat.puvvada 1.37 }
|
369 r.kieninger 1.54.2.1
370 if (rc != SCMO_OK)
|
371 venkat.puvvada 1.37 {
|
372 marek 1.43 PEG_TRACE((TRC_CMPIPROVIDERINTERFACE,Tracer::LEVEL3,
373 "Property %s not set on created instance."
374 "Either the property is not part of the class or"
|
375 r.kieninger 1.54.2.1 "not part of the property list. SCMO_RC=%d",
376 name,
377 rc));
378
379 switch (rc)
380 {
381 case SCMO_NOT_SAME_ORIGIN:
382 cmpiRC.rc = CMPI_RC_ERR_INVALID_PARAMETER;
383 break;
384 case SCMO_NOT_FOUND:
|
385 r.kieninger 1.54.2.8 //TBD: Should return an error here, but previous impl.
386 // returned OK. Is this correct?
387 //cmpiRC.rc = CMPI_RC_ERR_NO_SUCH_PROPERTY;
388 cmpiRC.rc = CMPI_RC_OK;
|
389 r.kieninger 1.54.2.1 break;
390 case SCMO_WRONG_TYPE:
391 case SCMO_NOT_AN_ARRAY:
392 case SCMO_IS_AN_ARRAY:
393 cmpiRC.rc = CMPI_RC_ERR_INVALID_DATA_TYPE;
394 break;
395 default:
396 cmpiRC.rc = CMPI_RC_ERR_FAILED;
397 break;
|
398 venkat.puvvada 1.37 }
|
399 r.kieninger 1.54.2.1 }
400
|
401 ms.aruran 1.39 PEG_METHOD_EXIT();
|
402 r.kieninger 1.54.2.1 return(cmpiRC);
|
403 venkat.puvvada 1.37 }
404
405 static CMPIStatus instSetProperty(const CMPIInstance* eInst,
|
406 kumpf 1.53 const char *name, const CMPIValue* data, CMPIType type)
|
407 venkat.puvvada 1.37 {
408 return instSetPropertyWithOrigin(eInst, name, data, type, NULL);
409 }
410
411 static CMPIObjectPath* instGetObjectPath(const CMPIInstance* eInst,
|
412 kumpf 1.53 CMPIStatus* rc)
|
413 venkat.puvvada 1.37 {
|
414 ms.aruran 1.39 PEG_METHOD_ENTER(
415 TRC_CMPIPROVIDERINTERFACE,
416 "CMPI_Instance:instGetObjectPath()");
|
417 r.kieninger 1.54.2.1
418 SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
|
419 venkat.puvvada 1.37 if (!inst)
420 {
421 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
|
422 ms.aruran 1.39 PEG_METHOD_EXIT();
|
423 venkat.puvvada 1.37 return NULL;
424 }
|
425 r.kieninger 1.54.2.1
|
426 venkat.puvvada 1.37 try
427 {
|
428 r.kieninger 1.54.2.7 // Generate keys from instance
429 inst->buildKeyBindingsFromProperties();
430
|
431 r.kieninger 1.54.2.1 // Since we make no difference between ObjectPath and Instance,
432 // we simply clone using the ObjectPathOnly option.
433 SCMOInstance* cInst = new SCMOInstance(inst->clone(true));
|
434 r.kieninger 1.54.2.7
|
435 r.kieninger 1.54.2.1 CMPIObjectPath* cmpiObjPath =
|
436 r.kieninger 1.54.2.7 reinterpret_cast<CMPIObjectPath *>
437 (new CMPI_Object(cInst,CMPI_Object::ObjectTypeObjectPath));
|
438 mreddy 1.35 CMSetStatus(rc,CMPI_RC_OK);
|
439 ms.aruran 1.39 PEG_METHOD_EXIT();
|
440 r.kieninger 1.54.2.1 return cmpiObjPath;
|
441 venkat.puvvada 1.37 }
442 catch (const PEGASUS_STD(bad_alloc)&)
443 {
444 CMSetStatus(rc, CMPI_RC_ERROR_SYSTEM);
|
445 ms.aruran 1.39 PEG_METHOD_EXIT();
|
446 venkat.puvvada 1.37 return NULL;
447 }
448 }
449
450 static CMPIStatus instSetObjectPath(
|
451 kumpf 1.53 CMPIInstance* eInst,
|
452 venkat.puvvada 1.37 const CMPIObjectPath *obj)
453 {
|
454 ms.aruran 1.39 PEG_METHOD_ENTER(
455 TRC_CMPIPROVIDERINTERFACE,
456 "CMPI_Instance:instSetObjectPath()");
|
457 r.kieninger 1.54.2.5
458 SCMOInstance* prevInst=(SCMOInstance*)eInst->hdl;
459 if (prevInst==NULL)
|
460 venkat.puvvada 1.37 {
|
461 ms.aruran 1.39 PEG_METHOD_EXIT();
|
462 venkat.puvvada 1.37 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
463 }
464 if (obj==NULL)
465 {
|
466 ms.aruran 1.39 PEG_METHOD_EXIT();
|
467 r.kieninger 1.54.2.1 CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
|
468 venkat.puvvada 1.37 }
469
|
470 r.kieninger 1.54.2.1 SCMOInstance* ref = (SCMOInstance*)(obj->hdl);
|
471 r.kieninger 1.54.2.5 if (ref->isSame(*prevInst))
|
472 venkat.puvvada 1.37 {
|
473 r.kieninger 1.54.2.1 // Since we represent CMPIObjectPath as well as CMPIInstance
474 // through SCMOInstance, in this case both point to the same
475 // physical SCMB and the objectPath is already set.
476 // So this path is a nop.
|
477 ms.aruran 1.39 PEG_METHOD_EXIT();
|
478 r.kieninger 1.54.2.5 CMReturn(CMPI_RC_OK);
|
479 venkat.puvvada 1.37 }
|
480 r.kieninger 1.54.2.1 else
|
481 marek 1.43 {
|
482 r.kieninger 1.54.2.1 // It is not possible to have an instance or objectPath in
483 // this implementation without a classname or namespace.
484 const char* nsRef = ref->getNameSpace();
|
485 marek 1.54.2.9 Uint64 clsRefL;
486 const char* clsRef = ref->getClassName_l(clsRefL);
487 Uint64 clsPrevInstL;
488 const char* clsPrevInst = prevInst->getClassName_l(clsPrevInstL);
|
489 r.kieninger 1.54.2.1
|
490 marek 1.54.2.9 if (System::strncasecmp(clsRef,clsRefL,clsPrevInst,clsPrevInstL))
|
491 r.kieninger 1.54.2.1 {
|
492 r.kieninger 1.54.2.6 // Set the new namespace
493 prevInst->setNameSpace(nsRef);
|
494 r.kieninger 1.54.2.1
|
495 r.kieninger 1.54.2.10 // Remove the previous key properties
|
496 r.kieninger 1.54.2.11 prevInst->clearKeyBindings();
|
497 r.kieninger 1.54.2.10
498 // Copy the key properties from the given ObjectPath
|
499 r.kieninger 1.54.2.6 CMPIrc rc = CMPISCMOUtilities::copySCMOKeyProperties(
500 ref, // source
501 prevInst); // target
502 if (rc != CMPI_RC_OK)
|
503 marek 1.43 {
|
504 r.kieninger 1.54.2.6 PEG_TRACE_CSTRING(
505 TRC_CMPIPROVIDERINTERFACE,
506 Tracer::LEVEL1,
507 "Failed to copy key bindings");
508 PEG_METHOD_EXIT();
509 CMReturn(CMPI_RC_ERR_FAILED);
|
510 r.kieninger 1.54.2.5 }
|
511 marek 1.43 }
|
512 r.kieninger 1.54.2.1 else
|
513 marek 1.43 {
|
514 r.kieninger 1.54.2.5 // Uurrgh, changing class on an existing
|
515 r.kieninger 1.54.2.1 // CMPIInstance is a prohibited change.
516 // Simply returning an error
517 PEG_TRACE_CSTRING(
518 TRC_CMPIPROVIDERINTERFACE,
519 Tracer::LEVEL1,
520 "Cannot set objectpath because it would change classname"
521 "or namespace of instance");
522 PEG_METHOD_EXIT();
523 CMReturnWithString(
|
524 r.kieninger 1.54.2.8 CMPI_RC_ERR_FAILED,
|
525 r.kieninger 1.54.2.1 string2CMPIString("Incompatible ObjectPath"));
|
526 marek 1.43 }
527 }
|
528 r.kieninger 1.54.2.1
529 PEG_METHOD_EXIT();
|
530 r.kieninger 1.54.2.5 CMReturn(CMPI_RC_OK);
|
531 marek 1.43 }
532
|
533 r.kieninger 1.54.2.1
|
534 venkat.puvvada 1.37 static CMPIStatus instSetPropertyFilter(CMPIInstance* eInst,
535 const char** propertyList, const char **keys)
536 {
|
537 ms.aruran 1.39 PEG_METHOD_ENTER(
538 TRC_CMPIPROVIDERINTERFACE,
539 "CMPI_Instance:instSetPropertyFilter()");
|
540 r.kieninger 1.54.2.1
|
541 venkat.puvvada 1.37 if (!eInst->hdl)
542 {
|
543 ms.aruran 1.39 PEG_METHOD_EXIT();
|
544 venkat.puvvada 1.37 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
545 }
|
546 marek 1.43 /* The property list is to be applied on the given instance.
547 Currently CMPI provider have to call instSetPropertyFilter to honor
548 property filters or have to filter for themselves.
|
549 r.kieninger 1.54.2.1 Removing properties from the SCMOInstance here helps to effectively
|
550 marek 1.43 avoid the need to carry a property list around in the CMPI layer.
|
551 kumpf 1.53
|
552 marek 1.48 A (propertyList == 0) means the property list is null and there
553 should be no filtering.
|
554 kumpf 1.53
|
555 marek 1.48 An empty propertylist(no property to be returned) is represented by
556 a valid propertyList pointer pointing to a null pointer, i.e.
557 (*propertyList == 0)
|
558 marek 1.43 */
|
559 venkat.puvvada 1.37
|
560 r.kieninger 1.54.2.1 SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
561 inst->setPropertyFilter(propertyList);
562
|
563 ms.aruran 1.39 PEG_METHOD_EXIT();
|
564 venkat.puvvada 1.37 CMReturn(CMPI_RC_OK);
565 }
566
567 static CMPIStatus instSetPropertyFilterIgnore(CMPIInstance* eInst,
568 const char** propertyList, const char **keys)
569 {
570 /* We ignore it. */
571 CMReturn ( CMPI_RC_OK);
572 }
|
573 schuur 1.1
|
574 dave.sudlik 1.31
|
575 schuur 1.1 }
576
577 static CMPIInstanceFT instance_FT={
|
578 venkat.puvvada 1.37 CMPICurrentVersion,
579 instRelease,
580 instClone,
581 instGetProperty,
582 instGetPropertyAt,
583 instGetPropertyCount,
584 instSetProperty,
585 instGetObjectPath,
586 instSetPropertyFilter,
|
587 konrad.r 1.19 #if defined(CMPI_VER_100)
|
588 venkat.puvvada 1.37 instSetObjectPath,
|
589 konrad.r 1.19 #endif
|
590 dave.sudlik 1.31 #if defined(CMPI_VER_200)
|
591 venkat.puvvada 1.37 instSetPropertyWithOrigin,
|
592 dave.sudlik 1.31 #endif
|
593 schuur 1.1 };
594
595 static CMPIInstanceFT instanceOnStack_FT={
|
596 venkat.puvvada 1.37 CMPICurrentVersion,
597 instReleaseNop,
598 instClone,
599 instGetProperty,
600 instGetPropertyAt,
601 instGetPropertyCount,
602 instSetProperty,
603 instGetObjectPath,
604 instSetPropertyFilterIgnore,
|
605 konrad.r 1.19 #if defined(CMPI_VER_100)
|
606 venkat.puvvada 1.37 instSetObjectPath,
|
607 konrad.r 1.19 #endif
|
608 dave.sudlik 1.31 #if defined(CMPI_VER_200)
|
609 venkat.puvvada 1.37 instSetPropertyWithOrigin,
|
610 dave.sudlik 1.31 #endif
|
611 schuur 1.1 };
612
613 CMPIInstanceFT *CMPI_Instance_Ftab=&instance_FT;
614 CMPIInstanceFT *CMPI_InstanceOnStack_Ftab=&instanceOnStack_FT;
615
616
|
617 r.kieninger 1.54.2.10 CMPI_InstanceOnStack::CMPI_InstanceOnStack(const SCMOInstance* ci)
618 {
619 PEG_METHOD_ENTER(
620 TRC_CMPIPROVIDERINTERFACE,
621 "CMPI_InstanceOnStack::CMPI_InstanceOnStack()");
622
623 hdl=(void*)ci;
624 ft=CMPI_InstanceOnStack_Ftab;
625 PEG_METHOD_EXIT();
626 }
627
|
628 r.kieninger 1.54.2.8 CMPI_InstanceOnStack::CMPI_InstanceOnStack(const SCMOInstance& ci)
|
629 venkat.puvvada 1.37 {
|
630 ms.aruran 1.39 PEG_METHOD_ENTER(
631 TRC_CMPIPROVIDERINTERFACE,
632 "CMPI_InstanceOnStack::CMPI_InstanceOnStack()");
633
|
634 r.kieninger 1.54.2.10 hdl=(void*) new SCMOInstance(ci);
|
635 venkat.puvvada 1.37 ft=CMPI_InstanceOnStack_Ftab;
|
636 ms.aruran 1.39 PEG_METHOD_EXIT();
|
637 venkat.puvvada 1.37 }
|
638 schuur 1.1
|
639 r.kieninger 1.54.2.10 CMPI_InstanceOnStack::~CMPI_InstanceOnStack()
640 {
641 if (hdl)
642 {
643 delete((SCMOInstance*)hdl);
644 }
645 }
646
|
647 schuur 1.1
648 PEGASUS_NAMESPACE_END
|
649 kumpf 1.53
|