(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.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                                              scmbArray[x] = value2SCMOValue(&(arrData[x].value), type);
358                                          }
359                          
360                                          rc = inst->setPropertyWithOrigin(name,
361                                                                           cimType,
362                                                                           &(scmbArray[0]),
363                                                                           true,          // isArray
364                                                                           arraySize,
365                                                                           origin);
366                                      }
367 venkat.puvvada 1.37              }
368 r.kieninger    1.54.2.1  
369                                  if (rc != SCMO_OK)
370 venkat.puvvada 1.37              {
371 marek          1.43                  PEG_TRACE((TRC_CMPIPROVIDERINTERFACE,Tracer::LEVEL3,
372                                                 "Property %s not set on created instance."
373                                                     "Either the property is not part of the class or"
374 r.kieninger    1.54.2.1                         "not part of the property list. SCMO_RC=%d",
375                                                 name,
376                                                 rc));
377                          
378                                      switch (rc)
379                                      {
380                                          case SCMO_NOT_SAME_ORIGIN:
381                                              cmpiRC.rc = CMPI_RC_ERR_INVALID_PARAMETER;
382                                              break;
383                                          case SCMO_NOT_FOUND:
384 r.kieninger    1.54.2.8                      //TBD: Should return an error here, but previous impl.
385                                              //     returned OK. Is this correct?
386                                              //cmpiRC.rc = CMPI_RC_ERR_NO_SUCH_PROPERTY;
387                                              cmpiRC.rc = CMPI_RC_OK;
388 r.kieninger    1.54.2.1                      break;
389                                          case SCMO_WRONG_TYPE:
390                                          case SCMO_NOT_AN_ARRAY:
391                                          case SCMO_IS_AN_ARRAY:
392                                              cmpiRC.rc = CMPI_RC_ERR_INVALID_DATA_TYPE;
393                                              break;
394                                          default:
395                                              cmpiRC.rc = CMPI_RC_ERR_FAILED;
396                                              break;
397 venkat.puvvada 1.37              }
398 r.kieninger    1.54.2.1          }
399                          
400 ms.aruran      1.39              PEG_METHOD_EXIT();
401 r.kieninger    1.54.2.1          return(cmpiRC);
402 venkat.puvvada 1.37          }
403                          
404                              static CMPIStatus instSetProperty(const CMPIInstance* eInst,
405 kumpf          1.53              const char *name, const CMPIValue* data, CMPIType type)
406 venkat.puvvada 1.37          {
407                                  return instSetPropertyWithOrigin(eInst, name, data, type, NULL);
408                              }
409                          
410                              static CMPIObjectPath* instGetObjectPath(const CMPIInstance* eInst,
411 kumpf          1.53              CMPIStatus* rc)
412 venkat.puvvada 1.37          {
413 ms.aruran      1.39              PEG_METHOD_ENTER(
414                                      TRC_CMPIPROVIDERINTERFACE,
415                                      "CMPI_Instance:instGetObjectPath()");
416 r.kieninger    1.54.2.1  
417                                  SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
418 venkat.puvvada 1.37              if (!inst)
419                                  {
420                                      CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
421 ms.aruran      1.39                  PEG_METHOD_EXIT();
422 venkat.puvvada 1.37                  return NULL;
423                                  }
424 r.kieninger    1.54.2.1  
425 venkat.puvvada 1.37              try
426                                  {
427 r.kieninger    1.54.2.7              // Generate keys from instance
428                                      inst->buildKeyBindingsFromProperties();
429                          
430 r.kieninger    1.54.2.1              // Since we make no difference between ObjectPath and Instance,
431                                      // we simply clone using the ObjectPathOnly option.
432                                      SCMOInstance* cInst = new SCMOInstance(inst->clone(true));
433 r.kieninger    1.54.2.7  
434 r.kieninger    1.54.2.1              CMPIObjectPath* cmpiObjPath =
435 r.kieninger    1.54.2.7                  reinterpret_cast<CMPIObjectPath *>
436                                          (new CMPI_Object(cInst,CMPI_Object::ObjectTypeObjectPath));
437 mreddy         1.35                  CMSetStatus(rc,CMPI_RC_OK);
438 ms.aruran      1.39                  PEG_METHOD_EXIT();
439 r.kieninger    1.54.2.1              return cmpiObjPath;
440 venkat.puvvada 1.37              }
441                                  catch (const PEGASUS_STD(bad_alloc)&)
442                                  {
443                                      CMSetStatus(rc, CMPI_RC_ERROR_SYSTEM);
444 ms.aruran      1.39                  PEG_METHOD_EXIT();
445 venkat.puvvada 1.37                  return NULL;
446                                  }
447                              }
448                          
449                              static CMPIStatus instSetObjectPath(
450 kumpf          1.53              CMPIInstance* eInst,
451 venkat.puvvada 1.37              const CMPIObjectPath *obj)
452                              {
453 ms.aruran      1.39              PEG_METHOD_ENTER(
454                                      TRC_CMPIPROVIDERINTERFACE,
455                                      "CMPI_Instance:instSetObjectPath()");
456 r.kieninger    1.54.2.5  
457                                  SCMOInstance* prevInst=(SCMOInstance*)eInst->hdl;
458                                  if (prevInst==NULL)
459 venkat.puvvada 1.37              {
460 ms.aruran      1.39                  PEG_METHOD_EXIT();
461 venkat.puvvada 1.37                  CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
462                                  }
463                                  if (obj==NULL)
464                                  {
465 ms.aruran      1.39                  PEG_METHOD_EXIT();
466 r.kieninger    1.54.2.1              CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
467 venkat.puvvada 1.37              }
468                          
469 r.kieninger    1.54.2.1          SCMOInstance* ref = (SCMOInstance*)(obj->hdl);
470 r.kieninger    1.54.2.5          if (ref->isSame(*prevInst))
471 venkat.puvvada 1.37              {
472 r.kieninger    1.54.2.1              // Since we represent CMPIObjectPath as well as CMPIInstance
473                                      // through SCMOInstance, in this case both point to the same
474                                      // physical SCMB and the objectPath is already set.
475                                      // So this path is a nop.
476 ms.aruran      1.39                  PEG_METHOD_EXIT();
477 r.kieninger    1.54.2.5              CMReturn(CMPI_RC_OK);
478 venkat.puvvada 1.37              }
479 r.kieninger    1.54.2.1          else
480 marek          1.43              {
481 r.kieninger    1.54.2.1              // It is not possible to have an instance or objectPath in
482                                      // this implementation without a classname or namespace.
483                                      const char* nsRef = ref->getNameSpace();
484 marek          1.54.2.9              Uint64 clsRefL;
485                                      const char* clsRef = ref->getClassName_l(clsRefL);
486                                      Uint64 clsPrevInstL;
487                                      const char* clsPrevInst = prevInst->getClassName_l(clsPrevInstL);
488 r.kieninger    1.54.2.1  
489 marek          1.54.2.9              if (System::strncasecmp(clsRef,clsRefL,clsPrevInst,clsPrevInstL))
490 r.kieninger    1.54.2.1              {
491 r.kieninger    1.54.2.6                  // Set the new namespace
492                                          prevInst->setNameSpace(nsRef);
493 r.kieninger    1.54.2.1  
494 r.kieninger    1.54.2.10                 // Remove the previous key properties
495 r.kieninger    1.54.2.11                 prevInst->clearKeyBindings();
496 r.kieninger    1.54.2.10 
497                                          // Copy the key properties from the given ObjectPath
498 r.kieninger    1.54.2.6                  CMPIrc rc = CMPISCMOUtilities::copySCMOKeyProperties(
499                                              ref,            // source
500                                              prevInst);      // target
501                                          if (rc != CMPI_RC_OK)
502 marek          1.43                      {
503 r.kieninger    1.54.2.6                      PEG_TRACE_CSTRING(
504                                                  TRC_CMPIPROVIDERINTERFACE,
505                                                  Tracer::LEVEL1,
506                                                  "Failed to copy key bindings");
507                                              PEG_METHOD_EXIT();
508                                              CMReturn(CMPI_RC_ERR_FAILED);
509 r.kieninger    1.54.2.5                  }
510 marek          1.43                  }
511 r.kieninger    1.54.2.1              else
512 marek          1.43                  {
513 r.kieninger    1.54.2.5                  // Uurrgh, changing class on an existing
514 r.kieninger    1.54.2.1                  // CMPIInstance is a prohibited change.
515                                          // Simply returning an error
516                                          PEG_TRACE_CSTRING(
517                                              TRC_CMPIPROVIDERINTERFACE,
518                                              Tracer::LEVEL1,
519                                              "Cannot set objectpath because it would change classname"
520                                              "or namespace of instance");
521                                          PEG_METHOD_EXIT();
522                                          CMReturnWithString(
523 r.kieninger    1.54.2.8                      CMPI_RC_ERR_FAILED,
524 r.kieninger    1.54.2.1                      string2CMPIString("Incompatible ObjectPath"));
525 marek          1.43                  }
526                                  }
527 r.kieninger    1.54.2.1  
528                                  PEG_METHOD_EXIT();
529 r.kieninger    1.54.2.5          CMReturn(CMPI_RC_OK);
530 marek          1.43          }
531                          
532 r.kieninger    1.54.2.1  
533 venkat.puvvada 1.37          static CMPIStatus instSetPropertyFilter(CMPIInstance* eInst,
534                                  const char** propertyList, const char **keys)
535                              {
536 ms.aruran      1.39              PEG_METHOD_ENTER(
537                                      TRC_CMPIPROVIDERINTERFACE,
538                                      "CMPI_Instance:instSetPropertyFilter()");
539 r.kieninger    1.54.2.1  
540 venkat.puvvada 1.37              if (!eInst->hdl)
541                                  {
542 ms.aruran      1.39                  PEG_METHOD_EXIT();
543 venkat.puvvada 1.37                  CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
544                                  }
545 marek          1.43              /* The property list is to be applied on the given instance.
546                                     Currently CMPI provider have to call instSetPropertyFilter to honor
547                                     property filters or have to filter for themselves.
548 r.kieninger    1.54.2.1             Removing properties from the SCMOInstance here helps to effectively
549 marek          1.43                 avoid the need to carry a property list around in the CMPI layer.
550 kumpf          1.53      
551 marek          1.48                 A (propertyList == 0) means the property list is null and there
552                                     should be no filtering.
553 kumpf          1.53      
554 marek          1.48                 An empty propertylist(no property to be returned) is represented by
555                                     a valid propertyList pointer pointing to a null pointer, i.e.
556                                     (*propertyList == 0)
557 marek          1.43              */
558 venkat.puvvada 1.37      
559 r.kieninger    1.54.2.1          SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
560                                  inst->setPropertyFilter(propertyList);
561                          
562 ms.aruran      1.39              PEG_METHOD_EXIT();
563 venkat.puvvada 1.37              CMReturn(CMPI_RC_OK);
564                              }
565                          
566                              static CMPIStatus instSetPropertyFilterIgnore(CMPIInstance* eInst,
567                                  const char** propertyList, const char **keys)
568                              {
569                                  /* We ignore it.  */
570                                  CMReturn ( CMPI_RC_OK);
571                              }
572 schuur         1.1       
573 dave.sudlik    1.31      
574 schuur         1.1       }
575                          
576                          static CMPIInstanceFT instance_FT={
577 venkat.puvvada 1.37          CMPICurrentVersion,
578                              instRelease,
579                              instClone,
580                              instGetProperty,
581                              instGetPropertyAt,
582                              instGetPropertyCount,
583                              instSetProperty,
584                              instGetObjectPath,
585                              instSetPropertyFilter,
586 konrad.r       1.19      #if defined(CMPI_VER_100)
587 venkat.puvvada 1.37          instSetObjectPath,
588 konrad.r       1.19      #endif
589 dave.sudlik    1.31      #if defined(CMPI_VER_200)
590 venkat.puvvada 1.37          instSetPropertyWithOrigin,
591 dave.sudlik    1.31      #endif
592 schuur         1.1       };
593                          
594                          static CMPIInstanceFT instanceOnStack_FT={
595 venkat.puvvada 1.37          CMPICurrentVersion,
596                              instReleaseNop,
597                              instClone,
598                              instGetProperty,
599                              instGetPropertyAt,
600                              instGetPropertyCount,
601                              instSetProperty,
602                              instGetObjectPath,
603                              instSetPropertyFilterIgnore,
604 konrad.r       1.19      #if defined(CMPI_VER_100)
605 venkat.puvvada 1.37          instSetObjectPath,
606 konrad.r       1.19      #endif
607 dave.sudlik    1.31      #if defined(CMPI_VER_200)
608 venkat.puvvada 1.37          instSetPropertyWithOrigin,
609 dave.sudlik    1.31      #endif
610 schuur         1.1       };
611                          
612                          CMPIInstanceFT *CMPI_Instance_Ftab=&instance_FT;
613                          CMPIInstanceFT *CMPI_InstanceOnStack_Ftab=&instanceOnStack_FT;
614                          
615                          
616 r.kieninger    1.54.2.10 CMPI_InstanceOnStack::CMPI_InstanceOnStack(const SCMOInstance* ci)
617                          {
618                              PEG_METHOD_ENTER(
619                                  TRC_CMPIPROVIDERINTERFACE,
620                                  "CMPI_InstanceOnStack::CMPI_InstanceOnStack()");
621                          
622                              hdl=(void*)ci;
623                              ft=CMPI_InstanceOnStack_Ftab;
624                              PEG_METHOD_EXIT();
625                          }
626                          
627 r.kieninger    1.54.2.8  CMPI_InstanceOnStack::CMPI_InstanceOnStack(const SCMOInstance& ci)
628 venkat.puvvada 1.37      {
629 ms.aruran      1.39          PEG_METHOD_ENTER(
630                                  TRC_CMPIPROVIDERINTERFACE,
631                                  "CMPI_InstanceOnStack::CMPI_InstanceOnStack()");
632                          
633 r.kieninger    1.54.2.10     hdl=(void*) new SCMOInstance(ci);
634 venkat.puvvada 1.37          ft=CMPI_InstanceOnStack_Ftab;
635 ms.aruran      1.39          PEG_METHOD_EXIT();
636 venkat.puvvada 1.37      }
637 schuur         1.1       
638 r.kieninger    1.54.2.10 CMPI_InstanceOnStack::~CMPI_InstanceOnStack()
639                          {
640                              if (hdl)
641                              {
642                                  delete((SCMOInstance*)hdl);
643                              }
644                          }
645                          
646 schuur         1.1       
647                          PEGASUS_NAMESPACE_END
648 kumpf          1.53      

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2