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
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 konrad.r 1.2 {
|
57 a.dunfey 1.16 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
58 kavita.gupta 1.22 {"providerDir", "lib;bin", IS_DYNAMIC, 0, 0, IS_VISIBLE},
|
59 r.kieninger 1.20 #elif defined(PEGASUS_OS_ZOS)
|
60 kavita.gupta 1.22 {"providerDir", "lib:provider", IS_DYNAMIC, 0, 0, IS_VISIBLE},
|
61 ouyang.jian 1.18 #elif defined(PEGASUS_OS_PASE) && defined(PEGASUS_USE_RELEASE_DIRS)
62 {"providerDir", "/QOpenSys/QIBM/ProdData/UME/Pegasus/provider",
|
63 kavita.gupta 1.22 IS_DYNAMIC, 0, 0, IS_VISIBLE}
|
64 gs.keenan 1.13 #elif defined(PEGASUS_OS_VMS)
|
65 kavita.gupta 1.22 {"providerDir", "/wbem_lib", IS_DYNAMIC, 0, 0, IS_VISIBLE},
|
66 konrad.r 1.3 #else
|
67 kavita.gupta 1.22 {"providerDir", "lib", IS_DYNAMIC, 0, 0, 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 if (String::equalNoCase(properties[i].propertyName, "providerDir"
146 ))
147 {
148 _providerDir->propertyName = properties[i].propertyName;
149 _providerDir->defaultValue = properties[i].defaultValue;
150 _providerDir->currentValue = properties[i].defaultValue;
151 _providerDir->plannedValue = properties[i].defaultValue;
152 _providerDir->dynamic = properties[i].dynamic;
153 _providerDir->domain = properties[i].domain;
154 _providerDir->domainSize = properties[i].domainSize;
155 _providerDir->externallyVisible = properties[i].externallyVisible;
156 }
157 }
158 konrad.r 1.2 }
159
160 struct ConfigProperty* ProviderDirPropertyOwner::_lookupConfigProperty(
|
161 aruran.ms 1.10 const String& name) const
|
162 konrad.r 1.2 {
163 if (String::equalNoCase(_providerDir->propertyName, name))
164 {
165 return _providerDir;
166 }
167 else
168 {
169 throw UnrecognizedConfigProperty(name);
170 }
171 }
172
|
173 kumpf 1.15 /**
174 Get information about the specified property.
|
175 konrad.r 1.2 */
176 void ProviderDirPropertyOwner::getPropertyInfo(
|
177 kumpf 1.15 const String& name,
|
178 vijay.eli 1.9 Array<String>& propertyInfo) const
|
179 konrad.r 1.2 {
180 propertyInfo.clear();
|
181 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
182 konrad.r 1.2
183 propertyInfo.append(configProperty->propertyName);
184 propertyInfo.append(configProperty->defaultValue);
185 propertyInfo.append(configProperty->currentValue);
186 propertyInfo.append(configProperty->plannedValue);
187 if (configProperty->dynamic)
188 {
189 propertyInfo.append(STRING_TRUE);
190 }
191 else
192 {
193 propertyInfo.append(STRING_FALSE);
194 }
195 if (configProperty->externallyVisible)
196 {
197 propertyInfo.append(STRING_TRUE);
198 }
199 else
200 {
201 propertyInfo.append(STRING_FALSE);
202 }
203 konrad.r 1.2 }
204
205
206 /**
|
207 kumpf 1.15 Get default value of the specified property.
|
208 konrad.r 1.2 */
|
209 vijay.eli 1.9 String ProviderDirPropertyOwner::getDefaultValue(const String& name) const
|
210 konrad.r 1.2 {
|
211 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
212 vijay.eli 1.9
|
213 konrad.r 1.2 return configProperty->defaultValue;
214 }
215
|
216 kumpf 1.15 /**
217 Get current value of the specified property.
|
218 konrad.r 1.2 */
|
219 vijay.eli 1.9 String ProviderDirPropertyOwner::getCurrentValue(const String& name) const
|
220 konrad.r 1.2 {
|
221 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
222 vijay.eli 1.9
|
223 kavita.gupta 1.22 AutoMutex lock(_providerDirMutex);
|
224 konrad.r 1.2 return configProperty->currentValue;
225 }
226
|
227 kumpf 1.15 /**
228 Get planned value of the specified property.
|
229 konrad.r 1.2 */
|
230 vijay.eli 1.9 String ProviderDirPropertyOwner::getPlannedValue(const String& name) const
|
231 konrad.r 1.2 {
|
232 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
233 vijay.eli 1.9
|
234 konrad.r 1.2 return configProperty->plannedValue;
235 }
236
|
237 kumpf 1.15 /**
238 Init current value of the specified property to the specified value.
|
239 konrad.r 1.2 */
240 void ProviderDirPropertyOwner::initCurrentValue(
|
241 kumpf 1.15 const String& name,
|
242 konrad.r 1.2 const String& value)
243 {
244 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
245 kavita.gupta 1.22 AutoMutex lock(_providerDirMutex);
|
246 konrad.r 1.2 configProperty->currentValue = value;
247 }
248
249
|
250 kumpf 1.15 /**
251 Init planned value of the specified property to the specified value.
|
252 konrad.r 1.2 */
253 void ProviderDirPropertyOwner::initPlannedValue(
|
254 kumpf 1.15 const String& name,
|
255 konrad.r 1.2 const String& value)
256 {
257 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
258 configProperty->plannedValue = value;
259 }
260
|
261 kumpf 1.15 /**
262 Update current value of the specified property to the specified value.
|
263 konrad.r 1.2 */
264 void ProviderDirPropertyOwner::updateCurrentValue(
|
265 kumpf 1.15 const String& name,
266 const String& value)
|
267 konrad.r 1.2 {
268 //
269 // make sure the property is dynamic before updating the value.
270 //
271 if (!isDynamic(name))
272 {
|
273 kumpf 1.15 throw NonDynamicConfigProperty(name);
|
274 konrad.r 1.2 }
|
275 kavita.gupta 1.22 initCurrentValue(name, value);
|
276 konrad.r 1.2 }
277
278
|
279 kumpf 1.15 /**
280 Update planned value of the specified property to the specified value.
|
281 konrad.r 1.2 */
282 void ProviderDirPropertyOwner::updatePlannedValue(
|
283 kumpf 1.15 const String& name,
|
284 konrad.r 1.2 const String& value)
285 {
286 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
287 configProperty->plannedValue = value;
288 }
289
|
290 kumpf 1.15 /**
291 Checks to see if the given value is valid or not.
|
292 konrad.r 1.2 */
|
293 kumpf 1.15 Boolean ProviderDirPropertyOwner::isValid(
294 const String& name,
295 const String& value) const
|
296 konrad.r 1.2 {
297
298 if (!isProviderDirValid( value ))
299 {
300 throw InvalidPropertyValue(name, value);
301 }
|
302 kumpf 1.15
|
303 konrad.r 1.2 return true;
304 }
305
|
306 kumpf 1.15 /**
307 Checks to see if the specified property is dynamic or not.
|
308 konrad.r 1.2 */
|
309 vijay.eli 1.9 Boolean ProviderDirPropertyOwner::isDynamic(const String& name) const
|
310 konrad.r 1.2 {
|
311 aruran.ms 1.10 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
312 vijay.eli 1.9
|
313 kumpf 1.15 return (configProperty->dynamic == IS_DYNAMIC);
|
314 konrad.r 1.2 }
315
316
317 PEGASUS_NAMESPACE_END
|