(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.1                 reinterpret_cast<CMPIInstance *>(new CMPI_Object(cInst,true));
 93                                     CMSetStatus(rc,CMPI_RC_OK);
 94 ms.aruran      1.39                 PEG_METHOD_EXIT();
 95                                     return cmpiInstance;
 96 venkat.puvvada 1.37             }
 97                                 catch (const PEGASUS_STD(bad_alloc)&)
 98                                 {
 99                                     CMSetStatus(rc, CMPI_RC_ERROR_SYSTEM);
100 ms.aruran      1.39                 PEG_METHOD_EXIT();
101 venkat.puvvada 1.37                 return NULL;
102                                 }
103                             }
104                         
105                             static CMPIData instGetPropertyAt(
106                                 const CMPIInstance* eInst, CMPICount pos, CMPIString** name,
107                                 CMPIStatus* rc)
108                             {
109 r.kieninger    1.54.2.1         CMPIData data={0,CMPI_badValue,{0}};
110 venkat.puvvada 1.37     
111 r.kieninger    1.54.2.1         SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
112 venkat.puvvada 1.37             if (!inst)
113                                 {
114                                     CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
115                                     return data;
116                                 }
117                         
118 r.kieninger    1.54.2.1         const void* value = 0;
119                                 Boolean isArray = 0;
120                                 Uint32 size = 0;
121                                 CIMType type = (CIMType)0;
122                                 const char* pName=0;
123                         
124                                 SCMO_RC src = inst->getPropertyAt((Uint32)pos,
125                                                                   &pName,
126                                                                   type,
127                                                                   &value,
128                                                                   isArray,
129                                                                   size);
130                                 if (src != SCMO_OK)
131                                 {
132                                     switch(src)
133                                     {
134                                     case SCMO_INDEX_OUT_OF_BOUND:
135                                         {
136                                             CMSetStatus(rc, CMPI_RC_ERR_NO_SUCH_PROPERTY);
137                                             CMPIData rdata={0,CMPI_nullValue|CMPI_notFound,{0}};
138                                             return rdata;
139 r.kieninger    1.54.2.1                 }
140                                         break;
141                         
142                                     case SCMO_NULL_VALUE:
143                                         {
144                                             // A NullValue does not indicate an error, but simply that
145                                             // no value has been set for the property.
146                                             data.type = type2CMPIType(type, isArray);
147                                             data.state = CMPI_nullValue;
148                                             data.value.uint64 = 0;
149                                         }
150                                         break;
151                         
152                                     default:
153                                         {
154                                             PEG_TRACE((
155                                                 TRC_CMPIPROVIDERINTERFACE,
156                                                 Tracer::LEVEL1,
157                                                 "Unexpected RC from SCMOInstance.instGetPropertyAt: %d",
158                                                 src));
159                                             CMSetStatus(rc, CMPI_RC_ERR_FAILED);
160 r.kieninger    1.54.2.1                     return data;
161                                         }
162                                         break;
163                                     }
164                                 }
165                                 else
166 venkat.puvvada 1.37             {
167 r.kieninger    1.54.2.1             CMPIType ct=type2CMPIType(type, isArray);
168                                     CMPISCMOUtilities::scmoValue2CMPIData( value, ct, &data );
169                                 }
170 venkat.puvvada 1.37     
171                         
172 r.kieninger    1.54.2.1         // Returning the property name as CMPI String
173 venkat.puvvada 1.37             if (name)
174                                 {
175 r.kieninger    1.54.2.1             *name=string2CMPIString(pName);
176 venkat.puvvada 1.37             }
177                         
178                                 CMSetStatus(rc,CMPI_RC_OK);
179                                 return data;
180                             }
181                         
182 kumpf          1.53         static CMPIData instGetProperty(const CMPIInstance* eInst,
183                                 const char *name, CMPIStatus* rc)
184 venkat.puvvada 1.37         {
185 r.kieninger    1.54.2.1         CMPIData data={0,CMPI_badValue,{0}};
186 venkat.puvvada 1.37     
187 r.kieninger    1.54.2.1         SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
188                                 if (!inst)
189 venkat.puvvada 1.37             {
190                                     CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
191                                     return data;
192                                 }
193 r.kieninger    1.54.2.1 
194 venkat.puvvada 1.37             if (!name)
195                                 {
196                                     CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
197                                     return data;
198                                 }
199                         
200 r.kieninger    1.54.2.1         const void* value = 0;
201                                 Boolean isArray = 0;
202                                 Uint32 size = 0;
203                                 CIMType type = (CIMType)0;
204                         
205                                 SCMO_RC src = inst->getProperty(name, type, &value, isArray, size);
206                                 if (src != SCMO_OK)
207 venkat.puvvada 1.37             {
208 r.kieninger    1.54.2.1             switch(src)
209                                     {
210                                     case SCMO_NOT_FOUND:
211                                         {
212                                             CMSetStatus(rc, CMPI_RC_ERR_NO_SUCH_PROPERTY);
213                                             return data;
214                                         }
215                                         break;
216                         
217                                     case SCMO_NULL_VALUE:
218                                         {
219                                             // A NullValue does not indicate an error, but simply that
220                                             // no value has been set for the property.
221                                             data.type = type2CMPIType(type, isArray);
222                                             data.state = CMPI_nullValue;
223                                             data.value.uint64 = 0;
224                                         }
225                                         break;
226                         
227                                     default:
228                                         {
229 r.kieninger    1.54.2.1                     PEG_TRACE((
230                                                 TRC_CMPIPROVIDERINTERFACE,
231                                                 Tracer::LEVEL1,
232                                                 "Unexpected RC from SCMOInstance.instGetPropertyAt: %d",
233                                                 src));
234                                             CMSetStatus(rc, CMPI_RC_ERR_FAILED);
235                                             return data;
236                                         }
237                                         break;
238                                     }
239                                 }
240                                 else
241                                 {
242                                     CMPIType ct=type2CMPIType(type, isArray);
243                                     CMPISCMOUtilities::scmoValue2CMPIData( value, ct, &data );
244 venkat.puvvada 1.37             }
245 r.kieninger    1.54.2.1 
246                         
247                                 CMSetStatus(rc,CMPI_RC_OK);
248 venkat.puvvada 1.37             return data;
249                             }
250                         
251                         
252 kumpf          1.53         static CMPICount instGetPropertyCount(const CMPIInstance* eInst,
253                                 CMPIStatus* rc)
254 venkat.puvvada 1.37         {
255 r.kieninger    1.54.2.1         SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
256 venkat.puvvada 1.37             if (!inst)
257                                 {
258                                     CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
259                                     return 0;
260                                 }
261                                 CMSetStatus(rc,CMPI_RC_OK);
262                                 return inst->getPropertyCount();
263                             }
264                         
265 kumpf          1.53         static CMPIStatus instSetPropertyWithOrigin(const CMPIInstance* eInst,
266 venkat.puvvada 1.37             const char* name, const CMPIValue* data, const CMPIType type,
267                                 const char* origin)
268                             {
269 ms.aruran      1.39             PEG_METHOD_ENTER(
270                                     TRC_CMPIPROVIDERINTERFACE,
271                                     "CMPI_Instance:instSetPropertyWithOrigin()");
272 r.kieninger    1.54.2.1 
273                                 SCMOInstance *inst=(SCMOInstance*)eInst->hdl;
274 venkat.puvvada 1.37             if (!inst)
275                                 {
276 ms.aruran      1.39                 PEG_METHOD_EXIT();
277 venkat.puvvada 1.37                 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
278                                 }
279                         
280 r.kieninger    1.54.2.1         CMPIStatus cmpiRC = {CMPI_RC_OK,0};
281                                 SCMO_RC rc;
282 venkat.puvvada 1.37     
283 r.kieninger    1.54.2.1         void* scmoData = (void*)data;
284 venkat.puvvada 1.37     
285 r.kieninger    1.54.2.1         CIMType cimType=type2CIMType(type);
286                                 if (!(type&CMPI_ARRAY))
287                                 {
288 venkat.puvvada 1.37     
289 r.kieninger    1.54.2.1             if (type == CMPI_dateTime)
290                                     {
291                                         scmoData = CMPISCMOUtilities::scmoDateTimeFromCMPI(
292                                             data->dateTime);
293                                     }
294                                     // The value structure of CMPIValue matches that of
295                                     // SCMO Values as long as not an array.
296                                     rc = inst->setPropertyWithOrigin(name,
297                                                                      cimType,
298                                                                      scmoData,
299                                                                      false,  // isArray
300                                                                      0,      // arraySize
301                                                                      origin);
302                         
303                                 }
304                                 else
305                                 {
306                                     // --rk-> TBD
307                                     return(cmpiRC);
308 kumpf          1.53                 /* The CMPI interface uses the type "CMPI_instance" to represent
309                                        both embedded objects and embedded instances. CMPI has no
310                                        "CMPI_object" type. So when converting a CMPIValue with type
311                                        "CMPI_instance" to a CIMValue (see value2CIMValue) the type
312                                        CIMTYPE_OBJECT is always used. If the property's type is
313 venkat.puvvada 1.37                    CIMTYPE_INSTANCE, and the value's type is CIMTYPE_OBJECT, then
314                                        we convert the value's type to match the property's type.
315 kumpf          1.53                 if (cp.getType() == CIMTYPE_INSTANCE &&
316 venkat.puvvada 1.37                     v.getType() == CIMTYPE_OBJECT)
317                                     {
318 venkat.puvvada 1.38                     if (cp.isArray())
319                                         {
320                                             if (!v.isArray())
321                                             {
322 kavita.gupta   1.40                             PEG_TRACE((
323                                                     TRC_CMPIPROVIDERINTERFACE,
324 marek          1.44                                 Tracer::LEVEL1,
325 kavita.gupta   1.40                                 "TypeMisMatch, Expected Type: %s, Actual Type: %s",
326                                                     cimTypeToString(cp.getType()),
327                                                     cimTypeToString(v.getType())));
328                                                 PEG_METHOD_EXIT();
329                                                 CMReturn(CMPI_RC_ERR_TYPE_MISMATCH);
330 venkat.puvvada 1.38                         }
331                                             Array<CIMObject> tmpObjs;
332                                             Array<CIMInstance> tmpInsts;
333                                             v.get(tmpObjs);
334                                             for (Uint32 i = 0; i < tmpObjs.size() ; ++i)
335                                             {
336                                                 tmpInsts.append(CIMInstance(tmpObjs[i]));
337 kumpf          1.53                         }
338 venkat.puvvada 1.38                         v.set(tmpInsts);
339                                         }
340                                         else
341 kumpf          1.53                     {
342 venkat.puvvada 1.38                         CIMObject co;
343                                             v.get(co);
344                                             if (co.isInstance())
345                                                 v.set(CIMInstance(co));
346                                         }
347 venkat.puvvada 1.37                 }
348                                     try
349 dave.sudlik    1.31                 {
350 venkat.puvvada 1.37                     cp.setValue(v);
351                                         if (origin)
352                                         {
353                                             CIMName oName(origin);
354                                             cp.setClassOrigin(oName);
355                                         }
356 dave.sudlik    1.31                 }
357 venkat.puvvada 1.37                 catch (const TypeMismatchException &)
358                                     {
359 ms.aruran      1.39                     PEG_TRACE((
360                                             TRC_CMPIPROVIDERINTERFACE,
361 marek          1.44                         Tracer::LEVEL1,
362 ms.aruran      1.39                         " TypeMisMatch exception for: %s",
363                                             name));
364                                         if (getenv("PEGASUS_CMPI_CHECKTYPES")!=NULL)
365                                         {
366                                             PEG_TRACE_CSTRING(
367                                                 TRC_CMPIPROVIDERINTERFACE,
368 marek          1.44                             Tracer::LEVEL1,
369 ms.aruran      1.39                             " Aborting because of CMPI_CHECKTYPES..");
370 venkat.puvvada 1.37                             abort();
371                                         }
372 ms.aruran      1.39                     PEG_METHOD_EXIT();
373 venkat.puvvada 1.37                     CMReturn(CMPI_RC_ERR_TYPE_MISMATCH);
374                                     }
375                                     catch (const InvalidNameException &)
376                                     {
377 ms.aruran      1.39                     PEG_TRACE((
378                                             TRC_CMPIPROVIDERINTERFACE,
379 marek          1.44                         Tracer::LEVEL1,
380 ms.aruran      1.39                         " InvalidName exception for: %s",
381                                             origin));
382                         
383                                         PEG_METHOD_EXIT();
384 venkat.puvvada 1.37                     CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
385                                     }
386                                     catch (const Exception &e)
387                                     {
388 thilo.boehm    1.46                     PEG_TRACE((TRC_CMPIPROVIDERINTERFACE,Tracer::LEVEL1,
389                                             "Exception for %s: %s",name,
390                                             (const char*)e.getMessage().getCString()));
391 ms.aruran      1.39                     if (getenv("PEGASUS_CMPI_CHECKTYPES")!=NULL)
392                                         {
393                                             PEG_TRACE_CSTRING(
394                                                 TRC_CMPIPROVIDERINTERFACE,
395 marek          1.44                             Tracer::LEVEL1,
396 ms.aruran      1.39                             " Aborting because of CMPI_CHECKTYPES..");
397 venkat.puvvada 1.37                             abort();
398                                         }
399 ms.aruran      1.39                     PEG_METHOD_EXIT();
400 venkat.puvvada 1.37                     CMReturnWithString(CMPI_RC_ERR_FAILED,
401                                             reinterpret_cast<CMPIString*>(
402                                             new CMPI_Object(e.getMessage())));
403                                     }
404 r.kieninger    1.54.2.1             */
405 venkat.puvvada 1.37             }
406 r.kieninger    1.54.2.1 
407                                 if (rc != SCMO_OK)
408 venkat.puvvada 1.37             {
409 marek          1.43                 PEG_TRACE((TRC_CMPIPROVIDERINTERFACE,Tracer::LEVEL3,
410                                                "Property %s not set on created instance."
411                                                    "Either the property is not part of the class or"
412 r.kieninger    1.54.2.1                        "not part of the property list. SCMO_RC=%d",
413                                                name,
414                                                rc));
415                         
416                                     switch (rc)
417                                     {
418                                         case SCMO_NOT_SAME_ORIGIN:
419                                             cmpiRC.rc = CMPI_RC_ERR_INVALID_PARAMETER;
420                                             break;
421                                         case SCMO_NOT_FOUND:
422                                             cmpiRC.rc = CMPI_RC_ERR_NO_SUCH_PROPERTY;
423                                             break;
424                                         case SCMO_WRONG_TYPE:
425                                             cmpiRC.rc = CMPI_RC_ERR_INVALID_DATA_TYPE;
426                                             break;
427                                         case SCMO_NOT_AN_ARRAY:
428                                             cmpiRC.rc = CMPI_RC_ERR_INVALID_DATA_TYPE;
429                                             break;
430                                         case SCMO_IS_AN_ARRAY:
431                                             cmpiRC.rc = CMPI_RC_ERR_INVALID_DATA_TYPE;
432                                             break;
433 r.kieninger    1.54.2.1                 default:
434                                             cmpiRC.rc = CMPI_RC_ERR_FAILED;
435                                             break;
436 venkat.puvvada 1.37             }
437 r.kieninger    1.54.2.1         }
438                         
439 ms.aruran      1.39             PEG_METHOD_EXIT();
440 r.kieninger    1.54.2.1         return(cmpiRC);
441 venkat.puvvada 1.37         }
442                         
443                             static CMPIStatus instSetProperty(const CMPIInstance* eInst,
444 kumpf          1.53             const char *name, const CMPIValue* data, CMPIType type)
445 venkat.puvvada 1.37         {
446                                 return instSetPropertyWithOrigin(eInst, name, data, type, NULL);
447                             }
448                         
449                             static CMPIObjectPath* instGetObjectPath(const CMPIInstance* eInst,
450 kumpf          1.53             CMPIStatus* rc)
451 venkat.puvvada 1.37         {
452 ms.aruran      1.39             PEG_METHOD_ENTER(
453                                     TRC_CMPIPROVIDERINTERFACE,
454                                     "CMPI_Instance:instGetObjectPath()");
455 r.kieninger    1.54.2.1 
456                                 SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
457 venkat.puvvada 1.37             if (!inst)
458                                 {
459                                     CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
460 ms.aruran      1.39                 PEG_METHOD_EXIT();
461 venkat.puvvada 1.37                 return NULL;
462                                 }
463 r.kieninger    1.54.2.1 
464 venkat.puvvada 1.37             try
465                                 {
466 r.kieninger    1.54.2.1             // Since we make no difference between ObjectPath and Instance,
467                                     // we simply clone using the ObjectPathOnly option.
468                                     SCMOInstance* cInst = new SCMOInstance(inst->clone(true));
469                                     CMPIObjectPath* cmpiObjPath =
470                                         reinterpret_cast<CMPIObjectPath *>(new CMPI_Object(cInst));
471 mreddy         1.35                 CMSetStatus(rc,CMPI_RC_OK);
472 ms.aruran      1.39                 PEG_METHOD_EXIT();
473 r.kieninger    1.54.2.1             return cmpiObjPath;
474 venkat.puvvada 1.37             }
475                                 catch (const PEGASUS_STD(bad_alloc)&)
476                                 {
477                                     CMSetStatus(rc, CMPI_RC_ERROR_SYSTEM);
478 ms.aruran      1.39                 PEG_METHOD_EXIT();
479 venkat.puvvada 1.37                 return NULL;
480                                 }
481                             }
482                         
483                             static CMPIStatus instSetObjectPath(
484 kumpf          1.53             CMPIInstance* eInst,
485 venkat.puvvada 1.37             const CMPIObjectPath *obj)
486                             {
487 ms.aruran      1.39             PEG_METHOD_ENTER(
488                                     TRC_CMPIPROVIDERINTERFACE,
489                                     "CMPI_Instance:instSetObjectPath()");
490 r.kieninger    1.54.2.1         SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
491 venkat.puvvada 1.37             if (inst==NULL)
492                                 {
493 ms.aruran      1.39                 PEG_METHOD_EXIT();
494 venkat.puvvada 1.37                 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
495                                 }
496                                 if (obj==NULL)
497                                 {
498 ms.aruran      1.39                 PEG_METHOD_EXIT();
499 r.kieninger    1.54.2.1             CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
500 venkat.puvvada 1.37             }
501                         
502 r.kieninger    1.54.2.1         SCMOInstance* ref = (SCMOInstance*)(obj->hdl);
503                                 if (ref->isSame(*inst))
504 venkat.puvvada 1.37             {
505 r.kieninger    1.54.2.1             // Since we represent CMPIObjectPath as well as CMPIInstance
506                                     // through SCMOInstance, in this case both point to the same
507                                     // physical SCMB and the objectPath is already set.
508                                     // So this path is a nop.
509 ms.aruran      1.39                 PEG_METHOD_EXIT();
510 r.kieninger    1.54.2.1             CMReturn ( CMPI_RC_OK);
511 venkat.puvvada 1.37             }
512 r.kieninger    1.54.2.1         else
513 marek          1.43             {
514 r.kieninger    1.54.2.1             // It is not possible to have an instance or objectPath in
515                                     // this implementation without a classname or namespace.
516                                     const char* nsRef = ref->getNameSpace();
517                                     const char* clsRef = ref->getClassName();
518                         
519                                     if ((0 == strcasecmp(nsRef, inst->getNameSpace())) &&
520                                         (0 == strcasecmp(clsRef, inst->getClassName())))
521                                     {
522                                         // Just loop through the key properties and set them
523                                         // one by one
524                                         SCMO_RC rc;
525                                         const char* keyName = 0;
526                                         const char* keyValue = 0;
527                         
528                                         CIMKeyBinding::Type keyType = (CIMKeyBinding::Type)0;
529                         
530                                         Uint32 numKeys = ref->getKeyBindingCount();
531                                         for (Uint32 x=0; x < numKeys; x++)
532 marek          1.43                     {
533 r.kieninger    1.54.2.1                     rc = ref->getKeyBindingAt(x, &keyName, keyType, &keyValue);
534                                             if ((rc != SCMO_OK) || (0==keyValue))
535 marek          1.43                         {
536 r.kieninger    1.54.2.1                         PEG_TRACE_CSTRING(
537                                                     TRC_CMPIPROVIDERINTERFACE,
538                                                     Tracer::LEVEL1,
539                                                     "Failed to retrieve keybinding");
540                                                 PEG_METHOD_EXIT();
541                                                 CMReturn(CMPI_RC_ERR_FAILED);
542 marek          1.43                         }
543 r.kieninger    1.54.2.1                     rc = inst->setKeyBindingAt(x, keyType, keyValue);
544                                             if (rc != SCMO_OK)
545 marek          1.43                         {
546 r.kieninger    1.54.2.1                         PEG_TRACE_CSTRING(
547                                                     TRC_CMPIPROVIDERINTERFACE,
548                                                     Tracer::LEVEL1,
549                                                     "Failed to set keybinding");
550                                                 PEG_METHOD_EXIT();
551                                                 CMReturn(CMPI_RC_ERR_FAILED);
552 marek          1.43                         }
553                                         }
554                                     }
555 r.kieninger    1.54.2.1             else
556 marek          1.43                 {
557 r.kieninger    1.54.2.1                 // Uurrgh, changing class and/or namespace on an existing
558                                         // CMPIInstance is a prohibited change.
559                                         // Simply returning an error
560                                         PEG_TRACE_CSTRING(
561                                             TRC_CMPIPROVIDERINTERFACE,
562                                             Tracer::LEVEL1,
563                                             "Cannot set objectpath because it would change classname"
564                                             "or namespace of instance");
565                                         PEG_METHOD_EXIT();
566                                         CMReturnWithString(
567                                             CMPI_RC_ERR_FAILED,
568                                             string2CMPIString("Incompatible ObjectPath"));
569 marek          1.43                 }
570                                 }
571 r.kieninger    1.54.2.1 
572                                 PEG_METHOD_EXIT();
573                                 CMReturn ( CMPI_RC_OK);
574 marek          1.43         }
575                         
576 r.kieninger    1.54.2.1 
577 venkat.puvvada 1.37         static CMPIStatus instSetPropertyFilter(CMPIInstance* eInst,
578                                 const char** propertyList, const char **keys)
579                             {
580 ms.aruran      1.39             PEG_METHOD_ENTER(
581                                     TRC_CMPIPROVIDERINTERFACE,
582                                     "CMPI_Instance:instSetPropertyFilter()");
583 r.kieninger    1.54.2.1 
584 venkat.puvvada 1.37             if (!eInst->hdl)
585                                 {
586 ms.aruran      1.39                 PEG_METHOD_EXIT();
587 venkat.puvvada 1.37                 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
588                                 }
589 marek          1.43             /* The property list is to be applied on the given instance.
590                                    Currently CMPI provider have to call instSetPropertyFilter to honor
591                                    property filters or have to filter for themselves.
592 r.kieninger    1.54.2.1            Removing properties from the SCMOInstance here helps to effectively
593 marek          1.43                avoid the need to carry a property list around in the CMPI layer.
594 kumpf          1.53     
595 marek          1.48                A (propertyList == 0) means the property list is null and there
596                                    should be no filtering.
597 kumpf          1.53     
598 marek          1.48                An empty propertylist(no property to be returned) is represented by
599                                    a valid propertyList pointer pointing to a null pointer, i.e.
600                                    (*propertyList == 0)
601 marek          1.43             */
602 venkat.puvvada 1.37     
603 r.kieninger    1.54.2.1         SCMOInstance* inst=(SCMOInstance*)eInst->hdl;
604                                 inst->setPropertyFilter(propertyList);
605                         
606 ms.aruran      1.39             PEG_METHOD_EXIT();
607 venkat.puvvada 1.37             CMReturn(CMPI_RC_OK);
608                             }
609                         
610                             static CMPIStatus instSetPropertyFilterIgnore(CMPIInstance* eInst,
611                                 const char** propertyList, const char **keys)
612                             {
613                                 /* We ignore it.  */
614                                 CMReturn ( CMPI_RC_OK);
615                             }
616 schuur         1.1      
617 dave.sudlik    1.31     
618 schuur         1.1      }
619                         
620                         static CMPIInstanceFT instance_FT={
621 venkat.puvvada 1.37         CMPICurrentVersion,
622                             instRelease,
623                             instClone,
624                             instGetProperty,
625                             instGetPropertyAt,
626                             instGetPropertyCount,
627                             instSetProperty,
628                             instGetObjectPath,
629                             instSetPropertyFilter,
630 konrad.r       1.19     #if defined(CMPI_VER_100)
631 venkat.puvvada 1.37         instSetObjectPath,
632 konrad.r       1.19     #endif
633 dave.sudlik    1.31     #if defined(CMPI_VER_200)
634 venkat.puvvada 1.37         instSetPropertyWithOrigin,
635 dave.sudlik    1.31     #endif
636 schuur         1.1      };
637                         
638                         static CMPIInstanceFT instanceOnStack_FT={
639 venkat.puvvada 1.37         CMPICurrentVersion,
640                             instReleaseNop,
641                             instClone,
642                             instGetProperty,
643                             instGetPropertyAt,
644                             instGetPropertyCount,
645                             instSetProperty,
646                             instGetObjectPath,
647                             instSetPropertyFilterIgnore,
648 konrad.r       1.19     #if defined(CMPI_VER_100)
649 venkat.puvvada 1.37         instSetObjectPath,
650 konrad.r       1.19     #endif
651 dave.sudlik    1.31     #if defined(CMPI_VER_200)
652 venkat.puvvada 1.37         instSetPropertyWithOrigin,
653 dave.sudlik    1.31     #endif
654 schuur         1.1      };
655                         
656                         CMPIInstanceFT *CMPI_Instance_Ftab=&instance_FT;
657                         CMPIInstanceFT *CMPI_InstanceOnStack_Ftab=&instanceOnStack_FT;
658                         
659                         
660 venkat.puvvada 1.37     CMPI_InstanceOnStack::CMPI_InstanceOnStack(const CIMInstance& ci)
661                         {
662 ms.aruran      1.39         PEG_METHOD_ENTER(
663                                 TRC_CMPIPROVIDERINTERFACE,
664                                 "CMPI_InstanceOnStack::CMPI_InstanceOnStack()");
665                         
666 venkat.puvvada 1.37         hdl=(void*)&ci;
667                             ft=CMPI_InstanceOnStack_Ftab;
668 ms.aruran      1.39         PEG_METHOD_EXIT();
669 venkat.puvvada 1.37     }
670 schuur         1.1      
671                         
672                         PEGASUS_NAMESPACE_END
673 kumpf          1.53     

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2