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.191 if (resolveInstance)
|
1017 mike 1.54 {
|
1018 kumpf 1.104 CIMConstClass cimClass;
|
1019 mike 1.184 Resolver::resolveInstance (
1020 cimInstance, _rep->_context, nameSpace, cimClass, true);
|
1021 mike 1.54 }
|
1022 kumpf 1.99
|
1023 kumpf 1.165 _filterInstance(
1024 cimInstance,
1025 propertyList,
1026 localOnly,
1027 includeQualifiers,
1028 includeClassOrigin);
|
1029 kumpf 1.104
|
1030 kumpf 1.52 PEG_METHOD_EXIT();
|
1031 mike 1.48 return cimInstance;
1032 }
1033
1034 void CIMRepository::deleteClass(
|
1035 kumpf 1.85 const CIMNamespaceName& nameSpace,
1036 const CIMName& className)
|
1037 mike 1.48 {
|
1038 kumpf 1.61 PEG_METHOD_ENTER(TRC_REPOSITORY,"CIMRepository::deleteClass");
|
1039 kumpf 1.58
|
1040 mike 1.184 WriteLock lock(_rep->_lock);
1041 AutoFileLock fileLock(_rep->_lockFile);
|
1042 kumpf 1.104
|
1043 mike 1.53 //
|
1044 kumpf 1.189 // Get the class and check to see if it is an association class.
|
1045 mike 1.53 //
|
1046 mike 1.51
|
1047 kumpf 1.104 CIMClass cimClass = _getClass(
1048 nameSpace, className, false, true, false, CIMPropertyList());
|
1049 mike 1.48 Boolean isAssociation = cimClass.isAssociation();
1050
|
1051 kumpf 1.192 _rep->_nameSpaceManager.checkDeleteClass(nameSpace, className);
|
1052 kumpf 1.189
1053 Array<CIMNamespaceName> dependentNameSpaceNames =
|
1054 kumpf 1.192 _rep->_nameSpaceManager.getDependentSchemaNameSpaceNames(nameSpace);
|
1055 kumpf 1.189
|
1056 mike 1.53 //
|
1057 kumpf 1.189 // Ensure no instances of this class exist in the repository.
|
1058 mike 1.53 //
|
1059 mike 1.151
|
1060 kumpf 1.189 for (Uint32 i = 0; i < dependentNameSpaceNames.size(); i++)
1061 {
1062 Array<CIMObjectPath> instanceNames =
1063 _rep->_persistentStore->enumerateInstanceNamesForClass(
1064 dependentNameSpaceNames[i], className);
|
1065 mike 1.151
|
1066 kumpf 1.189 if (instanceNames.size())
1067 {
1068 throw PEGASUS_CIM_EXCEPTION(
1069 CIM_ERR_CLASS_HAS_INSTANCES, className.getString());
1070 }
1071 }
|
1072 mike 1.48
|
1073 kumpf 1.189 #ifdef PEGASUS_USE_CLASS_CACHE
|
1074 kumpf 1.104
|
1075 kumpf 1.189 _classCache.evict(_getCacheKey(nameSpace, className));
|
1076 mike 1.48
|
1077 kumpf 1.189 #endif /* PEGASUS_USE_CLASS_CACHE */
|
1078 kumpf 1.58
|
1079 mike 1.53 //
|
1080 kumpf 1.189 // Delete the class. The NameSpaceManager::deleteClass() method throws
1081 // an exception if the class has subclasses.
|
1082 mike 1.53 //
1083
|
1084 kumpf 1.189 CIMName superClassName =
|
1085 kumpf 1.192 _rep->_nameSpaceManager.getSuperClassName(nameSpace, className);
|
1086 mike 1.53
|
1087 kumpf 1.192 _rep->_nameSpaceManager.deleteClass(nameSpace, className);
|
1088 mike 1.53
|
1089 kumpf 1.190 _rep->_persistentStore->deleteClass(
1090 nameSpace,
1091 className,
1092 superClassName,
1093 isAssociation,
1094 dependentNameSpaceNames);
|
1095 kumpf 1.58
1096 PEG_METHOD_EXIT();
|
1097 mike 1.53 }
1098
|
1099 mike 1.48 void CIMRepository::deleteInstance(
|
1100 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1101 kumpf 1.68 const CIMObjectPath& instanceName)
|
1102 mike 1.48 {
|
1103 mike 1.53 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::deleteInstance");
|
1104 mike 1.51
|
1105 kumpf 1.192 _rep->_nameSpaceManager.validateClass(
|
1106 kumpf 1.189 nameSpace, instanceName.getClassName());
1107
1108 CIMObjectPath normalizedInstanceName =
1109 _stripInstanceName(nameSpace, instanceName);
|
1110 r.kieninger 1.125
|
1111 mike 1.184 WriteLock lock(_rep->_lock);
1112 AutoFileLock fileLock(_rep->_lockFile);
|
1113 kumpf 1.104
|
1114 kumpf 1.189 _rep->_persistentStore->deleteInstance(nameSpace, normalizedInstanceName);
|
1115 mike 1.53
|
1116 kumpf 1.58 PEG_METHOD_EXIT();
|
1117 mike 1.48 }
1118
1119 void CIMRepository::createClass(
|
1120 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1121 chuck 1.110 const CIMClass& newClass,
|
1122 kumpf 1.155 const ContentLanguageList& contentLangs)
|
1123 mike 1.48 {
|
1124 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::createClass");
1125
|
1126 mike 1.184 WriteLock lock(_rep->_lock);
1127 AutoFileLock fileLock(_rep->_lockFile);
|
1128 kumpf 1.104 _createClass(nameSpace, newClass);
1129
1130 PEG_METHOD_EXIT();
1131 }
1132
1133 void CIMRepository::_createClass(
1134 const CIMNamespaceName& nameSpace,
1135 const CIMClass& newClass)
1136 {
1137 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_createClass");
1138
|
1139 mike 1.48 // -- Resolve the class:
|
1140 kumpf 1.104
|
1141 kumpf 1.194 CIMClass cimClass(newClass.clone());
1142 Resolver::resolveClass(cimClass, _rep->_context, nameSpace);
|
1143 mike 1.48
|
1144 kumpf 1.189 // -- Check whether the class may be created:
1145
|
1146 kumpf 1.192 _rep->_nameSpaceManager.checkCreateClass(
|
1147 kumpf 1.195 nameSpace, newClass.getClassName(), newClass.getSuperClassName());
|
1148 kumpf 1.189
|
1149 kumpf 1.190 // -- If an association class, build association entries:
|
1150 kumpf 1.189
|
1151 kumpf 1.190 Array<ClassAssociation> classAssocEntries;
|
1152 kumpf 1.189
|
1153 kumpf 1.190 if (cimClass.isAssociation())
1154 {
1155 classAssocEntries = _buildClassAssociationEntries(cimClass);
1156 }
|
1157 mike 1.48
|
1158 kumpf 1.195 // -- Strip the propagated elements, if required
1159
1160 if (!_rep->_storeCompleteClassDefinitions)
1161 {
1162 _stripPropagatedElements(cimClass);
1163 }
1164
|
1165 kumpf 1.190 // -- Create the class declaration:
1166
1167 _rep->_persistentStore->createClass(nameSpace, cimClass, classAssocEntries);
|
1168 mike 1.48
1169 // -- Create namespace manager entry:
1170
|
1171 kumpf 1.192 _rep->_nameSpaceManager.createClass(
|
1172 kumpf 1.189 nameSpace, cimClass.getClassName(), cimClass.getSuperClassName());
|
1173 kumpf 1.58
1174 PEG_METHOD_EXIT();
|
1175 mike 1.48 }
1176
|
1177 kumpf 1.68 CIMObjectPath CIMRepository::createInstance(
|
1178 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1179 chuck 1.110 const CIMInstance& newInstance,
|
1180 kumpf 1.155 const ContentLanguageList& contentLangs)
|
1181 mike 1.48 {
|
1182 kumpf 1.61 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::createInstance");
|
1183 mike 1.51
|
1184 mike 1.184 WriteLock lock(_rep->_lock);
1185 AutoFileLock fileLock(_rep->_lockFile);
|
1186 kumpf 1.104 CIMObjectPath instanceName = _createInstance(nameSpace, newInstance);
1187
1188 PEG_METHOD_EXIT();
1189 return instanceName;
1190 }
1191
1192 CIMObjectPath CIMRepository::_createInstance(
1193 const CIMNamespaceName& nameSpace,
1194 const CIMInstance& newInstance)
1195 {
1196 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_createInstance");
1197
|
1198 mike 1.53 //
|
1199 mike 1.54 // Resolve the instance. Looks up class and fills out properties but
1200 // not the qualifiers.
|
1201 mike 1.53 //
1202
|
1203 mike 1.51 CIMInstance cimInstance(newInstance);
|
1204 mike 1.48 CIMConstClass cimClass;
|
1205 mike 1.184 Resolver::resolveInstance (cimInstance, _rep->_context, nameSpace, cimClass,
|
1206 kumpf 1.76 false);
|
1207 kumpf 1.81 CIMObjectPath instanceName = cimInstance.buildPath(cimClass);
|
1208 mike 1.48
|
1209 mike 1.53 //
1210 // Make sure the class has keys (otherwise it will be impossible to
1211 // create the instance).
1212 //
|
1213 mike 1.48
1214 if (!cimClass.hasKeys())
1215 {
|
1216 humberto 1.88 PEG_METHOD_EXIT();
|
1217 kumpf 1.99 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1218 MessageLoaderParms("Repository.CIMRepository.CLASS_HAS_NO_KEYS",
|
1219 kumpf 1.104 "class has no keys: $0",
|
1220 kumpf 1.99 cimClass.getClassName().getString()));
|
1221 mike 1.48 }
1222
|
1223 mike 1.53 //
1224 // Be sure instance does not already exist:
1225 //
|
1226 mike 1.48
|
1227 mike 1.184 if (_rep->_checkInstanceAlreadyExists(nameSpace, instanceName))
|
1228 mike 1.48 {
|
1229 kumpf 1.52 PEG_METHOD_EXIT();
|
1230 kumpf 1.104 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_ALREADY_EXISTS,
|
1231 mike 1.51 instanceName.toString());
|
1232 mike 1.48 }
1233
|
1234 mike 1.53 //
|
1235 kumpf 1.190 // Build association entries if an association instance.
|
1236 mike 1.53 //
|
1237 mike 1.48
|
1238 kumpf 1.190 Array<InstanceAssociation> instAssocEntries;
1239
|
1240 mike 1.48 if (cimClass.isAssociation())
|
1241 kumpf 1.190 {
1242 instAssocEntries = _buildInstanceAssociationEntries(
1243 nameSpace, cimClass, cimInstance, instanceName);
1244 }
1245
1246 //
1247 // Create the instance
1248 //
|
1249 mike 1.53
|
1250 kumpf 1.189 _rep->_persistentStore->createInstance(
|
1251 kumpf 1.190 nameSpace, instanceName, cimInstance, instAssocEntries);
|
1252 mike 1.53
|
1253 kumpf 1.189 // ATTN: Why does this come after the create has completed?
|
1254 mike 1.184 Resolver::resolveInstance (
1255 cimInstance, _rep->_context, nameSpace, cimClass, true);
|
1256 mike 1.54
|
1257 kumpf 1.52 PEG_METHOD_EXIT();
|
1258 mike 1.53 return instanceName;
|
1259 mike 1.48 }
1260
1261 void CIMRepository::modifyClass(
|
1262 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1263 chuck 1.110 const CIMClass& modifiedClass,
|
1264 kumpf 1.155 const ContentLanguageList& contentLangs)
|
1265 mike 1.48 {
|
1266 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::modifyClass");
1267
|
1268 mike 1.184 WriteLock lock(_rep->_lock);
1269 AutoFileLock fileLock(_rep->_lockFile);
|
1270 kumpf 1.104 _modifyClass(nameSpace, modifiedClass);
1271
1272 PEG_METHOD_EXIT();
1273 }
1274
1275 void CIMRepository::_modifyClass(
1276 const CIMNamespaceName& nameSpace,
1277 const CIMClass& modifiedClass)
1278 {
1279 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_modifyClass");
1280
|
1281 mike 1.53 //
1282 // Resolve the class:
1283 //
|
1284 mike 1.51
|
1285 kumpf 1.194 CIMClass cimClass(modifiedClass.clone());
|
1286 kumpf 1.189 Resolver::resolveClass(cimClass, _rep->_context, nameSpace);
|
1287 mike 1.48
|
1288 mike 1.53 //
1289 // Check to see if it is okay to modify this class:
1290 //
|
1291 mike 1.48
|
1292 kumpf 1.195 CIMName oldSuperClassName;
1293
|
1294 kumpf 1.192 _rep->_nameSpaceManager.checkModifyClass(
|
1295 kumpf 1.195 nameSpace,
1296 modifiedClass.getClassName(),
1297 modifiedClass.getSuperClassName(),
1298 oldSuperClassName,
1299 !_rep->_storeCompleteClassDefinitions);
|
1300 mike 1.48
|
1301 mike 1.53 //
1302 // ATTN: KS
1303 // Disallow modification of classes which have instances (that are
1304 // in the repository). And we have no idea whether the class has
1305 // instances in other repositories or in providers. We should do
1306 // an enumerate instance names at a higher level (above the repository).
1307 //
|
1308 chip 1.118
|
1309 mike 1.151 #ifdef PEGASUS_USE_CLASS_CACHE
1310
|
1311 kumpf 1.189 String cacheKey = _getCacheKey(nameSpace, cimClass.getClassName());
1312 _classCache.evict(cacheKey);
|
1313 mike 1.151
1314 #endif /* PEGASUS_USE_CLASS_CACHE */
|
1315 mike 1.53
|
1316 kumpf 1.190 Boolean isAssociation = cimClass.isAssociation();
1317 Array<ClassAssociation> classAssocEntries;
|
1318 kumpf 1.58
|
1319 kumpf 1.190 if (isAssociation)
|
1320 kumpf 1.169 {
|
1321 kumpf 1.190 classAssocEntries = _buildClassAssociationEntries(cimClass);
|
1322 konrad.r 1.111 }
1323
|
1324 kumpf 1.195 // Strip the propagated elements, if required
1325
1326 if (!_rep->_storeCompleteClassDefinitions)
1327 {
1328 _stripPropagatedElements(cimClass);
1329 }
1330
|
1331 kumpf 1.190 _rep->_persistentStore->modifyClass(
|
1332 kumpf 1.195 nameSpace,
1333 cimClass,
1334 oldSuperClassName,
1335 isAssociation,
1336 classAssocEntries);
|
1337 mike 1.151
1338 //
1339 // Cache this class:
1340 //
1341
1342 #ifdef PEGASUS_USE_CLASS_CACHE
1343
|
1344 kumpf 1.189 _classCache.put(cacheKey, cimClass);
|
1345 mike 1.151
1346 #endif /* PEGASUS_USE_CLASS_CACHE */
1347
|
1348 kumpf 1.58 PEG_METHOD_EXIT();
|
1349 mike 1.48 }
1350
1351 void CIMRepository::modifyInstance(
|
1352 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1353 kumpf 1.70 const CIMInstance& modifiedInstance,
|
1354 mike 1.51 Boolean includeQualifiers,
|
1355 chuck 1.110 const CIMPropertyList& propertyList,
|
1356 kumpf 1.155 const ContentLanguageList& contentLangs)
|
1357 mike 1.48 {
|
1358 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::modifyInstance");
1359
|
1360 mike 1.184 WriteLock lock(_rep->_lock);
1361 AutoFileLock fileLock(_rep->_lockFile);
|
1362 kumpf 1.104
|
1363 mike 1.53 //
1364 // Do this:
1365 //
|
1366 mike 1.51
|
1367 mike 1.53 CIMInstance cimInstance; // The instance that replaces the original
|
1368 mike 1.51
1369 if (propertyList.isNull())
1370 {
1371 //
1372 // Replace all the properties in the instance
1373 //
1374 if (includeQualifiers)
1375 {
1376 //
1377 // Replace the entire instance with the given instance
1378 // (this is the default behavior)
1379 //
|
1380 kumpf 1.70 cimInstance = modifiedInstance;
|
1381 mike 1.51 }
1382 else
1383 {
1384 //
1385 // Replace all the properties in the instance, but keep the
1386 // original qualifiers on the instance and on the properties
1387 //
1388
|
1389 kumpf 1.104 cimInstance = _getInstance(
1390 nameSpace,
1391 modifiedInstance.getPath (),
1392 false,
1393 true,
1394 true,
|
1395 kumpf 1.191 CIMPropertyList(),
1396 false);
|
1397 mike 1.54
|
1398 mike 1.51 CIMInstance newInstance(
|
1399 kumpf 1.70 modifiedInstance.getPath ().getClassName());
|
1400 mike 1.54
|
1401 kumpf 1.70 CIMInstance givenInstance = modifiedInstance;
|
1402 mike 1.51
1403 //
1404 // Copy over the original instance qualifiers
1405 //
|
1406 mike 1.54
1407 for (Uint32 i = 0; i < cimInstance.getQualifierCount(); i++)
|
1408 mike 1.51 {
1409 newInstance.addQualifier(cimInstance.getQualifier(i));
1410 }
1411
1412 //
1413 // Loop through the properties replacing each property in the
1414 // original with a new value, but keeping the original qualifiers
1415 //
1416 for (Uint32 i=0; i<givenInstance.getPropertyCount(); i++)
1417 {
1418 // Copy the given property value (not qualifiers)
1419 CIMProperty givenProperty = givenInstance.getProperty(i);
1420 CIMProperty newProperty(
1421 givenProperty.getName(),
1422 givenProperty.getValue(),
1423 givenProperty.getArraySize(),
1424 givenProperty.getReferenceClassName(),
1425 givenProperty.getClassOrigin(),
1426 givenProperty.getPropagated());
1427
1428 // Copy the original property qualifiers
1429 mike 1.51 Uint32 origPos =
1430 cimInstance.findProperty(newProperty.getName());
1431 if (origPos != PEG_NOT_FOUND)
1432 {
1433 CIMProperty origProperty = cimInstance.getProperty(origPos);
1434 for (Uint32 j=0; j<origProperty.getQualifierCount(); j++)
1435 {
|
1436 r.kieninger 1.133 newProperty.addQualifier(origProperty.getQualifier(j));
|
1437 mike 1.51 }
1438 }
1439
1440 // Add the newly constructed property to the new instance
1441 newInstance.addProperty(newProperty);
1442 }
1443
1444 // Use the newly merged instance to replace the original instance
1445 cimInstance = newInstance;
1446 }
1447 }
1448 else
1449 {
1450 //
1451 // Replace only the properties specified in the given instance
1452 //
1453
|
1454 kumpf 1.191 cimInstance = _getInstance(
1455 nameSpace,
1456 modifiedInstance.getPath(),
1457 false,
1458 true,
1459 true,
1460 CIMPropertyList(),
1461 false);
|
1462 mike 1.55
|
1463 kumpf 1.70 CIMInstance givenInstance = modifiedInstance;
|
1464 mike 1.51
1465 // NOTE: Instance qualifiers are not changed when a property list
1466 // is specified. Property qualifiers are replaced with the
1467 // corresponding property values.
1468
1469 //
1470 // Loop through the propertyList replacing each property in the original
1471 //
|
1472 mike 1.53
|
1473 kumpf 1.74 for (Uint32 i=0; i<propertyList.size(); i++)
|
1474 mike 1.51 {
|
1475 kumpf 1.74 Uint32 origPropPos = cimInstance.findProperty(propertyList[i]);
|
1476 mike 1.51 if (origPropPos != PEG_NOT_FOUND)
1477 {
1478 // Case: Property set in original
1479 CIMProperty origProperty =
1480 cimInstance.getProperty(origPropPos);
1481
1482 // Get the given property value
1483 Uint32 givenPropPos =
|
1484 kumpf 1.74 givenInstance.findProperty(propertyList[i]);
|
1485 mike 1.51 if (givenPropPos != PEG_NOT_FOUND)
1486 {
1487 // Case: Property set in original and given
1488 CIMProperty givenProperty =
1489 givenInstance.getProperty(givenPropPos);
1490
1491 // Copy over the property from the given to the original
1492 if (includeQualifiers)
1493 {
1494 // Case: Total property replacement
1495 cimInstance.removeProperty(origPropPos);
1496 cimInstance.addProperty(givenProperty);
1497 }
1498 else
1499 {
1500 // Case: Replace only the property value (not quals)
1501 origProperty.setValue(givenProperty.getValue());
1502 cimInstance.removeProperty(origPropPos);
1503 cimInstance.addProperty(origProperty);
1504 }
1505 }
1506 mike 1.51 else
1507 {
1508 // Case: Property set in original and not in given
1509 // Just remove the property (set to null)
1510 cimInstance.removeProperty(origPropPos);
1511 }
1512 }
1513 else
1514 {
1515 // Case: Property not set in original
1516
1517 // Get the given property value
1518 Uint32 givenPropPos =
|
1519 kumpf 1.74 givenInstance.findProperty(propertyList[i]);
|
1520 mike 1.51 if (givenPropPos != PEG_NOT_FOUND)
1521 {
1522 // Case: Property set in given and not in original
1523 CIMProperty givenProperty =
1524 givenInstance.getProperty(givenPropPos);
1525
1526 // Copy over the property from the given to the original
1527 if (includeQualifiers)
1528 {
1529 // Case: Total property copy
1530 cimInstance.addProperty(givenProperty);
1531 }
1532 else
1533 {
1534 // Case: Copy only the property value (not qualifiers)
1535 CIMProperty newProperty(
1536 givenProperty.getName(),
1537 givenProperty.getValue(),
1538 givenProperty.getArraySize(),
1539 givenProperty.getReferenceClassName(),
1540 givenProperty.getClassOrigin(),
1541 mike 1.51 givenProperty.getPropagated());
1542 cimInstance.addProperty(newProperty);
1543 }
1544 }
1545 else
1546 {
1547 // Case: Property not set in original or in given
1548
1549 // Nothing to do; just make sure the property name is valid
1550 // ATTN: This is not the most efficient solution
1551 CIMClass cimClass = getClass(
1552 nameSpace, cimInstance.getClassName(), false);
|
1553 kumpf 1.74 if (cimClass.findProperty(propertyList[i]) == PEG_NOT_FOUND)
|
1554 mike 1.51 {
1555 // ATTN: This exception may be returned by setProperty
|
1556 kumpf 1.58 PEG_METHOD_EXIT();
|
1557 mike 1.51 throw PEGASUS_CIM_EXCEPTION(
1558 CIM_ERR_NO_SUCH_PROPERTY, "modifyInstance()");
1559 }
1560 }
1561 }
1562 }
1563 }
1564
|
1565 kumpf 1.189 CIMObjectPath normalizedInstanceName =
1566 _stripInstanceName(nameSpace, modifiedInstance.getPath());
|
1567 kumpf 1.168
1568 //
|
1569 kumpf 1.189 // Resolve the instance (do not propagate qualifiers from class since
1570 // this will bloat the instance).
|
1571 mike 1.53 //
1572
|
1573 kumpf 1.189 CIMConstClass cimClass;
1574 Resolver::resolveInstance(
1575 cimInstance, _rep->_context, nameSpace, cimClass, false);
|
1576 mike 1.48
|
1577 mike 1.53 //
|
1578 kumpf 1.189 // Disallow operation if the instance name was changed:
|
1579 mike 1.53 //
1580
|
1581 kumpf 1.189 if (cimInstance.buildPath(cimClass) != normalizedInstanceName)
|
1582 mike 1.51 {
|
1583 kumpf 1.104 PEG_METHOD_EXIT();
1584 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
1585 MessageLoaderParms(
|
1586 kumpf 1.189 "Repository.CIMRepository.ATTEMPT_TO_MODIFY_KEY_PROPERTY",
1587 "Attempted to modify a key property"));
|
1588 dmitry.mikulin 1.179 }
1589
|
1590 kumpf 1.189 _rep->_persistentStore->modifyInstance(
1591 nameSpace, normalizedInstanceName, cimInstance);
|
1592 mike 1.54
1593 //
1594 // Resolve the instance:
1595 //
1596
|
1597 kumpf 1.189 // ATTN: Why does this come after the modify has completed?
|
1598 mike 1.184 Resolver::resolveInstance (
1599 cimInstance, _rep->_context, nameSpace, cimClass, true);
|
1600 kumpf 1.58
1601 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 localOnly,
1656 Boolean includeQualifiers,
1657 Boolean includeClassOrigin,
|
1658 mike 1.51 const CIMPropertyList& propertyList)
|
1659 mike 1.48 {
|
1660 kumpf 1.163 PEG_METHOD_ENTER(TRC_REPOSITORY,
1661 "CIMRepository::enumerateInstancesForSubtree");
|
1662 kumpf 1.104
|
1663 mike 1.184 // It is not necessary to control access to the ReadWriteSem lock here.
|
1664 kumpf 1.104 // This method calls enumerateInstancesForClass, which does its own
1665 // access control.
1666
|
1667 karl 1.69 //
1668 // Get all descendent classes of this class:
1669 //
1670
|
1671 kumpf 1.85 Array<CIMName> classNames;
|
1672 kumpf 1.94 classNames.append(className);
|
1673 kumpf 1.192 _rep->_nameSpaceManager.getSubClassNames(
|
1674 mike 1.184 nameSpace, className, true, classNames);
|
1675 karl 1.69
1676 //
1677 // Get all instances for this class and all its descendent classes
1678 //
|
1679 kumpf 1.58
|
1680 kumpf 1.70 Array<CIMInstance> namedInstances;
|
1681 kumpf 1.104
|
1682 karl 1.69 for (Uint32 i = 0; i < classNames.size(); i++)
|
1683 karl 1.65 {
|
1684 karl 1.101 Array<CIMInstance> localNamedInstances =
|
1685 kumpf 1.163 enumerateInstancesForClass(nameSpace, classNames[i],
1686 false, includeQualifiers, includeClassOrigin, propertyList);
1687
|
1688 karl 1.101 // ATTN: Handles everything but deepInheritance.
|
1689 kumpf 1.188 for (Uint32 j = 0 ; j < localNamedInstances.size(); j++)
|
1690 karl 1.101 {
|
1691 kumpf 1.188 _filterInstance(localNamedInstances[j],
|
1692 karl 1.101 propertyList,
1693 localOnly,
1694 includeQualifiers,
1695 includeClassOrigin);
1696 }
1697 namedInstances.appendArray(localNamedInstances);
|
1698 karl 1.65 }
|
1699 karl 1.98
|
1700 karl 1.65 PEG_METHOD_EXIT();
1701 return namedInstances;
|
1702 karl 1.69 }
|
1703 karl 1.65
|
1704 kumpf 1.70 Array<CIMInstance> CIMRepository::enumerateInstancesForClass(
|
1705 kumpf 1.85 const CIMNamespaceName& nameSpace,
1706 const CIMName& className,
|
1707 karl 1.69 Boolean localOnly,
1708 Boolean includeQualifiers,
1709 Boolean includeClassOrigin,
1710 const CIMPropertyList& propertyList)
1711 {
|
1712 kumpf 1.104 PEG_METHOD_ENTER(TRC_REPOSITORY,
|
1713 kumpf 1.163 "CIMRepository::enumerateInstancesForClass");
|
1714 kumpf 1.104
|
1715 mike 1.184 ReadLock lock(_rep->_lock);
|
1716 kumpf 1.104
|
1717 kumpf 1.192 _rep->_nameSpaceManager.validateClass(nameSpace, className);
|
1718 kumpf 1.189
|
1719 mike 1.53 //
|
1720 kumpf 1.163 // Get all instances for this class
|
1721 mike 1.53 //
|
1722 mike 1.48
|
1723 kumpf 1.189 Array<CIMInstance> namedInstances =
1724 _rep->_persistentStore->enumerateInstancesForClass(
1725 nameSpace, className);
|
1726 mike 1.48
|
1727 kumpf 1.163 // Do any required filtering of properties, qualifiers, classorigin
1728 // on the returned instances.
1729 for (Uint32 i = 0 ; i < namedInstances.size(); i++)
1730 {
|
1731 kumpf 1.189 Resolver::resolveInstance(
1732 namedInstances[i], _rep->_context, nameSpace, true);
1733
|
1734 kumpf 1.163 _filterInstance(namedInstances[i],
1735 propertyList,
1736 localOnly,
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 false,
1866 includeQualifiers,
1867 includeClassOrigin,
|
1868 kumpf 1.191 propertyList,
1869 true);
|
1870 mike 1.51
1871 CIMObject cimObject(cimInstance);
|
1872 kumpf 1.71 cimObject.setPath (names[i]);
1873 result.append(cimObject);
|
1874 mike 1.51 }
|
1875 mike 1.48 }
1876
|
1877 kumpf 1.58 PEG_METHOD_EXIT();
|
1878 mike 1.48 return result;
1879 }
1880
|
1881 kumpf 1.68 Array<CIMObjectPath> CIMRepository::associatorNames(
|
1882 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1883 kumpf 1.68 const CIMObjectPath& objectName,
|
1884 kumpf 1.85 const CIMName& assocClass,
1885 const CIMName& resultClass,
|
1886 mike 1.48 const String& role,
1887 const String& resultRole)
1888 {
|
1889 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::associatorNames");
|
1890 mike 1.51
|
1891 mike 1.184 ReadLock lock(_rep->_lock);
|
1892 kumpf 1.104 Array<CIMObjectPath> result = _associatorNames(
1893 nameSpace, objectName, assocClass, resultClass, role, resultRole);
1894
1895 PEG_METHOD_EXIT();
1896 return result;
1897 }
1898
1899 Array<CIMObjectPath> CIMRepository::_associatorNames(
1900 const CIMNamespaceName& nameSpace,
1901 const CIMObjectPath& objectName,
1902 const CIMName& assocClass,
1903 const CIMName& resultClass,
1904 const String& role,
1905 const String& resultRole)
1906 {
1907 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_associatorNames");
1908
|
1909 mike 1.48 Array<String> associatorNames;
1910
|
1911 kumpf 1.93 // The assocClass parameter implies subclasses, so retrieve them
1912 Array<CIMName> assocClassList;
1913 if (!assocClass.isNull())
1914 {
|
1915 kumpf 1.192 _rep->_nameSpaceManager.getSubClassNames(
|
1916 kumpf 1.93 nameSpace, assocClass, true, assocClassList);
1917 assocClassList.append(assocClass);
1918 }
1919
1920 // The resultClass parameter implies subclasses, so retrieve them
1921 Array<CIMName> resultClassList;
1922 if (!resultClass.isNull())
1923 {
|
1924 kumpf 1.192 _rep->_nameSpaceManager.getSubClassNames(
|
1925 kumpf 1.93 nameSpace, resultClass, true, resultClassList);
1926 resultClassList.append(resultClass);
1927 }
1928
|
1929 kumpf 1.80 //
1930 // ATTN-CAKG-P2-20020726: The following condition does not correctly
1931 // distinguish instanceNames from classNames in every case
1932 // The instanceName of a singleton instance of a keyless class also
1933 // has no key bindings
1934 //
1935 if (objectName.getKeyBindings ().size () == 0)
|
1936 mike 1.48 {
|
1937 kumpf 1.93 CIMName className = objectName.getClassName();
1938
1939 Array<CIMName> classList;
|
1940 kumpf 1.192 _rep->_nameSpaceManager.getSuperClassNames(
|
1941 mike 1.184 nameSpace, className, classList);
|
1942 kumpf 1.93 classList.append(className);
1943
|
1944 kumpf 1.189 Array<CIMNamespaceName> nameSpaceList =
|
1945 kumpf 1.192 _rep->_nameSpaceManager.getSchemaNameSpaceNames(nameSpace);
|
1946 mike 1.48
|
1947 kumpf 1.189 for (Uint32 i = 0; i < nameSpaceList.size(); i++)
|
1948 kumpf 1.169 {
|
1949 kumpf 1.189 Array<String> associatorNamesForNameSpace;
1950
1951 _rep->_persistentStore->getClassAssociatorNames(
1952 nameSpaceList[i],
|
1953 kumpf 1.169 classList,
1954 assocClassList,
1955 resultClassList,
1956 role,
1957 resultRole,
|
1958 kumpf 1.189 associatorNamesForNameSpace);
1959
1960 associatorNames.appendArray(associatorNamesForNameSpace);
|
1961 kumpf 1.169 }
|
1962 mike 1.48 }
|
1963 kumpf 1.169 else
1964 {
|
1965 kumpf 1.192 _rep->_nameSpaceManager.validateClass(
|
1966 kumpf 1.189 nameSpace, objectName.getClassName());
|
1967 mike 1.48
|
1968 kumpf 1.189 _rep->_persistentStore->getInstanceAssociatorNames(
1969 nameSpace,
|
1970 mike 1.51 objectName,
|
1971 kumpf 1.93 assocClassList,
1972 resultClassList,
|
1973 mike 1.51 role,
1974 resultRole,
1975 associatorNames);
|
1976 mike 1.48 }
1977
|
1978 kumpf 1.68 Array<CIMObjectPath> result;
|
1979 mike 1.48
1980 for (Uint32 i = 0, n = associatorNames.size(); i < n; i++)
1981 {
|
1982 kumpf 1.68 CIMObjectPath r = associatorNames[i];
|
1983 mike 1.48
1984 if (r.getHost().size() == 0)
1985 r.setHost(System::getHostName());
1986
|
1987 kumpf 1.79 if (r.getNameSpace().isNull())
|
1988 mike 1.48 r.setNameSpace(nameSpace);
1989
|
1990 mike 1.51 result.append(r);
|
1991 mike 1.48 }
1992
|
1993 kumpf 1.58 PEG_METHOD_EXIT();
|
1994 mike 1.48 return result;
1995 }
1996
|
1997 kumpf 1.71 Array<CIMObject> CIMRepository::references(
|
1998 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
1999 kumpf 1.68 const CIMObjectPath& objectName,
|
2000 kumpf 1.85 const CIMName& resultClass,
|
2001 mike 1.48 const String& role,
2002 Boolean includeQualifiers,
2003 Boolean includeClassOrigin,
|
2004 mike 1.51 const CIMPropertyList& propertyList)
|
2005 mike 1.48 {
|
2006 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::references");
2007
|
2008 mike 1.184 ReadLock lock(_rep->_lock);
|
2009 kumpf 1.104
2010 Array<CIMObjectPath> names = _referenceNames(
|
2011 mike 1.51 nameSpace,
2012 objectName,
2013 resultClass,
2014 role);
|
2015 mike 1.48
|
2016 kumpf 1.71 Array<CIMObject> result;
|
2017 mike 1.48
2018 for (Uint32 i = 0, n = names.size(); i < n; i++)
2019 {
|
2020 kumpf 1.85 CIMNamespaceName tmpNameSpace = names[i].getNameSpace();
|
2021 mike 1.48
|
2022 kumpf 1.85 if (tmpNameSpace.isNull())
|
2023 mike 1.51 tmpNameSpace = nameSpace;
|
2024 mike 1.48
|
2025 mike 1.51 // ATTN: getInstance() should this be able to handle instance names
2026 // with host names and namespaces?
|
2027 mike 1.48
|
2028 kumpf 1.68 CIMObjectPath tmpRef = names[i];
|
2029 mike 1.51 tmpRef.setHost(String());
|
2030 kumpf 1.95 tmpRef.setNameSpace(CIMNamespaceName());
|
2031 mike 1.51
|
2032 kumpf 1.80 //
2033 // ATTN-CAKG-P2-20020726: The following condition does not correctly
2034 // distinguish instanceNames from classNames in every case
2035 // The instanceName of a singleton instance of a keyless class also
2036 // has no key bindings
2037 //
2038 if (objectName.getKeyBindings ().size () == 0)
|
2039 mike 1.51 {
|
2040 kumpf 1.104 CIMClass cimClass = _getClass(
|
2041 mike 1.51 tmpNameSpace,
2042 tmpRef.getClassName(),
2043 false,
2044 includeQualifiers,
2045 includeClassOrigin,
2046 propertyList);
2047
|
2048 kumpf 1.71 CIMObject cimObject = CIMObject (cimClass);
2049 cimObject.setPath (names[i]);
2050 result.append (cimObject);
|
2051 mike 1.51 }
2052 else
2053 {
|
2054 kumpf 1.104 CIMInstance instance = _getInstance(
|
2055 mike 1.51 tmpNameSpace,
2056 tmpRef,
2057 false,
2058 includeQualifiers,
2059 includeClassOrigin,
|
2060 kumpf 1.191 propertyList,
2061 true);
|
2062 mike 1.48
|
2063 kumpf 1.71 CIMObject cimObject = CIMObject (instance);
2064 cimObject.setPath (names[i]);
2065 result.append (cimObject);
|
2066 mike 1.51 }
|
2067 mike 1.48 }
2068
|
2069 kumpf 1.58 PEG_METHOD_EXIT();
|
2070 mike 1.48 return result;
2071 }
2072
|
2073 kumpf 1.68 Array<CIMObjectPath> CIMRepository::referenceNames(
|
2074 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
2075 kumpf 1.68 const CIMObjectPath& objectName,
|
2076 kumpf 1.85 const CIMName& resultClass,
|
2077 mike 1.48 const String& role)
2078 {
|
2079 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::referenceNames");
2080
|
2081 mike 1.184 ReadLock lock(_rep->_lock);
|
2082 kumpf 1.104 Array<CIMObjectPath> result = _referenceNames(
2083 nameSpace, objectName, resultClass, role);
2084
2085 PEG_METHOD_EXIT();
2086 return result;
2087 }
2088
2089 Array<CIMObjectPath> CIMRepository::_referenceNames(
2090 const CIMNamespaceName& nameSpace,
2091 const CIMObjectPath& objectName,
2092 const CIMName& resultClass,
2093 const String& role)
2094 {
2095 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_referenceNames");
2096
|
2097 mike 1.48 Array<String> tmpReferenceNames;
2098
|
2099 kumpf 1.93 // The resultClass parameter implies subclasses, so retrieve them
2100 Array<CIMName> resultClassList;
|
2101 a.dunfey 1.120
|
2102 kumpf 1.169 try
|
2103 kumpf 1.93 {
|
2104 kumpf 1.169 if (!resultClass.isNull())
2105 {
|
2106 kumpf 1.192 _rep->_nameSpaceManager.getSubClassNames(
|
2107 kumpf 1.169 nameSpace, resultClass, true, resultClassList);
2108 resultClassList.append(resultClass);
2109 }
|
2110 karl 1.86
|
2111 kumpf 1.169 // ATTN-CAKG-P2-20020726: The following condition does not correctly
2112 // distinguish instanceNames from classNames in every case
2113 // The instanceName of a singleton instance of a keyless class also
2114 // has no key bindings
2115 //
2116 if (objectName.getKeyBindings ().size () == 0)
2117 {
2118 CIMName className = objectName.getClassName();
|
2119 kumpf 1.93
|
2120 kumpf 1.169 Array<CIMName> classList;
|
2121 kumpf 1.192 _rep->_nameSpaceManager.getSuperClassNames(
|
2122 kumpf 1.169 nameSpace, className, classList);
2123 classList.append(className);
|
2124 kumpf 1.93
|
2125 kumpf 1.189 Array<CIMNamespaceName> nameSpaceList =
|
2126 kumpf 1.192 _rep->_nameSpaceManager.getSchemaNameSpaceNames(nameSpace);
|
2127 mike 1.48
|
2128 kumpf 1.189 for (Uint32 i = 0; i < nameSpaceList.size(); i++)
|
2129 kumpf 1.169 {
|
2130 kumpf 1.189 Array<String> referenceNamesForNameSpace;
2131
2132 _rep->_persistentStore->getClassReferenceNames(
2133 nameSpaceList[i],
2134 classList,
2135 resultClassList,
2136 role,
2137 referenceNamesForNameSpace);
|
2138 schuur 1.112
|
2139 kumpf 1.189 tmpReferenceNames.appendArray(referenceNamesForNameSpace);
|
2140 kumpf 1.169 }
|
2141 mike 1.51 }
|
2142 kumpf 1.169 else
2143 {
|
2144 kumpf 1.192 _rep->_nameSpaceManager.validateClass(
|
2145 kumpf 1.189 nameSpace, objectName.getClassName());
|
2146 schuur 1.112
|
2147 kumpf 1.189 _rep->_persistentStore->getInstanceReferenceNames(
2148 nameSpace,
|
2149 kumpf 1.169 objectName,
2150 resultClassList,
2151 role,
|
2152 kumpf 1.189 tmpReferenceNames);
|
2153 mike 1.51 }
|
2154 mike 1.48 }
|
2155 kumpf 1.169 catch (const CIMException& exception)
|
2156 kumpf 1.142 {
|
2157 kumpf 1.169 if (exception.getCode() == CIM_ERR_INVALID_CLASS)
2158 {
2159 throw PEGASUS_CIM_EXCEPTION(
2160 CIM_ERR_INVALID_PARAMETER, exception.getMessage());
2161 }
2162 else
2163 {
2164 throw;
2165 }
|
2166 kumpf 1.142 }
|
2167 mike 1.48
|
2168 kumpf 1.68 Array<CIMObjectPath> result;
|
2169 mike 1.48
2170 for (Uint32 i = 0, n = tmpReferenceNames.size(); i < n; i++)
2171 {
|
2172 kumpf 1.68 CIMObjectPath r = tmpReferenceNames[i];
|
2173 mike 1.48
2174 if (r.getHost().size() == 0)
2175 r.setHost(System::getHostName());
2176
|
2177 kumpf 1.79 if (r.getNameSpace().isNull())
|
2178 mike 1.48 r.setNameSpace(nameSpace);
2179
|
2180 mike 1.51 result.append(r);
|
2181 mike 1.48 }
2182
|
2183 kumpf 1.58 PEG_METHOD_EXIT();
|
2184 mike 1.48 return result;
2185 }
2186
2187 CIMValue CIMRepository::getProperty(
|
2188 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
2189 kumpf 1.68 const CIMObjectPath& instanceName,
|
2190 kumpf 1.85 const CIMName& propertyName)
|
2191 mike 1.48 {
|
2192 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::getProperty");
2193
|
2194 mike 1.184 ReadLock lock(_rep->_lock);
|
2195 kumpf 1.104
|
2196 mike 1.53 //
|
2197 kumpf 1.165 // Retrieve the specified instance
|
2198 mike 1.53 //
|
2199 mike 1.48
|
2200 kumpf 1.165 CIMInstance cimInstance = _getInstance(
|
2201 kumpf 1.191 nameSpace, instanceName, false, true, true, CIMPropertyList(), true);
|
2202 mike 1.48
|
2203 mike 1.53 //
|
2204 kumpf 1.165 // Get the requested property from the instance
|
2205 mike 1.53 //
|
2206 mike 1.48
2207 Uint32 pos = cimInstance.findProperty(propertyName);
2208
|
2209 mike 1.51 // ATTN: This breaks if the property is simply null
|
2210 kumpf 1.77 if (pos == PEG_NOT_FOUND)
|
2211 kumpf 1.58 {
2212 PEG_METHOD_EXIT();
|
2213 kumpf 1.149 throw PEGASUS_CIM_EXCEPTION(
2214 CIM_ERR_NO_SUCH_PROPERTY,
2215 propertyName.getString());
|
2216 kumpf 1.58 }
|
2217 mike 1.48
2218 CIMProperty prop = cimInstance.getProperty(pos);
2219
|
2220 mike 1.53 //
2221 // Return the value:
2222 //
|
2223 mike 1.48
|
2224 kumpf 1.58 PEG_METHOD_EXIT();
|
2225 mike 1.48 return prop.getValue();
2226 }
2227
2228 void CIMRepository::setProperty(
|
2229 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
2230 kumpf 1.68 const CIMObjectPath& instanceName,
|
2231 kumpf 1.85 const CIMName& propertyName,
|
2232 chuck 1.110 const CIMValue& newValue,
|
2233 kumpf 1.155 const ContentLanguageList& contentLangs)
|
2234 mike 1.48 {
|
2235 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::setProperty");
2236
|
2237 mike 1.184 // It is not necessary to control access to the ReadWriteSem lock here.
|
2238 kumpf 1.104 // This method calls modifyInstance, which does its own access control.
2239
|
2240 mike 1.51 //
2241 // Create the instance to pass to modifyInstance()
2242 //
|
2243 mike 1.53
|
2244 mike 1.51 CIMInstance instance(instanceName.getClassName());
2245 instance.addProperty(CIMProperty(propertyName, newValue));
|
2246 kumpf 1.70 instance.setPath (instanceName);
|
2247 mike 1.51
2248 //
2249 // Create the propertyList to pass to modifyInstance()
2250 //
|
2251 mike 1.53
|
2252 kumpf 1.79 Array<CIMName> propertyListArray;
|
2253 mike 1.51 propertyListArray.append(propertyName);
2254 CIMPropertyList propertyList(propertyListArray);
2255
2256 //
2257 // Modify the instance to set the value of the given property
2258 //
|
2259 kumpf 1.70 modifyInstance(nameSpace, instance, false, propertyList);
|
2260 kumpf 1.58
2261 PEG_METHOD_EXIT();
|
2262 mike 1.48 }
2263
2264 CIMQualifierDecl CIMRepository::getQualifier(
|
2265 kumpf 1.85 const CIMNamespaceName& nameSpace,
2266 const CIMName& qualifierName)
|
2267 mike 1.48 {
|
2268 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::getQualifier");
2269
|
2270 mike 1.184 ReadLock lock(_rep->_lock);
|
2271 kumpf 1.104 CIMQualifierDecl qualifierDecl = _getQualifier(nameSpace, qualifierName);
2272
2273 PEG_METHOD_EXIT();
2274 return qualifierDecl;
2275 }
2276
2277 CIMQualifierDecl CIMRepository::_getQualifier(
2278 const CIMNamespaceName& nameSpace,
2279 const CIMName& qualifierName)
2280 {
2281 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_getQualifier");
2282
|
2283 kumpf 1.189 CIMQualifierDecl qualifierDecl;
|
2284 mike 1.48
|
2285 kumpf 1.189 String qualifierCacheKey = _getCacheKey(nameSpace, qualifierName);
|
2286 mike 1.48
|
2287 kumpf 1.189 // Check the cache first:
|
2288 mike 1.48
|
2289 kumpf 1.189 if (!_qualifierCache.get(qualifierCacheKey, qualifierDecl))
|
2290 mike 1.48 {
|
2291 kumpf 1.189 // Not in cache so load from disk:
2292
2293 Array<CIMNamespaceName> nameSpaceList =
|
2294 kumpf 1.192 _rep->_nameSpaceManager.getSchemaNameSpaceNames(nameSpace);
|
2295 mike 1.153
|
2296 kumpf 1.189 for (Uint32 i = 0; i < nameSpaceList.size(); i++)
|
2297 mike 1.153 {
|
2298 kumpf 1.189 qualifierDecl = _rep->_persistentStore->getQualifier(
2299 nameSpaceList[i], qualifierName);
|
2300 mike 1.153
|
2301 kumpf 1.189 if (!qualifierDecl.isUninitialized())
2302 {
2303 // Put in cache
2304 _qualifierCache.put(qualifierCacheKey, qualifierDecl);
|
2305 mike 1.153
|
2306 kumpf 1.189 PEG_METHOD_EXIT();
2307 return qualifierDecl;
2308 }
2309 }
|
2310 mike 1.153
|
2311 kumpf 1.58 PEG_METHOD_EXIT();
|
2312 kumpf 1.189 throw PEGASUS_CIM_EXCEPTION(
2313 CIM_ERR_NOT_FOUND, qualifierName.getString());
|
2314 mike 1.48 }
2315
|
2316 kumpf 1.58 PEG_METHOD_EXIT();
|
2317 mike 1.48 return qualifierDecl;
2318 }
2319
2320 void CIMRepository::setQualifier(
|
2321 kumpf 1.85 const CIMNamespaceName& nameSpace,
|
2322 chuck 1.110 const CIMQualifierDecl& qualifierDecl,
|
2323 kumpf 1.155 const ContentLanguageList& contentLangs)
|
2324 mike 1.48 {
|
2325 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::setQualifier");
|
2326 chuck 1.110
|
2327 mike 1.184 WriteLock lock(_rep->_lock);
2328 AutoFileLock fileLock(_rep->_lockFile);
|
2329 kumpf 1.104 _setQualifier(nameSpace, qualifierDecl);
2330
2331 PEG_METHOD_EXIT();
2332 }
2333
2334 void CIMRepository::_setQualifier(
2335 const CIMNamespaceName& nameSpace,
2336 const CIMQualifierDecl& qualifierDecl)
2337 {
2338 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::_setQualifier");
2339
|
2340 kumpf 1.192 _rep->_nameSpaceManager.checkSetOrDeleteQualifier(
|
2341 kumpf 1.189 nameSpace, qualifierDecl.getName());
|
2342 mike 1.48
|
2343 kumpf 1.189 _rep->_persistentStore->setQualifier(nameSpace, qualifierDecl);
|
2344 mike 1.48
|
2345 kumpf 1.189 String qualifierCacheKey =
2346 _getCacheKey(nameSpace, qualifierDecl.getName());
2347 _qualifierCache.put(qualifierCacheKey, (CIMQualifierDecl&)qualifierDecl);
|
2348 jim.wunderlich 1.136
|
2349 kumpf 1.58 PEG_METHOD_EXIT();
|
2350 mike 1.48 }
2351
2352 void CIMRepository::deleteQualifier(
|
2353 kumpf 1.85 const CIMNamespaceName& nameSpace,
2354 const CIMName& qualifierName)
|
2355 mike 1.48 {
|
2356 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::deleteQualifier");
2357
|
2358 mike 1.184 WriteLock lock(_rep->_lock);
2359 AutoFileLock fileLock(_rep->_lockFile);
|
2360 kumpf 1.104
|
2361 kumpf 1.192 _rep->_nameSpaceManager.checkSetOrDeleteQualifier(
|
2362 kumpf 1.189 nameSpace, qualifierName);
|
2363 mike 1.48
|
2364 kumpf 1.189 _rep->_persistentStore->deleteQualifier(nameSpace, qualifierName);
|
2365 mike 1.48
|
2366 kumpf 1.189 String qualifierCacheKey = _getCacheKey(nameSpace, qualifierName);
2367 _qualifierCache.evict(qualifierCacheKey);
|
2368 mike 1.153
|
2369 kumpf 1.58 PEG_METHOD_EXIT();
|
2370 mike 1.48 }
2371
2372 Array<CIMQualifierDecl> CIMRepository::enumerateQualifiers(
|
2373 kumpf 1.85 const CIMNamespaceName& nameSpace)
|
2374 mike 1.48 {
|
2375 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::enumerateQualifiers");
2376
|
2377 mike 1.184 ReadLock lock(_rep->_lock);
|
2378 kumpf 1.104
|
2379 kumpf 1.189 Array<CIMQualifierDecl> qualifiers;
|
2380 mike 1.48
|
2381 kumpf 1.192 _rep->_nameSpaceManager.validateNameSpace(nameSpace);
|
2382 mike 1.48
|
2383 kumpf 1.189 qualifiers = _rep->_persistentStore->enumerateQualifiers(nameSpace);
|
2384 mike 1.48
|
2385 kumpf 1.58 PEG_METHOD_EXIT();
|
2386 mike 1.48 return qualifiers;
2387 }
2388
|
2389 kumpf 1.189 void CIMRepository::createNameSpace(
2390 const CIMNamespaceName& nameSpace,
2391 const NameSpaceAttributes& attributes)
|
2392 mike 1.48 {
|
2393 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::createNameSpace");
2394
|
2395 mike 1.184 WriteLock lock(_rep->_lock);
2396 AutoFileLock fileLock(_rep->_lockFile);
|
2397 kumpf 1.189
2398 Boolean shareable = false;
2399 Boolean updatesAllowed = true;
2400 String parentNameSpace;
2401
2402 for (NameSpaceAttributes::Iterator i = attributes.start(); i; i++)
2403 {
2404 String key = i.key();
2405 if (String::equalNoCase(key, "shareable"))
2406 {
2407 if (String::equalNoCase(i.value(), "true"))
2408 shareable = true;
2409 }
2410 else if (String::equalNoCase(key, "updatesAllowed"))
2411 {
2412 if (String::equalNoCase(i.value(), "false"))
2413 updatesAllowed = false;
2414 }
2415 else if (String::equalNoCase(key, "parent"))
2416 {
2417 parentNameSpace = i.value();
2418 kumpf 1.189 }
2419 else
2420 {
2421 PEG_METHOD_EXIT();
2422 throw PEGASUS_CIM_EXCEPTION(
2423 CIM_ERR_NOT_SUPPORTED,
2424 nameSpace.getString() + " option not supported: " + key);
2425 }
2426 }
2427
|
2428 kumpf 1.192 _rep->_nameSpaceManager.createNameSpace(
|
2429 kumpf 1.189 nameSpace, shareable, updatesAllowed, parentNameSpace);
2430
2431 try
2432 {
2433 _rep->_persistentStore->createNameSpace(
2434 nameSpace, shareable, updatesAllowed, parentNameSpace);
2435 }
2436 catch (...)
2437 {
|
2438 kumpf 1.192 _rep->_nameSpaceManager.deleteNameSpace(nameSpace);
|
2439 kumpf 1.189 throw;
2440 }
|
2441 schuur 1.112
2442 PEG_METHOD_EXIT();
2443 }
2444
|
2445 kumpf 1.189 void CIMRepository::modifyNameSpace(
2446 const CIMNamespaceName& nameSpace,
2447 const NameSpaceAttributes& attributes)
|
2448 schuur 1.112 {
2449 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::modifyNameSpace");
2450
|
2451 mike 1.184 WriteLock lock(_rep->_lock);
2452 AutoFileLock fileLock(_rep->_lockFile);
|
2453 kumpf 1.189
2454 Boolean shareable = false;
2455 Boolean updatesAllowed = true;
2456
2457 for (NameSpaceAttributes::Iterator i = attributes.start(); i; i++)
2458 {
2459 String key = i.key();
2460 if (String::equalNoCase(key, "shareable"))
2461 {
2462 if (String::equalNoCase(i.value(), "true"))
2463 shareable = true;
2464 }
2465 else if (String::equalNoCase(key, "updatesAllowed"))
2466 {
2467 if (String::equalNoCase(i.value(),"false"))
2468 updatesAllowed = false;
2469 }
2470 else
2471 {
2472 PEG_METHOD_EXIT();
2473 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
2474 kumpf 1.189 nameSpace.getString() + " option not supported: " + key);
2475 }
2476 }
2477
|
2478 kumpf 1.192 _rep->_nameSpaceManager.validateNameSpace(nameSpace);
|
2479 kumpf 1.189
2480 if (!shareable)
2481 {
2482 // Check for dependent namespaces
2483
2484 CIMNamespaceName dependentNameSpaceName;
2485
|
2486 kumpf 1.192 if (_rep->_nameSpaceManager.hasDependentNameSpace(
|
2487 kumpf 1.189 nameSpace, dependentNameSpaceName))
2488 {
2489 PEG_METHOD_EXIT();
2490 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
2491 "Namespace " + nameSpace.getString() +
2492 " has dependent namespace " +
2493 dependentNameSpaceName.getString());
2494 }
2495 }
2496
2497 _rep->_persistentStore->modifyNameSpace(
2498 nameSpace, shareable, updatesAllowed);
2499
|
2500 kumpf 1.192 _rep->_nameSpaceManager.modifyNameSpace(
|
2501 kumpf 1.189 nameSpace, shareable, updatesAllowed);
|
2502 kumpf 1.58
2503 PEG_METHOD_EXIT();
|
2504 mike 1.48 }
2505
|
2506 kumpf 1.85 Array<CIMNamespaceName> CIMRepository::enumerateNameSpaces() const
|
2507 mike 1.48 {
|
2508 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::enumerateNameSpaces");
2509
|
2510 mike 1.184 ReadLock lock(const_cast<ReadWriteSem&>(_rep->_lock));
|
2511 kumpf 1.104
|
2512 kumpf 1.85 Array<CIMNamespaceName> nameSpaceNames;
|
2513 kumpf 1.192 _rep->_nameSpaceManager.getNameSpaceNames(nameSpaceNames);
|
2514 kumpf 1.58
2515 PEG_METHOD_EXIT();
|
2516 mike 1.48 return nameSpaceNames;
2517 }
2518
|
2519 kumpf 1.85 void CIMRepository::deleteNameSpace(const CIMNamespaceName& nameSpace)
|
2520 mike 1.48 {
|
2521 kumpf 1.58 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::deleteNameSpace");
2522
|
2523 mike 1.184 WriteLock lock(_rep->_lock);
2524 AutoFileLock fileLock(_rep->_lockFile);
|
2525 kumpf 1.58
|
2526 kumpf 1.189 // Check for dependent namespaces
|
2527 mike 1.48
|
2528 kumpf 1.189 CIMNamespaceName dependentNameSpaceName;
|
2529 schuur 1.112
|
2530 kumpf 1.192 if (_rep->_nameSpaceManager.hasDependentNameSpace(
|
2531 kumpf 1.189 nameSpace, dependentNameSpaceName))
2532 {
2533 PEG_METHOD_EXIT();
2534 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
2535 "Namespace " + nameSpace.getString() +
2536 " has dependent namespace " +
2537 dependentNameSpaceName.getString());
2538 }
|
2539 schuur 1.115
|
2540 kumpf 1.189 // Make sure the namespace is empty
|
2541 mike 1.51
|
2542 kumpf 1.189 if (!_rep->_persistentStore->isNameSpaceEmpty(nameSpace))
2543 {
2544 PEG_METHOD_EXIT();
2545 throw NonEmptyNameSpace(nameSpace.getString());
2546 }
|
2547 kumpf 1.58
|
2548 kumpf 1.189 _rep->_persistentStore->deleteNameSpace(nameSpace);
|
2549 mike 1.53
|
2550 kumpf 1.192 _rep->_nameSpaceManager.deleteNameSpace(nameSpace);
|
2551 kumpf 1.58
2552 PEG_METHOD_EXIT();
|
2553 mike 1.48 }
2554
|
2555 kumpf 1.189 Boolean CIMRepository::getNameSpaceAttributes(const CIMNamespaceName& nameSpace,
2556 NameSpaceAttributes& attributes)
|
2557 mike 1.48 {
|
2558 kumpf 1.189 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::deleteNameSpace");
|
2559 kumpf 1.58
|
2560 kumpf 1.189 ReadLock lock(const_cast<ReadWriteSem&>(_rep->_lock));
2561 attributes.clear();
|
2562 mike 1.51
|
2563 kumpf 1.189 Boolean shareable;
2564 Boolean updatesAllowed;
2565 String parent;
|
2566 mike 1.51
|
2567 kumpf 1.192 if (!_rep->_nameSpaceManager.getNameSpaceAttributes(
|
2568 kumpf 1.189 nameSpace, shareable, updatesAllowed, parent))
|
2569 kumpf 1.58 {
2570 PEG_METHOD_EXIT();
|
2571 mike 1.51 return false;
|
2572 kumpf 1.58 }
|
2573 mike 1.51
|
2574 kumpf 1.189 attributes.insert("name", nameSpace.getString());
2575
2576 if (shareable)
2577 attributes.insert("shareable", "true");
2578 else
2579 attributes.insert("shareable", "false");
2580
2581 if (updatesAllowed)
2582 attributes.insert("updatesAllowed", "true");
2583 else
2584 attributes.insert("updatesAllowed", "false");
|
2585 mike 1.51
|
2586 kumpf 1.189 if (parent.size())
2587 attributes.insert("parent", parent);
|
2588 mike 1.51
|
2589 kumpf 1.58 PEG_METHOD_EXIT();
|
2590 mike 1.51 return true;
|
2591 mike 1.48 }
2592
|
2593 kumpf 1.189 Boolean CIMRepository::isRemoteNameSpace(
2594 const CIMNamespaceName& nameSpaceName,
2595 String& remoteInfo)
2596 {
2597 PEG_METHOD_ENTER(TRC_REPOSITORY, "CIMRepository::isRemoteNamespace");
2598 ReadLock lock(const_cast<ReadWriteSem&>(_rep->_lock));
2599 PEG_METHOD_EXIT();
|
2600 kumpf 1.192 return _rep->_nameSpaceManager.isRemoteNameSpace(
|
2601 kumpf 1.189 nameSpaceName, remoteInfo);
2602 }
|
2603 bob 1.49
|
2604 dave.sudlik 1.154 #ifdef PEGASUS_DEBUG
|
2605 kumpf 1.169 void CIMRepository::DisplayCacheStatistics()
|
2606 dave.sudlik 1.154 {
2607 #ifdef PEGASUS_USE_CLASS_CACHE
2608 cout << "Repository Class Cache Statistics:" << endl;
2609 _classCache.DisplayCacheStatistics();
2610 #endif
2611 cout << "Repository Qualifier Cache Statistics:" << endl;
2612 _qualifierCache.DisplayCacheStatistics();
2613 }
2614 #endif
2615
|
2616 mike 1.184 void CIMRepository::getSubClassNames(
2617 const CIMNamespaceName& nameSpaceName,
2618 const CIMName& className,
2619 Boolean deepInheritance,
2620 Array<CIMName>& subClassNames) const
2621 {
2622 ReadLock lock(const_cast<ReadWriteSem&>(_rep->_lock));
|
2623 kumpf 1.192 _rep->_nameSpaceManager.getSubClassNames(
|
2624 kumpf 1.189 nameSpaceName, className, deepInheritance, subClassNames);
|
2625 mike 1.184 }
2626
2627 void CIMRepository::getSuperClassNames(
2628 const CIMNamespaceName& nameSpaceName,
2629 const CIMName& className,
2630 Array<CIMName>& subClassNames) const
2631 {
2632 ReadLock lock(const_cast<ReadWriteSem&>(_rep->_lock));
|
2633 kumpf 1.192 _rep->_nameSpaceManager.getSuperClassNames(
|
2634 mike 1.184 nameSpaceName, className, subClassNames);
2635 }
2636
2637 Boolean CIMRepository::isDefaultInstanceProvider()
2638 {
2639 return _rep->_isDefaultInstanceProvider;
2640 }
2641
|
2642 mike 1.48 PEGASUS_NAMESPACE_END
|