1 martin 1.206 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.207 //
|
3 martin 1.206 // 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.207 //
|
10 martin 1.206 // 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.207 //
|
17 martin 1.206 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.207 //
|
20 martin 1.206 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.207 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.206 // 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.207 //
|
28 martin 1.206 //////////////////////////////////////////////////////////////////////////
|
29 mike 1.48 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
|
32 mike 1.51 #include <Pegasus/Common/Config.h>
|
33 mike 1.48 #include <cctype>
34 #include <cstdio>
35 #include <fstream>
|
36 kumpf 1.82 #include <Pegasus/Common/InternalException.h>
|
37 schuur 1.114
|
38 mike 1.48 #include <Pegasus/Common/DeclContext.h>
|
39 kumpf 1.76 #include <Pegasus/Common/Resolver.h>
|
40 mike 1.48 #include <Pegasus/Common/System.h>
|
41 kumpf 1.52 #include <Pegasus/Common/Tracer.h>
|
42 kumpf 1.63 #include <Pegasus/Common/PegasusVersion.h>
|
43 kumpf 1.169 #include <Pegasus/Common/MessageLoader.h>
|
44 mike 1.159 #include <Pegasus/Common/ReadWriteSem.h>
|
45 kumpf 1.63
|
46 thilo.boehm 1.210 #include <Pegasus/Repository/XmlStreamer.h>
47 #include <Pegasus/Repository/BinaryStreamer.h>
48 #include <Pegasus/Repository/AutoStreamer.h>
|
49 schuur 1.114
|
50 mike 1.48 #include "CIMRepository.h"
51 #include "RepositoryDeclContext.h"
|
52 mike 1.151 #include "ObjectCache.h"
|
53 mike 1.48
|
54 kumpf 1.201 #include "PersistentStore.h"
|
55 jim.wunderlich 1.136
|
56 schuur 1.112 #if 0
57 #undef PEG_METHOD_ENTER
58 #undef PEG_METHOD_EXIT
59 #define PEG_METHOD_ENTER(x,y) cout<<"--- Enter: "<<y<<endl;
60 #define PEG_METHOD_EXIT()
61 #endif
62
|
63 jim.wunderlich 1.138
|
64 kumpf 1.204 //==============================================================================
65 //
66 // The class cache caches up PEGASUS_CLASS_CACHE_SIZE fully resolved class
67 // definitions in memory. To override the default, define
68 // PEGASUS_CLASS_CACHE_SIZE in your build environment. To suppress the cache
69 // (and not compile it in at all), set PEGASUS_CLASS_CACHE_SIZE to 0.
70 //
71 //==============================================================================
72
73 #if !defined(PEGASUS_CLASS_CACHE_SIZE)
74 # define PEGASUS_CLASS_CACHE_SIZE 8
75 #endif
76
77 #if (PEGASUS_CLASS_CACHE_SIZE != 0)
78 # define PEGASUS_USE_CLASS_CACHE
79 #endif
80
81 #define PEGASUS_QUALIFIER_CACHE_SIZE 80
82
83
|
84 mike 1.48 PEGASUS_USING_STD;
85
86 PEGASUS_NAMESPACE_BEGIN
87
|
88 mike 1.184 class CIMRepositoryRep
89 {
90 public:
91
|
92 kumpf 1.204 CIMRepositoryRep()
93 :
94 #ifdef PEGASUS_USE_CLASS_CACHE
95 _classCache(PEGASUS_CLASS_CACHE_SIZE),
96 #endif /* PEGASUS_USE_CLASS_CACHE */
97 _qualifierCache(PEGASUS_QUALIFIER_CACHE_SIZE)
98 {
99 }
100
|
101 mike 1.184 /**
102 Checks whether an instance with the specified key values exists in the
103 class hierarchy of the specified class.
104
105 @param nameSpace the namespace of the instance
106 @param instanceName the name of the instance
107
108 @return true if the instance is found
109 false if the instance cannot be found
110 */
111 Boolean _checkInstanceAlreadyExists(
112 const CIMNamespaceName& nameSpace,
113 const CIMObjectPath& instanceName) const;
114
115 // This must be initialized in the constructor using values from the
116 // ConfigManager.
117 Boolean _isDefaultInstanceProvider;
118
|
119 kumpf 1.189 AutoPtr<ObjectStreamer> _streamer;
120
|
121 kumpf 1.201 AutoPtr<PersistentStore> _persistentStore;
|
122 kumpf 1.189
|
123 kumpf 1.195 /**
124 Indicates whether the class definitions in the persistent store are
125 complete (contain propagated elements).
126 */
127 Boolean _storeCompleteClassDefinitions;
128
|
129 kumpf 1.192 NameSpaceManager _nameSpaceManager;
|
130 mike 1.184
131 ReadWriteSem _lock;
132
133 RepositoryDeclContext* _context;
134
135 CString _lockFile;
|
136 mike 1.151
137 #ifdef PEGASUS_USE_CLASS_CACHE
|
138 kumpf 1.204 ObjectCache<CIMClass> _classCache;
|
139 mike 1.151 #endif /* PEGASUS_USE_CLASS_CACHE */
140
|
141 kumpf 1.204 ObjectCache<CIMQualifierDecl> _qualifierCache;
142 };
|
143 mike 1.153
|
144 kumpf 1.189 static String _getCacheKey(
145 const CIMNamespaceName& nameSpace,
146 const CIMName& entryName)
|
147 jim.wunderlich 1.136 {
|
148 kumpf 1.204 String key = nameSpace.getString();
149 key.append(':');
150 key.append(entryName.getString());
151 return key;
|
152 jim.wunderlich 1.136 }
153
154
|
155 karl 1.101 //
156 // The following _xx functions are local to the repository implementation
157 //
|
158 mike 1.48 ////////////////////////////////////////////////////////////////////////////////
159 //
|
160 kumpf 1.104 // _containsProperty
|
161 karl 1.97 //
162 ////////////////////////////////////////////////////////////////////////////////
|
163 karl 1.101
164 /** Check to see if the specified property is in the property list
|
165 kumpf 1.104 @param property the specified property
|
166 karl 1.101 @param propertyList the property list
|
167 kumpf 1.104 @return true if the property is in the list otherwise false.
|
168 karl 1.101 */
|
169 kumpf 1.189 static Boolean _containsProperty(
|
170 kumpf 1.195 const CIMProperty& property,
|
171 kumpf 1.169 const CIMPropertyList& propertyList)
|
172 karl 1.97 {
|
173 kumpf 1.104 // For each property in the propertly list
174 for (Uint32 p=0; p<propertyList.size(); p++)
175 {
176 if (propertyList[p].equal(property.getName()))
177 return true;
178 }
179 return false;
|
180 karl 1.97 }
181
|
182 karl 1.98 ////////////////////////////////////////////////////////////////////////////////
183 //
184 // removeAllQualifiers - Remove all of the qualifiers from a class
185 //
186 ////////////////////////////////////////////////////////////////////////////////
|
187 karl 1.101
188 /* removes all Qualifiers from a CIMClass. This function removes all
189 of the qualifiers from the class, from all of the properties,
190 from the methods, and from the parameters attached to the methods.
191 @param cimClass reference to the class from which qualifiers are to
192 be removed.
|
193 kumpf 1.169 NOTE: This would be logical to be moved to CIMClass since it may be
194 more general than this usage.
|
195 karl 1.101 */
|
196 kumpf 1.189 static void _removeAllQualifiers(CIMClass& cimClass)
|
197 karl 1.98 {
|
198 kumpf 1.104 // remove qualifiers of the class
199 Uint32 count = 0;
|
200 kumpf 1.169 while ((count = cimClass.getQualifierCount()) > 0)
|
201 kumpf 1.104 cimClass.removeQualifier(count - 1);
202
203 // remove qualifiers from the properties
204 for (Uint32 i = 0; i < cimClass.getPropertyCount(); i++)
205 {
206 CIMProperty p = cimClass.getProperty(i);
|
207 kumpf 1.169 count = 0;
208 while ((count = p.getQualifierCount()) > 0)
|
209 kumpf 1.104 p.removeQualifier(count - 1);
210 }
|
211 kumpf 1.169
|
212 kumpf 1.104 // remove qualifiers from the methods
213 for (Uint32 i = 0; i < cimClass.getMethodCount(); i++)
214 {
215 CIMMethod m = cimClass.getMethod(i);
216 for (Uint32 j = 0 ; j < m.getParameterCount(); j++)
217 {
218 CIMParameter p = m.getParameter(j);
219 count = 0;
220 while ((count = p.getQualifierCount()) > 0)
221 p.removeQualifier(count - 1);
222 }
|
223 kumpf 1.169 count = 0;
224 while ((count = m.getQualifierCount()) > 0)
|
225 kumpf 1.104 m.removeQualifier(count - 1);
226 }
|
227 karl 1.98 }
228
229 /////////////////////////////////////////////////////////////////////////
230 //
|
231 kumpf 1.195 // _stripPropagatedElements
|
232 karl 1.98 //
233 /////////////////////////////////////////////////////////////////////////
|
234 karl 1.101
|
235 kumpf 1.195 /* Removes propagated elements from the CIMClass, including properties,
236 methods, and qualifiers attached to the class, properties, methods, and
237 parameters.
|
238 karl 1.101 */
|
239 kumpf 1.195 static void _stripPropagatedElements(CIMClass& cimClass)
|
240 karl 1.98 {
|
241 kumpf 1.195 // Remove the propagated qualifiers from the class.
242 // Work backwards because removal may be cheaper. Sint32 covers count=0
243 for (Sint32 i = cimClass.getQualifierCount() - 1; i >= 0; i--)
|
244 kumpf 1.104 {
|
245 kumpf 1.195 if (cimClass.getQualifier(i).getPropagated())
|
246 kumpf 1.104 {
247 cimClass.removeQualifier(i);
248 }
249 }
250
|
251 kumpf 1.195 // Remove the propagated properties.
252 for (Sint32 i = cimClass.getPropertyCount() - 1; i >= 0; i--)
|
253 kumpf 1.104 {
254 CIMProperty p = cimClass.getProperty(i);
|
255 kumpf 1.195 if (p.getPropagated())
256 {
257 cimClass.removeProperty(i);
258 }
259 else
|
260 kumpf 1.104 {
|
261 kumpf 1.195 // Remove the propagated qualifiers from the property.
262 for (Sint32 j = p.getQualifierCount() - 1; j >= 0; j--)
|
263 kumpf 1.104 {
|
264 kumpf 1.195 if (p.getQualifier(j).getPropagated())
265 {
266 p.removeQualifier(j);
267 }
|
268 kumpf 1.104 }
269 }
270 }
|
271 kumpf 1.169
|
272 kumpf 1.195 // Remove the propagated methods.
273 for (Sint32 i = cimClass.getMethodCount() - 1; i >= 0; i--)
|
274 kumpf 1.104 {
275 CIMMethod m = cimClass.getMethod(i);
|
276 kumpf 1.195 if (m.getPropagated())
277 {
278 cimClass.removeMethod(i);
279 }
280 else
|
281 kumpf 1.104 {
|
282 kumpf 1.195 // Remove the propagated qualifiers from the method.
283 for (Sint32 j = m.getQualifierCount() - 1; j >= 0; j--)
|
284 kumpf 1.104 {
|
285 kumpf 1.195 if (m.getQualifier(j).getPropagated())
|
286 kumpf 1.104 {
|
287 kumpf 1.195 m.removeQualifier(j);
|
288 kumpf 1.104 }
289 }
290
|
291 kumpf 1.195 // Remove the propagated qualifiers from the method parameters.
292 for (Sint32 j = m.getParameterCount() - 1; j >= 0; j--)
|
293 kumpf 1.104 {
|
294 kumpf 1.195 CIMParameter p = m.getParameter(j);
295 for (Sint32 k = p.getQualifierCount() - 1; k >= 0; k--)
296 {
297 if (p.getQualifier(k).getPropagated())
298 {
299 p.removeQualifier(k);
300 }
301 }
|
302 kumpf 1.104 }
303 }
304 }
|
305 karl 1.98 }
|
306 karl 1.97
|
307 karl 1.103 /* remove the properties from an instance based on attributes.
|
308 karl 1.101 @param Instance from which properties will be removed.
309 @param propertyList PropertyList is used in the removal algorithm
310 NOTE: This could be logical to move to CIMInstance since the
311 usage is more general than just in the repository
312 */
|
313 kumpf 1.189 static void _removeProperties(
|
314 kumpf 1.169 CIMInstance& cimInstance,
|
315 kumpf 1.209 const CIMPropertyList& propertyList)
|
316 karl 1.101 {
|
317 kumpf 1.209 if (!propertyList.isNull())
|
318 karl 1.101 {
319 // Loop through properties to remove those that do not filter through
320 // local only attribute and are not in the property list.
321 // Work backwards because removal may be cheaper. Sint32 covers count=0
|
322 kumpf 1.209 for (Sint32 i = (cimInstance.getPropertyCount() - 1); i >= 0; i--)
|
323 karl 1.101 {
|
324 kumpf 1.209 // Since the propertyList is not NULL, only properties in the list
325 // should be included in the instance.
326 if (!_containsProperty(cimInstance.getProperty(i), propertyList))
|
327 karl 1.101 cimInstance.removeProperty(i);
328 }
329 }
330 }
331
332 /* remove all Qualifiers from a single CIMInstance. Removes
333 all of the qualifiers from the instance and from properties
334 within the instance.
335 @param instance from which parameters are removed.
336 NOTE: This could be logical to be moved to CIMInstance since
337 the usage may be more general than just in the repository.
338 */
|
339 kumpf 1.189 static void _removeAllQualifiers(CIMInstance& cimInstance)
|
340 karl 1.101 {
|
341 kumpf 1.169 // remove qualifiers from the instance
342 Uint32 count = 0;
343 while ((count = cimInstance.getQualifierCount()) > 0)
344 cimInstance.removeQualifier(count - 1);
|
345 karl 1.101
|
346 kumpf 1.169 // remove qualifiers from the properties
347 for (Uint32 i = 0; i < cimInstance.getPropertyCount(); i++)
348 {
349 CIMProperty p = cimInstance.getProperty(i);
350 count = 0;
351 while ((count = p.getQualifierCount()) > 0)
352 p.removeQualifier(count - 1);
353 }
|
354 karl 1.101 }
|
355 kumpf 1.169
|
356 karl 1.101 /* removes all ClassOrigin attributes from a single CIMInstance. Removes
357 the classOrigin attribute from each property in the Instance.
358 @param Instance from which the ClassOrigin Properties will be removed.
359 NOTE: Logical to be moved to CIMInstance since it may be more general
360 than just the repositoryl
361 */
|
362 kumpf 1.189 static void _removeClassOrigins(CIMInstance& cimInstance)
|
363 karl 1.101 {
|
364 marek 1.174 PEG_TRACE_CSTRING(TRC_REPOSITORY, Tracer::LEVEL4, "Remove Class Origins");
|
365 kumpf 1.104
|
366 kumpf 1.169 Uint32 propertyCount = cimInstance.getPropertyCount();
367 for (Uint32 i = 0; i < propertyCount ; i++)
368 cimInstance.getProperty(i).setClassOrigin(CIMName());
|
369 karl 1.101 }
370
|
371 karl 1.103 /* Filters the properties, qualifiers, and classorigin out of a single instance.
|
372 kumpf 1.209 Based on the parameters provided for propertyList, includeQualifiers,
|
373 karl 1.101 and includeClassOrigin, this function simply filters the properties
374 qualifiers, and classOrigins out of a single instance. This function
375 was created to have a single piece of code that processes getinstance
376 and enumerateInstances returns.
377 @param cimInstance reference to instance to be processed.
|
378 kumpf 1.209 @param propertyList If not null, defines the properties to be included in
379 the instance.
|
380 karl 1.101 @param includeQualifiers Boolean defining if qualifiers to be returned.
381 @param includeClassOrigin Boolean defining if ClassOrigin attribute to
382 be removed from properties.
383 */
|
384 kumpf 1.189 static void _filterInstance(
|
385 kumpf 1.169 CIMInstance& cimInstance,
386 const CIMPropertyList& propertyList,
387 Boolean includeQualifiers,
388 Boolean includeClassOrigin)
|
389 karl 1.101 {
|
390 kumpf 1.209 // Remove properties based on propertyList
391 _removeProperties(cimInstance, propertyList);
|
392 kumpf 1.164
|
393 karl 1.101 // If includequalifiers false, remove all qualifiers from
394 // properties.
395
|
396 kumpf 1.169 if (!includeQualifiers)
|
397 karl 1.101 {
398 _removeAllQualifiers(cimInstance);
399 }
|
400 kumpf 1.164
|
401 karl 1.103 // if ClassOrigin Flag false, remove classOrigin info from Instance object
402 // by setting the classOrigin to Null.
|
403 kumpf 1.164
|
404 karl 1.101 if (!includeClassOrigin)
405 {
406 _removeClassOrigins(cimInstance);
407 }
408 }
|
409 kumpf 1.164
|
410 kumpf 1.190 static Array<ClassAssociation> _buildClassAssociationEntries(
411 const CIMConstClass& assocClass)
412 {
413 PEG_METHOD_ENTER(TRC_REPOSITORY, "_buildClassAssociationEntries");
414
415 Array<ClassAssociation> classAssocEntries;
416
417 // Get the association's class name:
418
419 CIMName assocClassName = assocClass.getClassName();
420
421 // For each property:
422
423 Uint32 n = assocClass.getPropertyCount();
424
425 for (Uint32 i = 0; i < n; i++)
426 {
427 CIMConstProperty fromProp = assocClass.getProperty(i);
428
429 if (fromProp.getType() == CIMTYPE_REFERENCE)
430 {
431 kumpf 1.190 for (Uint32 j = 0; j < n; j++)
432 {
433 CIMConstProperty toProp = assocClass.getProperty(j);
434
435 if (toProp.getType() == CIMTYPE_REFERENCE &&
436 (!fromProp.getName().equal(toProp.getName())))
437 {
438 classAssocEntries.append(ClassAssociation(
439 assocClassName,
440 fromProp.getReferenceClassName(),
441 fromProp.getName(),
442 toProp.getReferenceClassName(),
443 toProp.getName()));
444 }
445 }
446 }
447 }
448
449 PEG_METHOD_EXIT();
450 return classAssocEntries;
451 }
452 kumpf 1.190
453 /*
454 This routine does the following:
455
456 1. Creates two entries in the association file for each relationship
457 formed by this new association instance. A binary association
458 (one with two references) ties two instances together. Suppose
459 there are two instances: I1 and I2. Then two entries are created:
460
461 I2 -> I1
462 I1 -> I2
463
464 For a ternary relationship, six entries will be created. Suppose
465 there are three instances: I1, I2, and I3:
466
467 I1 -> I2
468 I1 -> I3
469 I2 -> I1
470 I2 -> I3
471 I3 -> I1
472 I3 -> I2
473 kumpf 1.190
474 So for an N-ary relationship, there will be N! entries created.
475
476 2. Verifies that the association instance refers to real objects.
477 (note that an association reference may refer to either an instance
478 or a class). Throws an exception if one of the references does not
479 refer to a valid object.
480 */
481 static Array<InstanceAssociation> _buildInstanceAssociationEntries(
482 const CIMNamespaceName& nameSpace,
483 const CIMConstClass& cimClass,
484 const CIMInstance& cimInstance,
485 const CIMObjectPath& instanceName)
486 {
487 PEG_METHOD_ENTER(TRC_REPOSITORY, "_buildInstanceAssociationEntries");
488
489 Array<InstanceAssociation> instanceAssocEntries;
490
491 // Get the association's instance name and class name:
492
493 String assocInstanceName = instanceName.toString();
494 kumpf 1.190 CIMName assocClassName = instanceName.getClassName();
495
496 // For each property:
497
498 for (Uint32 i = 0, n = cimInstance.getPropertyCount(); i < n; i++)
499 {
500 CIMConstProperty fromProp = cimInstance.getProperty(i);
501
502 // If a reference property:
503
504 if (fromProp.getType() == CIMTYPE_REFERENCE)
505 {
506 // For each property:
507
508 for (Uint32 j = 0, m = cimInstance.getPropertyCount(); j < m; j++)
509 {
510 CIMConstProperty toProp = cimInstance.getProperty(j);
511
512 // If a reference property and not the same property:
513
514 if (toProp.getType() == CIMTYPE_REFERENCE &&
515 kumpf 1.190 (!fromProp.getName().equal (toProp.getName())))
516 {
517 CIMObjectPath fromRef;
518 fromProp.getValue().get(fromRef);
519
520 CIMObjectPath toRef;
521 toProp.getValue().get(toRef);
522
523
524 // Fix for bugzilla 667:
525 // Strip off the hostname if it is the same as the
526 // local host
527 if ((fromRef.getHost() != String::EMPTY) &&
528 (System::isLocalHost(fromRef.getHost())))
529 {
530 PEG_TRACE_CSTRING(TRC_REPOSITORY, Tracer::LEVEL4,
531 "Stripping off local hostName from fromRef");
532 fromRef.setHost(String::EMPTY);
533 }
534
535 // Strip off the namespace when it is the same as the
536 kumpf 1.190 // one this instance is created in.
537 if ((fromRef.getHost() == String::EMPTY) &&
538 (fromRef.getNameSpace() == nameSpace))
539 {
540 PEG_TRACE_CSTRING(TRC_REPOSITORY, Tracer::LEVEL4,
541 "Stripping off local nameSpace from fromRef");
542 fromRef.setNameSpace(CIMNamespaceName());
543 }
544
545 // Strip off the hostname if it is the same as the
546 // local host
547 if ((toRef.getHost() != String::EMPTY) &&
548 (System::isLocalHost(toRef.getHost())))
549 {
550 PEG_TRACE_CSTRING(TRC_REPOSITORY, Tracer::LEVEL4,
551 "Stripping off local hostName from toRef");
552 toRef.setHost(String::EMPTY);
553 }
554
555 // Strip off the namespace when it is the same as the
556 // one this instance is created in.
557 kumpf 1.190 if ((toRef.getHost() == String::EMPTY) &&
558 (toRef.getNameSpace() == nameSpace))
559 {
560 PEG_TRACE_CSTRING(TRC_REPOSITORY, Tracer::LEVEL4,
561 "Stripping off local nameSpace from toRef");
562 toRef.setNameSpace(CIMNamespaceName());
563 }
564
565 instanceAssocEntries.append(InstanceAssociation(
566 assocInstanceName,
567 assocClassName,
568 fromRef.toString(),
569 fromRef.getClassName(),
570 fromProp.getName(),
571 toRef.toString(),
572 toRef.getClassName(),
573 toProp.getName()));
574 }
575 }
576 }
577 }
578 kumpf 1.190
579 PEG_METHOD_EXIT();
580 return instanceAssocEntries;
581 }
582
|
583 kumpf 1.189 /**
584 Converts an object path to an instance name. The host name is set to the
585 empty string. The namespace is set to null if it matches the specified
586 namespace. Otherwise, if it is not null, a CIM_ERR_NOT_FOUND exception is
587 thrown.
|
588 mike 1.48
|
589 kumpf 1.189 This function allows the repository to store instance names with
590 consistent contents to facilitate equality tests. (See Bug 1508.)
|
591 david 1.96
|
592 kumpf 1.189 */
593 static CIMObjectPath _stripInstanceName(
594 const CIMNamespaceName& nameSpace,
595 const CIMObjectPath& instanceName)
|
596 kumpf 1.165 {
|
597 kumpf 1.189 CIMObjectPath normalizedInstanceName = instanceName;
598 normalizedInstanceName.setHost(String::EMPTY);
|
599 kumpf 1.165
|
600 kumpf 1.189 if (instanceName.getNameSpace() == nameSpace)
|
601 kumpf 1.165 {
|
602 kumpf 1.189 normalizedInstanceName.setNameSpace(CIMNamespaceName());
|
603 kumpf 1.165 }
|
604 kumpf 1.189 else if (!instanceName.getNameSpace().isNull())
|
605 kumpf 1.165 {
|
606 kumpf 1.189 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_FOUND, instanceName.toString());
|
607 kumpf 1.165 }
608
|
609 kumpf 1.189 return normalizedInstanceName;
|
610 kumpf 1.168 }
611
612 ////////////////////////////////////////////////////////////////////////////////
613 //
|
614 mike 1.48 // CIMRepository
615 //
616 // The following are not implemented:
617 //
618 // CIMRepository::execQuery()
619 // CIMRepository::invokeMethod()
620 //
621 // Note that invokeMethod() will not never implemented since it is not
622 // meaningful for a repository.
623 //
|
624 dmitry.mikulin 1.181 // Note that if declContext is passed to the CIMRepository constructor,
625 // the repository object will own it and will delete it when appropriate.
626 //
|
627 mike 1.48 ////////////////////////////////////////////////////////////////////////////////
628
|
629 kumpf 1.166 CIMRepository::CIMRepository(
630 const String& repositoryRoot,
|
631 dmitry.mikulin 1.181 Uint32 mode,
632 RepositoryDeclContext* declContext)
|
633 jim.wunderlich 1.134 {
634 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::CIMRepository");
635
|
636 kumpf 1.166 Boolean binaryMode = mode & CIMRepository::MODE_BIN;
|
637 kumpf 1.142
|
638 kumpf 1.166 if (mode == CIMRepository::MODE_DEFAULT)
|
639 kumpf 1.142 {
|
640 kumpf 1.158 binaryMode = ConfigManager::parseBooleanValue(
641 ConfigManager::getInstance()->getCurrentValue(
642 "enableBinaryRepository"));
|
643 schuur 1.114 }
644
|
645 kumpf 1.166 // FUTURE?? - compressMode = mode & CIMRepository::MODE_COMPRESSED;
|
646 kumpf 1.189 Boolean compressMode = false;
|
647 jim.wunderlich 1.136
|
648 kumpf 1.189 #ifdef PEGASUS_ENABLE_COMPRESSED_REPOSITORY // PEP214
|
649 kumpf 1.196 compressMode = true;
|
650 kumpf 1.169 char* s = getenv("PEGASUS_ENABLE_COMPRESSED_REPOSITORY");
|
651 jim.wunderlich 1.136 if (s && (strcmp(s, "build_non_compressed") == 0))
|
652 kumpf 1.142 {
|
653 kumpf 1.189 compressMode = false;
|
654 kumpf 1.142 #ifdef TEST_OUTPUT
655 cout << "In Compress mode: build_non_compresed found" << endl;
|
656 jim.wunderlich 1.136 #endif /* TEST_OUTPUT */
|
657 kumpf 1.142 }
658 #endif /* PEGASUS_ENABLE_COMPRESSED_REPOSITORY */
|
659 jim.wunderlich 1.136
|
660 kumpf 1.142 #ifdef TEST_OUTPUT
661 cout << "repositoryRoot = " << repositoryRoot << endl;
|
662 kumpf 1.166 cout << "CIMRepository: binaryMode=" << binaryMode <<
663 ", mode=" << mode << endl;
|
664 jim.wunderlich 1.136 cout << "CIMRepository: compressMode= " << compressMode << endl;
665 #endif /* TEST_OUTPUT */
|
666 jim.wunderlich 1.134
|
667 kumpf 1.189 _rep = new CIMRepositoryRep();
668
|
669 marek 1.183 if (binaryMode)
|
670 kumpf 1.169 {
671 // BUILD BINARY
|
672 kumpf 1.189 _rep->_streamer.reset(
673 new AutoStreamer(new BinaryStreamer(), BINREP_MARKER));
674 ((AutoStreamer*)_rep->_streamer.get())->addReader(new XmlStreamer(), 0);
|
675 kumpf 1.169 }
676 else
677 {
678 // BUILD XML
|
679 kumpf 1.189 _rep->_streamer.reset(new AutoStreamer(new XmlStreamer(), 0xff));
680 ((AutoStreamer*)_rep->_streamer.get())->addReader(
|
681 kumpf 1.169 new BinaryStreamer(), BINREP_MARKER);
|
682 kumpf 1.189 ((AutoStreamer*)_rep->_streamer.get())->addReader(new XmlStreamer(), 0);
|
683 schuur 1.116 }
|
684 schuur 1.114
|
685 dmitry.mikulin 1.181 // If declContext is supplied by the caller, don't allocate it.
|
686 kumpf 1.208 // CIMRepository will take ownership and will be responsible for
|
687 dmitry.mikulin 1.181 // deleting it.
688 if (declContext)
|
689 mike 1.184 _rep->_context = declContext;
|
690 dmitry.mikulin 1.181 else
|
691 mike 1.184 _rep->_context = new RepositoryDeclContext();
692 _rep->_context->setRepository(this);
|
693 dmitry.mikulin 1.181
|
694 mike 1.184 _rep->_isDefaultInstanceProvider = ConfigManager::parseBooleanValue(
|
695 kumpf 1.158 ConfigManager::getInstance()->getCurrentValue(
696 "repositoryIsDefaultInstanceProvider"));
|
697 kumpf 1.58
|
698 mike 1.184 _rep->_lockFile = ConfigManager::getInstance()->getHomedPath(
|
699 kumpf 1.160 PEGASUS_REPOSITORY_LOCK_FILE).getCString();
700
|
701 kumpf 1.201 _rep->_persistentStore.reset(PersistentStore::createPersistentStore(
|
702 kumpf 1.192 repositoryRoot,
703 _rep->_streamer.get(),
704 compressMode));
705
|
706 kumpf 1.195 _rep->_storeCompleteClassDefinitions =
707 _rep->_persistentStore->storeCompleteClassDefinitions();
708
|
709 kumpf 1.192 // Initialize the NameSpaceManager
710
711 Array<NamespaceDefinition> nameSpaces =
712 _rep->_persistentStore->enumerateNameSpaces();
713
714 Uint32 i = 0;
715 while (i < nameSpaces.size())
716 {
717 if (nameSpaces[i].parentNameSpace.isNull() ||
718 _rep->_nameSpaceManager.nameSpaceExists(
719 nameSpaces[i].parentNameSpace))
720 {
721 // Parent namespace exists; go ahead and initialize this namespace
722 _rep->_nameSpaceManager.initializeNameSpace(
723 nameSpaces[i],
724 _rep->_persistentStore->enumerateClassNames(
725 nameSpaces[i].name));
726 i++;
727 }
728 else
729 {
730 kumpf 1.192 // If the parent namespace appears later in the list, swap the
731 // entries and repeat this iteration
732 Boolean swapped = false;
733 for (Uint32 j = i + 1; j < nameSpaces.size(); j++)
734 {
735 if (nameSpaces[i].parentNameSpace == nameSpaces[j].name)
736 {
737 NamespaceDefinition tmp = nameSpaces[j];
738 nameSpaces[j] = nameSpaces[i];
739 nameSpaces[i] = tmp;
740 swapped = true;
741 break;
742 }
743 }
|
744 kumpf 1.189
|
745 kumpf 1.192 if (!swapped)
746 {
747 PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL1,
748 "Namespace: %s ignored - parent namespace %s not found",
749 (const char*)nameSpaces[i].name.getString().getCString(),
750 (const char*)nameSpaces[i].parentNameSpace.getString().
751 getCString()));
752 nameSpaces.remove(i);
753 }
754 }
|
755 kumpf 1.189 }
756
|
757 kumpf 1.192 if (!_rep->_nameSpaceManager.nameSpaceExists("root"))
|
758 kumpf 1.189 {
759 // Create a root namespace per ...
760 // Specification for CIM Operations over HTTP
761 // Version 1.0
762 // 2.5 Namespace Manipulation
763 //
764 // There are no intrinsic methods defined specifically for the
765 // purpose of manipulating CIM Namespaces. However, the
766 // modelling of the a CIM Namespace using the class
767 // __Namespace, together with the requirement that that
768 // root Namespace MUST be supported by all CIM Servers,
769 // implies that all Namespace operations can be supported.
770
771 createNameSpace("root");
772 }
|
773 kumpf 1.168
|
774 kumpf 1.58 PEG_METHOD_EXIT();
|
775 mike 1.48 }
776
777 CIMRepository::~CIMRepository()
778 {
|
779 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::~CIMRepository");
780
|
781 mike 1.184 delete _rep->_context;
|
782 kumpf 1.58
|
783 mike 1.184 delete _rep;
784
|
785 kumpf 1.58 PEG_METHOD_EXIT();
|
786 mike 1.48 }
787
|
788 kumpf 1.104 String _toString(Boolean x)
|
789 mike 1.51 {
|
790 kumpf 1.104 return(x ? "true" : "false");
|
791 mike 1.51 }
792
|
793 kumpf 1.104 CIMClass CIMRepository::getClass(
794 const CIMNamespaceName& nameSpace,
795 const CIMName& className,
796 Boolean localOnly,
797 Boolean includeQualifiers,
798 Boolean includeClassOrigin,
799 const CIMPropertyList& propertyList)
|
800 mike 1.51 {
|
801 kumpf 1.104 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::getClass");
|
802 kumpf 1.58
|
803 mike 1.184 ReadLock lock(_rep->_lock);
|
804 kumpf 1.104 CIMClass cimClass = _getClass(nameSpace,
805 className,
806 localOnly,
807 includeQualifiers,
808 includeClassOrigin,
809 propertyList);
|
810 kumpf 1.58
811 PEG_METHOD_EXIT();
|
812 kumpf 1.104 return cimClass;
|
813 mike 1.51 }
814
|
815 kumpf 1.104 CIMClass CIMRepository::_getClass(
|
816 kumpf 1.85 const CIMNamespaceName& nameSpace,
817 const CIMName& className,
|
818 mike 1.48 Boolean localOnly,
819 Boolean includeQualifiers,
820 Boolean includeClassOrigin,
|
821 mike 1.205 const CIMPropertyList& propertyList,
822 Boolean clone)
|
823 mike 1.48 {
|
824 kumpf 1.104 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_getClass");
|
825 kumpf 1.58
|
826 thilo.boehm 1.193 PEG_TRACE((TRC_REPOSITORY, Tracer::LEVEL4,
827 "nameSpace= %s, className= %s, localOnly= %s"
828 ", includeQualifiers= %s, includeClassOrigin= %s",
829 (const char*)nameSpace.getString().getCString(),
830 (const char*)className.getString().getCString(),
831 (localOnly?"true":"false"),
832 (includeQualifiers?"true":"false"),
833 (includeClassOrigin?"true":"false")));
|
834 kumpf 1.104
835 CIMClass cimClass;
|
836 kumpf 1.203 // The class cache contains complete class definitions
837 Boolean classIncludesPropagatedElements = true;
|
838 mike 1.51
|
839 mike 1.151 #ifdef PEGASUS_USE_CLASS_CACHE
|
840 kumpf 1.203 // Check the cache first. Note that the cache contains complete class
841 // definitions including propagated elements.
|
842 mike 1.151
|
843 kumpf 1.189 String cacheKey = _getCacheKey(nameSpace, className);
|
844 mike 1.151
|
845 mike 1.205 if (!_rep->_classCache.get(cacheKey, cimClass, clone))
|
846 kumpf 1.189 {
847 // Not in cache so load from disk:
848 #endif
|
849 mike 1.151
|
850 kumpf 1.189 CIMNamespaceName actualNameSpaceName;
851 CIMName superClassName;
|
852 kumpf 1.192 _rep->_nameSpaceManager.locateClass(
|
853 kumpf 1.189 nameSpace, className, actualNameSpaceName, superClassName);
|
854 mike 1.151
|
855 kumpf 1.189 cimClass = _rep->_persistentStore->getClass(
856 actualNameSpaceName, className, superClassName);
|
857 kumpf 1.203 classIncludesPropagatedElements = _rep->_storeCompleteClassDefinitions;
858
859 if (!localOnly && !classIncludesPropagatedElements)
860 {
861 // Propagate the superclass elements to this class.
862 Resolver::resolveClass(cimClass, _rep->_context, nameSpace);
863 classIncludesPropagatedElements = true;
864 }
|
865 mike 1.151
|
866 kumpf 1.189 #ifdef PEGASUS_USE_CLASS_CACHE
|
867 kumpf 1.203 if (classIncludesPropagatedElements)
868 {
869 // Put in cache:
|
870 mike 1.151
|
871 mike 1.205 _rep->_classCache.put(cacheKey, cimClass, clone);
|
872 kumpf 1.203 }
|
873 mike 1.51 }
|
874 kumpf 1.189 #endif
|
875 mike 1.48
|
876 mike 1.205 #if !defined(PEGASUS_USE_CLASS_CACHE)
877 // This flag must be true if caching is disabled, otherwise, an unecessary
878 // copy could be created below.
879 clone = true;
880 #endif
881
882 // If clone is true, then cimClass is a clone (not shared with cache).
883 // Else, it refers to the same one in the cache and any code below that
884 // changes it, will need to clone it first.
885
|
886 kumpf 1.203 if (localOnly && classIncludesPropagatedElements)
|
887 kumpf 1.195 {
|
888 mike 1.205 // We must clone after all since object is modified below.
889 if (!clone)
890 cimClass = cimClass.clone();
891
|
892 kumpf 1.203 _stripPropagatedElements(cimClass);
|
893 kumpf 1.195 }
|
894 kumpf 1.104
|
895 kumpf 1.195 // Remove properties based on propertyList
896 if (!propertyList.isNull())
|
897 karl 1.97 {
|
898 mike 1.205 // We must clone after all since object is modified below.
899 if (!clone)
900 cimClass = cimClass.clone();
901
|
902 kumpf 1.195 // Remove properties that are not in the property list.
|
903 kumpf 1.104 // Work backwards because removal may be cheaper. Sint32 covers count=0
|
904 kumpf 1.195 for (Sint32 i = cimClass.getPropertyCount() - 1; i >= 0; i--)
|
905 kumpf 1.104 {
|
906 kumpf 1.195 if (!_containsProperty(cimClass.getProperty(i), propertyList))
|
907 kumpf 1.104 {
908 cimClass.removeProperty(i);
909 }
910 }
911 }
912
913 // If includequalifiers false, remove all qualifiers from
914 // properties, methods and parameters.
|
915 kumpf 1.169 if (!includeQualifiers)
|
916 kumpf 1.104 {
|
917 mike 1.205 // We must clone after all since object is modified below.
918 if (!clone)
919 cimClass = cimClass.clone();
920
|
921 kumpf 1.104 _removeAllQualifiers(cimClass);
922 }
|
923 kumpf 1.169
|
924 kumpf 1.104 // if ClassOrigin Flag false, remove classOrigin info from class object
925 // by setting the property to Null.
926 if (!includeClassOrigin)
927 {
|
928 mike 1.205 // We must clone after all since object is modified below.
929 if (!clone)
930 cimClass = cimClass.clone();
931
|
932 marek 1.174 PEG_TRACE_CSTRING(TRC_REPOSITORY, Tracer::LEVEL4,
|
933 kumpf 1.169 "Remove Class Origins");
|
934 kumpf 1.104
935 Uint32 propertyCount = cimClass.getPropertyCount();
936 for (Uint32 i = 0; i < propertyCount ; i++)
937 cimClass.getProperty(i).setClassOrigin(CIMName());
938
939 Uint32 methodCount = cimClass.getMethodCount();
940 for (Uint32 i=0; i < methodCount ; i++)
941 cimClass.getMethod(i).setClassOrigin(CIMName());
942 }
|
943 karl 1.97
|
944 kumpf 1.58 PEG_METHOD_EXIT();
|
945 mike 1.48 return cimClass;
946 }
947
|
948 mike 1.184 Boolean CIMRepositoryRep::_checkInstanceAlreadyExists(
|
949 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
950 kumpf 1.162 const CIMObjectPath& instanceName) const
|
951 mike 1.48 {
|
952 kumpf 1.162 PEG_METHOD_ENTER(TRC_REPOSITORY,
953 "CIMRepository::_checkInstanceAlreadyExists");
|
954 kumpf 1.58
|
955 mike 1.53 //
|
956 kumpf 1.162 // Get the names of all superclasses and subclasses of this class
|
957 mike 1.53 //
|
958 mike 1.51
|
959 kumpf 1.85 Array<CIMName> classNames;
|
960 kumpf 1.162 CIMName className = instanceName.getClassName();
|
961 kumpf 1.94 classNames.append(className);
|
962 kumpf 1.192 _nameSpaceManager.getSubClassNames(nameSpace, className, true, classNames);
963 _nameSpaceManager.getSuperClassNames(nameSpace, className, classNames);
|
964 mike 1.48
|
965 mike 1.53 //
|
966 kumpf 1.162 // Search for an instance with the specified key values
|
967 mike 1.53 //
|
968 mike 1.48
969 for (Uint32 i = 0; i < classNames.size(); i++)
970 {
|
971 kumpf 1.189 CIMObjectPath tmpInstanceName = CIMObjectPath(
972 String::EMPTY,
973 CIMNamespaceName(),
974 classNames[i],
975 instanceName.getKeyBindings());
|
976 mike 1.48
|
977 kumpf 1.189 if (_persistentStore->instanceExists(nameSpace, tmpInstanceName))
|
978 mike 1.51 {
|
979 kumpf 1.58 PEG_METHOD_EXIT();
|
980 mike 1.51 return true;
981 }
|
982 mike 1.48 }
983
|
984 kumpf 1.58 PEG_METHOD_EXIT();
|
985 mike 1.48 return false;
986 }
987
988 CIMInstance CIMRepository::getInstance(
|
989 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
990 kumpf 1.68 const CIMObjectPath& instanceName,
|
991 mike 1.48 Boolean includeQualifiers,
992 Boolean includeClassOrigin,
|
993 mike 1.55 const CIMPropertyList& propertyList)
|
994 mike 1.48 {
|
995 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::getInstance");
996
|
997 mike 1.184 ReadLock lock(_rep->_lock);
|
998 kumpf 1.165
|
999 kumpf 1.169 CIMInstance cimInstance = _getInstance(
1000 nameSpace,
1001 instanceName,
1002 includeQualifiers,
1003 includeClassOrigin,
|
1004 kumpf 1.191 propertyList,
1005 true);
|
1006 kumpf 1.104
1007 PEG_METHOD_EXIT();
1008 return cimInstance;
1009 }
1010
1011 CIMInstance CIMRepository::_getInstance(
1012 const CIMNamespaceName& nameSpace,
1013 const CIMObjectPath& instanceName,
1014 Boolean includeQualifiers,
1015 Boolean includeClassOrigin,
|
1016 kumpf 1.191 const CIMPropertyList& propertyList,
1017 Boolean resolveInstance)
|
1018 kumpf 1.104 {
1019 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_getInstance");
1020
|
1021 kumpf 1.189 CIMObjectPath normalizedInstanceName =
1022 _stripInstanceName(nameSpace, instanceName);
|
1023 r.kieninger 1.125
|
1024 kumpf 1.192 if (!_rep->_nameSpaceManager.classExists(
|
1025 mike 1.184 nameSpace, instanceName.getClassName()))
|
1026 kumpf 1.162 {
1027 throw PEGASUS_CIM_EXCEPTION(
1028 CIM_ERR_INVALID_CLASS, instanceName.getClassName().getString());
1029 }
1030
|
1031 kumpf 1.189 CIMInstance cimInstance =
1032 _rep->_persistentStore->getInstance(nameSpace, normalizedInstanceName);
|
1033 mike 1.51
|
1034 mike 1.54 //
1035 // Resolve the instance (if requested):
1036 //
1037
|
1038 kumpf 1.198 if (resolveInstance && includeQualifiers)
|
1039 mike 1.54 {
|
1040 kumpf 1.198 // Instances are resolved in persistent storage by the
1041 // createInstance and modifyInstance operations, but qualifiers
1042 // are not propagated. The only reason to perform resolution
1043 // here is if qualifiers are requested in the instance.
1044
|
1045 kumpf 1.104 CIMConstClass cimClass;
|
1046 mike 1.184 Resolver::resolveInstance (
1047 cimInstance, _rep->_context, nameSpace, cimClass, true);
|
1048 mike 1.54 }
|
1049 kumpf 1.99
|
1050 kumpf 1.165 _filterInstance(
1051 cimInstance,
1052 propertyList,
1053 includeQualifiers,
1054 includeClassOrigin);
|
1055 kumpf 1.104
|
1056 kumpf 1.52 PEG_METHOD_EXIT();
|
1057 mike 1.48 return cimInstance;
1058 }
1059
1060 void CIMRepository::deleteClass(
|
1061 kumpf 1.85 const CIMNamespaceName& nameSpace,
1062 const CIMName& className)
|
1063 mike 1.48 {
|
1064 kumpf 1.61 PEG_METHOD_ENTER(TRC_REPOSITORY,"CIMRepository::deleteClass");
|
1065 kumpf 1.58
|
1066 mike 1.184 WriteLock lock(_rep->_lock);
1067 AutoFileLock fileLock(_rep->_lockFile);
|
1068 kumpf 1.104
|
1069 mike 1.53 //
|
1070 kumpf 1.189 // Get the class and check to see if it is an association class.
|
1071 mike 1.53 //
|
1072 mike 1.51
|
1073 kumpf 1.104 CIMClass cimClass = _getClass(
1074 nameSpace, className, false, true, false, CIMPropertyList());
|
1075 mike 1.48 Boolean isAssociation = cimClass.isAssociation();
1076
|
1077 kumpf 1.192 _rep->_nameSpaceManager.checkDeleteClass(nameSpace, className);
|
1078 kumpf 1.189
1079 Array<CIMNamespaceName> dependentNameSpaceNames =
|
1080 kumpf 1.192 _rep->_nameSpaceManager.getDependentSchemaNameSpaceNames(nameSpace);
|
1081 kumpf 1.189
|
1082 mike 1.53 //
|
1083 kumpf 1.189 // Ensure no instances of this class exist in the repository.
|
1084 mike 1.53 //
|
1085 mike 1.151
|
1086 kumpf 1.189 for (Uint32 i = 0; i < dependentNameSpaceNames.size(); i++)
1087 {
1088 Array<CIMObjectPath> instanceNames =
1089 _rep->_persistentStore->enumerateInstanceNamesForClass(
1090 dependentNameSpaceNames[i], className);
|
1091 mike 1.151
|
1092 kumpf 1.189 if (instanceNames.size())
1093 {
1094 throw PEGASUS_CIM_EXCEPTION(
1095 CIM_ERR_CLASS_HAS_INSTANCES, className.getString());
1096 }
1097 }
|
1098 mike 1.48
|
1099 kumpf 1.189 #ifdef PEGASUS_USE_CLASS_CACHE
|
1100 kumpf 1.104
|
1101 kumpf 1.204 _rep->_classCache.evict(_getCacheKey(nameSpace, className));
|
1102 mike 1.48
|
1103 kumpf 1.189 #endif /* PEGASUS_USE_CLASS_CACHE */
|
1104 kumpf 1.58
|
1105 mike 1.53 //
|
1106 kumpf 1.189 // Delete the class. The NameSpaceManager::deleteClass() method throws
1107 // an exception if the class has subclasses.
|
1108 mike 1.53 //
1109
|
1110 kumpf 1.189 CIMName superClassName =
|
1111 kumpf 1.192 _rep->_nameSpaceManager.getSuperClassName(nameSpace, className);
|
1112 mike 1.53
|
1113 kumpf 1.192 _rep->_nameSpaceManager.deleteClass(nameSpace, className);
|
1114 mike 1.53
|
1115 kumpf 1.190 _rep->_persistentStore->deleteClass(
1116 nameSpace,
1117 className,
1118 superClassName,
1119 isAssociation,
1120 dependentNameSpaceNames);
|
1121 kumpf 1.58
1122 PEG_METHOD_EXIT();
|
1123 mike 1.53 }
1124
|
1125 mike 1.48 void CIMRepository::deleteInstance(
|
1126 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1127 kumpf 1.68 const CIMObjectPath& instanceName)
|
1128 mike 1.48 {
|
1129 mike 1.53 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::deleteInstance");
|
1130 mike 1.51
|
1131 kumpf 1.192 _rep->_nameSpaceManager.validateClass(
|
1132 kumpf 1.189 nameSpace, instanceName.getClassName());
1133
1134 CIMObjectPath normalizedInstanceName =
1135 _stripInstanceName(nameSpace, instanceName);
|
1136 r.kieninger 1.125
|
1137 mike 1.184 WriteLock lock(_rep->_lock);
1138 AutoFileLock fileLock(_rep->_lockFile);
|
1139 kumpf 1.104
|
1140 kumpf 1.189 _rep->_persistentStore->deleteInstance(nameSpace, normalizedInstanceName);
|
1141 mike 1.53
|
1142 kumpf 1.58 PEG_METHOD_EXIT();
|
1143 mike 1.48 }
1144
1145 void CIMRepository::createClass(
|
1146 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1147 kumpf 1.199 const CIMClass& newClass)
|
1148 mike 1.48 {
|
1149 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::createClass");
1150
|
1151 mike 1.184 WriteLock lock(_rep->_lock);
1152 AutoFileLock fileLock(_rep->_lockFile);
|
1153 kumpf 1.104 _createClass(nameSpace, newClass);
1154
1155 PEG_METHOD_EXIT();
1156 }
1157
1158 void CIMRepository::_createClass(
1159 const CIMNamespaceName& nameSpace,
1160 const CIMClass& newClass)
1161 {
1162 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_createClass");
1163
|
1164 kumpf 1.197 // -- Check whether the class may be created:
1165
1166 _rep->_nameSpaceManager.checkCreateClass(
1167 nameSpace, newClass.getClassName(), newClass.getSuperClassName());
1168
|
1169 mike 1.48 // -- Resolve the class:
|
1170 kumpf 1.104
|
1171 kumpf 1.194 CIMClass cimClass(newClass.clone());
1172 Resolver::resolveClass(cimClass, _rep->_context, nameSpace);
|
1173 mike 1.48
|
1174 kumpf 1.190 // -- If an association class, build association entries:
|
1175 kumpf 1.189
|
1176 kumpf 1.190 Array<ClassAssociation> classAssocEntries;
|
1177 kumpf 1.189
|
1178 kumpf 1.190 if (cimClass.isAssociation())
1179 {
1180 classAssocEntries = _buildClassAssociationEntries(cimClass);
1181 }
|
1182 mike 1.48
|
1183 kumpf 1.195 // -- Strip the propagated elements, if required
1184
1185 if (!_rep->_storeCompleteClassDefinitions)
1186 {
1187 _stripPropagatedElements(cimClass);
1188 }
1189
|
1190 kumpf 1.190 // -- Create the class declaration:
1191
1192 _rep->_persistentStore->createClass(nameSpace, cimClass, classAssocEntries);
|
1193 mike 1.48
1194 // -- Create namespace manager entry:
1195
|
1196 kumpf 1.192 _rep->_nameSpaceManager.createClass(
|
1197 kumpf 1.189 nameSpace, cimClass.getClassName(), cimClass.getSuperClassName());
|
1198 kumpf 1.58
1199 PEG_METHOD_EXIT();
|
1200 mike 1.48 }
1201
|
1202 kumpf 1.68 CIMObjectPath CIMRepository::createInstance(
|
1203 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1204 kumpf 1.199 const CIMInstance& newInstance)
|
1205 mike 1.48 {
|
1206 kumpf 1.61 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::createInstance");
|
1207 mike 1.51
|
1208 mike 1.184 WriteLock lock(_rep->_lock);
1209 AutoFileLock fileLock(_rep->_lockFile);
|
1210 kumpf 1.104 CIMObjectPath instanceName = _createInstance(nameSpace, newInstance);
1211
1212 PEG_METHOD_EXIT();
1213 return instanceName;
1214 }
1215
1216 CIMObjectPath CIMRepository::_createInstance(
1217 const CIMNamespaceName& nameSpace,
1218 const CIMInstance& newInstance)
1219 {
1220 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_createInstance");
1221
|
1222 mike 1.53 //
|
1223 mike 1.54 // Resolve the instance. Looks up class and fills out properties but
1224 // not the qualifiers.
|
1225 mike 1.53 //
1226
|
1227 kumpf 1.200 CIMInstance cimInstance(newInstance.clone());
|
1228 mike 1.48 CIMConstClass cimClass;
|
1229 mike 1.184 Resolver::resolveInstance (cimInstance, _rep->_context, nameSpace, cimClass,
|
1230 kumpf 1.76 false);
|
1231 kumpf 1.81 CIMObjectPath instanceName = cimInstance.buildPath(cimClass);
|
1232 mike 1.48
|
1233 mike 1.53 //
1234 // Make sure the class has keys (otherwise it will be impossible to
1235 // create the instance).
1236 //
|
1237 mike 1.48
1238 if (!cimClass.hasKeys())
1239 {
|
1240 humberto 1.88 PEG_METHOD_EXIT();
|
1241 kumpf 1.99 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1242 MessageLoaderParms("Repository.CIMRepository.CLASS_HAS_NO_KEYS",
|
1243 kumpf 1.104 "class has no keys: $0",
|
1244 kumpf 1.99 cimClass.getClassName().getString()));
|
1245 mike 1.48 }
1246
|
1247 mike 1.53 //
1248 // Be sure instance does not already exist:
1249 //
|
1250 mike 1.48
|
1251 mike 1.184 if (_rep->_checkInstanceAlreadyExists(nameSpace, instanceName))
|
1252 mike 1.48 {
|
1253 kumpf 1.52 PEG_METHOD_EXIT();
|
1254 kumpf 1.104 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ALREADY_EXISTS,
|
1255 mike 1.51 instanceName.toString());
|
1256 mike 1.48 }
1257
|
1258 mike 1.53 //
|
1259 kumpf 1.190 // Build association entries if an association instance.
|
1260 mike 1.53 //
|
1261 mike 1.48
|
1262 kumpf 1.190 Array<InstanceAssociation> instAssocEntries;
1263
|
1264 mike 1.48 if (cimClass.isAssociation())
|
1265 kumpf 1.190 {
1266 instAssocEntries = _buildInstanceAssociationEntries(
1267 nameSpace, cimClass, cimInstance, instanceName);
1268 }
1269
1270 //
1271 // Create the instance
1272 //
|
1273 mike 1.53
|
1274 kumpf 1.189 _rep->_persistentStore->createInstance(
|
1275 kumpf 1.190 nameSpace, instanceName, cimInstance, instAssocEntries);
|
1276 mike 1.53
|
1277 kumpf 1.52 PEG_METHOD_EXIT();
|
1278 mike 1.53 return instanceName;
|
1279 mike 1.48 }
1280
1281 void CIMRepository::modifyClass(
|
1282 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1283 kumpf 1.199 const CIMClass& modifiedClass)
|
1284 mike 1.48 {
|
1285 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::modifyClass");
1286
|
1287 mike 1.184 WriteLock lock(_rep->_lock);
1288 AutoFileLock fileLock(_rep->_lockFile);
|
1289 kumpf 1.104 _modifyClass(nameSpace, modifiedClass);
1290
1291 PEG_METHOD_EXIT();
1292 }
1293
1294 void CIMRepository::_modifyClass(
1295 const CIMNamespaceName& nameSpace,
1296 const CIMClass& modifiedClass)
1297 {
1298 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_modifyClass");
1299
|
1300 mike 1.53 //
1301 // Check to see if it is okay to modify this class:
1302 //
|
1303 mike 1.48
|
1304 kumpf 1.195 CIMName oldSuperClassName;
1305
|
1306 kumpf 1.192 _rep->_nameSpaceManager.checkModifyClass(
|
1307 kumpf 1.195 nameSpace,
1308 modifiedClass.getClassName(),
1309 modifiedClass.getSuperClassName(),
1310 oldSuperClassName,
1311 !_rep->_storeCompleteClassDefinitions);
|
1312 mike 1.48
|
1313 mike 1.53 //
|
1314 kumpf 1.197 // Resolve the class:
1315 //
1316
1317 CIMClass cimClass(modifiedClass.clone());
1318 Resolver::resolveClass(cimClass, _rep->_context, nameSpace);
1319
1320 //
|
1321 mike 1.53 // ATTN: KS
1322 // Disallow modification of classes which have instances (that are
1323 // in the repository). And we have no idea whether the class has
1324 // instances in other repositories or in providers. We should do
1325 // an enumerate instance names at a higher level (above the repository).
1326 //
|
1327 chip 1.118
|
1328 mike 1.151 #ifdef PEGASUS_USE_CLASS_CACHE
1329
|
1330 kumpf 1.203 // Modifying this class may invalidate subclass definitions in the cache.
1331 // Since class modification is relatively rare, we just flush the entire
1332 // cache rather than specifically evicting subclass definitions.
|
1333 kumpf 1.204 _rep->_classCache.clear();
|
1334 mike 1.151
1335 #endif /* PEGASUS_USE_CLASS_CACHE */
|
1336 mike 1.53
|
1337 kumpf 1.190 Boolean isAssociation = cimClass.isAssociation();
1338 Array<ClassAssociation> classAssocEntries;
|
1339 kumpf 1.58
|
1340 kumpf 1.190 if (isAssociation)
|
1341 kumpf 1.169 {
|
1342 kumpf 1.190 classAssocEntries = _buildClassAssociationEntries(cimClass);
|
1343 konrad.r 1.111 }
1344
|
1345 kumpf 1.195 // Strip the propagated elements, if required
1346
1347 if (!_rep->_storeCompleteClassDefinitions)
1348 {
1349 _stripPropagatedElements(cimClass);
1350 }
1351
|
1352 kumpf 1.190 _rep->_persistentStore->modifyClass(
|
1353 kumpf 1.195 nameSpace,
1354 cimClass,
1355 oldSuperClassName,
1356 isAssociation,
1357 classAssocEntries);
|
1358 mike 1.151
|
1359 kumpf 1.58 PEG_METHOD_EXIT();
|
1360 mike 1.48 }
1361
1362 void CIMRepository::modifyInstance(
|
1363 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1364 kumpf 1.70 const CIMInstance& modifiedInstance,
|
1365 mike 1.51 Boolean includeQualifiers,
|
1366 kumpf 1.199 const CIMPropertyList& propertyList)
|
1367 mike 1.48 {
|
1368 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::modifyInstance");
1369
|
1370 mike 1.184 WriteLock lock(_rep->_lock);
1371 AutoFileLock fileLock(_rep->_lockFile);
|
1372 kumpf 1.104
|
1373 mike 1.53 //
1374 // Do this:
1375 //
|
1376 mike 1.51
|
1377 mike 1.53 CIMInstance cimInstance; // The instance that replaces the original
|
1378 mike 1.51
1379 if (propertyList.isNull())
1380 {
1381 //
1382 // Replace all the properties in the instance
1383 //
1384 if (includeQualifiers)
1385 {
1386 //
1387 // Replace the entire instance with the given instance
1388 // (this is the default behavior)
1389 //
|
1390 kumpf 1.200 cimInstance = modifiedInstance.clone();
|
1391 mike 1.51 }
1392 else
1393 {
1394 //
1395 // Replace all the properties in the instance, but keep the
1396 // original qualifiers on the instance and on the properties
1397 //
1398
|
1399 kumpf 1.104 cimInstance = _getInstance(
1400 nameSpace,
1401 modifiedInstance.getPath (),
1402 true,
1403 true,
|
1404 kumpf 1.191 CIMPropertyList(),
1405 false);
|
1406 mike 1.54
|
1407 mike 1.51 CIMInstance newInstance(
|
1408 kumpf 1.70 modifiedInstance.getPath ().getClassName());
|
1409 mike 1.54
|
1410 kumpf 1.200 CIMConstInstance givenInstance = modifiedInstance;
|
1411 mike 1.51
1412 //
1413 // Copy over the original instance qualifiers
1414 //
|
1415 mike 1.54
1416 for (Uint32 i = 0; i < cimInstance.getQualifierCount(); i++)
|
1417 mike 1.51 {
1418 newInstance.addQualifier(cimInstance.getQualifier(i));
1419 }
1420
1421 //
1422 // Loop through the properties replacing each property in the
1423 // original with a new value, but keeping the original qualifiers
1424 //
1425 for (Uint32 i=0; i<givenInstance.getPropertyCount(); i++)
1426 {
1427 // Copy the given property value (not qualifiers)
|
1428 kumpf 1.200 CIMConstProperty givenProperty = givenInstance.getProperty(i);
|
1429 mike 1.51 CIMProperty newProperty(
1430 givenProperty.getName(),
1431 givenProperty.getValue(),
1432 givenProperty.getArraySize(),
1433 givenProperty.getReferenceClassName(),
1434 givenProperty.getClassOrigin(),
1435 givenProperty.getPropagated());
1436
1437 // Copy the original property qualifiers
1438 Uint32 origPos =
1439 cimInstance.findProperty(newProperty.getName());
1440 if (origPos != PEG_NOT_FOUND)
1441 {
1442 CIMProperty origProperty = cimInstance.getProperty(origPos);
1443 for (Uint32 j=0; j<origProperty.getQualifierCount(); j++)
1444 {
|
1445 r.kieninger 1.133 newProperty.addQualifier(origProperty.getQualifier(j));
|
1446 mike 1.51 }
1447 }
1448
1449 // Add the newly constructed property to the new instance
1450 newInstance.addProperty(newProperty);
1451 }
1452
1453 // Use the newly merged instance to replace the original instance
1454 cimInstance = newInstance;
1455 }
1456 }
1457 else
1458 {
1459 //
1460 // Replace only the properties specified in the given instance
1461 //
1462
|
1463 kumpf 1.191 cimInstance = _getInstance(
1464 nameSpace,
1465 modifiedInstance.getPath(),
1466 true,
1467 true,
1468 CIMPropertyList(),
1469 false);
|
1470 mike 1.55
|
1471 kumpf 1.200 CIMConstInstance givenInstance = modifiedInstance;
|
1472 mike 1.51
1473 // NOTE: Instance qualifiers are not changed when a property list
1474 // is specified. Property qualifiers are replaced with the
1475 // corresponding property values.
1476
1477 //
1478 // Loop through the propertyList replacing each property in the original
1479 //
|
1480 mike 1.53
|
1481 kumpf 1.74 for (Uint32 i=0; i<propertyList.size(); i++)
|
1482 mike 1.51 {
|
1483 kumpf 1.74 Uint32 origPropPos = cimInstance.findProperty(propertyList[i]);
|
1484 mike 1.51 if (origPropPos != PEG_NOT_FOUND)
1485 {
1486 // Case: Property set in original
1487 CIMProperty origProperty =
1488 cimInstance.getProperty(origPropPos);
1489
1490 // Get the given property value
1491 Uint32 givenPropPos =
|
1492 kumpf 1.74 givenInstance.findProperty(propertyList[i]);
|
1493 mike 1.51 if (givenPropPos != PEG_NOT_FOUND)
1494 {
1495 // Case: Property set in original and given
|
1496 kumpf 1.200 CIMConstProperty givenProperty =
|
1497 mike 1.51 givenInstance.getProperty(givenPropPos);
1498
1499 // Copy over the property from the given to the original
1500 if (includeQualifiers)
1501 {
1502 // Case: Total property replacement
1503 cimInstance.removeProperty(origPropPos);
|
1504 kumpf 1.200 cimInstance.addProperty(givenProperty.clone());
|
1505 mike 1.51 }
1506 else
1507 {
1508 // Case: Replace only the property value (not quals)
1509 origProperty.setValue(givenProperty.getValue());
1510 cimInstance.removeProperty(origPropPos);
1511 cimInstance.addProperty(origProperty);
1512 }
1513 }
1514 else
1515 {
1516 // Case: Property set in original and not in given
1517 // Just remove the property (set to null)
1518 cimInstance.removeProperty(origPropPos);
1519 }
1520 }
1521 else
1522 {
1523 // Case: Property not set in original
1524
1525 // Get the given property value
1526 mike 1.51 Uint32 givenPropPos =
|
1527 kumpf 1.74 givenInstance.findProperty(propertyList[i]);
|
1528 mike 1.51 if (givenPropPos != PEG_NOT_FOUND)
1529 {
1530 // Case: Property set in given and not in original
|
1531 kumpf 1.200 CIMConstProperty givenProperty =
|
1532 mike 1.51 givenInstance.getProperty(givenPropPos);
1533
1534 // Copy over the property from the given to the original
1535 if (includeQualifiers)
1536 {
1537 // Case: Total property copy
|
1538 kumpf 1.200 cimInstance.addProperty(givenProperty.clone());
|
1539 mike 1.51 }
1540 else
1541 {
1542 // Case: Copy only the property value (not qualifiers)
1543 CIMProperty newProperty(
1544 givenProperty.getName(),
1545 givenProperty.getValue(),
1546 givenProperty.getArraySize(),
1547 givenProperty.getReferenceClassName(),
1548 givenProperty.getClassOrigin(),
1549 givenProperty.getPropagated());
1550 cimInstance.addProperty(newProperty);
1551 }
1552 }
1553 else
1554 {
1555 // Case: Property not set in original or in given
1556
1557 // Nothing to do; just make sure the property name is valid
1558 // ATTN: This is not the most efficient solution
1559 CIMClass cimClass = getClass(
1560 mike 1.51 nameSpace, cimInstance.getClassName(), false);
|
1561 kumpf 1.74 if (cimClass.findProperty(propertyList[i]) == PEG_NOT_FOUND)
|
1562 mike 1.51 {
1563 // ATTN: This exception may be returned by setProperty
|
1564 kumpf 1.58 PEG_METHOD_EXIT();
|
1565 mike 1.51 throw PEGASUS_CIM_EXCEPTION(
1566 CIM_ERR_NO_SUCH_PROPERTY, "modifyInstance()");
1567 }
1568 }
1569 }
1570 }
1571 }
1572
|
1573 kumpf 1.189 CIMObjectPath normalizedInstanceName =
1574 _stripInstanceName(nameSpace, modifiedInstance.getPath());
|
1575 kumpf 1.168
1576 //
|
1577 kumpf 1.189 // Resolve the instance (do not propagate qualifiers from class since
1578 // this will bloat the instance).
|
1579 mike 1.53 //
1580
|
1581 kumpf 1.189 CIMConstClass cimClass;
1582 Resolver::resolveInstance(
1583 cimInstance, _rep->_context, nameSpace, cimClass, false);
|
1584 mike 1.48
|
1585 mike 1.53 //
|
1586 kumpf 1.189 // Disallow operation if the instance name was changed:
|
1587 mike 1.53 //
1588
|
1589 kumpf 1.189 if (cimInstance.buildPath(cimClass) != normalizedInstanceName)
|
1590 mike 1.51 {
|
1591 kumpf 1.104 PEG_METHOD_EXIT();
1592 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1593 MessageLoaderParms(
|
1594 kumpf 1.189 "Repository.CIMRepository.ATTEMPT_TO_MODIFY_KEY_PROPERTY",
1595 "Attempted to modify a key property"));
|
1596 dmitry.mikulin 1.179 }
1597
|
1598 kumpf 1.189 _rep->_persistentStore->modifyInstance(
1599 nameSpace, normalizedInstanceName, cimInstance);
|
1600 mike 1.54
|
1601 kumpf 1.58 PEG_METHOD_EXIT();
|
1602 mike 1.48 }
1603
1604 Array<CIMClass> CIMRepository::enumerateClasses(
|
1605 kumpf 1.85 const CIMNamespaceName& nameSpace,
1606 const CIMName& className,
|
1607 mike 1.48 Boolean deepInheritance,
1608 Boolean localOnly,
1609 Boolean includeQualifiers,
1610 Boolean includeClassOrigin)
1611 {
|
1612 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::enumerateClasses");
|
1613 mike 1.51
|
1614 mike 1.184 ReadLock lock(_rep->_lock);
|
1615 kumpf 1.104
|
1616 kumpf 1.85 Array<CIMName> classNames;
|
1617 mike 1.48
|
1618 kumpf 1.192 _rep->_nameSpaceManager.getSubClassNames(
|
1619 mike 1.51 nameSpace, className, deepInheritance, classNames);
|
1620 mike 1.48
1621 Array<CIMClass> result;
1622
1623 for (Uint32 i = 0; i < classNames.size(); i++)
1624 {
|
1625 kumpf 1.104 result.append(_getClass(nameSpace, classNames[i], localOnly,
1626 includeQualifiers, includeClassOrigin, CIMPropertyList()));
|
1627 mike 1.48 }
1628
|
1629 kumpf 1.58 PEG_METHOD_EXIT();
|
1630 mike 1.48 return result;
1631 }
1632
|
1633 kumpf 1.85 Array<CIMName> CIMRepository::enumerateClassNames(
1634 const CIMNamespaceName& nameSpace,
1635 const CIMName& className,
|
1636 mike 1.48 Boolean deepInheritance)
1637 {
|
1638 kumpf 1.59 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::enumerateClassNames");
|
1639 kumpf 1.58
|
1640 mike 1.184 ReadLock lock(_rep->_lock);
|
1641 kumpf 1.104
|
1642 kumpf 1.85 Array<CIMName> classNames;
|
1643 mike 1.48
|
1644 kumpf 1.192 _rep->_nameSpaceManager.getSubClassNames(
|
1645 schuur 1.112 nameSpace, className, deepInheritance, classNames,true);
|
1646 mike 1.48
|
1647 kumpf 1.58 PEG_METHOD_EXIT();
|
1648 mike 1.48 return classNames;
1649 }
1650
|
1651 kumpf 1.163 Array<CIMInstance> CIMRepository::enumerateInstancesForSubtree(
|
1652 kumpf 1.85 const CIMNamespaceName& nameSpace,
1653 const CIMName& className,
|
1654 mike 1.48 Boolean deepInheritance,
1655 Boolean includeQualifiers,
1656 Boolean includeClassOrigin,
|
1657 mike 1.51 const CIMPropertyList& propertyList)
|
1658 mike 1.48 {
|
1659 kumpf 1.163 PEG_METHOD_ENTER(TRC_REPOSITORY,
1660 "CIMRepository::enumerateInstancesForSubtree");
|
1661 kumpf 1.104
|
1662 mike 1.184 // It is not necessary to control access to the ReadWriteSem lock here.
|
1663 kumpf 1.104 // This method calls enumerateInstancesForClass, which does its own
1664 // access control.
1665
|
1666 karl 1.69 //
1667 // Get all descendent classes of this class:
1668 //
1669
|
1670 kumpf 1.85 Array<CIMName> classNames;
|
1671 kumpf 1.94 classNames.append(className);
|
1672 kumpf 1.192 _rep->_nameSpaceManager.getSubClassNames(
|
1673 mike 1.184 nameSpace, className, true, classNames);
|
1674 karl 1.69
1675 //
1676 // Get all instances for this class and all its descendent classes
1677 //
|
1678 kumpf 1.58
|
1679 kumpf 1.70 Array<CIMInstance> namedInstances;
|
1680 kumpf 1.104
|
1681 karl 1.69 for (Uint32 i = 0; i < classNames.size(); i++)
|
1682 karl 1.65 {
|
1683 karl 1.101 Array<CIMInstance> localNamedInstances =
|
1684 kumpf 1.163 enumerateInstancesForClass(nameSpace, classNames[i],
|
1685 kumpf 1.209 includeQualifiers, includeClassOrigin, propertyList);
|
1686 kumpf 1.163
|
1687 kumpf 1.208 // The propertyList, includeQualifiers, and includeClassOrigin
|
1688 kumpf 1.209 // filtering is done in enumerateInstancesForClass.
|
1689 kumpf 1.198 // ATTN: deepInheritance filtering is not performed.
1690
|
1691 karl 1.101 namedInstances.appendArray(localNamedInstances);
|
1692 karl 1.65 }
|
1693 karl 1.98
|
1694 karl 1.65 PEG_METHOD_EXIT();
1695 return namedInstances;
|
1696 karl 1.69 }
|
1697 karl 1.65
|
1698 kumpf 1.70 Array<CIMInstance> CIMRepository::enumerateInstancesForClass(
|
1699 kumpf 1.85 const CIMNamespaceName& nameSpace,
1700 const CIMName& className,
|
1701 karl 1.69 Boolean includeQualifiers,
1702 Boolean includeClassOrigin,
1703 const CIMPropertyList& propertyList)
1704 {
|
1705 kumpf 1.104 PEG_METHOD_ENTER(TRC_REPOSITORY,
|
1706 kumpf 1.163 "CIMRepository::enumerateInstancesForClass");
|
1707 kumpf 1.104
|
1708 mike 1.184 ReadLock lock(_rep->_lock);
|
1709 kumpf 1.104
|
1710 kumpf 1.192 _rep->_nameSpaceManager.validateClass(nameSpace, className);
|
1711 kumpf 1.189
|
1712 mike 1.53 //
|
1713 kumpf 1.163 // Get all instances for this class
|
1714 mike 1.53 //
|
1715 mike 1.48
|
1716 kumpf 1.189 Array<CIMInstance> namedInstances =
1717 _rep->_persistentStore->enumerateInstancesForClass(
1718 nameSpace, className);
|
1719 mike 1.48
|
1720 kumpf 1.163 // Do any required filtering of properties, qualifiers, classorigin
1721 // on the returned instances.
1722 for (Uint32 i = 0 ; i < namedInstances.size(); i++)
1723 {
|
1724 kumpf 1.198 if (includeQualifiers)
1725 {
1726 // Instances are resolved in persistent storage by the
1727 // createInstance and modifyInstance operations, but qualifiers
1728 // are not propagated. The only reason to perform resolution
1729 // here is if qualifiers are requested in the instance.
1730 Resolver::resolveInstance(
1731 namedInstances[i], _rep->_context, nameSpace, true);
1732 }
|
1733 kumpf 1.189
|
1734 kumpf 1.209 _filterInstance(
1735 namedInstances[i],
|
1736 kumpf 1.163 propertyList,
1737 includeQualifiers,
1738 includeClassOrigin);
1739 }
1740
|
1741 kumpf 1.58 PEG_METHOD_EXIT();
|
1742 mike 1.51 return namedInstances;
|
1743 mike 1.48 }
|
1744 kumpf 1.104
|
1745 kumpf 1.163 Array<CIMObjectPath> CIMRepository::enumerateInstanceNamesForSubtree(
|
1746 kumpf 1.85 const CIMNamespaceName& nameSpace,
1747 const CIMName& className)
|
1748 mike 1.48 {
|
1749 kumpf 1.163 PEG_METHOD_ENTER(TRC_REPOSITORY,
1750 "CIMRepository::enumerateInstanceNamesForSubtree");
|
1751 mike 1.51
|
1752 mike 1.184 // It is not necessary to control access to the ReadWriteSem lock here.
|
1753 kumpf 1.165 // This method calls enumerateInstanceNamesForClass, which does its own
1754 // access control.
|
1755 kumpf 1.104
|
1756 karl 1.65 //
|
1757 karl 1.69 // Get names of descendent classes:
|
1758 karl 1.65 //
|
1759 kumpf 1.165
|
1760 kumpf 1.85 Array<CIMName> classNames;
|
1761 kumpf 1.94 classNames.append(className);
|
1762 kumpf 1.192 _rep->_nameSpaceManager.getSubClassNames(
|
1763 mike 1.184 nameSpace, className, true, classNames);
|
1764 karl 1.65
1765 //
|
1766 kumpf 1.165 // Enumerate instance names for each of the subclasses
|
1767 karl 1.65 //
|
1768 karl 1.69 Array<CIMObjectPath> instanceNames;
|
1769 karl 1.65
|
1770 karl 1.69 for (Uint32 i = 0; i < classNames.size(); i++)
1771 {
|
1772 kumpf 1.165 instanceNames.appendArray(
1773 enumerateInstanceNamesForClass(nameSpace, classNames[i]));
|
1774 karl 1.65 }
1775
|
1776 karl 1.69 PEG_METHOD_EXIT();
1777 return instanceNames;
1778 }
1779
1780 Array<CIMObjectPath> CIMRepository::enumerateInstanceNamesForClass(
|
1781 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1782 kumpf 1.163 const CIMName& className)
|
1783 karl 1.69 {
|
1784 kumpf 1.104 PEG_METHOD_ENTER(TRC_REPOSITORY,
|
1785 kumpf 1.163 "CIMRepository::enumerateInstanceNamesForClass");
|
1786 kumpf 1.104
|
1787 mike 1.184 ReadLock lock(_rep->_lock);
|
1788 karl 1.69
|
1789 kumpf 1.192 _rep->_nameSpaceManager.validateClass(nameSpace, className);
|
1790 mike 1.48
|
1791 kumpf 1.189 Array<CIMObjectPath> instanceNames =
1792 _rep->_persistentStore->enumerateInstanceNamesForClass(
1793 nameSpace, className);
|
1794 mike 1.53
|
1795 kumpf 1.52 PEG_METHOD_EXIT();
|
1796 mike 1.48 return instanceNames;
1797 }
|
1798 karl 1.69
|
1799 mike 1.48
|
1800 kumpf 1.71 Array<CIMObject> CIMRepository::associators(
|
1801 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1802 kumpf 1.68 const CIMObjectPath& objectName,
|
1803 kumpf 1.85 const CIMName& assocClass,
1804 const CIMName& resultClass,
|
1805 mike 1.48 const String& role,
1806 const String& resultRole,
1807 Boolean includeQualifiers,
1808 Boolean includeClassOrigin,
|
1809 mike 1.51 const CIMPropertyList& propertyList)
|
1810 mike 1.48 {
|
1811 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::associators");
1812
|
1813 mike 1.184 ReadLock lock(_rep->_lock);
|
1814 kumpf 1.104
1815 Array<CIMObjectPath> names = _associatorNames(
|
1816 mike 1.51 nameSpace,
1817 objectName,
1818 assocClass,
1819 resultClass,
1820 role,
1821 resultRole);
|
1822 mike 1.48
|
1823 kumpf 1.71 Array<CIMObject> result;
|
1824 mike 1.48
1825 for (Uint32 i = 0, n = names.size(); i < n; i++)
1826 {
|
1827 kumpf 1.85 CIMNamespaceName tmpNameSpace = names[i].getNameSpace();
|
1828 mike 1.48
|
1829 kumpf 1.85 if (tmpNameSpace.isNull())
|
1830 mike 1.51 tmpNameSpace = nameSpace;
|
1831 mike 1.48
|
1832 kumpf 1.80 //
1833 // ATTN-CAKG-P2-20020726: The following condition does not correctly
1834 // distinguish instanceNames from classNames in every case
1835 // The instanceName of a singleton instance of a keyless class also
1836 // has no key bindings
1837 //
1838 if (names[i].getKeyBindings ().size () == 0)
|
1839 mike 1.51 {
|
1840 kumpf 1.68 CIMObjectPath tmpRef = names[i];
|
1841 mike 1.51 tmpRef.setHost(String());
|
1842 kumpf 1.95 tmpRef.setNameSpace(CIMNamespaceName());
|
1843 mike 1.51
|
1844 kumpf 1.104 CIMClass cimClass = _getClass(
|
1845 mike 1.51 tmpNameSpace,
1846 tmpRef.getClassName(),
1847 false,
1848 includeQualifiers,
1849 includeClassOrigin,
1850 propertyList);
1851
1852 CIMObject cimObject(cimClass);
|
1853 kumpf 1.71 cimObject.setPath (names[i]);
1854 result.append(cimObject);
|
1855 mike 1.51 }
1856 else
1857 {
|
1858 kumpf 1.68 CIMObjectPath tmpRef = names[i];
|
1859 mike 1.51 tmpRef.setHost(String());
|
1860 kumpf 1.95 tmpRef.setNameSpace(CIMNamespaceName());
|
1861 mike 1.51
|
1862 kumpf 1.104 CIMInstance cimInstance = _getInstance(
|
1863 mike 1.51 tmpNameSpace,
1864 tmpRef,
1865 includeQualifiers,
1866 includeClassOrigin,
|
1867 kumpf 1.191 propertyList,
1868 true);
|
1869 mike 1.51
1870 CIMObject cimObject(cimInstance);
|
1871 kumpf 1.71 cimObject.setPath (names[i]);
1872 result.append(cimObject);
|
1873 mike 1.51 }
|
1874 mike 1.48 }
1875
|
1876 kumpf 1.58 PEG_METHOD_EXIT();
|
1877 mike 1.48 return result;
1878 }
1879
|
1880 kumpf 1.68 Array<CIMObjectPath> CIMRepository::associatorNames(
|
1881 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1882 kumpf 1.68 const CIMObjectPath& objectName,
|
1883 kumpf 1.85 const CIMName& assocClass,
1884 const CIMName& resultClass,
|
1885 mike 1.48 const String& role,
1886 const String& resultRole)
1887 {
|
1888 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::associatorNames");
|
1889 mike 1.51
|
1890 mike 1.184 ReadLock lock(_rep->_lock);
|
1891 kumpf 1.104 Array<CIMObjectPath> result = _associatorNames(
1892 nameSpace, objectName, assocClass, resultClass, role, resultRole);
1893
1894 PEG_METHOD_EXIT();
1895 return result;
1896 }
1897
1898 Array<CIMObjectPath> CIMRepository::_associatorNames(
1899 const CIMNamespaceName& nameSpace,
1900 const CIMObjectPath& objectName,
1901 const CIMName& assocClass,
1902 const CIMName& resultClass,
1903 const String& role,
1904 const String& resultRole)
1905 {
1906 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_associatorNames");
1907
|
1908 mike 1.48 Array<String> associatorNames;
1909
|
1910 kumpf 1.93 // The assocClass parameter implies subclasses, so retrieve them
1911 Array<CIMName> assocClassList;
1912 if (!assocClass.isNull())
1913 {
|
1914 kumpf 1.192 _rep->_nameSpaceManager.getSubClassNames(
|
1915 kumpf 1.93 nameSpace, assocClass, true, assocClassList);
1916 assocClassList.append(assocClass);
1917 }
1918
1919 // The resultClass parameter implies subclasses, so retrieve them
1920 Array<CIMName> resultClassList;
1921 if (!resultClass.isNull())
1922 {
|
1923 kumpf 1.192 _rep->_nameSpaceManager.getSubClassNames(
|
1924 kumpf 1.93 nameSpace, resultClass, true, resultClassList);
1925 resultClassList.append(resultClass);
1926 }
1927
|
1928 kumpf 1.80 //
1929 // ATTN-CAKG-P2-20020726: The following condition does not correctly
1930 // distinguish instanceNames from classNames in every case
1931 // The instanceName of a singleton instance of a keyless class also
1932 // has no key bindings
1933 //
1934 if (objectName.getKeyBindings ().size () == 0)
|
1935 mike 1.48 {
|
1936 kumpf 1.93 CIMName className = objectName.getClassName();
1937
1938 Array<CIMName> classList;
|
1939 kumpf 1.192 _rep->_nameSpaceManager.getSuperClassNames(
|
1940 mike 1.184 nameSpace, className, classList);
|
1941 kumpf 1.93 classList.append(className);
1942
|
1943 kumpf 1.189 Array<CIMNamespaceName> nameSpaceList =
|
1944 kumpf 1.192 _rep->_nameSpaceManager.getSchemaNameSpaceNames(nameSpace);
|
1945 mike 1.48
|
1946 kumpf 1.189 for (Uint32 i = 0; i < nameSpaceList.size(); i++)
|
1947 kumpf 1.169 {
|
1948 kumpf 1.189 Array<String> associatorNamesForNameSpace;
1949
1950 _rep->_persistentStore->getClassAssociatorNames(
1951 nameSpaceList[i],
|
1952 kumpf 1.169 classList,
1953 assocClassList,
1954 resultClassList,
1955 role,
1956 resultRole,
|
1957 kumpf 1.189 associatorNamesForNameSpace);
1958
1959 associatorNames.appendArray(associatorNamesForNameSpace);
|
1960 kumpf 1.169 }
|
1961 mike 1.48 }
|
1962 kumpf 1.169 else
1963 {
|
1964 kumpf 1.192 _rep->_nameSpaceManager.validateClass(
|
1965 kumpf 1.189 nameSpace, objectName.getClassName());
|
1966 mike 1.48
|
1967 kumpf 1.189 _rep->_persistentStore->getInstanceAssociatorNames(
1968 nameSpace,
|
1969 mike 1.51 objectName,
|
1970 kumpf 1.93 assocClassList,
1971 resultClassList,
|
1972 mike 1.51 role,
1973 resultRole,
1974 associatorNames);
|
1975 mike 1.48 }
1976
|
1977 kumpf 1.68 Array<CIMObjectPath> result;
|
1978 mike 1.48
1979 for (Uint32 i = 0, n = associatorNames.size(); i < n; i++)
1980 {
|
1981 kumpf 1.68 CIMObjectPath r = associatorNames[i];
|
1982 mike 1.48
1983 if (r.getHost().size() == 0)
1984 r.setHost(System::getHostName());
1985
|
1986 kumpf 1.79 if (r.getNameSpace().isNull())
|
1987 mike 1.48 r.setNameSpace(nameSpace);
1988
|
1989 mike 1.51 result.append(r);
|
1990 mike 1.48 }
1991
|
1992 kumpf 1.58 PEG_METHOD_EXIT();
|
1993 mike 1.48 return result;
1994 }
1995
|
1996 kumpf 1.71 Array<CIMObject> CIMRepository::references(
|
1997 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1998 kumpf 1.68 const CIMObjectPath& objectName,
|
1999 kumpf 1.85 const CIMName& resultClass,
|
2000 mike 1.48 const String& role,
2001 Boolean includeQualifiers,
2002 Boolean includeClassOrigin,
|
2003 mike 1.51 const CIMPropertyList& propertyList)
|
2004 mike 1.48 {
|
2005 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::references");
2006
|
2007 mike 1.184 ReadLock lock(_rep->_lock);
|
2008 kumpf 1.104
2009 Array<CIMObjectPath> names = _referenceNames(
|
2010 mike 1.51 nameSpace,
2011 objectName,
2012 resultClass,
2013 role);
|
2014 mike 1.48
|
2015 kumpf 1.71 Array<CIMObject> result;
|
2016 mike 1.48
2017 for (Uint32 i = 0, n = names.size(); i < n; i++)
2018 {
|
2019 kumpf 1.85 CIMNamespaceName tmpNameSpace = names[i].getNameSpace();
|
2020 mike 1.48
|
2021 kumpf 1.85 if (tmpNameSpace.isNull())
|
2022 mike 1.51 tmpNameSpace = nameSpace;
|
2023 mike 1.48
|
2024 mike 1.51 // ATTN: getInstance() should this be able to handle instance names
2025 // with host names and namespaces?
|
2026 mike 1.48
|
2027 kumpf 1.68 CIMObjectPath tmpRef = names[i];
|
2028 mike 1.51 tmpRef.setHost(String());
|
2029 kumpf 1.95 tmpRef.setNameSpace(CIMNamespaceName());
|
2030 mike 1.51
|
2031 kumpf 1.80 //
2032 // ATTN-CAKG-P2-20020726: The following condition does not correctly
2033 // distinguish instanceNames from classNames in every case
2034 // The instanceName of a singleton instance of a keyless class also
2035 // has no key bindings
2036 //
2037 if (objectName.getKeyBindings ().size () == 0)
|
2038 mike 1.51 {
|
2039 kumpf 1.104 CIMClass cimClass = _getClass(
|
2040 mike 1.51 tmpNameSpace,
2041 tmpRef.getClassName(),
2042 false,
2043 includeQualifiers,
2044 includeClassOrigin,
2045 propertyList);
2046
|
2047 kumpf 1.71 CIMObject cimObject = CIMObject (cimClass);
2048 cimObject.setPath (names[i]);
2049 result.append (cimObject);
|
2050 mike 1.51 }
2051 else
2052 {
|
2053 kumpf 1.104 CIMInstance instance = _getInstance(
|
2054 mike 1.51 tmpNameSpace,
2055 tmpRef,
2056 includeQualifiers,
2057 includeClassOrigin,
|
2058 kumpf 1.191 propertyList,
2059 true);
|
2060 mike 1.48
|
2061 kumpf 1.71 CIMObject cimObject = CIMObject (instance);
2062 cimObject.setPath (names[i]);
2063 result.append (cimObject);
|
2064 mike 1.51 }
|
2065 mike 1.48 }
2066
|
2067 kumpf 1.58 PEG_METHOD_EXIT();
|
2068 mike 1.48 return result;
2069 }
2070
|
2071 kumpf 1.68 Array<CIMObjectPath> CIMRepository::referenceNames(
|
2072 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
2073 kumpf 1.68 const CIMObjectPath& objectName,
|
2074 kumpf 1.85 const CIMName& resultClass,
|
2075 mike 1.48 const String& role)
2076 {
|
2077 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::referenceNames");
2078
|
2079 mike 1.184 ReadLock lock(_rep->_lock);
|
2080 kumpf 1.104 Array<CIMObjectPath> result = _referenceNames(
2081 nameSpace, objectName, resultClass, role);
2082
2083 PEG_METHOD_EXIT();
2084 return result;
2085 }
2086
2087 Array<CIMObjectPath> CIMRepository::_referenceNames(
2088 const CIMNamespaceName& nameSpace,
2089 const CIMObjectPath& objectName,
2090 const CIMName& resultClass,
2091 const String& role)
2092 {
2093 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_referenceNames");
2094
|
2095 mike 1.48 Array<String> tmpReferenceNames;
2096
|
2097 kumpf 1.93 // The resultClass parameter implies subclasses, so retrieve them
2098 Array<CIMName> resultClassList;
|
2099 a.dunfey 1.120
|
2100 kumpf 1.169 try
|
2101 kumpf 1.93 {
|
2102 kumpf 1.169 if (!resultClass.isNull())
2103 {
|
2104 kumpf 1.192 _rep->_nameSpaceManager.getSubClassNames(
|
2105 kumpf 1.169 nameSpace, resultClass, true, resultClassList);
2106 resultClassList.append(resultClass);
2107 }
|
2108 karl 1.86
|
2109 kumpf 1.169 // ATTN-CAKG-P2-20020726: The following condition does not correctly
2110 // distinguish instanceNames from classNames in every case
2111 // The instanceName of a singleton instance of a keyless class also
2112 // has no key bindings
2113 //
2114 if (objectName.getKeyBindings ().size () == 0)
2115 {
2116 CIMName className = objectName.getClassName();
|
2117 kumpf 1.93
|
2118 kumpf 1.169 Array<CIMName> classList;
|
2119 kumpf 1.192 _rep->_nameSpaceManager.getSuperClassNames(
|
2120 kumpf 1.169 nameSpace, className, classList);
2121 classList.append(className);
|
2122 kumpf 1.93
|
2123 kumpf 1.189 Array<CIMNamespaceName> nameSpaceList =
|
2124 kumpf 1.192 _rep->_nameSpaceManager.getSchemaNameSpaceNames(nameSpace);
|
2125 mike 1.48
|
2126 kumpf 1.189 for (Uint32 i = 0; i < nameSpaceList.size(); i++)
|
2127 kumpf 1.169 {
|
2128 kumpf 1.189 Array<String> referenceNamesForNameSpace;
2129
2130 _rep->_persistentStore->getClassReferenceNames(
2131 nameSpaceList[i],
2132 classList,
2133 resultClassList,
2134 role,
2135 referenceNamesForNameSpace);
|
2136 schuur 1.112
|
2137 kumpf 1.189 tmpReferenceNames.appendArray(referenceNamesForNameSpace);
|
2138 kumpf 1.169 }
|
2139 mike 1.51 }
|
2140 kumpf 1.169 else
2141 {
|
2142 kumpf 1.192 _rep->_nameSpaceManager.validateClass(
|
2143 kumpf 1.189 nameSpace, objectName.getClassName());
|
2144 schuur 1.112
|
2145 kumpf 1.189 _rep->_persistentStore->getInstanceReferenceNames(
2146 nameSpace,
|
2147 kumpf 1.169 objectName,
2148 resultClassList,
2149 role,
|
2150 kumpf 1.189 tmpReferenceNames);
|
2151 mike 1.51 }
|
2152 mike 1.48 }
|
2153 kumpf 1.169 catch (const CIMException& exception)
|
2154 kumpf 1.142 {
|
2155 kumpf 1.169 if (exception.getCode() == CIM_ERR_INVALID_CLASS)
2156 {
2157 throw PEGASUS_CIM_EXCEPTION(
2158 CIM_ERR_INVALID_PARAMETER, exception.getMessage());
2159 }
2160 else
2161 {
2162 throw;
2163 }
|
2164 kumpf 1.142 }
|
2165 mike 1.48
|
2166 kumpf 1.68 Array<CIMObjectPath> result;
|
2167 mike 1.48
2168 for (Uint32 i = 0, n = tmpReferenceNames.size(); i < n; i++)
2169 {
|
2170 kumpf 1.68 CIMObjectPath r = tmpReferenceNames[i];
|
2171 mike 1.48
2172 if (r.getHost().size() == 0)
2173 r.setHost(System::getHostName());
2174
|
2175 kumpf 1.79 if (r.getNameSpace().isNull())
|
2176 mike 1.48 r.setNameSpace(nameSpace);
2177
|
2178 mike 1.51 result.append(r);
|
2179 mike 1.48 }
2180
|
2181 kumpf 1.58 PEG_METHOD_EXIT();
|
2182 mike 1.48 return result;
2183 }
2184
2185 CIMValue CIMRepository::getProperty(
|
2186 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
2187 kumpf 1.68 const CIMObjectPath& instanceName,
|
2188 kumpf 1.85 const CIMName& propertyName)
|
2189 mike 1.48 {
|
2190 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::getProperty");
2191
|
2192 mike 1.184 ReadLock lock(_rep->_lock);
|
2193 kumpf 1.104
|
2194 mike 1.53 //
|
2195 kumpf 1.165 // Retrieve the specified instance
|
2196 mike 1.53 //
|
2197 mike 1.48
|
2198 kumpf 1.165 CIMInstance cimInstance = _getInstance(
|
2199 kumpf 1.209 nameSpace, instanceName, true, true, CIMPropertyList(), false);
|
2200 mike 1.48
|
2201 mike 1.53 //
|
2202 kumpf 1.165 // Get the requested property from the instance
|
2203 mike 1.53 //
|
2204 mike 1.48
2205 Uint32 pos = cimInstance.findProperty(propertyName);
2206
|
2207 mike 1.51 // ATTN: This breaks if the property is simply null
|
2208 kumpf 1.77 if (pos == PEG_NOT_FOUND)
|
2209 kumpf 1.58 {
2210 PEG_METHOD_EXIT();
|
2211 kumpf 1.149 throw PEGASUS_CIM_EXCEPTION(
2212 CIM_ERR_NO_SUCH_PROPERTY,
2213 propertyName.getString());
|
2214 kumpf 1.58 }
|
2215 mike 1.48
2216 CIMProperty prop = cimInstance.getProperty(pos);
2217
|
2218 mike 1.53 //
2219 // Return the value:
2220 //
|
2221 mike 1.48
|
2222 kumpf 1.58 PEG_METHOD_EXIT();
|
2223 mike 1.48 return prop.getValue();
2224 }
2225
2226 void CIMRepository::setProperty(
|
2227 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
2228 kumpf 1.68 const CIMObjectPath& instanceName,
|
2229 kumpf 1.85 const CIMName& propertyName,
|
2230 kumpf 1.199 const CIMValue& newValue)
|
2231 mike 1.48 {
|
2232 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::setProperty");
2233
|
2234 mike 1.184 // It is not necessary to control access to the ReadWriteSem lock here.
|
2235 kumpf 1.104 // This method calls modifyInstance, which does its own access control.
2236
|
2237 mike 1.51 //
2238 // Create the instance to pass to modifyInstance()
2239 //
|
2240 mike 1.53
|
2241 mike 1.51 CIMInstance instance(instanceName.getClassName());
2242 instance.addProperty(CIMProperty(propertyName, newValue));
|
2243 kumpf 1.70 instance.setPath (instanceName);
|
2244 mike 1.51
2245 //
2246 // Create the propertyList to pass to modifyInstance()
2247 //
|
2248 mike 1.53
|
2249 kumpf 1.79 Array<CIMName> propertyListArray;
|
2250 mike 1.51 propertyListArray.append(propertyName);
2251 CIMPropertyList propertyList(propertyListArray);
2252
2253 //
2254 // Modify the instance to set the value of the given property
2255 //
|
2256 kumpf 1.70 modifyInstance(nameSpace, instance, false, propertyList);
|
2257 kumpf 1.58
2258 PEG_METHOD_EXIT();
|
2259 mike 1.48 }
2260
2261 CIMQualifierDecl CIMRepository::getQualifier(
|
2262 kumpf 1.85 const CIMNamespaceName& nameSpace,
2263 const CIMName& qualifierName)
|
2264 mike 1.48 {
|
2265 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::getQualifier");
2266
|
2267 mike 1.184 ReadLock lock(_rep->_lock);
|
2268 kumpf 1.104 CIMQualifierDecl qualifierDecl = _getQualifier(nameSpace, qualifierName);
2269
2270 PEG_METHOD_EXIT();
2271 return qualifierDecl;
2272 }
2273
2274 CIMQualifierDecl CIMRepository::_getQualifier(
2275 const CIMNamespaceName& nameSpace,
2276 const CIMName& qualifierName)
2277 {
2278 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_getQualifier");
2279
|
2280 kumpf 1.189 CIMQualifierDecl qualifierDecl;
|
2281 mike 1.48
|
2282 kumpf 1.189 String qualifierCacheKey = _getCacheKey(nameSpace, qualifierName);
|
2283 mike 1.48
|
2284 kumpf 1.189 // Check the cache first:
|
2285 mike 1.48
|
2286 kumpf 1.204 if (!_rep->_qualifierCache.get(qualifierCacheKey, qualifierDecl))
|
2287 mike 1.48 {
|
2288 kumpf 1.189 // Not in cache so load from disk:
2289
2290 Array<CIMNamespaceName> nameSpaceList =
|
2291 kumpf 1.192 _rep->_nameSpaceManager.getSchemaNameSpaceNames(nameSpace);
|
2292 mike 1.153
|
2293 kumpf 1.189 for (Uint32 i = 0; i < nameSpaceList.size(); i++)
|
2294 mike 1.153 {
|
2295 kumpf 1.189 qualifierDecl = _rep->_persistentStore->getQualifier(
2296 nameSpaceList[i], qualifierName);
|
2297 mike 1.153
|
2298 kumpf 1.189 if (!qualifierDecl.isUninitialized())
2299 {
2300 // Put in cache
|
2301 kumpf 1.204 _rep->_qualifierCache.put(qualifierCacheKey, qualifierDecl);
|
2302 mike 1.153
|
2303 kumpf 1.189 PEG_METHOD_EXIT();
2304 return qualifierDecl;
2305 }
2306 }
|
2307 mike 1.153
|
2308 kumpf 1.58 PEG_METHOD_EXIT();
|
2309 kumpf 1.189 throw PEGASUS_CIM_EXCEPTION(
2310 CIM_ERR_NOT_FOUND, qualifierName.getString());
|
2311 mike 1.48 }
2312
|
2313 kumpf 1.58 PEG_METHOD_EXIT();
|
2314 mike 1.48 return qualifierDecl;
2315 }
2316
2317 void CIMRepository::setQualifier(
|
2318 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
2319 kumpf 1.199 const CIMQualifierDecl& qualifierDecl)
|
2320 mike 1.48 {
|
2321 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::setQualifier");
|
2322 chuck 1.110
|
2323 mike 1.184 WriteLock lock(_rep->_lock);
2324 AutoFileLock fileLock(_rep->_lockFile);
|
2325 kumpf 1.104 _setQualifier(nameSpace, qualifierDecl);
2326
2327 PEG_METHOD_EXIT();
2328 }
2329
2330 void CIMRepository::_setQualifier(
2331 const CIMNamespaceName& nameSpace,
2332 const CIMQualifierDecl& qualifierDecl)
2333 {
2334 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_setQualifier");
2335
|
2336 kumpf 1.192 _rep->_nameSpaceManager.checkSetOrDeleteQualifier(
|
2337 kumpf 1.189 nameSpace, qualifierDecl.getName());
|
2338 mike 1.48
|
2339 kumpf 1.189 _rep->_persistentStore->setQualifier(nameSpace, qualifierDecl);
|
2340 mike 1.48
|
2341 kumpf 1.189 String qualifierCacheKey =
2342 _getCacheKey(nameSpace, qualifierDecl.getName());
|
2343 kumpf 1.204 _rep->_qualifierCache.put(
2344 qualifierCacheKey, (CIMQualifierDecl&)qualifierDecl);
|
2345 jim.wunderlich 1.136
|
2346 kumpf 1.58 PEG_METHOD_EXIT();
|
2347 mike 1.48 }
2348
2349 void CIMRepository::deleteQualifier(
|
2350 kumpf 1.85 const CIMNamespaceName& nameSpace,
2351 const CIMName& qualifierName)
|
2352 mike 1.48 {
|
2353 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::deleteQualifier");
2354
|
2355 mike 1.184 WriteLock lock(_rep->_lock);
2356 AutoFileLock fileLock(_rep->_lockFile);
|
2357 kumpf 1.104
|
2358 kumpf 1.192 _rep->_nameSpaceManager.checkSetOrDeleteQualifier(
|
2359 kumpf 1.189 nameSpace, qualifierName);
|
2360 mike 1.48
|
2361 kumpf 1.189 _rep->_persistentStore->deleteQualifier(nameSpace, qualifierName);
|
2362 mike 1.48
|
2363 kumpf 1.189 String qualifierCacheKey = _getCacheKey(nameSpace, qualifierName);
|
2364 kumpf 1.204 _rep->_qualifierCache.evict(qualifierCacheKey);
|
2365 mike 1.153
|
2366 kumpf 1.58 PEG_METHOD_EXIT();
|
2367 mike 1.48 }
2368
2369 Array<CIMQualifierDecl> CIMRepository::enumerateQualifiers(
|
2370 kumpf 1.85 const CIMNamespaceName& nameSpace)
|
2371 mike 1.48 {
|
2372 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::enumerateQualifiers");
2373
|
2374 mike 1.184 ReadLock lock(_rep->_lock);
|
2375 kumpf 1.104
|
2376 kumpf 1.189 Array<CIMQualifierDecl> qualifiers;
|
2377 mike 1.48
|
2378 kumpf 1.192 _rep->_nameSpaceManager.validateNameSpace(nameSpace);
|
2379 mike 1.48
|
2380 kumpf 1.189 qualifiers = _rep->_persistentStore->enumerateQualifiers(nameSpace);
|
2381 mike 1.48
|
2382 kumpf 1.58 PEG_METHOD_EXIT();
|
2383 mike 1.48 return qualifiers;
2384 }
2385
|
2386 kumpf 1.189 void CIMRepository::createNameSpace(
2387 const CIMNamespaceName& nameSpace,
2388 const NameSpaceAttributes& attributes)
|
2389 mike 1.48 {
|
2390 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::createNameSpace");
2391
|
2392 mike 1.184 WriteLock lock(_rep->_lock);
2393 AutoFileLock fileLock(_rep->_lockFile);
|
2394 kumpf 1.189
2395 Boolean shareable = false;
2396 Boolean updatesAllowed = true;
2397 String parentNameSpace;
|
2398 venkat.puvvada 1.202 String remoteInfo;
|
2399 kumpf 1.189
2400 for (NameSpaceAttributes::Iterator i = attributes.start(); i; i++)
2401 {
2402 String key = i.key();
2403 if (String::equalNoCase(key, "shareable"))
2404 {
2405 if (String::equalNoCase(i.value(), "true"))
2406 shareable = true;
2407 }
2408 else if (String::equalNoCase(key, "updatesAllowed"))
2409 {
2410 if (String::equalNoCase(i.value(), "false"))
2411 updatesAllowed = false;
2412 }
2413 else if (String::equalNoCase(key, "parent"))
2414 {
2415 parentNameSpace = i.value();
2416 }
|
2417 venkat.puvvada 1.202 else if (String::equalNoCase(key, "remoteInfo"))
2418 {
2419 remoteInfo = i.value();
2420 }
|
2421 kumpf 1.189 else
2422 {
2423 PEG_METHOD_EXIT();
2424 throw PEGASUS_CIM_EXCEPTION(
2425 CIM_ERR_NOT_SUPPORTED,
2426 nameSpace.getString() + " option not supported: " + key);
2427 }
2428 }
2429
|
2430 kumpf 1.192 _rep->_nameSpaceManager.createNameSpace(
|
2431 venkat.puvvada 1.202 nameSpace, shareable, updatesAllowed, parentNameSpace, remoteInfo);
|
2432 kumpf 1.189
2433 try
2434 {
2435 _rep->_persistentStore->createNameSpace(
|
2436 venkat.puvvada 1.202 nameSpace, shareable, updatesAllowed, parentNameSpace, remoteInfo);
|
2437 kumpf 1.189 }
2438 catch (...)
2439 {
|
2440 kumpf 1.192 _rep->_nameSpaceManager.deleteNameSpace(nameSpace);
|
2441 kumpf 1.189 throw;
2442 }
|
2443 schuur 1.112
2444 PEG_METHOD_EXIT();
2445 }
2446
|
2447 kumpf 1.189 void CIMRepository::modifyNameSpace(
2448 const CIMNamespaceName& nameSpace,
2449 const NameSpaceAttributes& attributes)
|
2450 schuur 1.112 {
2451 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::modifyNameSpace");
2452
|
2453 mike 1.184 WriteLock lock(_rep->_lock);
2454 AutoFileLock fileLock(_rep->_lockFile);
|
2455 kumpf 1.189
2456 Boolean shareable = false;
2457 Boolean updatesAllowed = true;
2458
2459 for (NameSpaceAttributes::Iterator i = attributes.start(); i; i++)
2460 {
2461 String key = i.key();
2462 if (String::equalNoCase(key, "shareable"))
2463 {
2464 if (String::equalNoCase(i.value(), "true"))
2465 shareable = true;
2466 }
2467 else if (String::equalNoCase(key, "updatesAllowed"))
2468 {
2469 if (String::equalNoCase(i.value(),"false"))
2470 updatesAllowed = false;
2471 }
2472 else
2473 {
2474 PEG_METHOD_EXIT();
2475 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
2476 kumpf 1.189 nameSpace.getString() + " option not supported: " + key);
2477 }
2478 }
2479
|
2480 kumpf 1.192 _rep->_nameSpaceManager.validateNameSpace(nameSpace);
|
2481 kumpf 1.189
2482 if (!shareable)
2483 {
2484 // Check for dependent namespaces
2485
2486 CIMNamespaceName dependentNameSpaceName;
2487
|
2488 kumpf 1.192 if (_rep->_nameSpaceManager.hasDependentNameSpace(
|
2489 kumpf 1.189 nameSpace, dependentNameSpaceName))
2490 {
2491 PEG_METHOD_EXIT();
2492 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
2493 "Namespace " + nameSpace.getString() +
2494 " has dependent namespace " +
2495 dependentNameSpaceName.getString());
2496 }
2497 }
2498
2499 _rep->_persistentStore->modifyNameSpace(
2500 nameSpace, shareable, updatesAllowed);
2501
|
2502 kumpf 1.192 _rep->_nameSpaceManager.modifyNameSpace(
|
2503 kumpf 1.189 nameSpace, shareable, updatesAllowed);
|
2504 kumpf 1.58
2505 PEG_METHOD_EXIT();
|
2506 mike 1.48 }
2507
|
2508 kumpf 1.85 Array<CIMNamespaceName> CIMRepository::enumerateNameSpaces() const
|
2509 mike 1.48 {
|
2510 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::enumerateNameSpaces");
2511
|
2512 mike 1.184 ReadLock lock(const_cast<ReadWriteSem&>(_rep->_lock));
|
2513 kumpf 1.104
|
2514 kumpf 1.85 Array<CIMNamespaceName> nameSpaceNames;
|
2515 kumpf 1.192 _rep->_nameSpaceManager.getNameSpaceNames(nameSpaceNames);
|
2516 kumpf 1.58
2517 PEG_METHOD_EXIT();
|
2518 mike 1.48 return nameSpaceNames;
2519 }
2520
|
2521 kumpf 1.85 void CIMRepository::deleteNameSpace(const CIMNamespaceName& nameSpace)
|
2522 mike 1.48 {
|
2523 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::deleteNameSpace");
2524
|
2525 mike 1.184 WriteLock lock(_rep->_lock);
2526 AutoFileLock fileLock(_rep->_lockFile);
|
2527 kumpf 1.58
|
2528 kumpf 1.189 // Check for dependent namespaces
|
2529 mike 1.48
|
2530 kumpf 1.189 CIMNamespaceName dependentNameSpaceName;
|
2531 schuur 1.112
|
2532 kumpf 1.192 if (_rep->_nameSpaceManager.hasDependentNameSpace(
|
2533 kumpf 1.189 nameSpace, dependentNameSpaceName))
2534 {
2535 PEG_METHOD_EXIT();
2536 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
2537 "Namespace " + nameSpace.getString() +
2538 " has dependent namespace " +
2539 dependentNameSpaceName.getString());
2540 }
|
2541 schuur 1.115
|
2542 kumpf 1.189 // Make sure the namespace is empty
|
2543 mike 1.51
|
2544 kumpf 1.189 if (!_rep->_persistentStore->isNameSpaceEmpty(nameSpace))
2545 {
2546 PEG_METHOD_EXIT();
2547 throw NonEmptyNameSpace(nameSpace.getString());
2548 }
|
2549 kumpf 1.58
|
2550 kumpf 1.189 _rep->_persistentStore->deleteNameSpace(nameSpace);
|
2551 mike 1.53
|
2552 kumpf 1.192 _rep->_nameSpaceManager.deleteNameSpace(nameSpace);
|
2553 kumpf 1.58
2554 PEG_METHOD_EXIT();
|
2555 mike 1.48 }
2556
|
2557 kumpf 1.189 Boolean CIMRepository::getNameSpaceAttributes(const CIMNamespaceName& nameSpace,
2558 NameSpaceAttributes& attributes)
|
2559 mike 1.48 {
|
2560 kumpf 1.189 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::deleteNameSpace");
|
2561 kumpf 1.58
|
2562 kumpf 1.189 ReadLock lock(const_cast<ReadWriteSem&>(_rep->_lock));
2563 attributes.clear();
|
2564 mike 1.51
|
2565 kumpf 1.189 Boolean shareable;
2566 Boolean updatesAllowed;
2567 String parent;
|
2568 venkat.puvvada 1.202 String remoteInfo;
|
2569 mike 1.51
|
2570 kumpf 1.192 if (!_rep->_nameSpaceManager.getNameSpaceAttributes(
|
2571 venkat.puvvada 1.202 nameSpace, shareable, updatesAllowed, parent, remoteInfo))
|
2572 kumpf 1.58 {
2573 PEG_METHOD_EXIT();
|
2574 mike 1.51 return false;
|
2575 kumpf 1.58 }
|
2576 mike 1.51
|
2577 kumpf 1.189 attributes.insert("name", nameSpace.getString());
2578
2579 if (shareable)
2580 attributes.insert("shareable", "true");
2581 else
2582 attributes.insert("shareable", "false");
2583
2584 if (updatesAllowed)
2585 attributes.insert("updatesAllowed", "true");
2586 else
2587 attributes.insert("updatesAllowed", "false");
|
2588 mike 1.51
|
2589 kumpf 1.189 if (parent.size())
2590 attributes.insert("parent", parent);
|
2591 mike 1.51
|
2592 venkat.puvvada 1.202 if (remoteInfo.size())
2593 attributes.insert("remoteInfo", remoteInfo);
2594
|
2595 kumpf 1.58 PEG_METHOD_EXIT();
|
2596 mike 1.51 return true;
|
2597 mike 1.48 }
2598
|
2599 kumpf 1.189 Boolean CIMRepository::isRemoteNameSpace(
2600 const CIMNamespaceName& nameSpaceName,
2601 String& remoteInfo)
2602 {
2603 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::isRemoteNamespace");
2604 ReadLock lock(const_cast<ReadWriteSem&>(_rep->_lock));
2605 PEG_METHOD_EXIT();
|
2606 kumpf 1.192 return _rep->_nameSpaceManager.isRemoteNameSpace(
|
2607 kumpf 1.189 nameSpaceName, remoteInfo);
2608 }
|
2609 bob 1.49
|
2610 dave.sudlik 1.154 #ifdef PEGASUS_DEBUG
|
2611 kumpf 1.169 void CIMRepository::DisplayCacheStatistics()
|
2612 dave.sudlik 1.154 {
2613 #ifdef PEGASUS_USE_CLASS_CACHE
2614 cout << "Repository Class Cache Statistics:" << endl;
|
2615 kumpf 1.204 _rep->_classCache.DisplayCacheStatistics();
|
2616 dave.sudlik 1.154 #endif
2617 cout << "Repository Qualifier Cache Statistics:" << endl;
|
2618 kumpf 1.204 _rep->_qualifierCache.DisplayCacheStatistics();
|
2619 dave.sudlik 1.154 }
2620 #endif
2621
|
2622 mike 1.184 void CIMRepository::getSubClassNames(
2623 const CIMNamespaceName& nameSpaceName,
2624 const CIMName& className,
2625 Boolean deepInheritance,
2626 Array<CIMName>& subClassNames) const
2627 {
2628 ReadLock lock(const_cast<ReadWriteSem&>(_rep->_lock));
|
2629 kumpf 1.192 _rep->_nameSpaceManager.getSubClassNames(
|
2630 kumpf 1.189 nameSpaceName, className, deepInheritance, subClassNames);
|
2631 mike 1.184 }
2632
2633 void CIMRepository::getSuperClassNames(
2634 const CIMNamespaceName& nameSpaceName,
2635 const CIMName& className,
2636 Array<CIMName>& subClassNames) const
2637 {
2638 ReadLock lock(const_cast<ReadWriteSem&>(_rep->_lock));
|
2639 kumpf 1.192 _rep->_nameSpaceManager.getSuperClassNames(
|
2640 mike 1.184 nameSpaceName, className, subClassNames);
2641 }
2642
2643 Boolean CIMRepository::isDefaultInstanceProvider()
2644 {
2645 return _rep->_isDefaultInstanceProvider;
2646 }
2647
|
2648 mike 1.205 CIMConstClass CIMRepository::getFullConstClass(
2649 const CIMNamespaceName& nameSpace,
2650 const CIMName& className)
2651 {
2652 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::getFullConstClass");
2653
2654 ReadLock lock(_rep->_lock);
2655 CIMClass cimClass = _getClass(nameSpace, className, false, true, true,
2656 CIMPropertyList(), false);
2657
2658 PEG_METHOD_EXIT();
2659 return cimClass;
2660 }
2661
|
2662 mike 1.48 PEGASUS_NAMESPACE_END
|