(file) Return to CMPI_Instance.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / CMPI

  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.1             SCMOInstance* cInst = new SCMOInstance(inst->clone());
 91 kumpf          1.53                 CMPIInstance* cmpiInstance =
 92 r.kieninger    1.54.2.7                 reinterpret_cast<CMPIInstance *>
 93                                         (new CMPI_Object(cInst,CMPI_Object::ObjectTypeInstance));
 94 r.kieninger    1.54.2.1             CMSetStatus(rc,CMPI_RC_OK);
 95 ms.aruran      1.39                 PEG_METHOD_EXIT();
 96                                     return cmpiInstance;
 97 venkat.puvvada 1.37             }
 98                                 catch (const PEGASUS_STD(bad_alloc)&)
 99                                 {
100                                     CMSetStatus(rc, CMPI_RC_ERROR_SYSTEM);
101 ms.aruran      1.39                 PEG_METHOD_EXIT();
102 venkat.puvvada 1.37                 return NULL;
103                                 }
104                             }
105                         
106                             static CMPIData instGetPropertyAt(
107                                 const CMPIInstance* eInst, CMPICount pos, CMPIString** name,
108                                 CMPIStatus* rc)
109                             {
110 r.kieninger    1.54.2.1         CMPIData data={0,CMPI_badValue,{0}};
111 venkat.puvvada 1.37     
112 r.kieninger    1.54.2.1         SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
113 venkat.puvvada 1.37             if (!inst)
114                                 {
115                                     CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
116                                     return data;
117                                 }
118                         
119 r.kieninger    1.54.2.2         const SCMBUnion* value = 0;
120 r.kieninger    1.54.2.1         Boolean isArray = 0;
121                                 Uint32 size = 0;
122                                 CIMType type = (CIMType)0;
123                                 const char* pName=0;
124                         
125                                 SCMO_RC src = inst->getPropertyAt((Uint32)pos,
126                                                                   &pName,
127                                                                   type,
128                                                                   &value,
129                                                                   isArray,
130                                                                   size);
131 r.kieninger    1.54.2.7         switch(src)
132 r.kieninger    1.54.2.1         {
133 r.kieninger    1.54.2.7             case SCMO_OK:
134 r.kieninger    1.54.2.1             {
135 r.kieninger    1.54.2.7                 CMPIType ct=type2CMPIType(type, isArray);
136                                         CMPISCMOUtilities::scmoValue2CMPIData( value, ct, &data );
137                                         if ((ct&~CMPI_ARRAY) == CMPI_string)
138 r.kieninger    1.54.2.1                 {
139 r.kieninger    1.54.2.7                     // We always receive strings as an array of pointers
140                                             // with at least one element, which needs to be released
141                                             // after it was converted to CMPIData
142                                             free((void*)value);
143 r.kieninger    1.54.2.1                 }
144                                         break;
145 r.kieninger    1.54.2.7             }
146                                     case SCMO_INDEX_OUT_OF_BOUND:
147                                     {
148                                         CMSetStatus(rc, CMPI_RC_ERR_NO_SUCH_PROPERTY);
149                                         CMPIData rdata={0,CMPI_nullValue|CMPI_notFound,{0}};
150                                         return rdata;
151                                         break;
152                                     }
153 r.kieninger    1.54.2.1 
154                                     case SCMO_NULL_VALUE:
155 r.kieninger    1.54.2.7             {
156                                         // A NullValue does not indicate an error, but simply that
157                                         // no value has been set for the property.
158                                         data.type = type2CMPIType(type, isArray);
159                                         data.state = CMPI_nullValue;
160                                         data.value.uint64 = 0;
161 r.kieninger    1.54.2.1                 break;
162 r.kieninger    1.54.2.7             }
163 r.kieninger    1.54.2.1 
164                                     default:
165 r.kieninger    1.54.2.3             {
166 r.kieninger    1.54.2.7                 // Other return codes should not appear here, but are possible
167                                         // code wise (i.e. SCMO_NOT_FOUND etc.)
168                                         PEG_TRACE((
169                                             TRC_CMPIPROVIDERINTERFACE,
170                                             Tracer::LEVEL2,
171                                             "Unexpected RC from SCMOInstance.instGetPropertyAt: %d",
172                                             src));
173                                         CMSetStatus(rc, CMPI_RC_ERR_FAILED);
174                                         return data;
175 r.kieninger    1.54.2.3             }
176 r.kieninger    1.54.2.7             break;
177 r.kieninger    1.54.2.1         }
178 venkat.puvvada 1.37     
179                         
180 r.kieninger    1.54.2.1         // Returning the property name as CMPI String
181 venkat.puvvada 1.37             if (name)
182                                 {
183 r.kieninger    1.54.2.1             *name=string2CMPIString(pName);
184 venkat.puvvada 1.37             }
185                         
186                                 CMSetStatus(rc,CMPI_RC_OK);
187                                 return data;
188                             }
189                         
190 kumpf          1.53         static CMPIData instGetProperty(const CMPIInstance* eInst,
191                                 const char *name, CMPIStatus* rc)
192 venkat.puvvada 1.37         {
193 r.kieninger    1.54.2.1         CMPIData data={0,CMPI_badValue,{0}};
194 venkat.puvvada 1.37     
195 r.kieninger    1.54.2.1         SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
196                                 if (!inst)
197 venkat.puvvada 1.37             {
198                                     CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
199                                     return data;
200                                 }
201 r.kieninger    1.54.2.1 
202 venkat.puvvada 1.37             if (!name)
203                                 {
204                                     CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
205                                     return data;
206                                 }
207                         
208 r.kieninger    1.54.2.2         const SCMBUnion* value = 0;
209 r.kieninger    1.54.2.1         Boolean isArray = 0;
210                                 Uint32 size = 0;
211                                 CIMType type = (CIMType)0;
212                         
213                                 SCMO_RC src = inst->getProperty(name, type, &value, isArray, size);
214                                 if (src != SCMO_OK)
215 venkat.puvvada 1.37             {
216 r.kieninger    1.54.2.1             switch(src)
217                                     {
218                                     case SCMO_NOT_FOUND:
219                                         {
220                                             CMSetStatus(rc, CMPI_RC_ERR_NO_SUCH_PROPERTY);
221                                             return data;
222                                         }
223                                         break;
224                         
225                                     case SCMO_NULL_VALUE:
226                                         {
227                                             // A NullValue does not indicate an error, but simply that
228                                             // no value has been set for the property.
229 r.kieninger    1.54.2.8 
230                                             // TBD: Though the CMPI specification mandates to return a 
231                                             // nullvalue when a property exists on an instance but has 
232                                             // not yet been assigned a value, for compatibility with 
233                                             // previous versions we return CMPI_RC_ERR_NO_SUCH_PROPERTY 
234                                             // in this case.
235                                             // If SCMO would distinguish between nullvalues and values
236                                             // that have not been set at all on an instance, we could
237                                             // be more precise here.
238                                             /*
239                                                  // Correct code for nullvalues
240                                                  data.type = type2CMPIType(type, isArray);
241                                                  data.state = CMPI_nullValue;
242                                                  data.value.uint64 = 0;
243                                             */
244                                             // Code for properties that have not been set
245                                             CMSetStatus(rc, CMPI_RC_ERR_NO_SUCH_PROPERTY);
246                                             return data;
247                         
248 r.kieninger    1.54.2.1                 }
249                                         break;
250                         
251                                     default:
252                                         {
253                                             PEG_TRACE((
254                                                 TRC_CMPIPROVIDERINTERFACE,
255                                                 Tracer::LEVEL1,
256                                                 "Unexpected RC from SCMOInstance.instGetPropertyAt: %d",
257                                                 src));
258                                             CMSetStatus(rc, CMPI_RC_ERR_FAILED);
259                                             return data;
260                                         }
261                                         break;
262                                     }
263                                 }
264                                 else
265                                 {
266                                     CMPIType ct=type2CMPIType(type, isArray);
267 r.kieninger    1.54.2.3             CMPISCMOUtilities::scmoValue2CMPIData(value, ct, &data, size);
268                                     if ((ct&~CMPI_ARRAY) == CMPI_string)
269                                     {
270                                         // We always receive strings as an array of pointers
271                                         // with at least one element, which needs to be released
272                                         // after it was converted to CMPIData
273                                         free((void*)value);
274                                     }
275 venkat.puvvada 1.37             }
276 r.kieninger    1.54.2.1 
277                         
278                                 CMSetStatus(rc,CMPI_RC_OK);
279 venkat.puvvada 1.37             return data;
280                             }
281                         
282                         
283 kumpf          1.53         static CMPICount instGetPropertyCount(const CMPIInstance* eInst,
284                                 CMPIStatus* rc)
285 venkat.puvvada 1.37         {
286 r.kieninger    1.54.2.1         SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
287 venkat.puvvada 1.37             if (!inst)
288                                 {
289                                     CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
290                                     return 0;
291                                 }
292                                 CMSetStatus(rc,CMPI_RC_OK);
293                                 return inst->getPropertyCount();
294                             }
295                         
296 r.kieninger    1.54.2.2     static CMPIStatus instSetPropertyWithOrigin(
297                                 const CMPIInstance* eInst,
298                                 const char* name, 
299                                 const CMPIValue* data, 
300                                 const CMPIType type,
301 venkat.puvvada 1.37             const char* origin)
302                             {
303 ms.aruran      1.39             PEG_METHOD_ENTER(
304                                     TRC_CMPIPROVIDERINTERFACE,
305                                     "CMPI_Instance:instSetPropertyWithOrigin()");
306 r.kieninger    1.54.2.1 
307                                 SCMOInstance *inst=(SCMOInstance*)eInst->hdl;
308 venkat.puvvada 1.37             if (!inst)
309                                 {
310 ms.aruran      1.39                 PEG_METHOD_EXIT();
311 venkat.puvvada 1.37                 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
312                                 }
313                         
314 r.kieninger    1.54.2.1         CMPIStatus cmpiRC = {CMPI_RC_OK,0};
315                                 SCMO_RC rc;
316 venkat.puvvada 1.37     
317 r.kieninger    1.54.2.1         if (!(type&CMPI_ARRAY))
318                                 {
319 r.kieninger    1.54.2.2             CIMType cimType=type2CIMType(type);
320                                     SCMBUnion scmoData = value2SCMOValue(data, type);
321 venkat.puvvada 1.37     
322 r.kieninger    1.54.2.1             rc = inst->setPropertyWithOrigin(name,
323                                                                      cimType,
324 r.kieninger    1.54.2.2                                              &scmoData,
325 r.kieninger    1.54.2.1                                              false,  // isArray
326                                                                      0,      // arraySize
327                                                                      origin);
328                                 }
329                                 else
330                                 {
331 r.kieninger    1.54.2.2             //Get the type of the elements in the array
332                                     CMPIType aType=type&~CMPI_ARRAY;
333                                     CIMType cimType=type2CIMType(aType);
334                         
335 r.kieninger    1.54.2.5             if( data == NULL || data->array == NULL )
336 r.kieninger    1.54.2.2             {
337 r.kieninger    1.54.2.5                 // In this case just set a NULL Value
338                                         rc = inst->setPropertyWithOrigin(name,cimType,0,true,0,origin);
339 r.kieninger    1.54.2.2             }
340 r.kieninger    1.54.2.5             else
341                                     {
342                                         // When data is not NULL and data->array is also set
343                                         CMPI_Array* ar = (CMPI_Array*)data->array->hdl;
344                                         CMPIData* arrData = (CMPIData*)ar->hdl;
345                         
346                         
347                                         Uint32 arraySize = arrData->value.uint32;
348                         
349 r.kieninger    1.54.2.2 
350 r.kieninger    1.54.2.5                 // Convert the array of CMPIData to an array of SCMBUnion
351                                         SCMBUnion scmbArray[arraySize];
352                                         for (unsigned int x=0; x<arraySize; x++)
353                                         {
354                                             scmbArray[x] = value2SCMOValue(&(arrData[x].value), type);
355                                         }
356                         
357                                         rc = inst->setPropertyWithOrigin(name,
358                                                                          cimType,
359                                                                          &(scmbArray[0]),
360                                                                          true,          // isArray
361                                                                          arraySize,
362                                                                          origin);
363                                     }
364 venkat.puvvada 1.37             }
365 r.kieninger    1.54.2.1 
366                                 if (rc != SCMO_OK)
367 venkat.puvvada 1.37             {
368 marek          1.43                 PEG_TRACE((TRC_CMPIPROVIDERINTERFACE,Tracer::LEVEL3,
369                                                "Property %s not set on created instance."
370                                                    "Either the property is not part of the class or"
371 r.kieninger    1.54.2.1                        "not part of the property list. SCMO_RC=%d",
372                                                name,
373                                                rc));
374                         
375                                     switch (rc)
376                                     {
377                                         case SCMO_NOT_SAME_ORIGIN:
378                                             cmpiRC.rc = CMPI_RC_ERR_INVALID_PARAMETER;
379                                             break;
380                                         case SCMO_NOT_FOUND:
381 r.kieninger    1.54.2.8                     //TBD: Should return an error here, but previous impl.
382                                             //     returned OK. Is this correct?
383                                             //cmpiRC.rc = CMPI_RC_ERR_NO_SUCH_PROPERTY;
384                                             cmpiRC.rc = CMPI_RC_OK;
385 r.kieninger    1.54.2.1                     break;
386                                         case SCMO_WRONG_TYPE:
387                                             cmpiRC.rc = CMPI_RC_ERR_INVALID_DATA_TYPE;
388                                             break;
389                                         case SCMO_NOT_AN_ARRAY:
390                                             cmpiRC.rc = CMPI_RC_ERR_INVALID_DATA_TYPE;
391                                             break;
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                                     const char* clsRef = ref->getClassName();
486                         
487 r.kieninger    1.54.2.5             if (0 == strcasecmp(clsRef, prevInst->getClassName()))
488 r.kieninger    1.54.2.1             {
489 r.kieninger    1.54.2.6                 // Set the new namespace
490                                         prevInst->setNameSpace(nsRef);
491 r.kieninger    1.54.2.1 
492 r.kieninger    1.54.2.6                 // Now we try to copy the key properties from the given
493                                         // ObjectPath
494                                         // TODO: Remove the previously set key properties.
495                                         //       Set isSet to false and remove userdefined keys.
496                                         CMPIrc rc = CMPISCMOUtilities::copySCMOKeyProperties(
497                                             ref,            // source
498                                             prevInst);      // target
499                                         if (rc != CMPI_RC_OK)
500 marek          1.43                     {
501 r.kieninger    1.54.2.6                     PEG_TRACE_CSTRING(
502                                                 TRC_CMPIPROVIDERINTERFACE,
503                                                 Tracer::LEVEL1,
504                                                 "Failed to copy key bindings");
505                                             PEG_METHOD_EXIT();
506                                             CMReturn(CMPI_RC_ERR_FAILED);
507 r.kieninger    1.54.2.5                 }
508 marek          1.43                 }
509 r.kieninger    1.54.2.1             else
510 marek          1.43                 {
511 r.kieninger    1.54.2.5                 // Uurrgh, changing class on an existing
512 r.kieninger    1.54.2.1                 // CMPIInstance is a prohibited change.
513                                         // Simply returning an error
514                                         PEG_TRACE_CSTRING(
515                                             TRC_CMPIPROVIDERINTERFACE,
516                                             Tracer::LEVEL1,
517                                             "Cannot set objectpath because it would change classname"
518                                             "or namespace of instance");
519                                         PEG_METHOD_EXIT();
520                                         CMReturnWithString(
521 r.kieninger    1.54.2.8                     CMPI_RC_ERR_FAILED,
522 r.kieninger    1.54.2.1                     string2CMPIString("Incompatible ObjectPath"));
523 marek          1.43                 }
524                                 }
525 r.kieninger    1.54.2.1 
526                                 PEG_METHOD_EXIT();
527 r.kieninger    1.54.2.5         CMReturn(CMPI_RC_OK);
528 marek          1.43         }
529                         
530 r.kieninger    1.54.2.1 
531 venkat.puvvada 1.37         static CMPIStatus instSetPropertyFilter(CMPIInstance* eInst,
532                                 const char** propertyList, const char **keys)
533                             {
534 ms.aruran      1.39             PEG_METHOD_ENTER(
535                                     TRC_CMPIPROVIDERINTERFACE,
536                                     "CMPI_Instance:instSetPropertyFilter()");
537 r.kieninger    1.54.2.1 
538 venkat.puvvada 1.37             if (!eInst->hdl)
539                                 {
540 ms.aruran      1.39                 PEG_METHOD_EXIT();
541 venkat.puvvada 1.37                 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
542                                 }
543 marek          1.43             /* The property list is to be applied on the given instance.
544                                    Currently CMPI provider have to call instSetPropertyFilter to honor
545                                    property filters or have to filter for themselves.
546 r.kieninger    1.54.2.1            Removing properties from the SCMOInstance here helps to effectively
547 marek          1.43                avoid the need to carry a property list around in the CMPI layer.
548 kumpf          1.53     
549 marek          1.48                A (propertyList == 0) means the property list is null and there
550                                    should be no filtering.
551 kumpf          1.53     
552 marek          1.48                An empty propertylist(no property to be returned) is represented by
553                                    a valid propertyList pointer pointing to a null pointer, i.e.
554                                    (*propertyList == 0)
555 marek          1.43             */
556 venkat.puvvada 1.37     
557 r.kieninger    1.54.2.1         SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
558                                 inst->setPropertyFilter(propertyList);
559                         
560 ms.aruran      1.39             PEG_METHOD_EXIT();
561 venkat.puvvada 1.37             CMReturn(CMPI_RC_OK);
562                             }
563                         
564                             static CMPIStatus instSetPropertyFilterIgnore(CMPIInstance* eInst,
565                                 const char** propertyList, const char **keys)
566                             {
567                                 /* We ignore it.  */
568                                 CMReturn ( CMPI_RC_OK);
569                             }
570 schuur         1.1      
571 dave.sudlik    1.31     
572 schuur         1.1      }
573                         
574                         static CMPIInstanceFT instance_FT={
575 venkat.puvvada 1.37         CMPICurrentVersion,
576                             instRelease,
577                             instClone,
578                             instGetProperty,
579                             instGetPropertyAt,
580                             instGetPropertyCount,
581                             instSetProperty,
582                             instGetObjectPath,
583                             instSetPropertyFilter,
584 konrad.r       1.19     #if defined(CMPI_VER_100)
585 venkat.puvvada 1.37         instSetObjectPath,
586 konrad.r       1.19     #endif
587 dave.sudlik    1.31     #if defined(CMPI_VER_200)
588 venkat.puvvada 1.37         instSetPropertyWithOrigin,
589 dave.sudlik    1.31     #endif
590 schuur         1.1      };
591                         
592                         static CMPIInstanceFT instanceOnStack_FT={
593 venkat.puvvada 1.37         CMPICurrentVersion,
594                             instReleaseNop,
595                             instClone,
596                             instGetProperty,
597                             instGetPropertyAt,
598                             instGetPropertyCount,
599                             instSetProperty,
600                             instGetObjectPath,
601                             instSetPropertyFilterIgnore,
602 konrad.r       1.19     #if defined(CMPI_VER_100)
603 venkat.puvvada 1.37         instSetObjectPath,
604 konrad.r       1.19     #endif
605 dave.sudlik    1.31     #if defined(CMPI_VER_200)
606 venkat.puvvada 1.37         instSetPropertyWithOrigin,
607 dave.sudlik    1.31     #endif
608 schuur         1.1      };
609                         
610                         CMPIInstanceFT *CMPI_Instance_Ftab=&instance_FT;
611                         CMPIInstanceFT *CMPI_InstanceOnStack_Ftab=&instanceOnStack_FT;
612                         
613                         
614 r.kieninger    1.54.2.8 CMPI_InstanceOnStack::CMPI_InstanceOnStack(const SCMOInstance& ci)
615 venkat.puvvada 1.37     {
616 ms.aruran      1.39         PEG_METHOD_ENTER(
617                                 TRC_CMPIPROVIDERINTERFACE,
618                                 "CMPI_InstanceOnStack::CMPI_InstanceOnStack()");
619                         
620 venkat.puvvada 1.37         hdl=(void*)&ci;
621                             ft=CMPI_InstanceOnStack_Ftab;
622 ms.aruran      1.39         PEG_METHOD_EXIT();
623 venkat.puvvada 1.37     }
624 schuur         1.1      
625                         
626                         PEGASUS_NAMESPACE_END
627 kumpf          1.53     

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2