1 a.dunfey 1.1 //%2006////////////////////////////////////////////////////////////////////////
2 //
3 // 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 // IBM Corp.; EMC Corporation, The Open Group.
7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
11 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
13 //
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 //
21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 a.dunfey 1.1 // 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 s.manicka 1.2.4.2 //=============================================================================
|
31 a.dunfey 1.1
32
33 ///////////////////////////////////////////////////////////////////////////////
34 // Interop Provider - This provider services those classes from the
35 // DMTF Interop schema in an implementation compliant with the SMI-S v1.1
36 // Server Profile
37 //
38 // Please see PG_ServerProfile20.mof in the directory
|
39 s.manicka 1.2.4.2 // $(PEGASUS_ROOT)/Schemas/Pegasus/InterOp/VER20 for details regarding the
|
40 a.dunfey 1.1 // classes supported by this control provider.
41 //
42 // Interop forces all creates to the PEGASUS_NAMESPACENAME_INTEROP
43 // namespace. There is a test on each operation that returns
44 // the Invalid Class CIMDError
45 // This is a control provider and as such uses the Tracer functions
46 // for data and function traces. Since we do not expect high volume
47 // use we added a number of traces to help diagnostics.
48 ///////////////////////////////////////////////////////////////////////////////
49
50 #include "InteropProvider.h"
51 #include "InteropProviderUtils.h"
52 #include "InteropConstants.h"
53
54 PEGASUS_USING_STD;
|
55 a.dunfey 1.2 PEGASUS_NAMESPACE_BEGIN
|
56 a.dunfey 1.1
57 /*****************************************************************************
58 *
59 * Implementation of AssociationProvider associators method
60 *
61 *****************************************************************************/
62 void InteropProvider::associators(
63 const OperationContext & context,
64 const CIMObjectPath & objectName,
65 const CIMName & associationClass,
66 const CIMName & resultClass,
67 const String & role,
68 const String & resultRole,
69 const Boolean includeQualifiers,
70 const Boolean includeClassOrigin,
71 const CIMPropertyList & propertyList,
72 ObjectResponseHandler & handler)
73 {
74 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
75 "InteropProvider::associators()");
|
76 a.dunfey 1.2 initProvider();
|
77 marek 1.2.4.1 PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
|
78 s.manicka 1.2.4.2 "%s associators. objectName= %s, assocClass= %s resultClass= %s "
79 "role= %s resultRole %s, includeQualifiers= %s, "
80 "includeClassOrigin= %s, PropertyList= %s",
|
81 a.dunfey 1.1 thisProvider,
82 (const char *)objectName.toString().getCString(),
83 (const char *)associationClass.getString().getCString(),
84 (const char *)resultClass.getString().getCString(),
85 (const char *)role.getCString(),
86 (const char *)resultRole.getCString(),
87 boolToString(includeQualifiers),
88 boolToString(includeClassOrigin),
|
89 marek 1.2.4.1 (const char *)propertyListToString(propertyList).getCString()));
|
90 a.dunfey 1.1
91 handler.processing();
92 String originRole = role;
93 String targetRole = resultRole;
|
94 s.manicka 1.2.4.2 Uint32 numIterations = 1;
|
95 a.dunfey 1.1 //
96 // The localReferences call retrieves instances of the desired association
97 // class and sets the originRole and targetRole properties if currently
98 // empty.
99 //
|
100 s.manicka 1.2.4.2 if (associationClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
101 {
102 if (originRole.size() == 0 && targetRole.size() == 0)
103 {
104 originRole = String("Antecedent");
105 targetRole = String("Dependent");
106 numIterations = 2;
107 }
108 }
109 for (Uint32 i = 0; i < numIterations; ++i)
110 {
111 Array<CIMInstance> refs = localReferences(
112 context,
113 objectName,
114 associationClass,
115 originRole,
116 targetRole,
117 CIMPropertyList(),
118 resultClass);
119 for (Uint32 i = 0, n = refs.size(); i < n; ++i)
120 {
121 s.manicka 1.2.4.2 CIMInstance & currentRef = refs[i];
122 // Retrieve the "other side" of the association
123 CIMObjectPath currentTarget = getRequiredValue<CIMObjectPath>(
124 currentRef,
125 targetRole);
126 CIMInstance tmpInstance = localGetInstance(
127 context,
128 currentTarget,
129 propertyList);
130 tmpInstance.setPath(currentTarget);
131 handler.deliver(tmpInstance);
132 }
133 if (numIterations == 2)
134 {
135 originRole = String("Dependent");
136 targetRole = String("Antecedent");
137 }
|
138 a.dunfey 1.1 }
139 handler.complete();
140
141 PEG_METHOD_EXIT();
142 }
143
144 /*****************************************************************************
145 *
146 * Implementation of AssociationProvider associatorNames method
147 *
148 *****************************************************************************/
149 void InteropProvider::associatorNames(
150 const OperationContext & context,
151 const CIMObjectPath & objectName,
152 const CIMName & associationClass,
153 const CIMName & resultClass,
154 const String & role,
155 const String & resultRole,
156 ObjectPathResponseHandler & handler)
157 {
158 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
159 a.dunfey 1.1 "InteropProvider::associatorNames()");
|
160 a.dunfey 1.2 initProvider();
|
161 marek 1.2.4.1 PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
|
162 s.manicka 1.2.4.2 "%s associatorNames.objectName= %s, assocClass= %s resultClass= %s "
163 "role= %s resultRole = %s",
|
164 a.dunfey 1.1 thisProvider,
165 (const char *)objectName.toString().getCString(),
166 (const char *)associationClass.getString().getCString(),
167 (const char *)resultClass.getString().getCString(),
168 (const char *)role.getCString(),
|
169 marek 1.2.4.1 (const char *)resultRole.getCString()));
|
170 a.dunfey 1.1
171 handler.processing();
|
172 s.manicka 1.2.4.2 String originRole = role;
|
173 a.dunfey 1.1 String targetRole = resultRole;
|
174 s.manicka 1.2.4.2 Uint32 numIterations = 1;
|
175 a.dunfey 1.1 //
176 // The localReferences call retrieves instances of the desired association
177 // class and sets the originRole and targetRole properties if currently
178 // empty.
179 //
|
180 s.manicka 1.2.4.2 if (associationClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
181 {
182 if (originRole.size() == 0 && targetRole.size() == 0)
183 {
184 originRole = String("Antecedent");
185 targetRole = String("Dependent");
186 numIterations = 2;
187 }
188 }
189 for (Uint32 i = 0; i < numIterations; ++i)
190 {
191 Array<CIMInstance> refs = localReferences(
192 context,
193 objectName,
194 associationClass,
195 originRole,
196 targetRole,
197 CIMPropertyList(),
198 resultClass);
199 for (Uint32 i = 0, n = refs.size(); i < n; ++i)
200 {
201 s.manicka 1.2.4.2 CIMInstance & currentRef = refs[i];
202 CIMObjectPath currentTarget = getRequiredValue<CIMObjectPath>(
203 currentRef,
204 targetRole);
205 handler.deliver(currentTarget);
206 }
207 if (numIterations == 2)
208 {
209 originRole = String("Dependent");
210 targetRole = String("Antecedent");
211 }
|
212 a.dunfey 1.1 }
213 handler.complete();
214 PEG_METHOD_EXIT();
215 }
216
217
218 /*****************************************************************************
219 *
220 * Implementation of AssociationProvider references method
221 *
222 *****************************************************************************/
223 void InteropProvider::references(
224 const OperationContext & context,
225 const CIMObjectPath & objectName,
226 const CIMName & resultClass,
227 const String & role,
228 const Boolean includeQualifiers,
229 const Boolean includeClassOrigin,
230 const CIMPropertyList & propertyList,
231 ObjectResponseHandler & handler)
232 {
233 a.dunfey 1.1 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
234 "InteropProvider::references()");
|
235 a.dunfey 1.2 initProvider();
|
236 marek 1.2.4.1 PEG_TRACE((TRC_CONTROLPROVIDER, Tracer::LEVEL4,
|
237 s.manicka 1.2.4.2 "%s references. objectName= %s, resultClass= %s role= %s "
238 "includeQualifiers= %s, includeClassOrigin= %s, PropertyList= %s",
|
239 a.dunfey 1.1 thisProvider,
240 (const char *)objectName.toString().getCString(),
241 (const char *)resultClass.getString().getCString(),
242 (const char *)role.getCString(),
243 boolToString(includeQualifiers),
244 boolToString(includeClassOrigin),
|
245 marek 1.2.4.1 (const char *)propertyListToString(propertyList).getCString()));
|
246 a.dunfey 1.1
247 handler.processing();
248 String tmpRole = role;
249 String tmpTarget;
|
250 s.manicka 1.2.4.2 Uint32 numIterations = 1;
|
251 a.dunfey 1.1 //
252 // Makes call to internal references method to get result, supplying the
253 // role parameter, but obviously not setting a resultRole/target parameter.
254 //
|
255 s.manicka 1.2.4.2 if (resultClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
256 {
257 if (tmpRole.size() == 0)
258 {
259 tmpRole = String("Antecedent");
260 tmpTarget = String("Dependent");
261 numIterations = 2;
262 }
263 }
264 for (Uint32 i = 0; i < numIterations; ++i)
265 {
266 Array<CIMInstance> refs = localReferences(
267 context,
268 objectName,
269 resultClass,
270 tmpRole,
271 tmpTarget);
272 for (Uint32 i = 0, n = refs.size(); i < n; ++i)
273 {
274 handler.deliver((CIMObject)refs[i]);
275 }
276 s.manicka 1.2.4.2 if (numIterations == 2)
277 {
278 tmpRole = String("Dependent");
279 tmpTarget = String("Antecedent");
280 }
281 }
|
282 a.dunfey 1.1 handler.complete();
283 PEG_METHOD_EXIT();
284 }
285
286 /*****************************************************************************
287 *
288 * Implementation of AssociationProvider referenceNames method
289 *
290 *****************************************************************************/
291 void InteropProvider::referenceNames(
292 const OperationContext & context,
293 const CIMObjectPath & objectName,
294 const CIMName & resultClass,
295 const String & role,
296 ObjectPathResponseHandler & handler)
297 {
298 PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
299 "InteropProvider::referenceNames()");
|
300 a.dunfey 1.2 initProvider();
|
301 a.dunfey 1.1 handler.processing();
302
303 String tmpRole = role;
304 String tmpTarget;
|
305 s.manicka 1.2.4.2 Uint32 numIterations = 1;
|
306 a.dunfey 1.1 //
307 // Makes call to internal references method to get result, supplying the
308 // role parameter, but obviously not setting a resultRole/target parameter.
309 //
|
310 s.manicka 1.2.4.2 if (resultClass.equal(PEGASUS_CLASSNAME_PG_REFERENCEDPROFILE))
311 {
312 if (tmpRole.size() == 0)
313 {
314 tmpRole = String("Antecedent");
315 tmpTarget = String("Dependent");
316 numIterations = 2;
317 }
318 }
319 for (Uint32 i = 0; i < numIterations; ++i)
|
320 a.dunfey 1.1 {
|
321 s.manicka 1.2.4.2 Array<CIMInstance> refs = localReferences(
322 context,
323 objectName,
324 resultClass,
325 tmpRole,
326 tmpTarget);
327 for (Uint32 i = 0, n = refs.size(); i < n; ++i)
328 {
329 handler.deliver(refs[i].getPath());
330 }
331 if (numIterations == 2)
332 {
333 tmpRole = String("Dependent");
334 tmpTarget = String("Antecedent");
335 }
|
336 a.dunfey 1.1 }
337
338 handler.complete();
339
340 PEG_METHOD_EXIT();
341 }
342
343
|
344 a.dunfey 1.2 PEGASUS_NAMESPACE_END
|
345 a.dunfey 1.1 // END_OF_FILE
|