1 martin 1.82 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.83 //
|
3 martin 1.82 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.83 //
|
10 martin 1.82 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.83 //
|
17 martin 1.82 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.83 //
|
20 martin 1.82 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.83 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.82 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.83 //
|
28 martin 1.82 //////////////////////////////////////////////////////////////////////////
|
29 mike 1.22 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
|
32 kumpf 1.32 #include "CIMInstanceRep.h"
|
33 mike 1.22 #include "CIMInstance.h"
|
34 kumpf 1.32 #include "CIMClassRep.h"
|
35 kumpf 1.34 #include "CIMScope.h"
|
36 mike 1.22 #include "DeclContext.h"
|
37 kumpf 1.42 #include "Resolver.h"
|
38 mike 1.22 #include "CIMName.h"
|
39 kumpf 1.38 #include "Constants.h"
|
40 mike 1.69 #include "StrLit.h"
|
41 mike 1.22
|
42 mike 1.29 PEGASUS_USING_STD;
43
|
44 mike 1.22 PEGASUS_NAMESPACE_BEGIN
45
|
46 kumpf 1.39 CIMInstanceRep::CIMInstanceRep(const CIMObjectPath& reference)
|
47 mike 1.29 : CIMObjectRep(reference)
|
48 mike 1.22 {
|
49 mike 1.24
|
50 mike 1.22 }
51
52 CIMInstanceRep::~CIMInstanceRep()
53 {
54
55 }
56
57 void CIMInstanceRep::resolve(
58 DeclContext* context,
|
59 kumpf 1.44 const CIMNamespaceName& nameSpace,
|
60 mike 1.29 CIMConstClass& cimClassOut,
61 Boolean propagateQualifiers)
|
62 mike 1.22 {
63 // ATTN: Verify that references are initialized.
64
65 if (!context)
|
66 kumpf 1.72 throw NullPointer();
|
67 mike 1.22
68 //----------------------------------------------------------------------
69 // First obtain the class:
70 //----------------------------------------------------------------------
71
72 CIMConstClass cimClass =
|
73 kumpf 1.72 context->lookupClass(nameSpace, _reference.getClassName());
|
74 mike 1.22
|
75 kumpf 1.45 if (cimClass.isUninitialized())
|
76 kumpf 1.72 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS,
|
77 kumpf 1.50 _reference.getClassName().getString ());
|
78 mike 1.22
79 cimClassOut = cimClass;
80
81 //----------------------------------------------------------------------
82 // Disallow instantiation of abstract classes.
83 //----------------------------------------------------------------------
84
85 if (cimClass.isAbstract())
|
86 kumpf 1.72 throw InstantiatedAbstractClass(_reference.getClassName().getString ());
|
87 mike 1.22
88 //----------------------------------------------------------------------
|
89 mike 1.29 // Validate and propagate qualifiers.
|
90 mike 1.22 //----------------------------------------------------------------------
91 _qualifiers.resolve(
|
92 kumpf 1.72 context,
93 nameSpace,
|
94 kumpf 1.53 (cimClass.isAssociation()) ? CIMScope::ASSOCIATION : CIMScope::CLASS,
|
95 kumpf 1.72 false,
96 cimClass._rep->_qualifiers,
97 propagateQualifiers);
|
98 mike 1.22
99 //----------------------------------------------------------------------
100 // First iterate the properties of this instance and verify that
101 // each one is defined in the class and then resolve each one.
102 //----------------------------------------------------------------------
103
|
104 kumpf 1.44 CIMName className = cimClass.getClassName();
|
105 mike 1.22
106 for (Uint32 i = 0, n = _properties.size(); i < n; i++)
107 {
|
108 kumpf 1.72 CIMProperty& property = _properties[i];
|
109 mike 1.22
|
110 kumpf 1.72 Uint32 index = cimClass.findProperty(property.getName());
|
111 mike 1.22
|
112 kumpf 1.72 if (index == PEG_NOT_FOUND)
|
113 kumpf 1.31 {
114 //
115 // Allow addition of Creator property to Indication Subscription,
116 // Filter and Handler instances
117 //
|
118 kumpf 1.72 // l10n add language property support
119 if (!(((className.equal
|
120 kumpf 1.50 (CIMName (PEGASUS_CLASSNAME_INDSUBSCRIPTION))) ||
|
121 kumpf 1.72 (className.equal
|
122 yi.zhou 1.63 (CIMName (PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION))) ||
|
123 kumpf 1.72 (className.equal
|
124 kumpf 1.50 (CIMName (PEGASUS_CLASSNAME_INDHANDLER_CIMXML))) ||
|
125 anusha.kandepu 1.87 #ifdef PEGASUS_ENABLE_PROTOCOL_WSMAN
126 (className.equal
127 (CIMName (PEGASUS_CLASSNAME_INDHANDLER_WSMAN))) ||
128 #endif
|
129 kumpf 1.72 (className.equal
|
130 tony 1.56 (CIMName (PEGASUS_CLASSNAME_LSTNRDST_CIMXML))) ||
|
131 kumpf 1.72 (className.equal
|
132 kumpf 1.50 (CIMName (PEGASUS_CLASSNAME_INDHANDLER_SNMP))) ||
|
133 yi.zhou 1.63 #ifdef PEGASUS_ENABLE_SYSTEM_LOG_HANDLER
|
134 kumpf 1.72 (className.equal
|
135 yi.zhou 1.63 (CIMName (PEGASUS_CLASSNAME_LSTNRDST_SYSTEM_LOG))) ||
136 #endif
|
137 yi.zhou 1.64 #ifdef PEGASUS_ENABLE_EMAIL_HANDLER
|
138 kumpf 1.72 (className.equal
|
139 yi.zhou 1.64 (CIMName (PEGASUS_CLASSNAME_LSTNRDST_EMAIL))) ||
140 #endif
|
141 dev.meetei 1.88 (className.equal
142 (CIMName (PEGASUS_CLASSNAME_LSTNRDST_FILE))) ||
143
|
144 kumpf 1.50 (className.equal (CIMName (PEGASUS_CLASSNAME_INDFILTER)))) &&
|
145 kumpf 1.72 ((property.getName ().equal
|
146 chuck 1.54 (CIMName (PEGASUS_PROPERTYNAME_INDSUB_CREATOR))) ||
|
147 kumpf 1.72 (property.getName ().equal
|
148 chuck 1.54 (CIMName (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS))) ||
|
149 kumpf 1.72 (property.getName ().equal
|
150 venkat.puvvada 1.84 (CIMName (PEGASUS_PROPERTYNAME_LSTNRDST_CREATIONTIME))) ||
151 (property.getName ().equal
|
152 chuck 1.54 (CIMName (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS))))))
|
153 kumpf 1.31 {
|
154 kumpf 1.72 throw NoSuchProperty(property.getName().getString ());
|
155 kumpf 1.31 }
156 }
157 else
158 {
|
159 kumpf 1.72 // resolve the property
160 Resolver::resolveProperty (property, context, nameSpace, true,
|
161 kumpf 1.48 cimClass.getProperty (index), propagateQualifiers);
|
162 kumpf 1.31 }
|
163 mike 1.22 }
164
165 //----------------------------------------------------------------------
166 // Inject all properties from the class that are not included in the
167 // instance. Copy over the class-origin and set the propagated flag
|
168 karl 1.58 // to true. NOTE: The propagated flag indicates that the property
169 // was not part of the property set input with the create and
|
170 kumpf 1.72 // was inherited from the default in the class (see cimxml spec sect 3.1.5)
|
171 mike 1.22 //----------------------------------------------------------------------
172
173 for (Uint32 i = 0, m = 0, n = cimClass.getPropertyCount(); i < n; i++)
174 {
|
175 kumpf 1.72 CIMConstProperty property = cimClass.getProperty(i);
176 const CIMName& name = property.getName();
177
178 // See if this instance already contains a property with this name:
179
180 Boolean found = false;
181
|
182 kumpf 1.80 for (Uint32 j = m, s = _properties.size(); j < s; j++)
|
183 kumpf 1.72 {
184 if (name.equal(_properties[j].getName()))
185 {
186 found = true;
187 break;
188 }
189 }
190
191 if (!found)
192 {
|
193 kumpf 1.81 CIMProperty p;
194 if (propagateQualifiers)
195 {
196 p = property.clone();
197 }
198 else
199 {
200 p = CIMProperty(
201 property.getName(),
202 property.getValue(),
203 property.getArraySize(),
204 property.getReferenceClassName(),
205 property.getClassOrigin(),
206 property.getPropagated());
207 }
|
208 kumpf 1.72 p.setPropagated(true);
209 _properties.insert(m++, p);
210 }
|
211 mike 1.22 }
212 }
213
|
214 mike 1.24 CIMInstanceRep::CIMInstanceRep(const CIMInstanceRep& x) : CIMObjectRep(x)
|
215 mike 1.22 {
216 }
217
|
218 kumpf 1.46 CIMObjectPath CIMInstanceRep::buildPath(
|
219 mike 1.22 const CIMConstClass& cimClass) const
220 {
221 //--------------------------------------------------------------------------
222 // Get class name:
223 //--------------------------------------------------------------------------
224
|
225 kumpf 1.44 CIMName className = getClassName();
|
226 mike 1.22
227 //--------------------------------------------------------------------------
228 // Get key names:
229 //--------------------------------------------------------------------------
230
|
231 kumpf 1.44 Array<CIMName> keyNames;
|
232 mike 1.22 cimClass.getKeyNames(keyNames);
233
234 if (keyNames.size() == 0)
|
235 kumpf 1.72 return CIMObjectPath("", CIMNamespaceName(), className);
|
236 mike 1.22
237 //--------------------------------------------------------------------------
238 // Get type and value for each key (building up key bindings):
239 //--------------------------------------------------------------------------
240
|
241 kumpf 1.49 Array<CIMKeyBinding> keyBindings;
|
242 mike 1.22
243 for (Uint32 i = 0, n = keyNames.size(); i < n; i++)
244 {
|
245 kumpf 1.72 const CIMName& keyName = keyNames[i];
|
246 mike 1.22
|
247 kumpf 1.72 Uint32 index = findProperty(keyName);
|
248 kumpf 1.66 if (index == PEG_NOT_FOUND)
249 {
250 throw NoSuchProperty(keyName.getString());
251 }
|
252 mike 1.22
|
253 kumpf 1.72 CIMConstProperty tmp = getProperty(index);
|
254 marek 1.78 keyBindings.append(CIMKeyBinding(keyName, tmp.getValue()));
|
255 mike 1.22 }
256
|
257 kumpf 1.55 return CIMObjectPath(String(), CIMNamespaceName(), className, keyBindings);
|
258 mike 1.22 }
|
259 anusha.kandepu 1.85 void CIMInstanceRep::filter(
|
260 marek 1.89 Boolean,
261 Boolean,
262 const CIMPropertyList&)
|
263 anusha.kandepu 1.85 {
264 return;
265 }
|
266 mike 1.22
267 PEGASUS_NAMESPACE_END
|