1 martin 1.23 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.24 //
|
3 martin 1.23 // 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.24 //
|
10 martin 1.23 // 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.24 //
|
17 martin 1.23 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.24 //
|
20 martin 1.23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.23 // 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.24 //
|
28 martin 1.23 //////////////////////////////////////////////////////////////////////////
|
29 konrad.r 1.2 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32
33 ///////////////////////////////////////////////////////////////////////////////
|
34 kumpf 1.15 //
|
35 konrad.r 1.2 // This file has implementation for the providerDir property owner class.
36 //
37 ///////////////////////////////////////////////////////////////////////////////
38
39 #include <Pegasus/Common/Config.h>
40 #include <Pegasus/Common/Tracer.h>
41 #include <Pegasus/Common/FileSystem.h>
42 #include <Pegasus/Config/ConfigManager.h>
43 #include "ProviderDirPropertyOwner.h"
|
44 dl.meetei 1.29.8.1 #include "ConfigExceptions.h"
|
45 konrad.r 1.2
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 a.dunfey 1.16 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
58 kumpf 1.26 {"providerDir", "lib;bin", IS_DYNAMIC, IS_VISIBLE},
|
59 r.kieninger 1.20 #elif defined(PEGASUS_OS_ZOS)
|
60 kumpf 1.26 {"providerDir", "lib:provider", IS_DYNAMIC, IS_VISIBLE},
|
61 ouyang.jian 1.18 #elif defined(PEGASUS_OS_PASE) && defined(PEGASUS_USE_RELEASE_DIRS)
|
62 kumpf 1.25 {"providerDir", "/QOpenSys/QIBM/ProdData/UME/Pegasus/provider",
|
63 kumpf 1.26 IS_DYNAMIC, IS_VISIBLE}
|
64 gs.keenan 1.13 #elif defined(PEGASUS_OS_VMS)
|
65 kumpf 1.26 {"providerDir", "/wbem_lib", IS_DYNAMIC, IS_VISIBLE},
|
66 konrad.r 1.3 #else
|
67 kumpf 1.26 {"providerDir", "lib", IS_DYNAMIC, IS_VISIBLE},
|
68 konrad.r 1.3 #endif
|
69 konrad.r 1.2 };
70
71 const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
72
73
74 /** Constructors */
75 ProviderDirPropertyOwner::ProviderDirPropertyOwner()
76 {
77 _providerDir = new ConfigProperty;
78 }
79
80 /** Destructor */
81 ProviderDirPropertyOwner::~ProviderDirPropertyOwner()
82 {
83 delete _providerDir;
84 }
85
86 /**
|
87 kumpf 1.15 Checks if the given directory is existing and writable
|
88 konrad.r 1.2 */
89 Boolean isProviderDirValid(const String& dirName)
90 {
|
91 marek 1.14 String path;
92 Uint32 pos=0;
93 Uint32 token=0;
94
95 // make multiple, relative paths absolute for check
96 String temp = ConfigManager::getHomedPath(dirName);
97 do
98 {
99 if (( pos = temp.find(FileSystem::getPathDelimiter())) == PEG_NOT_FOUND)
100 {
101 pos = temp.size();
102 token = 0;
|
103 kumpf 1.15 }
104 else
|
105 marek 1.14 {
106 token = 1;
107 }
108 path = temp.subString(0,pos);
109 if (!FileSystem::isDirectory(path))
110 {
|
111 kumpf 1.21 Logger::put_l(
112 Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
113 MessageLoaderParms(
114 "Config.ProviderDirPropertyOwner.NOT_A_DIRECTORY",
115 "providerDir configuration value $0 is not a directory.",
116 path));
|
117 marek 1.14 return false;
118 }
119 if (!FileSystem::canRead(path))
120 {
|
121 kumpf 1.21 Logger::put_l(
122 Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
123 MessageLoaderParms(
124 "Config.ProviderDirPropertyOwner.DIRECTORY_NOT_READABLE",
125 "providerDir configuration directory $0 is not readable.",
126 path));
|
127 marek 1.14 return false;
128 }
|
129 kumpf 1.15 temp.remove(0,pos+token);
|
130 marek 1.14 }
|
131 kumpf 1.15 while ( temp.size() > 0 );
|
132 konrad.r 1.2 return true;
133 }
|
134 kumpf 1.15
|
135 konrad.r 1.2 /**
|
136 kumpf 1.15 Initialize the config properties.
|
137 konrad.r 1.2 */
138 void ProviderDirPropertyOwner::initialize()
139 {
140 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
141 {
142 //
143 // Initialize the properties with default values
144 //
|
145 kavita.gupta 1.27 if (String::equal(properties[i].propertyName, "providerDir"))
|
146 konrad.r 1.2 {
147 _providerDir->propertyName = properties[i].propertyName;
148 _providerDir->defaultValue = properties[i].defaultValue;
149 _providerDir->currentValue = properties[i].defaultValue;
150 _providerDir->plannedValue = properties[i].defaultValue;
151 _providerDir->dynamic = properties[i].dynamic;
152 _providerDir->externallyVisible = properties[i].externallyVisible;
153 }
154 }
155 }
156
157 struct ConfigProperty* ProviderDirPropertyOwner::_lookupConfigProperty(
|
158 aruran.ms 1.10 const String& name) const
|
159 konrad.r 1.2 {
|
160 kavita.gupta 1.27 if (String::equal(_providerDir->propertyName, name))
|
161 konrad.r 1.2 {
162 return _providerDir;
163 }
164 else
165 {
166 throw UnrecognizedConfigProperty(name);
167 }
168 }
169
|
170 kumpf 1.15 /**
171 Get information about the specified property.
|
172 konrad.r 1.2 */
173 void ProviderDirPropertyOwner::getPropertyInfo(
|
174 kumpf 1.15 const String& name,
|
175 vijay.eli 1.9 Array<String>& propertyInfo) const
|
176 konrad.r 1.2 {
177 propertyInfo.clear();
|
178 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
179 konrad.r 1.2
180 propertyInfo.append(configProperty->propertyName);
181 propertyInfo.append(configProperty->defaultValue);
182 propertyInfo.append(configProperty->currentValue);
183 propertyInfo.append(configProperty->plannedValue);
184 if (configProperty->dynamic)
185 {
186 propertyInfo.append(STRING_TRUE);
187 }
188 else
189 {
190 propertyInfo.append(STRING_FALSE);
191 }
192 if (configProperty->externallyVisible)
193 {
194 propertyInfo.append(STRING_TRUE);
195 }
196 else
197 {
198 propertyInfo.append(STRING_FALSE);
199 }
200 konrad.r 1.2 }
201
202
203 /**
|
204 kumpf 1.15 Get default value of the specified property.
|
205 konrad.r 1.2 */
|
206 vijay.eli 1.9 String ProviderDirPropertyOwner::getDefaultValue(const String& name) const
|
207 konrad.r 1.2 {
|
208 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
209 vijay.eli 1.9
|
210 konrad.r 1.2 return configProperty->defaultValue;
211 }
212
|
213 kumpf 1.15 /**
214 Get current value of the specified property.
|
215 konrad.r 1.2 */
|
216 vijay.eli 1.9 String ProviderDirPropertyOwner::getCurrentValue(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 kavita.gupta 1.22 AutoMutex lock(_providerDirMutex);
|
221 konrad.r 1.2 return configProperty->currentValue;
222 }
223
|
224 kumpf 1.15 /**
225 Get planned value of the specified property.
|
226 konrad.r 1.2 */
|
227 vijay.eli 1.9 String ProviderDirPropertyOwner::getPlannedValue(const String& name) const
|
228 konrad.r 1.2 {
|
229 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
230 vijay.eli 1.9
|
231 konrad.r 1.2 return configProperty->plannedValue;
232 }
233
|
234 kumpf 1.15 /**
235 Init current value of the specified property to the specified value.
|
236 konrad.r 1.2 */
237 void ProviderDirPropertyOwner::initCurrentValue(
|
238 kumpf 1.15 const String& name,
|
239 konrad.r 1.2 const String& value)
240 {
241 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
242 kavita.gupta 1.22 AutoMutex lock(_providerDirMutex);
|
243 konrad.r 1.2 configProperty->currentValue = value;
244 }
245
246
|
247 kumpf 1.15 /**
248 Init planned value of the specified property to the specified value.
|
249 konrad.r 1.2 */
250 void ProviderDirPropertyOwner::initPlannedValue(
|
251 kumpf 1.15 const String& name,
|
252 konrad.r 1.2 const String& value)
253 {
254 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
255 configProperty->plannedValue = value;
256 }
257
|
258 kumpf 1.15 /**
259 Update current value of the specified property to the specified value.
|
260 konrad.r 1.2 */
261 void ProviderDirPropertyOwner::updateCurrentValue(
|
262 kumpf 1.15 const String& name,
|
263 venkat.puvvada 1.28 const String& value,
|
264 venkat.puvvada 1.29 const String& userName,
265 Uint32 timeoutSeconds)
|
266 konrad.r 1.2 {
267 //
268 // make sure the property is dynamic before updating the value.
269 //
270 if (!isDynamic(name))
271 {
|
272 kumpf 1.15 throw NonDynamicConfigProperty(name);
|
273 konrad.r 1.2 }
|
274 kavita.gupta 1.22 initCurrentValue(name, value);
|
275 konrad.r 1.2 }
276
277
|
278 kumpf 1.15 /**
279 Update planned value of the specified property to the specified value.
|
280 konrad.r 1.2 */
281 void ProviderDirPropertyOwner::updatePlannedValue(
|
282 kumpf 1.15 const String& name,
|
283 konrad.r 1.2 const String& value)
284 {
285 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
286 configProperty->plannedValue = value;
287 }
288
|
289 kumpf 1.15 /**
290 Checks to see if the given value is valid or not.
|
291 konrad.r 1.2 */
|
292 kumpf 1.15 Boolean ProviderDirPropertyOwner::isValid(
293 const String& name,
294 const String& value) const
|
295 konrad.r 1.2 {
296
297 if (!isProviderDirValid( value ))
298 {
299 throw InvalidPropertyValue(name, value);
300 }
|
301 kumpf 1.15
|
302 konrad.r 1.2 return true;
303 }
304
|
305 kumpf 1.15 /**
306 Checks to see if the specified property is dynamic or not.
|
307 konrad.r 1.2 */
|
308 vijay.eli 1.9 Boolean ProviderDirPropertyOwner::isDynamic(const String& name) const
|
309 konrad.r 1.2 {
|
310 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
311 vijay.eli 1.9
|
312 kumpf 1.15 return (configProperty->dynamic == IS_DYNAMIC);
|
313 konrad.r 1.2 }
314
315
316 PEGASUS_NAMESPACE_END
|