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