1 karl 1.12 //%2006////////////////////////////////////////////////////////////////////////
|
2 konrad.r 1.2 //
|
3 karl 1.5 // 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 konrad.r 1.2 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.5 // 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.7 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.12 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 konrad.r 1.2 //
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 //%/////////////////////////////////////////////////////////////////////////////
33
34 konrad.r 1.2
35 ///////////////////////////////////////////////////////////////////////////////
|
36 kumpf 1.15 //
|
37 konrad.r 1.2 // This file has implementation for the providerDir property owner class.
38 //
39 ///////////////////////////////////////////////////////////////////////////////
40
41 #include <Pegasus/Common/Config.h>
42 #include <Pegasus/Common/Tracer.h>
43 #include <Pegasus/Common/FileSystem.h>
44 #include <Pegasus/Config/ConfigManager.h>
45 #include "ProviderDirPropertyOwner.h"
46
47
48 PEGASUS_NAMESPACE_BEGIN
49
50 ///////////////////////////////////////////////////////////////////////////////
51 // ProviderDirPropertyOwner
52 //
53 // When a new ProviderDir property is added, make sure to add the property name
54 // and the default attributes of that property in the table below.
55 ///////////////////////////////////////////////////////////////////////////////
56
57 static struct ConfigPropertyRow properties[] =
58 konrad.r 1.2 {
|
59 a.dunfey 1.16 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
60 konrad.r 1.6 {"providerDir", "lib;bin", IS_STATIC, 0, 0, IS_VISIBLE},
|
61 marek 1.11 #elif defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
62 {"providerDir", "lib:provider", IS_STATIC, 0, 0, IS_VISIBLE},
|
63 ouyang.jian 1.18 #elif defined(PEGASUS_OS_PASE) && defined(PEGASUS_USE_RELEASE_DIRS)
64 {"providerDir", "/QOpenSys/QIBM/ProdData/UME/Pegasus/provider",
65 IS_STATIC, 0, 0, IS_VISIBLE}
|
66 gs.keenan 1.13 #elif defined(PEGASUS_OS_VMS)
|
67 carson.hovey 1.17 {"providerDir", "/wbem_lib", IS_STATIC, 0, 0, IS_VISIBLE},
|
68 konrad.r 1.3 #else
|
69 konrad.r 1.6 {"providerDir", "lib", IS_STATIC, 0, 0, IS_VISIBLE},
|
70 konrad.r 1.3 #endif
|
71 konrad.r 1.2 };
72
73 const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
74
75
76 /** Constructors */
77 ProviderDirPropertyOwner::ProviderDirPropertyOwner()
78 {
79 _providerDir = new ConfigProperty;
80 }
81
82 /** Destructor */
83 ProviderDirPropertyOwner::~ProviderDirPropertyOwner()
84 {
85 delete _providerDir;
86 }
87
88 /**
|
89 kumpf 1.15 Checks if the given directory is existing and writable
|
90 konrad.r 1.2 */
91 Boolean isProviderDirValid(const String& dirName)
92 {
|
93 marek 1.14 String path;
94 Uint32 pos=0;
95 Uint32 token=0;
96
97 // make multiple, relative paths absolute for check
98 String temp = ConfigManager::getHomedPath(dirName);
99 do
100 {
101 if (( pos = temp.find(FileSystem::getPathDelimiter())) == PEG_NOT_FOUND)
102 {
103 pos = temp.size();
104 token = 0;
|
105 kumpf 1.15 }
106 else
|
107 marek 1.14 {
108 token = 1;
109 }
110 path = temp.subString(0,pos);
111 if (!FileSystem::isDirectory(path))
112 {
|
113 kumpf 1.19 Logger::put(
114 Logger::ERROR_LOG,System::CIMSERVER, Logger::SEVERE,
115 "$0 is not a directory!",
116 path);
|
117 marek 1.14 return false;
118 }
119 if (!FileSystem::canRead(path))
120 {
|
121 kumpf 1.19 Logger::put(
122 Logger::ERROR_LOG,System::CIMSERVER, Logger::SEVERE,
123 "Cannot $0 is not readable!",
124 path);
|
125 marek 1.14 return false;
126 }
127 #ifndef PEGASUS_OS_ZOS
128 if (FileSystem::canWrite(path))
129 {
|
130 kumpf 1.19 Logger::put(
131 Logger::ERROR_LOG,System::CIMSERVER, Logger::WARNING,
132 "$0 is writeable! Possible security risk.",
133 path);
|
134 marek 1.14 }
|
135 marek 1.11 #endif
|
136 kumpf 1.15 temp.remove(0,pos+token);
|
137 marek 1.14 }
|
138 kumpf 1.15 while ( temp.size() > 0 );
|
139 konrad.r 1.2 return true;
140 }
|
141 kumpf 1.15
|
142 konrad.r 1.2 /**
|
143 kumpf 1.15 Initialize the config properties.
|
144 konrad.r 1.2 */
145 void ProviderDirPropertyOwner::initialize()
146 {
147 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
148 {
149 //
150 // Initialize the properties with default values
151 //
152 if (String::equalNoCase(properties[i].propertyName, "providerDir"
153 ))
154 {
155 _providerDir->propertyName = properties[i].propertyName;
156 _providerDir->defaultValue = properties[i].defaultValue;
157 _providerDir->currentValue = properties[i].defaultValue;
158 _providerDir->plannedValue = properties[i].defaultValue;
159 _providerDir->dynamic = properties[i].dynamic;
160 _providerDir->domain = properties[i].domain;
161 _providerDir->domainSize = properties[i].domainSize;
162 _providerDir->externallyVisible = properties[i].externallyVisible;
163 }
164 }
165 konrad.r 1.2 }
166
167 struct ConfigProperty* ProviderDirPropertyOwner::_lookupConfigProperty(
|
168 aruran.ms 1.10 const String& name) const
|
169 konrad.r 1.2 {
170 if (String::equalNoCase(_providerDir->propertyName, name))
171 {
172 return _providerDir;
173 }
174 else
175 {
176 throw UnrecognizedConfigProperty(name);
177 }
178 }
179
|
180 kumpf 1.15 /**
181 Get information about the specified property.
|
182 konrad.r 1.2 */
183 void ProviderDirPropertyOwner::getPropertyInfo(
|
184 kumpf 1.15 const String& name,
|
185 vijay.eli 1.9 Array<String>& propertyInfo) const
|
186 konrad.r 1.2 {
187 propertyInfo.clear();
|
188 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
189 konrad.r 1.2
190 propertyInfo.append(configProperty->propertyName);
191 propertyInfo.append(configProperty->defaultValue);
192 propertyInfo.append(configProperty->currentValue);
193 propertyInfo.append(configProperty->plannedValue);
194 if (configProperty->dynamic)
195 {
196 propertyInfo.append(STRING_TRUE);
197 }
198 else
199 {
200 propertyInfo.append(STRING_FALSE);
201 }
202 if (configProperty->externallyVisible)
203 {
204 propertyInfo.append(STRING_TRUE);
205 }
206 else
207 {
208 propertyInfo.append(STRING_FALSE);
209 }
210 konrad.r 1.2 }
211
212
213 /**
|
214 kumpf 1.15 Get default value of the specified property.
|
215 konrad.r 1.2 */
|
216 vijay.eli 1.9 String ProviderDirPropertyOwner::getDefaultValue(const String& name) const
|
217 konrad.r 1.2 {
|
218 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
219 vijay.eli 1.9
|
220 konrad.r 1.2 return configProperty->defaultValue;
221 }
222
|
223 kumpf 1.15 /**
224 Get current value of the specified property.
|
225 konrad.r 1.2 */
|
226 vijay.eli 1.9 String ProviderDirPropertyOwner::getCurrentValue(const String& name) const
|
227 konrad.r 1.2 {
|
228 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
229 vijay.eli 1.9
|
230 konrad.r 1.2 return configProperty->currentValue;
231 }
232
|
233 kumpf 1.15 /**
234 Get planned value of the specified property.
|
235 konrad.r 1.2 */
|
236 vijay.eli 1.9 String ProviderDirPropertyOwner::getPlannedValue(const String& name) const
|
237 konrad.r 1.2 {
|
238 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
239 vijay.eli 1.9
|
240 konrad.r 1.2 return configProperty->plannedValue;
241 }
242
|
243 kumpf 1.15 /**
244 Init current value of the specified property to the specified value.
|
245 konrad.r 1.2 */
246 void ProviderDirPropertyOwner::initCurrentValue(
|
247 kumpf 1.15 const String& name,
|
248 konrad.r 1.2 const String& value)
249 {
250 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
251 configProperty->currentValue = value;
252 }
253
254
|
255 kumpf 1.15 /**
256 Init planned value of the specified property to the specified value.
|
257 konrad.r 1.2 */
258 void ProviderDirPropertyOwner::initPlannedValue(
|
259 kumpf 1.15 const String& name,
|
260 konrad.r 1.2 const String& value)
261 {
262 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
263 configProperty->plannedValue = value;
264 }
265
|
266 kumpf 1.15 /**
267 Update current value of the specified property to the specified value.
|
268 konrad.r 1.2 */
269 void ProviderDirPropertyOwner::updateCurrentValue(
|
270 kumpf 1.15 const String& name,
271 const String& value)
|
272 konrad.r 1.2 {
273 //
274 // make sure the property is dynamic before updating the value.
275 //
276 if (!isDynamic(name))
277 {
|
278 kumpf 1.15 throw NonDynamicConfigProperty(name);
|
279 konrad.r 1.2 }
280
281 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
282 configProperty->currentValue = value;
283 }
284
285
|
286 kumpf 1.15 /**
287 Update planned value of the specified property to the specified value.
|
288 konrad.r 1.2 */
289 void ProviderDirPropertyOwner::updatePlannedValue(
|
290 kumpf 1.15 const String& name,
|
291 konrad.r 1.2 const String& value)
292 {
293 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
294 configProperty->plannedValue = value;
295 }
296
|
297 kumpf 1.15 /**
298 Checks to see if the given value is valid or not.
|
299 konrad.r 1.2 */
|
300 kumpf 1.15 Boolean ProviderDirPropertyOwner::isValid(
301 const String& name,
302 const String& value) const
|
303 konrad.r 1.2 {
304
305 if (!isProviderDirValid( value ))
306 {
307 throw InvalidPropertyValue(name, value);
308 }
|
309 kumpf 1.15
|
310 konrad.r 1.2 return true;
311 }
312
|
313 kumpf 1.15 /**
314 Checks to see if the specified property is dynamic or not.
|
315 konrad.r 1.2 */
|
316 vijay.eli 1.9 Boolean ProviderDirPropertyOwner::isDynamic(const String& name) const
|
317 konrad.r 1.2 {
|
318 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
319 vijay.eli 1.9
|
320 kumpf 1.15 return (configProperty->dynamic == IS_DYNAMIC);
|
321 konrad.r 1.2 }
322
323
324 PEGASUS_NAMESPACE_END
|