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

  1 karl  1.28 //%2006////////////////////////////////////////////////////////////////////////
  2 schuur 1.1  //
  3 karl   1.14 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4             // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5             // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6 schuur 1.1  // IBM Corp.; EMC Corporation, The Open Group.
  7 karl   1.14 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8             // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl   1.16 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10             // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl   1.28 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12             // EMC Corporation; Symantec Corporation; The Open Group.
 13 schuur 1.1  //
 14             // Permission is hereby granted, free of charge, to any person obtaining a copy
 15             // of this software and associated documentation files (the "Software"), to
 16             // deal in the Software without restriction, including without limitation the
 17             // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18             // sell copies of the Software, and to permit persons to whom the Software is
 19             // furnished to do so, subject to the following conditions:
 20 karl   1.28 // 
 21 schuur 1.1  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22             // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23             // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24             // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25             // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26             // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27             // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28             // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29             //
 30             //==============================================================================
 31             //
 32             //%/////////////////////////////////////////////////////////////////////////////
 33             
 34 r.kieninger 1.27 #include <Pegasus/Common/CIMNameUnchecked.h>
 35 mike        1.29 #include <Pegasus/Common/AutoPtr.h>
 36 schuur      1.4  #include "CMPI_Version.h"
 37 schuur      1.2  
 38 schuur      1.1  #include "CMPI_Instance.h"
 39                  #include "CMPI_Broker.h"
 40                  #include "CMPI_Value.h"
 41                  #include "CMPI_String.h"
 42                  
 43                  #include <Pegasus/Common/InternalException.h>
 44 konrad.r    1.18 #include <Pegasus/Common/System.h>
 45 mike        1.29 #include <Pegasus/Common/Mutex.h>
 46 schuur      1.1  #include <string.h>
 47 dave.sudlik 1.23 #include <new>
 48 ms.aruran   1.39 #include <Pegasus/Common/Tracer.h>
 49 schuur      1.1  
 50                  PEGASUS_USING_STD;
 51                  PEGASUS_NAMESPACE_BEGIN
 52                  
 53 venkat.puvvada 1.37 extern "C" 
 54                     {
 55 schuur         1.12 
 56 venkat.puvvada 1.37     static CMPIStatus instRelease(CMPIInstance* eInst)
 57                         {
 58                             CIMInstance* inst=(CIMInstance*)eInst->hdl;
 59                             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                         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 venkat.puvvada 1.37         CIMInstance* inst=(CIMInstance*)eInst->hdl;
 82                             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 vijay.eli      1.22             AutoPtr<CIMInstance> cInst(new CIMInstance(inst->clone()));
 91                                 AutoPtr<CMPI_Object> obj(new CMPI_Object(cInst.get()));
 92                                 cInst.release();
 93                                 obj->unlink();
 94 mreddy         1.35             CMSetStatus(rc,CMPI_RC_OK);
 95 ms.aruran      1.39             CMPIInstance* cmpiInstance = 
 96                                     reinterpret_cast<CMPIInstance *>(obj.release());
 97                                 PEG_METHOD_EXIT();
 98                                 return cmpiInstance;
 99 venkat.puvvada 1.37         }
100                             catch (const PEGASUS_STD(bad_alloc)&)
101                             {
102                                 CMSetStatus(rc, CMPI_RC_ERROR_SYSTEM);
103 ms.aruran      1.39             PEG_METHOD_EXIT();
104 venkat.puvvada 1.37             return NULL;
105                             }
106                         }
107                     
108                         static CMPIData instGetPropertyAt(
109                             const CMPIInstance* eInst, CMPICount pos, CMPIString** name,
110                             CMPIStatus* rc)
111                         {
112                             CIMInstance* inst=(CIMInstance*)eInst->hdl;
113                             CMPIData data={0,CMPI_nullValue,{0}};
114                     
115                             if (!inst)
116                             {
117                                 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
118                                 return data;
119                             }
120                     
121                             if (pos>inst->getPropertyCount())
122                             {
123                                 CMSetStatus(rc, CMPI_RC_ERR_NO_SUCH_PROPERTY);
124                                 CMPIData data={0,CMPI_nullValue|CMPI_notFound,{0}};
125 venkat.puvvada 1.37             return data;
126                             }
127                             const CIMProperty& p=inst->getProperty(pos);
128                             const CIMValue& v=p.getValue();
129                             CIMType pType=p.getType();
130                             CMPIType t=type2CMPIType(pType,p.isArray());
131                     
132                             value2CMPIData(v,t,&data);
133                     
134                             if (name)
135                             {
136                                 String str=p.getName().getString();
137                                 *name=(CMPIString*)string2CMPIString(str);
138                             }
139                     
140                             CMSetStatus(rc,CMPI_RC_OK);
141                             return data;
142                         }
143                     
144                         static CMPIData instGetProperty(const CMPIInstance* eInst, 
145                             const char *name, CMPIStatus* rc)   
146 venkat.puvvada 1.37     {
147                             CMPIData data={0,CMPI_nullValue|CMPI_notFound,{0}};
148                     
149                             if (!eInst->hdl)
150                             {
151                                 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
152                                 return data;
153                             }
154                             if (!name)
155                             {
156                                 CMSetStatus(rc, CMPI_RC_ERR_INVALID_PARAMETER);
157                                 return data;
158                             }
159                             CIMInstance* inst=(CIMInstance*)eInst->hdl;
160                             Uint32 pos=inst->findProperty(String(name));
161                     
162                             if (pos!=PEG_NOT_FOUND)
163                             {
164                                 CMSetStatus(rc,CMPI_RC_OK);
165                                 return instGetPropertyAt(eInst,pos,NULL,rc);
166                             }
167 venkat.puvvada 1.37         CMSetStatus(rc, CMPI_RC_ERR_NO_SUCH_PROPERTY);
168                             return data;
169                         }
170                     
171                     
172                         static CMPICount instGetPropertyCount(const CMPIInstance* eInst, 
173                             CMPIStatus* rc) 
174                         {
175                             CIMInstance* inst=(CIMInstance*)eInst->hdl;
176                             if (!inst)
177                             {
178                                 CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
179                                 return 0;
180                             }
181                             CMSetStatus(rc,CMPI_RC_OK);
182                             return inst->getPropertyCount();
183                         }
184                     
185                         static CMPIStatus instSetPropertyWithOrigin(const CMPIInstance* eInst, 
186                             const char* name, const CMPIValue* data, const CMPIType type,
187                             const char* origin)
188 venkat.puvvada 1.37     {
189 ms.aruran      1.39         PEG_METHOD_ENTER(
190                                 TRC_CMPIPROVIDERINTERFACE,
191                                 "CMPI_Instance:instSetPropertyWithOrigin()");
192 venkat.puvvada 1.37         CIMInstance *inst=(CIMInstance*)eInst->hdl;
193                             if (!inst)
194                             {
195 ms.aruran      1.39             PEG_METHOD_EXIT();
196 venkat.puvvada 1.37             CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
197                             }
198                             CMPIrc rc;
199                             CIMValue v=value2CIMValue(data,type,&rc);
200                             CIMNameUnchecked sName(name);
201                             Uint32 pos;
202                             int count=0;
203                     
204                             if ((pos=inst->findProperty(sName))!=PEG_NOT_FOUND)
205                             {
206                     
207                                 CIMProperty cp=inst->getProperty(pos);
208                     
209                     
210                                 /* The CMPI interface uses the type "CMPI_instance" to represent 
211                                    both embedded objects and embedded instances. CMPI has no 
212                                    "CMPI_object" type. So when converting a CMPIValue with type 
213                                    "CMPI_instance" to a CIMValue (see value2CIMValue) the type 
214                                    CIMTYPE_OBJECT is always used. If the property's type is 
215                                    CIMTYPE_INSTANCE, and the value's type is CIMTYPE_OBJECT, then
216                                    we convert the value's type to match the property's type.
217 venkat.puvvada 1.37             */
218 venkat.puvvada 1.42 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
219 venkat.puvvada 1.37             if (cp.getType() == CIMTYPE_INSTANCE && 
220                                     v.getType() == CIMTYPE_OBJECT)
221                                 {
222 venkat.puvvada 1.38                 if (cp.isArray())
223                                     {
224                                         if (!v.isArray())
225                                         {
226 kavita.gupta   1.40                         PEG_TRACE((
227                                                 TRC_CMPIPROVIDERINTERFACE,
228 mike           1.43.4.1                             Tracer::LEVEL1,
229 kavita.gupta   1.40                                 "TypeMisMatch, Expected Type: %s, Actual Type: %s",
230                                                     cimTypeToString(cp.getType()),
231                                                     cimTypeToString(v.getType())));
232                                                 PEG_METHOD_EXIT();
233                                                 CMReturn(CMPI_RC_ERR_TYPE_MISMATCH);
234 venkat.puvvada 1.38                         }
235                                             Array<CIMObject> tmpObjs;
236                                             Array<CIMInstance> tmpInsts;
237                                             v.get(tmpObjs);
238                                             for (Uint32 i = 0; i < tmpObjs.size() ; ++i)
239                                             {
240                                                 tmpInsts.append(CIMInstance(tmpObjs[i]));
241                                             } 
242                                             v.set(tmpInsts);
243                                         }
244                                         else
245                                         {  
246                                             CIMObject co;
247                                             v.get(co);
248                                             if (co.isInstance())
249                                                 v.set(CIMInstance(co));
250                                         }
251 venkat.puvvada 1.37                 }
252 venkat.puvvada 1.42     #endif
253 venkat.puvvada 1.37                 try
254 dave.sudlik    1.31                 {
255 venkat.puvvada 1.37                     cp.setValue(v);
256                                         if (origin)
257                                         {
258                                             CIMName oName(origin);
259                                             cp.setClassOrigin(oName);
260                                         }
261 dave.sudlik    1.31                 }
262 venkat.puvvada 1.37                 catch (const TypeMismatchException &)
263                                     {
264 ms.aruran      1.39                     PEG_TRACE((
265                                             TRC_CMPIPROVIDERINTERFACE,
266 mike           1.43.4.1                     Tracer::LEVEL1,
267 ms.aruran      1.39                         " TypeMisMatch exception for: %s",
268                                             name));
269                                         if (getenv("PEGASUS_CMPI_CHECKTYPES")!=NULL)
270                                         {
271                                             PEG_TRACE_CSTRING(
272                                                 TRC_CMPIPROVIDERINTERFACE,
273 mike           1.43.4.1                         Tracer::LEVEL1,
274 ms.aruran      1.39                             " Aborting because of CMPI_CHECKTYPES..");
275 venkat.puvvada 1.37                             abort();
276                                         }
277 ms.aruran      1.39                     PEG_METHOD_EXIT();
278 venkat.puvvada 1.37                     CMReturn(CMPI_RC_ERR_TYPE_MISMATCH);
279                                     }
280                                     catch (const InvalidNameException &)
281                                     {
282 ms.aruran      1.39                     PEG_TRACE((
283                                             TRC_CMPIPROVIDERINTERFACE,
284 mike           1.43.4.1                     Tracer::LEVEL1,
285 ms.aruran      1.39                         " InvalidName exception for: %s",
286                                             origin));
287                         
288                                         PEG_METHOD_EXIT();
289 venkat.puvvada 1.37                     CMReturn(CMPI_RC_ERR_INVALID_PARAMETER);
290                                     }
291                                     catch (const Exception &e)
292                                     {
293 ms.aruran      1.39                     PEG_TRACE_STRING(
294                                             TRC_CMPIPROVIDERINTERFACE,
295 mike           1.43.4.1                     Tracer::LEVEL1,
296 ms.aruran      1.39                         "  " + e.getMessage() + " exception for " + name);
297                                         if (getenv("PEGASUS_CMPI_CHECKTYPES")!=NULL)
298                                         {
299                                             PEG_TRACE_CSTRING(
300                                                 TRC_CMPIPROVIDERINTERFACE,
301 mike           1.43.4.1                         Tracer::LEVEL1,
302 ms.aruran      1.39                             " Aborting because of CMPI_CHECKTYPES..");
303 venkat.puvvada 1.37                             abort();
304                                         }
305 ms.aruran      1.39                     PEG_METHOD_EXIT();
306 venkat.puvvada 1.37                     CMReturnWithString(CMPI_RC_ERR_FAILED,
307                                             reinterpret_cast<CMPIString*>(
308                                             new CMPI_Object(e.getMessage())));
309                                     }
310                                 }
311                                 else
312                                 {
313 marek          1.43                 PEG_TRACE((TRC_CMPIPROVIDERINTERFACE,Tracer::LEVEL3,
314                                                "Property %s not set on created instance."
315                                                    "Either the property is not part of the class or"
316                                                        "not part of the property list.",
317                                                name));
318 venkat.puvvada 1.37             }
319 ms.aruran      1.39             PEG_METHOD_EXIT();
320 venkat.puvvada 1.37             CMReturn(CMPI_RC_OK);
321                             }
322                         
323                             static CMPIStatus instSetProperty(const CMPIInstance* eInst,
324                                 const char *name, const CMPIValue* data, CMPIType type) 
325                             {
326                                 return instSetPropertyWithOrigin(eInst, name, data, type, NULL);
327                             }
328                         
329                             static CMPIObjectPath* instGetObjectPath(const CMPIInstance* eInst,
330                                 CMPIStatus* rc) 
331                             {
332 ms.aruran      1.39             PEG_METHOD_ENTER(
333                                     TRC_CMPIPROVIDERINTERFACE,
334                                     "CMPI_Instance:instGetObjectPath()");
335 venkat.puvvada 1.37             CIMInstance* inst=(CIMInstance*)eInst->hdl;
336                                 if (!inst)
337                                 {
338                                     CMSetStatus(rc, CMPI_RC_ERR_INVALID_HANDLE);
339 ms.aruran      1.39                 PEG_METHOD_EXIT();
340 venkat.puvvada 1.37                 return NULL;
341                                 }
342                                 const CIMObjectPath &clsRef=inst->getPath();
343                                 AutoPtr<CIMObjectPath> objPath(NULL);
344                                 AutoPtr<CMPI_Object> obj(NULL);
345                                 try
346                                 {
347 dave.sudlik    1.41                 /* Check if NameSpace is NULL before calling GetClass. When
348                                        providers run out-of-process and getClass request is made 
349                                        through CIMClient,  CIMOperationRequestEncoder tries to 
350                                        encode the request and finds the namespace is invalid 
351                                        (empty) and throws InvalidNamespaceNameException. 
352                                     */
353                                     if (clsRef.getKeyBindings().size()==0 && 
354                                         !clsRef.getNameSpace().isNull())
355 venkat.puvvada 1.37                 {
356                                         CIMClass *cc=mbGetClass(CMPI_ThreadContext::getBroker(),clsRef);
357                                         /* It seems that when converting the CIMInstnace to XML form, 
358                                            we miss CIMObjectPath from it. When we don't have namespace 
359                                            we may not get class, so make ObjectPath with class-name 
360                                            only.
361                                            TODO: This will create problems when passing the 
362                                            EmbeddedInstances as arguements to MethodProviders, where it
363                                            needs to get ObjectPath from instance. Shall we need to 
364                                            include CIMObjectPath in CIMInstance while converting to XML 
365                                            form ??? ...  
366                                         */
367                                         if (!cc)
368                                         {
369                                             objPath.reset(new CIMObjectPath(clsRef));
370                                         }
371                                         else
372                                         {
373                                             const CIMObjectPath &ref=inst->buildPath(
374                                                 *(reinterpret_cast<const CIMConstClass*>(cc)));
375                                             objPath.reset(new CIMObjectPath(ref));
376 venkat.puvvada 1.37                     }
377 vijay.eli      1.22                 }
378 venkat.puvvada 1.37                 else
379                                         objPath.reset(new CIMObjectPath(clsRef));
380 vijay.eli      1.22                 obj.reset(new CMPI_Object(objPath.get()));
381                                     objPath.release();
382 mreddy         1.35                 CMSetStatus(rc,CMPI_RC_OK);
383 ms.aruran      1.39                 CMPIObjectPath* cmpiObjectPath = 
384                                         reinterpret_cast<CMPIObjectPath*> (obj.release());
385                                     PEG_METHOD_EXIT();
386                                     return cmpiObjectPath; 
387 venkat.puvvada 1.37             }
388                                 catch (const PEGASUS_STD(bad_alloc)&)
389                                 {
390                                     CMSetStatus(rc, CMPI_RC_ERROR_SYSTEM);
391 ms.aruran      1.39                 PEG_METHOD_EXIT();
392 venkat.puvvada 1.37                 return NULL;
393                                 }
394                             }
395                         
396                             static CMPIStatus instSetObjectPath(
397                                 CMPIInstance* eInst, 
398                                 const CMPIObjectPath *obj)
399                             {
400 ms.aruran      1.39             PEG_METHOD_ENTER(
401                                     TRC_CMPIPROVIDERINTERFACE,
402                                     "CMPI_Instance:instSetObjectPath()");
403 venkat.puvvada 1.37             CIMInstance* inst=(CIMInstance*)eInst->hdl;
404                                 if (inst==NULL)
405                                 {
406 ms.aruran      1.39                 PEG_METHOD_EXIT();
407 venkat.puvvada 1.37                 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
408                                 }
409                                 if (obj==NULL)
410                                 {
411 ms.aruran      1.39                 PEG_METHOD_EXIT();
412 venkat.puvvada 1.37                 CMReturn ( CMPI_RC_ERR_INVALID_PARAMETER);
413                                 }
414                         
415                                 CIMObjectPath &ref = *(CIMObjectPath*)(obj->hdl);
416                                 try
417                                 {
418                                     inst->setPath(ref); 
419                                 }
420                                 catch (const TypeMismatchException &e)
421                                 {
422 ms.aruran      1.39                 PEG_METHOD_EXIT();
423 venkat.puvvada 1.37                 CMReturnWithString(CMPI_RC_ERR_FAILED,
424                                         reinterpret_cast<CMPIString*>(
425                                             new CMPI_Object(e.getMessage())));
426                                 }
427 ms.aruran      1.39             PEG_METHOD_EXIT();
428 venkat.puvvada 1.37             CMReturn ( CMPI_RC_OK);
429                             }
430                         
431 marek          1.43         /* The function removes all properties not part of the given
432                                array of property names(property lists).
433                                Function can handle second list being set or not set.
434                                This is an internal function used by instSetPropertyFilter()
435                             */
436                             static void filterCIMInstance(
437                                 const char** listroot1,
438                                 const char** listroot2,
439                                 CIMInstance & inst)
440                             {
441                                 /* listroot1 never can be 0, this function is only called by 
442                                    instSetPropertyFilter() and the check is done there already */
443                                 
444                                 /* determine number of properties on the instance */
445                                 int propertyCount = inst.getPropertyCount();
446                         
447                                 /* number of properties in each property list */
448                                 int numProperties1 = 0;
449                                 int numProperties2 = 0;            
450                                 /* Masks for property lists
451                                    0 = list element not yet found
452 marek          1.43                1 = list element already found)
453                                 */            
454                                 char * plMask1=0;
455                                 char * plMask2=0;            
456                                 /* end of array of property list names */
457                                 const char **listend1 = listroot1;
458                                 /* place end pointer at end of array and count number of properties
459                                    named in the first list */
460                                 while (*listend1) 
461                                 {
462                                     listend1++;
463                                 }
464                                 /* former while loop steps one field to far, step one back */
465                                 listend1--;
466                                 /* calculate last valid index of a property */
467                                 numProperties1 = listend1 - listroot1;
468                                 /* reserver memory for index + 1 property mask fields */
469                                 plMask1 = (char*) calloc(1, numProperties1+1);
470                         
471                                 /* special dish for two lists, need to check those at same time */
472                                 /* variable to hold end of array of property list names */
473 marek          1.43             const char **listend2 = listroot2;
474                                 /* place end pointer at end of array and count number of properties
475                                    named in the first list */
476                                 if (listroot2)
477                                 {
478                                     while (*listend2) 
479                                     {
480                                         listend2++;
481                                     }
482                                     /* former while loop steps one field to far, step one back */
483                                     listend2--;
484                                     /* calculate last valid index of a property */
485                                     numProperties2 = listend2 - listroot2;
486                                     /* reserver memory for index + 1 property mask fields */
487                                     plMask2 = (char*) calloc(1, numProperties2+1);
488                                 }
489                         
490                                 /* for each property on the instance */
491                                 /* use reverse order, so we don't change index of properties not yet
492                                    checked when removing a property */
493                                 for (int idx=propertyCount-1; idx >= 0; idx--)
494 marek          1.43             {
495                                     CIMConstProperty prop = inst.getProperty(idx);
496                                     CString cName = prop.getName().getString().getCString();
497                                     const char* pName = (const char*)cName;
498                                     
499                                     /* work the property list backward too, as often times
500                                        properties on the instance and in the list are ordered in the
501                                        same way, this helps reduce number of required strcasecmp */
502                                     int found = false;
503                                     /* use temporary list1 to step through the list */
504                                     const char **list1 = listend1;
505                         
506                                     /* steps through the entire property list and does compare
507                                        the name in the property list with the currently investigated
508                                        name of the property, except one of the following conditions
509                                        is true:
510                                          1.) the property list element has already been found as
511                                              indicated by the property list mask
512                                          2.) the property is found, mark it as found in the mask and
513                                              leave the for-loop
514                                     */
515 marek          1.43                 for (int pos1=numProperties1; pos1 >= 0; pos1--,list1--)
516                                     {
517                                         if (!plMask1[pos1])
518                                         {
519                                             if (System::strcasecmp(pName, *list1)==0)
520                                             {
521                                                 found = true;
522                                                 plMask1[pos1] = 1;
523                                                 break;
524                                             }
525                                         }
526                                     }
527                                     /* Do the same algorithm for the second list too,
528                                        except if we found the property already */
529                                     if (listroot2 && !found)
530                                     {
531                                         /* use temporary list2 to step through the list */
532                                         const char **list2 = listend2;
533                                         for (int pos2=numProperties2; pos2 >= 0; pos2--,list2--)
534                                         {
535                                             if (!plMask2[pos2])
536 marek          1.43                         {
537                                                 if (System::strcasecmp(pName, *list2)==0)
538                                                 {
539                                                     found = true;
540                                                     plMask2[pos2] = 1;
541                                                     break;
542                                                 }
543                                             }
544                                         }
545                                     }
546                                     /* If the property could not be found in either property list,
547                                        remove the property from the instance */
548                                     if (!found)
549                                     {
550                                         inst.removeProperty(idx);
551                                     }
552                                 }
553                                 free(plMask1);
554                                 if (listroot2)
555                                 {
556                                     free(plMask2);
557 marek          1.43             }
558                             }
559                         
560 venkat.puvvada 1.37         static CMPIStatus instSetPropertyFilter(CMPIInstance* eInst,
561                                 const char** propertyList, const char **keys)
562                             {
563 ms.aruran      1.39             PEG_METHOD_ENTER(
564                                     TRC_CMPIPROVIDERINTERFACE,
565                                     "CMPI_Instance:instSetPropertyFilter()");
566 venkat.puvvada 1.37             if (!eInst->hdl)
567                                 {
568 ms.aruran      1.39                 PEG_METHOD_EXIT();
569 venkat.puvvada 1.37                 CMReturn(CMPI_RC_ERR_INVALID_HANDLE);
570                                 }
571 marek          1.43             /* The property list is to be applied on the given instance.
572                                    Currently CMPI provider have to call instSetPropertyFilter to honor
573                                    property filters or have to filter for themselves.
574                                    Removing properties from the CIMInstance here helps to effectively
575                                    avoid the need to carry a property list around in the CMPI layer.
576                                 */
577 venkat.puvvada 1.37     
578 marek          1.43             CIMInstance& inst=*(CIMInstance*)(eInst->hdl);
579                                 if (propertyList && *propertyList)
580 venkat.puvvada 1.37             {
581 marek          1.43                 if (!(keys && *keys))
582 venkat.puvvada 1.37                 {
583 marek          1.43                     filterCIMInstance(propertyList, 0, inst);
584 venkat.puvvada 1.37                 }
585 marek          1.43                 else
586                                     {
587                                         filterCIMInstance(propertyList, keys, inst);
588                                     }
589                                 };
590 ms.aruran      1.39             PEG_METHOD_EXIT();
591 venkat.puvvada 1.37             CMReturn(CMPI_RC_OK);
592                             }
593                         
594                             static CMPIStatus instSetPropertyFilterIgnore(CMPIInstance* eInst,
595                                 const char** propertyList, const char **keys)
596                             {
597                                 /* We ignore it.  */
598                                 CMReturn ( CMPI_RC_OK);
599                             }
600 schuur         1.1      
601 dave.sudlik    1.31     
602 schuur         1.1      }
603                         
604                         static CMPIInstanceFT instance_FT={
605 venkat.puvvada 1.37         CMPICurrentVersion,
606                             instRelease,
607                             instClone,
608                             instGetProperty,
609                             instGetPropertyAt,
610                             instGetPropertyCount,
611                             instSetProperty,
612                             instGetObjectPath,
613                             instSetPropertyFilter,
614 konrad.r       1.19     #if defined(CMPI_VER_100)
615 venkat.puvvada 1.37         instSetObjectPath,
616 konrad.r       1.19     #endif
617 dave.sudlik    1.31     #if defined(CMPI_VER_200)
618 venkat.puvvada 1.37         instSetPropertyWithOrigin,
619 dave.sudlik    1.31     #endif
620 schuur         1.1      };
621                         
622                         static CMPIInstanceFT instanceOnStack_FT={
623 venkat.puvvada 1.37         CMPICurrentVersion,
624                             instReleaseNop,
625                             instClone,
626                             instGetProperty,
627                             instGetPropertyAt,
628                             instGetPropertyCount,
629                             instSetProperty,
630                             instGetObjectPath,
631                             instSetPropertyFilterIgnore,
632 konrad.r       1.19     #if defined(CMPI_VER_100)
633 venkat.puvvada 1.37         instSetObjectPath,
634 konrad.r       1.19     #endif
635 dave.sudlik    1.31     #if defined(CMPI_VER_200)
636 venkat.puvvada 1.37         instSetPropertyWithOrigin,
637 dave.sudlik    1.31     #endif
638 schuur         1.1      };
639                         
640                         CMPIInstanceFT *CMPI_Instance_Ftab=&instance_FT;
641                         CMPIInstanceFT *CMPI_InstanceOnStack_Ftab=&instanceOnStack_FT;
642                         
643                         
644 venkat.puvvada 1.37     CMPI_InstanceOnStack::CMPI_InstanceOnStack(const CIMInstance& ci)
645                         {
646 ms.aruran      1.39         PEG_METHOD_ENTER(
647                                 TRC_CMPIPROVIDERINTERFACE,
648                                 "CMPI_InstanceOnStack::CMPI_InstanceOnStack()");
649                         
650 venkat.puvvada 1.37         hdl=(void*)&ci;
651                             ft=CMPI_InstanceOnStack_Ftab;
652 ms.aruran      1.39         PEG_METHOD_EXIT();
653 venkat.puvvada 1.37     }
654 schuur         1.1      
655                         
656                         PEGASUS_NAMESPACE_END
657 venkat.puvvada 1.37         

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2