1 martin 1.30 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.31 //
|
3 martin 1.30 // 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.31 //
|
10 martin 1.30 // 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.31 //
|
17 martin 1.30 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.31 //
|
20 martin 1.30 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.31 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.30 // 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.31 //
|
28 martin 1.30 //////////////////////////////////////////////////////////////////////////
|
29 kumpf 1.1 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32
33 ///////////////////////////////////////////////////////////////////////////////
|
34 kumpf 1.23 //
|
35 kumpf 1.1 // This file has implementation for the file system 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 "FileSystemPropertyOwner.h"
44
45
46 PEGASUS_USING_STD;
47
48 PEGASUS_NAMESPACE_BEGIN
49
50 ///////////////////////////////////////////////////////////////////////////////
51 // FileSystemPropertyOwner
52 //
53 // When a new FileSystem property is added, make sure to add the property name
54 // and the default attributes of that property in the table below.
55 ///////////////////////////////////////////////////////////////////////////////
56 kumpf 1.1
57 static struct ConfigPropertyRow properties[] =
58 {
|
59 kumpf 1.21 {"repositoryDir", PEGASUS_REPOSITORY_DIR, IS_STATIC, 0, 0, IS_VISIBLE},
|
60 ouyang.jian 1.25 #if defined(PEGASUS_OS_PASE)
|
61 kumpf 1.32 {"messageDir", "/QOpenSys/QIBM/ProdData/UME/Pegasus/msg", IS_STATIC,
|
62 ouyang.jian 1.25 0, 0, IS_VISIBLE},
63 #else
|
64 konrad.r 1.13 {"messageDir", "msg", IS_STATIC, 0, 0, IS_VISIBLE},
|
65 ouyang.jian 1.25 #endif
|
66 b.whiteley 1.26 #if defined(PEGASUS_OS_TYPE_WINDOWS)
|
67 marek 1.27 {"providerManagerDir", "bin", IS_STATIC, 0, 0, IS_VISIBLE},
|
68 r.kieninger 1.28 #elif defined(PEGASUS_OS_ZOS)
|
69 marek 1.27 {"providerManagerDir", "lib", IS_STATIC, 0, 0, IS_VISIBLE},
|
70 b.whiteley 1.26 #elif defined(PEGASUS_OS_PASE) && defined(PEGASUS_USE_RELEASE_DIRS)
|
71 kumpf 1.32 {"providerManagerDir",
72 "/QOpenSys/QIBM/ProdData/UME/Pegasus/lib",
|
73 cheng.sp 1.32.2.1 IS_STATIC, 0, 0, IS_VISIBLE},
74 #elif defined(PEGASUS_OS_AIX) && defined(PEGASUS_USE_RELEASE_DIRS)
75 {"providerManagerDir", "/usr/lib", IS_STATIC, IS_VISIBLE},
|
76 b.whiteley 1.26 #elif defined(PEGASUS_OS_VMS)
77 {"providerManagerDir", "/wbem_lib", IS_STATIC, 0, 0, IS_VISIBLE},
78 #else
79 {"providerManagerDir", "lib", IS_STATIC, 0, 0, IS_VISIBLE},
80 #endif
|
81 kumpf 1.1 };
82
83 const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
84
85
86 /** Constructors */
87 FileSystemPropertyOwner::FileSystemPropertyOwner()
88 {
|
89 a.arora 1.10 _repositoryDir.reset(new ConfigProperty);
90 _messageDir.reset(new ConfigProperty);
|
91 b.whiteley 1.26 _providerManagerDir.reset(new ConfigProperty);
|
92 kumpf 1.1 }
93
94
95 /**
|
96 kumpf 1.23 Checks if the given directory is existing and writable
|
97 kumpf 1.1 */
98 Boolean isDirValid(const String& dirName)
99 {
|
100 marek 1.22 String directoryName(ConfigManager::getHomedPath(dirName));
|
101 kumpf 1.23 if (FileSystem::isDirectory(directoryName) &&
|
102 marek 1.22 FileSystem::canWrite(directoryName))
|
103 kumpf 1.1 {
104 return true;
105 }
106 return false;
107 }
|
108 kumpf 1.23
|
109 kumpf 1.1 /**
|
110 kumpf 1.23 Initialize the config properties.
|
111 kumpf 1.1 */
112 void FileSystemPropertyOwner::initialize()
113 {
114 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
115 {
116 //
117 // Initialize the properties with default values
118 //
119 if (String::equalNoCase(properties[i].propertyName, "repositoryDir"))
120 {
121 _repositoryDir->propertyName = properties[i].propertyName;
122 _repositoryDir->defaultValue = properties[i].defaultValue;
123 _repositoryDir->currentValue = properties[i].defaultValue;
124 _repositoryDir->plannedValue = properties[i].defaultValue;
125 _repositoryDir->dynamic = properties[i].dynamic;
126 _repositoryDir->domain = properties[i].domain;
127 _repositoryDir->domainSize = properties[i].domainSize;
|
128 kumpf 1.6 _repositoryDir->externallyVisible = properties[i].externallyVisible;
|
129 kumpf 1.1 }
|
130 david 1.9 else if (String::equalNoCase(properties[i].propertyName, "messageDir"))
131 {
132 _messageDir->propertyName = properties[i].propertyName;
133 _messageDir->defaultValue = properties[i].defaultValue;
134 _messageDir->currentValue = properties[i].defaultValue;
135 _messageDir->plannedValue = properties[i].defaultValue;
136 _messageDir->dynamic = properties[i].dynamic;
137 _messageDir->domain = properties[i].domain;
138 _messageDir->domainSize = properties[i].domainSize;
139 _messageDir->externallyVisible = properties[i].externallyVisible;
140 }
|
141 kumpf 1.32 else if (String::equalNoCase(properties[i].propertyName,
|
142 b.whiteley 1.26 "providerManagerDir"))
143 {
144 _providerManagerDir->propertyName = properties[i].propertyName;
145 _providerManagerDir->defaultValue = properties[i].defaultValue;
146 _providerManagerDir->currentValue = properties[i].defaultValue;
147 _providerManagerDir->plannedValue = properties[i].defaultValue;
148 _providerManagerDir->dynamic = properties[i].dynamic;
149 _providerManagerDir->domain = properties[i].domain;
150 _providerManagerDir->domainSize = properties[i].domainSize;
|
151 kumpf 1.32 _providerManagerDir->externallyVisible =
|
152 b.whiteley 1.26 properties[i].externallyVisible;
153 }
|
154 kumpf 1.1 }
155 }
156
|
157 kumpf 1.3 struct ConfigProperty* FileSystemPropertyOwner::_lookupConfigProperty(
|
158 aruran.ms 1.18 const String& name) const
|
159 kumpf 1.1 {
160 if (String::equalNoCase(_repositoryDir->propertyName, name))
161 {
|
162 a.arora 1.10 return _repositoryDir.get();
|
163 david 1.9 }
164 if (String::equalNoCase(_messageDir->propertyName, name))
165 {
|
166 a.arora 1.10 return _messageDir.get();
|
167 kumpf 1.1 }
|
168 b.whiteley 1.26 if (String::equalNoCase(_providerManagerDir->propertyName, name))
|
169 kumpf 1.1 {
|
170 b.whiteley 1.26 return _providerManagerDir.get();
|
171 kumpf 1.1 }
|
172 b.whiteley 1.26 throw UnrecognizedConfigProperty(name);
|
173 kumpf 1.1 }
174
|
175 kumpf 1.23 /**
176 Get information about the specified property.
|
177 kumpf 1.1 */
|
178 kumpf 1.3 void FileSystemPropertyOwner::getPropertyInfo(
|
179 kumpf 1.23 const String& name,
|
180 vijay.eli 1.17 Array<String>& propertyInfo) const
|
181 kumpf 1.1 {
|
182 kumpf 1.3 propertyInfo.clear();
|
183 aruran.ms 1.18 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
184 kumpf 1.3
185 propertyInfo.append(configProperty->propertyName);
186 propertyInfo.append(configProperty->defaultValue);
187 propertyInfo.append(configProperty->currentValue);
188 propertyInfo.append(configProperty->plannedValue);
189 if (configProperty->dynamic)
|
190 kumpf 1.6 {
191 propertyInfo.append(STRING_TRUE);
192 }
193 else
194 {
195 propertyInfo.append(STRING_FALSE);
196 }
197 if (configProperty->externallyVisible)
|
198 kumpf 1.1 {
|
199 kumpf 1.3 propertyInfo.append(STRING_TRUE);
|
200 kumpf 1.1 }
201 else
202 {
|
203 kumpf 1.3 propertyInfo.append(STRING_FALSE);
|
204 kumpf 1.1 }
205 }
206
|
207 kumpf 1.3
208 /**
|
209 kumpf 1.23 Get default value of the specified property.
|
210 kumpf 1.3 */
|
211 vijay.eli 1.17 String FileSystemPropertyOwner::getDefaultValue(const String& name) const
|
212 kumpf 1.3 {
|
213 kumpf 1.23 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
214 vijay.eli 1.17
|
215 kumpf 1.3 return configProperty->defaultValue;
216 }
217
|
218 kumpf 1.23 /**
219 Get current value of the specified property.
|
220 kumpf 1.1 */
|
221 vijay.eli 1.17 String FileSystemPropertyOwner::getCurrentValue(const String& name) const
|
222 kumpf 1.1 {
|
223 aruran.ms 1.18 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
224 vijay.eli 1.17
|
225 kumpf 1.3 return configProperty->currentValue;
|
226 kumpf 1.1 }
227
|
228 kumpf 1.23 /**
229 Get planned value of the specified property.
|
230 kumpf 1.1 */
|
231 vijay.eli 1.17 String FileSystemPropertyOwner::getPlannedValue(const String& name) const
|
232 kumpf 1.1 {
|
233 aruran.ms 1.18 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
234 vijay.eli 1.17
|
235 kumpf 1.3 return configProperty->plannedValue;
|
236 kumpf 1.1 }
237
|
238 kumpf 1.23 /**
239 Init current value of the specified property to the specified value.
|
240 kumpf 1.1 */
241 void FileSystemPropertyOwner::initCurrentValue(
|
242 kumpf 1.23 const String& name,
|
243 kumpf 1.1 const String& value)
244 {
|
245 kumpf 1.3 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
246 configProperty->currentValue = value;
|
247 kumpf 1.1 }
248
249
|
250 kumpf 1.23 /**
251 Init planned value of the specified property to the specified value.
|
252 kumpf 1.1 */
253 void FileSystemPropertyOwner::initPlannedValue(
|
254 kumpf 1.23 const String& name,
|
255 kumpf 1.1 const String& value)
256 {
|
257 kumpf 1.3 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
258 configProperty->plannedValue = value;
|
259 kumpf 1.1 }
260
|
261 kumpf 1.23 /**
262 Update current value of the specified property to the specified value.
|
263 kumpf 1.1 */
264 void FileSystemPropertyOwner::updateCurrentValue(
|
265 kumpf 1.23 const String& name,
266 const String& value)
|
267 kumpf 1.1 {
268 //
269 // make sure the property is dynamic before updating the value.
270 //
271 if (!isDynamic(name))
272 {
|
273 kumpf 1.23 throw NonDynamicConfigProperty(name);
|
274 kumpf 1.1 }
|
275 kumpf 1.3
276 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
277 configProperty->currentValue = value;
|
278 kumpf 1.1 }
279
280
|
281 kumpf 1.23 /**
282 Update planned value of the specified property to the specified value.
|
283 kumpf 1.1 */
284 void FileSystemPropertyOwner::updatePlannedValue(
|
285 kumpf 1.23 const String& name,
|
286 kumpf 1.1 const String& value)
287 {
|
288 kumpf 1.3 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
289 configProperty->plannedValue = value;
|
290 kumpf 1.1 }
291
|
292 kumpf 1.23 /**
293 Checks to see if the given value is valid or not.
|
294 kumpf 1.1 */
|
295 kumpf 1.23 Boolean FileSystemPropertyOwner::isValid(
296 const String& name,
297 const String& value) const
|
298 kumpf 1.1 {
|
299 kumpf 1.23 if (!isDirValid(value))
|
300 kumpf 1.1 {
301 throw InvalidPropertyValue(name, value);
302 }
|
303 kumpf 1.23
|
304 kumpf 1.1 return true;
305 }
306
|
307 kumpf 1.23 /**
308 Checks to see if the specified property is dynamic or not.
|
309 kumpf 1.1 */
|
310 vijay.eli 1.17 Boolean FileSystemPropertyOwner::isDynamic(const String& name) const
|
311 kumpf 1.1 {
|
312 aruran.ms 1.18 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
313 vijay.eli 1.17
|
314 kumpf 1.23 return (configProperty->dynamic == IS_DYNAMIC);
|
315 kumpf 1.1 }
316
317
318 PEGASUS_NAMESPACE_END
|