1 karl 1.7 //%2006////////////////////////////////////////////////////////////////////////
|
2 kumpf 1.1 //
|
3 karl 1.4 // 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.3 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.4 // 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.5 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.7 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 kumpf 1.1 //
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 // 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 // Author: Barbara Packard (barbara_packard@hp.com)
33 //
34 kumpf 1.1 // Modified By:
35 //
36 //%/////////////////////////////////////////////////////////////////////////////
37
38 // WMIAssociatorProvider.cpp: implementation of the WMIAssociatorProvider class.
39 //
40 //////////////////////////////////////////////////////////////////////
41
42 #include "stdafx.h"
43
44 #include "WMICollector.h"
45 #include "WMIBaseProvider.h"
46 #include "WMIClassProvider.h"
47 #include "WMIInstanceProvider.h"
48 #include "WMIAssociatorProvider.h"
49
50 #include "WMIProperty.h"
51 #include "WMIString.h"
52 #include "WMIValue.h"
53 #include "WMIQualifier.h"
54 #include "WMIQualifierSet.h"
55 kumpf 1.1 #include "WMIType.h"
56 #include "WMIException.h"
57
58
59 //////////////////////////////////////////////////////////////////////////////
60 // WMIAssociatorProvider::
61 //
62 // ///////////////////////////////////////////////////////////////////////////
63 PEGASUS_NAMESPACE_BEGIN
64
65 /////////////////////////////////////////////////////////////////////
66 // Construction/Destruction
67 //////////////////////////////////////////////////////////////////////
68
69 WMIAssociatorProvider::WMIAssociatorProvider()
70 {
71 _collector = NULL;
72 m_bInitialized = false;
73 }
74
75 WMIAssociatorProvider::~WMIAssociatorProvider()
76 kumpf 1.1 {
77 cleanup();
78 }
79
80 //////////////////////////////////////////////////////////////////////////////
81 // WMIAssociatorProvider::associators
82 //
83 // NOTE: This method sets up the query string and then calls
84 // WMIBaseProvider::execCIMQuery
85 //////////////////////////////////////////////////////////////////////////////
86 Array<CIMObject> WMIAssociatorProvider::associators(
87 const String& nameSpace,
|
88 kumpf 1.2 const String& userName,
89 const String& password,
|
90 kumpf 1.1 const CIMObjectPath& objectName,
91 const String& assocClass,
92 const String& resultClass,
93 const String& role,
94 const String& resultRole,
95 Boolean includeQualifiers,
96 Boolean includeClassOrigin,
97 const CIMPropertyList& propertyList)
98 {
99 String sQuery;
100 String sQueryLanguage;
101
102 Array<CIMObject> objects;
103
104 PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIAssociatorProvider::associators()");
105
106 sQueryLanguage = qString(Q_WQL);
107 sQuery = getAssocQueryString(objectName,
108 assocClass,
109 resultClass,
110 role,
111 kumpf 1.1 resultRole);
112
|
113 kumpf 1.2 objects = execCIMQuery(nameSpace,
114 userName,
115 password,
|
116 kumpf 1.1 sQueryLanguage,
117 sQuery,
118 propertyList,
119 includeQualifiers,
120 includeClassOrigin);
121
122 PEG_METHOD_EXIT();
123
124 return objects;
125 }
126
127 //////////////////////////////////////////////////////////////////////////////
128 // WMIAssociatorProvider::associatorNames
129 //
130 // ///////////////////////////////////////////////////////////////////////////
131 Array<CIMObjectPath> WMIAssociatorProvider::associatorNames(
132 const String& nameSpace,
|
133 kumpf 1.2 const String& userName,
134 const String& password,
|
135 kumpf 1.1 const CIMObjectPath& objectName,
136 const String& assocClass,
137 const String& resultClass,
138 const String& role,
139 const String& resultRole)
140 {
141 Array<CIMObject> objects;
142 Array<CIMObjectPath> objectNames;
143
144 PEG_METHOD_ENTER(TRC_WMIPROVIDER,"WMIAssociatorProvider::associatorNames()");
145
146 // create an empty property list to save time...
147 Array<CIMName> propNames;
148 CIMPropertyList propertyList(propNames);
149
150 // now get the objects
151 objects = associators( nameSpace,
|
152 kumpf 1.2 userName,
153 password,
|
154 kumpf 1.1 objectName,
155 assocClass,
156 resultClass,
157 role,
158 resultRole,
159 false,
160 false,
161 propertyList);
162
163 // now get the names from the object
164 Uint32 size = objects.size();
165 Uint32 i;
|
166 mateus.baur 1.6
167 //check if namespace is remote
168 CIMNamespaceName oNamespace(nameSpace);
169 String strNamespace = oNamespace.getString();
170 String strNamespaceLower = strNamespace;
171 strNamespaceLower.toLower();
172 String strRemotePrefix = "";
173
174 if (strNamespaceLower.subString(0, 4) != "root")
175 {
176 Uint32 uiPos = strNamespaceLower.find("root");
177 if (uiPos == PEG_NOT_FOUND)
178 throw CIMException(CIM_ERR_FAILED);
179
180 strRemotePrefix = strNamespace.subString(0, uiPos);
181 }
|
182 kumpf 1.1
183 for (i=0; i<size; i++)
|
184 mateus.baur 1.6 {
185 CIMObjectPath oObjectPath = objects[i].getPath();
186
187 if (strRemotePrefix != "")
188 {
189 strNamespace = strRemotePrefix;
190 oNamespace = strNamespace.append(oObjectPath.getNameSpace().getString());
191 oObjectPath.setNameSpace(oNamespace);
192 }
193
194 objectNames.append(oObjectPath);
|
195 kumpf 1.1 }
196
197 PEG_METHOD_EXIT();
198
199 return objectNames;
200 }
201
202 //////////////////////////////////////////////////////////////////////////////
203 // WMIAssociatorProvider
204 // private methods
205 //
206 // ///////////////////////////////////////////////////////////////////////////
207
208 //////////////////////////////////////////////////////////////////////////////
209 // WMIAssociatorProvider::getAssocQueryString - calls the BaseProvider method
210 // to build the query string from the input parameters
211 //
212 // ///////////////////////////////////////////////////////////////////////////
213 String WMIAssociatorProvider::getAssocQueryString(const CIMObjectPath &objectName,
214 const String &assocClass,
215 const String &resultClass,
216 kumpf 1.1 const String &role,
217 const String &resultRole)
218 {
219 String sQuery;
220
221 sQuery = qString(Q_ASSOCIATORS);
222
223 return getQueryString(objectName, sQuery, assocClass, resultClass, role, resultRole);
224
225 }
226
227
228 PEGASUS_NAMESPACE_END
|