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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2