1 konrad.r 1.2 //%2003////////////////////////////////////////////////////////////////////////
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 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 konrad.r 1.2 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Konrad Rzeszutek <konradr@us.ibm.com>
27 //
28 //
29 //%/////////////////////////////////////////////////////////////////////////////
30
31
32 ///////////////////////////////////////////////////////////////////////////////
33 //
34 // This file has implementation for the providerDir property owner class.
35 //
36 ///////////////////////////////////////////////////////////////////////////////
37
38 #include <Pegasus/Common/Config.h>
39 #include <Pegasus/Common/Tracer.h>
40 #include <Pegasus/Common/FileSystem.h>
41 #include <Pegasus/Common/Destroyer.h>
42 #include <Pegasus/Config/ConfigManager.h>
43 konrad.r 1.2 #include "ProviderDirPropertyOwner.h"
44
45
46 PEGASUS_NAMESPACE_BEGIN
47
48 ///////////////////////////////////////////////////////////////////////////////
49 // ProviderDirPropertyOwner
50 //
51 // When a new ProviderDir property is added, make sure to add the property name
52 // and the default attributes of that property in the table below.
53 ///////////////////////////////////////////////////////////////////////////////
54
55 static struct ConfigPropertyRow properties[] =
56 {
|
57 konrad.r 1.3 #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
58 {"providerDir", "lib;bin", 0, 0, 0, 1},
59 #else
|
91 konrad.r 1.2 pos = temp.size();
92 token = 0;
93 }
94 else {
95 token = 1;
96 }
97 path = temp.subString(0,pos);
98 if (FileSystem::canWrite(path)) {
99 Logger::put_l(Logger::ERROR_LOG,System::CIMSERVER,
100 Logger::WARNING,
101 "$0 is writeable! Possible security risk.",
102 path);
103 }
104 if ( !FileSystem::isDirectory(path) ||
105 !FileSystem::canRead(path)) {
106 if (!FileSystem::isDirectory(path)) {
107 Logger::put_l(Logger::ERROR_LOG,System::CIMSERVER,
108 Logger::SEVERE,
109 "$0 is not a directory!",
110 path);
111 }
112 konrad.r 1.2 if (!FileSystem::canRead(path)) {
113 Logger::put_l(Logger::ERROR_LOG,System::CIMSERVER,
114 Logger::SEVERE,
115 "Cannot $0 is not readable!",
116 path);
117 }
118 //cerr << "Not a good directory.\n";
119 return false;
120 }
121 temp.remove(0,pos+token);
122 }
123 while ( temp.size() > 0 );
124
125 return true;
126 }
127
128 /**
129 Initialize the config properties.
130 */
131 void ProviderDirPropertyOwner::initialize()
132 {
133 konrad.r 1.2 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
134 {
135 //
136 // Initialize the properties with default values
137 //
138 if (String::equalNoCase(properties[i].propertyName, "providerDir"
139 ))
140 {
141 _providerDir->propertyName = properties[i].propertyName;
142 _providerDir->defaultValue = properties[i].defaultValue;
143 _providerDir->currentValue = properties[i].defaultValue;
144 _providerDir->plannedValue = properties[i].defaultValue;
145 _providerDir->dynamic = properties[i].dynamic;
146 _providerDir->domain = properties[i].domain;
147 _providerDir->domainSize = properties[i].domainSize;
148 _providerDir->externallyVisible = properties[i].externallyVisible;
149 }
150 }
151 }
152
153 struct ConfigProperty* ProviderDirPropertyOwner::_lookupConfigProperty(
154 konrad.r 1.2 const String& name)
155 {
156 if (String::equalNoCase(_providerDir->propertyName, name))
157 {
158 return _providerDir;
159 }
160 else
161 {
162 throw UnrecognizedConfigProperty(name);
163 }
164 }
165
166 /**
167 Get information about the specified property.
168 */
169 void ProviderDirPropertyOwner::getPropertyInfo(
170 const String& name,
171 Array<String>& propertyInfo)
172 {
173 propertyInfo.clear();
174
175 konrad.r 1.2 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
176
177 propertyInfo.append(configProperty->propertyName);
178 propertyInfo.append(configProperty->defaultValue);
179 propertyInfo.append(configProperty->currentValue);
180 propertyInfo.append(configProperty->plannedValue);
181 if (configProperty->dynamic)
182 {
183 propertyInfo.append(STRING_TRUE);
184 }
185 else
186 {
187 propertyInfo.append(STRING_FALSE);
188 }
189 if (configProperty->externallyVisible)
190 {
191 propertyInfo.append(STRING_TRUE);
192 }
193 else
194 {
195 propertyInfo.append(STRING_FALSE);
196 konrad.r 1.2 }
197 }
198
199
200 /**
201 Get default value of the specified property.
202 */
203 const String ProviderDirPropertyOwner::getDefaultValue(const String& name)
204 {
205 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
206 return configProperty->defaultValue;
207 }
208
209 /**
210 Get current value of the specified property.
211 */
212 const String ProviderDirPropertyOwner::getCurrentValue(const String& name)
213 {
214 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
215 return configProperty->currentValue;
216 }
217 konrad.r 1.2
218 /**
219 Get planned value of the specified property.
220 */
221 const String ProviderDirPropertyOwner::getPlannedValue(const String& name)
222 {
223 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
224 return configProperty->plannedValue;
225 }
226
227 /**
228 Init current value of the specified property to the specified value.
229 */
230 void ProviderDirPropertyOwner::initCurrentValue(
231 const String& name,
232 const String& value)
233 {
234 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
235 configProperty->currentValue = value;
236 }
237
238 konrad.r 1.2
239 /**
240 Init planned value of the specified property to the specified value.
241 */
242 void ProviderDirPropertyOwner::initPlannedValue(
243 const String& name,
244 const String& value)
245 {
246 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
247 configProperty->plannedValue = value;
248 }
249
250 /**
251 Update current value of the specified property to the specified value.
252 */
253 void ProviderDirPropertyOwner::updateCurrentValue(
254 const String& name,
255 const String& value)
256 {
257 //
258 // make sure the property is dynamic before updating the value.
259 konrad.r 1.2 //
260 if (!isDynamic(name))
261 {
262 throw NonDynamicConfigProperty(name);
263 }
264
265 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
266 configProperty->currentValue = value;
267 }
268
269
270 /**
271 Update planned value of the specified property to the specified value.
272 */
273 void ProviderDirPropertyOwner::updatePlannedValue(
274 const String& name,
275 const String& value)
276 {
277 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
278 configProperty->plannedValue = value;
279 }
280 konrad.r 1.2
281 /**
282 Checks to see if the given value is valid or not.
283 */
284 Boolean ProviderDirPropertyOwner::isValid(const String& name, const String& value)
285 {
286
287 if (!isProviderDirValid( value ))
288 {
289 throw InvalidPropertyValue(name, value);
290 }
291
292 return true;
293 }
294
295 /**
296 Checks to see if the specified property is dynamic or not.
297 */
298 Boolean ProviderDirPropertyOwner::isDynamic(const String& name)
299 {
300 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
301 konrad.r 1.2 return configProperty->dynamic;
302 }
303
304
305 PEGASUS_NAMESPACE_END
|