(file) Return to ObjectNormalizer.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 karl  1.31 //%2006////////////////////////////////////////////////////////////////////////
  2 chip  1.1  //
  3 karl  1.16 // 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 chip  1.1  // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.16 // 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.21 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.31 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 chip  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.31 // 
 21 chip  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            #include <Pegasus/Common/ObjectNormalizer.h>
 35 a.dunfey 1.32 #include <Pegasus/Common/ArrayInternal.h>
 36 chip     1.1  
 37               PEGASUS_NAMESPACE_BEGIN
 38               
 39 a.dunfey 1.32 CIMQualifier _processQualifier(
 40 kumpf    1.34     CIMConstQualifier& referenceQualifier,
 41                   CIMConstQualifier& cimQualifier)
 42 chip     1.1  {
 43 chip     1.17     // check name
 44 kumpf    1.34     if (!referenceQualifier.getName().equal(cimQualifier.getName()))
 45 chip     1.17     {
 46 chip     1.22         MessageLoaderParms message(
 47                           "Common.ObjectNormalizer.INVALID_QUALIFIER_NAME",
 48 chip     1.23             "Invalid qualifier name: $0",
 49 chip     1.22             cimQualifier.getName().getString());
 50 chip     1.17 
 51                       throw CIMException(CIM_ERR_FAILED, message);
 52                   }
 53 chip     1.15 
 54                   // check type
 55 kumpf    1.34     if (referenceQualifier.getType() != cimQualifier.getType())
 56 chip     1.15     {
 57 chip     1.22         MessageLoaderParms message(
 58                           "Common.ObjectNormalizer.INVALID_QUALIFIER_TYPE",
 59 chip     1.23             "Invalid qualifier type: $0",
 60 chip     1.22             cimQualifier.getName().getString());
 61 chip     1.15 
 62 chip     1.17         throw CIMException(CIM_ERR_FAILED, message);
 63 chip     1.15     }
 64 chip     1.1  
 65 chip     1.17     CIMQualifier normalizedQualifier(
 66                       referenceQualifier.getName(),
 67                       referenceQualifier.getValue(),  // default value
 68                       referenceQualifier.getFlavor(),
 69                       referenceQualifier.getPropagated() == 0 ? false : true);
 70 chip     1.1  
 71 chip     1.26     // TODO: check override
 72               
 73 chip     1.17     // update value
 74 kumpf    1.34     if (!cimQualifier.getValue().isNull())
 75 chip     1.1      {
 76 chip     1.17         normalizedQualifier.setValue(cimQualifier.getValue());
 77 chip     1.1      }
 78               
 79 kumpf    1.34     return normalizedQualifier;
 80 chip     1.1  }
 81               
 82 a.dunfey 1.32 CIMProperty ObjectNormalizer::_processProperty(
 83 kumpf    1.34     CIMConstProperty& referenceProperty,
 84                   CIMConstProperty& instProperty,
 85 chip     1.26     Boolean includeQualifiers,
 86 a.dunfey 1.32     Boolean includeClassOrigin,
 87 kumpf    1.34     NormalizerContext* context,
 88                   const CIMNamespaceName& nameSpace)
 89 chip     1.1  {
 90 chip     1.17     // check name
 91 kumpf    1.34     if (!referenceProperty.getName().equal(instProperty.getName()))
 92 chip     1.17     {
 93 chip     1.22         MessageLoaderParms message(
 94                           "Common.ObjectNormalizer.INVALID_PROPERTY_NAME",
 95 chip     1.23             "Invalid property name: $0",
 96 a.dunfey 1.32             instProperty.getName().getString());
 97 chip     1.17 
 98                       throw CIMException(CIM_ERR_FAILED, message);
 99                   }
100 chip     1.1  
101 chip     1.15     // check type
102 a.dunfey 1.32     CIMType referencePropType = referenceProperty.getType();
103                   CIMType instPropType = instProperty.getType();
104 kumpf    1.34     if (referencePropType != instPropType)
105 a.dunfey 1.32     {
106               #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
107                       // CMPI Providers cannot return a CIMTYPE_INSTANCE, so if the
108                       // referenceProperty type is CIMTYPE_INSTANCE and the instProperty
109                       // type is CIMTYPE_OBJECT, ignore the mismatch. The Normalizer
110                       // will correct it.
111 kumpf    1.34         if (referencePropType != CIMTYPE_INSTANCE ||
112 a.dunfey 1.32             instPropType != CIMTYPE_OBJECT)
113               #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT
114                       {
115                           MessageLoaderParms message(
116                               "Common.ObjectNormalizer.INVALID_PROPERTY_TYPE",
117                               "Invalid property type: $0",
118                               instProperty.getName().getString());
119 chip     1.15 
120 a.dunfey 1.32             throw CIMException(CIM_ERR_FAILED, message);
121                       }
122 chip     1.15     }
123               
124 chip     1.17     // TODO: check array size?
125               
126                   CIMProperty normalizedProperty(
127                       referenceProperty.getName(),
128                       referenceProperty.getValue(),   // default value
129                       referenceProperty.getArraySize(),
130                       referenceProperty.getReferenceClassName(),
131                       CIMName(),
132                       false);
133 chip     1.1  
134                   // TODO: check override (especially for references)?
135               
136 chip     1.14     // update value
137 kumpf    1.34     if (!instProperty.getValue().isNull())
138 chip     1.17     {
139 a.dunfey 1.32 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
140                       // This happens ONLY when the referencePropType is CIMTYPE_INSTANCE
141                       // and the cimPropType is CIMTYPE_OBJECT, otherwise an exception
142                       // would have been thrown. Correct the mismatch here.
143 kumpf    1.34         if (referencePropType != instPropType)
144 a.dunfey 1.32         {
145                           CIMObject tmpObject;
146                           instProperty.getValue().get(tmpObject);
147                           normalizedProperty.setValue(CIMInstance(tmpObject));
148                       }
149                       else
150               #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT
151                       {
152                           normalizedProperty.setValue(instProperty.getValue());
153                       }
154 chip     1.17     }
155 chip     1.6  
156 chip     1.17     // update class origin
157 kumpf    1.34     if (includeClassOrigin)
158 chip     1.1      {
159 chip     1.17         normalizedProperty.setClassOrigin(referenceProperty.getClassOrigin());
160 chip     1.1      }
161               
162                   // add qualifiers
163 kumpf    1.34     if (includeQualifiers)
164 chip     1.1      {
165 chip     1.17         // propagate class property qualifiers
166 kumpf    1.34         for (Uint32 i=0, n = referenceProperty.getQualifierCount(); i < n; i++)
167 chip     1.1          {
168 kumpf    1.34             CIMConstQualifier referenceQualifier =
169                               referenceProperty.getQualifier(i);
170 chip     1.1  
171 kumpf    1.34             Uint32 pos =
172                               instProperty.findQualifier(referenceQualifier.getName());
173 chip     1.1  
174 chip     1.26             // update value if qualifier is present in the specified property
175 kumpf    1.34             if (pos != PEG_NOT_FOUND)
176 chip     1.26             {
177 a.dunfey 1.32                 CIMConstQualifier cimQualifier = instProperty.getQualifier(pos);
178 chip     1.14 
179 chip     1.26                 CIMQualifier normalizedQualifier =
180                                   _processQualifier(
181                                       referenceQualifier,
182                                       cimQualifier);
183 chip     1.14 
184 chip     1.26                 normalizedProperty.addQualifier(normalizedQualifier);
185 chip     1.14             }
186                           else
187                           {
188 chip     1.26                 normalizedProperty.addQualifier(referenceQualifier.clone());
189 chip     1.1              }
190                       }
191                   }
192 a.dunfey 1.32 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
193               #ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY
194 kumpf    1.34     else if (referenceProperty.getType() == CIMTYPE_INSTANCE)
195 a.dunfey 1.32     {
196                       Uin32 refPos = referenceProperty.findQualifier("EmbeddedInstance");
197                       Uin32 cimPos = instProperty.findQualifier("EmbeddedInstance");
198 kumpf    1.34         if (refPos != PEG_NOT_FOUND && cimPos == PEG_NOT_FOUND)
199 a.dunfey 1.32         {
200                           instProperty.addQualifier(refProperty.getQualifier(pos));
201                       }
202                   }
203               #endif
204               
205                   // Check the type of the embedded instance against the class specified by
206                   // the EmbeddedInstance qualifier. We can only do this if the context
207                   // is non-zero.
208 kumpf    1.34     if (context != 0)
209 a.dunfey 1.32     {
210 kumpf    1.34         if (referenceProperty.getType() == CIMTYPE_INSTANCE)
211 a.dunfey 1.32         {
212                           Uint32 pos = referenceProperty.findQualifier("EmbeddedInstance");
213               
214                           PEGASUS_ASSERT(pos != PEG_NOT_FOUND);
215               
216                           String qualClassStr;
217                           referenceProperty.getQualifier(pos).getValue().get(
218                               qualClassStr);
219                           CIMName embedInstClassName(qualClassStr);
220                           Array<CIMName> embeddedInstSubclasses =
221                               context->enumerateClassNames(nameSpace, embedInstClassName,
222                                   true);
223                           embeddedInstSubclasses.append(embedInstClassName);
224               
225                           Array<CIMInstance> embeddedInstances;
226 kumpf    1.34             if (referenceProperty.isArray())
227 a.dunfey 1.32             {
228                               instProperty.getValue().get(embeddedInstances);
229                           }
230                           else
231                           {
232                               CIMInstance embeddedInst;
233                               instProperty.getValue().get(embeddedInst);
234                               embeddedInstances.append(embeddedInst);
235                           }
236               
237                           Array<CIMClass> embeddedClassDefs;
238 kumpf    1.34             for (Uint32 i = 0, n = embeddedInstances.size(); i < n; ++i)
239 a.dunfey 1.32             {
240 kumpf    1.34                 CIMInstance& currentInstance = embeddedInstances[i];
241 a.dunfey 1.32                 CIMName currentClassName = currentInstance.getClassName();
242 kumpf    1.34                 if (Contains(embeddedInstSubclasses, currentClassName))
243 a.dunfey 1.32                 {
244                                   CIMClass embeddedClassDef;
245                                   bool found = false;
246 kumpf    1.34                     for (Uint32 j = 0, m = embeddedClassDefs.size(); j < m;
247 a.dunfey 1.32                         ++j)
248                                   {
249 kumpf    1.34                         CIMClass& tmpClassDef = embeddedClassDefs[j];
250                                       if (tmpClassDef.getClassName() == currentClassName)
251 a.dunfey 1.32                         {
252                                           embeddedClassDef = tmpClassDef;
253                                           found = true;
254                                       }
255                                   }
256               
257 kumpf    1.34                     if (!found)
258 a.dunfey 1.32                     {
259                                       embeddedClassDef = context->getClass(nameSpace,
260                                           currentClassName);
261                                       embeddedClassDefs.append(embeddedClassDef);
262                                   }
263               
264 kumpf    1.35                     SharedPtr<NormalizerContext> tmpContext(context->clone());
265 a.dunfey 1.32                     ObjectNormalizer tmpNormalizer(embeddedClassDef,
266                                       includeQualifiers, includeClassOrigin, nameSpace,
267                                       tmpContext);
268 kumpf    1.34                     if (currentInstance.getPath().getKeyBindings().size()==0)
269 a.dunfey 1.32                     {
270                                       currentInstance.setPath(
271                                           currentInstance.buildPath(embeddedClassDef));
272                                   }
273 kumpf    1.34                     embeddedInstances[i] =
274                                       tmpNormalizer.processInstance(currentInstance);
275 a.dunfey 1.32                 }
276                               else
277                               {
278                                   MessageLoaderParms message(
279 kumpf    1.34                         "Common.ObjectNormalizer."
280                                           "INVALID_EMBEDDED_INSTANCE_TYPE",
281                                       "Found embedded instance of type $0: was expecting "
282                                           "$1 for property $2",
283 a.dunfey 1.32                         currentClassName.getString(),
284                                       qualClassStr,
285                                       instProperty.getName().getString());
286               
287                                   throw CIMException(CIM_ERR_FAILED, message);
288                               }
289                           }
290               
291 kumpf    1.34             if (referenceProperty.isArray())
292 a.dunfey 1.32             {
293                             normalizedProperty.setValue(CIMValue(embeddedInstances));
294                           }
295                           else
296                           {
297                             normalizedProperty.setValue(CIMValue(embeddedInstances[0]));
298                           }
299                       }
300                   }
301               #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT
302 chip     1.1  
303 kumpf    1.34     return normalizedProperty;
304 chip     1.1  }
305               
306 kumpf    1.34 ObjectNormalizer::ObjectNormalizer()
307 chip     1.24     : _includeQualifiers(false),
308 a.dunfey 1.32     _includeClassOrigin(false),
309                   _context(0)
310 chip     1.20 {
311               }
312               
313 chip     1.17 ObjectNormalizer::ObjectNormalizer(
314 kumpf    1.34     const CIMClass& cimClass,
315 chip     1.26     Boolean includeQualifiers,
316 a.dunfey 1.32     Boolean includeClassOrigin,
317 kumpf    1.34     const CIMNamespaceName& nameSpace,
318 kumpf    1.35     SharedPtr<NormalizerContext>& context)
319 a.dunfey 1.32   : _cimClass(cimClass),
320 chip     1.17     _includeQualifiers(includeQualifiers),
321 a.dunfey 1.32     _includeClassOrigin(includeClassOrigin),
322                   _context(context),
323                   _nameSpace(nameSpace)
324 chip     1.1  {
325 kumpf    1.34     if (!_cimClass.isUninitialized())
326 chip     1.26     {
327 kumpf    1.34         // ATTN: the following code is intended to expedite normalizing
328                       // instances and instance object paths by establishing the keys
329                       // once now rather than multiple times later. it is biased
330 chip     1.26         // toward providers that return many instances with many properties.
331               
332                       // build a reference object path within the class
333                       Array<CIMKeyBinding> keys;
334               
335 kumpf    1.34         for (Uint32 i = 0, n = _cimClass.getPropertyCount(); i < n; i++)
336 chip     1.26         {
337                           CIMConstProperty referenceProperty = _cimClass.getProperty(i);
338               
339                           Uint32 pos = referenceProperty.findQualifier("key");
340               
341 kumpf    1.34             if ((pos != PEG_NOT_FOUND) &&
342                               (referenceProperty.getQualifier(pos).getValue().equal(
343                                    CIMValue(true))))
344 chip     1.26             {
345 kumpf    1.34                 if (referenceProperty.getType() == CIMTYPE_REFERENCE)
346 chip     1.30                 {
347 kumpf    1.34                     // ATTN: a fake reference is inserted in the key so that
348                                   // the _BubbleSort() method in CIMObjectPath does not
349                                   // throw and exception. It implicitly validates keys of
350                                   // type REFERENCE so just place a dummy value for now.
351                                   // The value will be replaced by the normalized object
352                                   // later.
353                                   keys.append(CIMKeyBinding(referenceProperty.getName(),
354                                       "class.key=\"value\"", CIMKeyBinding::REFERENCE));
355 chip     1.30                 }
356                               else
357                               {
358 kumpf    1.34                     keys.append(CIMKeyBinding(referenceProperty.getName(),
359                                       referenceProperty.getValue()));
360 chip     1.30                 }
361 chip     1.26             }
362                       }
363               
364                       // update class object path
365                       CIMObjectPath cimObjectPath(_cimClass.getPath());
366               
367                       cimObjectPath.setKeyBindings(keys);
368               
369                       _cimClass.setPath(cimObjectPath);
370                   }
371 chip     1.1  }
372               
373 kumpf    1.34 CIMObjectPath ObjectNormalizer::processClassObjectPath(
374                   const CIMObjectPath& cimObjectPath) const
375 chip     1.1  {
376 chip     1.17     // pre-check
377 kumpf    1.34     if (_cimClass.isUninitialized())
378 chip     1.17     {
379                       // do nothing
380 kumpf    1.34         return cimObjectPath;
381 chip     1.17     }
382 chip     1.1  
383 chip     1.29     /*
384 kumpf    1.34     // ATTN: moving similar logic to the response handlers because this
385                   // type of error should be checked regardless with or without
386                   // normalization enabled.
387                   if (cimObjectPath.getClassName().isNull())
388 chip     1.17     {
389                       throw CIMException(CIM_ERR_FAILED, "uninitialized object path");
390                   }
391 chip     1.29     */
392 chip     1.1  
393 chip     1.22     /*
394 kumpf    1.34     // ATTN: The following code is currently redundant because the CIMName
395                   // object validates legal names when it is constructed. It is included
396                   // here for completeness.
397 chip     1.17     // check class name
398 kumpf    1.34     if (!CIMName(cimObjectPath.getClassName()).legal())
399 chip     1.22     {
400                       MessageLoaderParms message(
401                           "Common.ObjectNormalizer.INVALID_CLASS_NAME",
402 chip     1.23             "Invalid class name: $0",
403 chip     1.22             cimObjectPath.getClassName().getString());
404               
405                       throw CIMException(CIM_ERR_FAILED, message);
406                   }
407                   */
408               
409                   // check class type
410 kumpf    1.34     if (!_cimClass.getClassName().equal(cimObjectPath.getClassName()))
411 chip     1.1      {
412 chip     1.22         MessageLoaderParms message(
413                           "Common.ObjectNormalizer.INVALID_CLASS_TYPE",
414 chip     1.23             "Invalid class type: $0",
415 chip     1.22             cimObjectPath.getClassName().getString());
416 chip     1.1  
417 chip     1.17         throw CIMException(CIM_ERR_FAILED, message);
418                   }
419 chip     1.1  
420 chip     1.17     CIMObjectPath normalizedObjectPath(
421                       _cimClass.getPath().getHost(),
422                       _cimClass.getPath().getNameSpace(),
423 chip     1.26         _cimClass.getClassName());
424 chip     1.1  
425 chip     1.17     // ignore any keys, they are not part of a class object path
426 chip     1.6  
427 kumpf    1.34     return normalizedObjectPath;
428 chip     1.17 }
429 chip     1.1  
430 kumpf    1.34 CIMObjectPath ObjectNormalizer::processInstanceObjectPath(
431                   const CIMObjectPath& cimObjectPath) const
432 chip     1.17 {
433                   // pre-check
434 kumpf    1.34     if (_cimClass.isUninitialized())
435 chip     1.17     {
436                       // do nothing
437 kumpf    1.34         return cimObjectPath;
438 chip     1.17     }
439 chip     1.14 
440 chip     1.29     /*
441 kumpf    1.34     // ATTN: moving similar logic to the response handlers because this
442                   // type of error should be checked regardless with or without
443                   // normalization enabled.
444                   if (cimObjectPath.getClassName().isNull())
445 chip     1.17     {
446                       throw CIMException(CIM_ERR_FAILED, "uninitialized object path");
447 chip     1.1      }
448 chip     1.29     */
449 chip     1.1  
450 chip     1.22     /*
451 kumpf    1.34     // ATTN: The following code is currently redundant because the CIMName
452                   // object validates legal names when it is constructed. It is included
453                   // here for completeness.
454 chip     1.17     // check class name
455 kumpf    1.34     if (!CIMName(cimObjectPath.getClassName()).legal())
456 chip     1.22     {
457                       MessageLoaderParms message(
458                           "Common.ObjectNormalizer.INVALID_CLASS_NAME",
459 chip     1.23             "Invalid class name: $0",
460 chip     1.22             cimObjectPath.getClassName().getString());
461               
462                       throw CIMException(CIM_ERR_FAILED, message);
463                   }
464                   */
465               
466                   // check class type
467 kumpf    1.34     if (!_cimClass.getClassName().equal(cimObjectPath.getClassName()))
468 chip     1.1      {
469 chip     1.22         MessageLoaderParms message(
470                           "Common.ObjectNormalizer.INVALID_CLASS_TYPE",
471 chip     1.23             "Invalid class type: $0",
472 chip     1.22             cimObjectPath.getClassName().getString());
473 chip     1.1  
474 chip     1.17         throw CIMException(CIM_ERR_FAILED, message);
475                   }
476 chip     1.1  
477 chip     1.17     CIMObjectPath normalizedObjectPath(
478                       _cimClass.getPath().getHost(),
479                       _cimClass.getPath().getNameSpace(),
480 chip     1.26         _cimClass.getClassName());
481               
482                   Array<CIMKeyBinding> normalizedKeys;
483 chip     1.1  
484 chip     1.26     Array<CIMKeyBinding> referenceKeys = _cimClass.getPath().getKeyBindings();
485                   Array<CIMKeyBinding> cimKeys = cimObjectPath.getKeyBindings();
486 chip     1.1  
487 kumpf    1.34     for (Uint32 i = 0, n = referenceKeys.size(); i < n; i++)
488 chip     1.1      {
489 chip     1.26         CIMKeyBinding key;
490 chip     1.17 
491 chip     1.26         // override the value from the specified object
492 kumpf    1.34         for (Uint32 j = 0, m = cimKeys.size(); j < m; j++)
493 chip     1.17         {
494 kumpf    1.34             if (referenceKeys[i].getName().equal(cimKeys[j].getName()))
495 chip     1.17             {
496 chip     1.26                 // check type
497 kumpf    1.34                 if (referenceKeys[i].getType() != cimKeys[j].getType())
498 chip     1.22                 {
499                                   MessageLoaderParms message(
500 chip     1.26                         "Common.ObjectNormalizer.INVALID_KEY_TYPE",
501                                       "Invalid key type: $0",
502                                       referenceKeys[i].getName().getString());
503 chip     1.22 
504                                   throw CIMException(CIM_ERR_FAILED, message);
505                               }
506               
507 kumpf    1.34                 key = CIMKeyBinding(referenceKeys[i].getName(),
508                                   cimKeys[j].getValue(), referenceKeys[i].getType());
509 chip     1.26 
510 chip     1.17                 break;
511                           }
512 chip     1.26         }
513 chip     1.1  
514 chip     1.26         // key not found
515 kumpf    1.34         if (key.getName().isNull())
516 chip     1.26         {
517                           MessageLoaderParms message(
518                               "Common.ObjectNormalizer.MISSING_KEY",
519                               "Missing key: $0",
520                               referenceKeys[i].getName().getString());
521               
522                           throw CIMException(CIM_ERR_FAILED, message);
523 chip     1.1          }
524 chip     1.26 
525                       normalizedKeys.append(key);
526 chip     1.1      }
527               
528 chip     1.26     normalizedObjectPath.setKeyBindings(normalizedKeys);
529 chip     1.17 
530 kumpf    1.34     return normalizedObjectPath;
531 chip     1.17 }
532               
533 kumpf    1.34 CIMInstance ObjectNormalizer::processInstance(
534                   const CIMInstance& cimInstance) const
535 chip     1.17 {
536                   // pre-checks
537 kumpf    1.34     if (_cimClass.isUninitialized())
538 chip     1.1      {
539 chip     1.17         // do nothing
540 kumpf    1.34         return cimInstance;
541 chip     1.17     }
542 chip     1.1  
543 chip     1.29     /*
544 kumpf    1.34     // ATTN: moving similar logic to the response handlers because this
545                   // type of error should be checked regardless with or without
546                   // normalization enabled.
547                   if (cimInstance.isUninitialized())
548 chip     1.17     {
549                       throw CIMException(CIM_ERR_FAILED, "unintialized instance object.");
550 chip     1.1      }
551 chip     1.29     */
552 chip     1.1  
553 chip     1.26     CIMInstance normalizedInstance(_cimClass.getClassName());
554 chip     1.22 
555 chip     1.26     // proces object path
556 kumpf    1.34     normalizedInstance.setPath(
557                       processInstanceObjectPath(cimInstance.getPath()));
558 chip     1.1  
559 chip     1.17     // process instance qualifiers
560 kumpf    1.34     if (_includeQualifiers)
561 chip     1.1      {
562 chip     1.17         // propagate class qualifiers
563 kumpf    1.34         for (Uint32 i = 0, n = _cimClass.getQualifierCount(); i < n; i++)
564 chip     1.1          {
565 chip     1.17             CIMConstQualifier referenceQualifier = _cimClass.getQualifier(i);
566 chip     1.1  
567 kumpf    1.34             Uint32 pos =
568                               cimInstance.findQualifier(referenceQualifier.getName());
569 chip     1.1  
570 chip     1.26             // update value if qualifier is present in the specified property
571 kumpf    1.34             if (pos != PEG_NOT_FOUND)
572 chip     1.1              {
573 chip     1.26                 CIMConstQualifier cimQualifier = cimInstance.getQualifier(pos);
574 chip     1.12 
575 chip     1.26                 CIMQualifier normalizedQualifier =
576                                   _processQualifier(
577                                       referenceQualifier,
578                                       cimQualifier);
579 chip     1.12 
580 chip     1.26                 normalizedInstance.addQualifier(normalizedQualifier);
581 chip     1.1              }
582 chip     1.12             else
583                           {
584 chip     1.26                 normalizedInstance.addQualifier(referenceQualifier.clone());
585 chip     1.12             }
586 chip     1.1          }
587                   }
588               
589 kumpf    1.34     // check property names and types. any properties in the class but not
590                   // in the instance are implicitly dropped.
591 mreddy   1.36     for (Uint32 i = 0, n = cimInstance.getPropertyCount(); i < n; i++)
592 chip     1.1      {
593 mreddy   1.36         CIMConstProperty instProperty = cimInstance.getProperty(i);
594 chip     1.6  
595 mreddy   1.36         Uint32 pos = _cimClass.findProperty(instProperty.getName());
596 chip     1.1  
597 kumpf    1.34         if (pos != PEG_NOT_FOUND)
598 chip     1.1          {
599 mreddy   1.36             CIMConstProperty cimProperty = _cimClass.getProperty(pos);
600 chip     1.1  
601 chip     1.24             CIMProperty normalizedProperty =
602                               _processProperty(
603 chip     1.26                     cimProperty,
604 mreddy   1.36                     instProperty,
605 chip     1.24                     _includeQualifiers,
606 a.dunfey 1.32                     _includeClassOrigin,
607                                   _context.get(),
608                                   _nameSpace);
609 chip     1.1  
610 chip     1.24             normalizedInstance.addProperty(normalizedProperty);
611 chip     1.9          }
612 chip     1.1      }
613               
614 kumpf    1.34     return normalizedInstance;
615 chip     1.1  }
616               
617               PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2