1 karl 1.24 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.18 // 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 karl 1.16 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.18 // 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.21 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.24 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 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 karl 1.21 //
|
21 mike 1.2 // 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 // Author: Nag Boranna (nagaraja_boranna@hp.com)
33 //
34 // Modified By: Yi Zhou (yi_zhou@hp.com)
|
35 kumpf 1.14 // Warren Otsuka (warren.otsuka@hp.com)
|
36 kumpf 1.15 // Sushma Fernandes, Hewlett-Packard Company
37 // (sushma_fernandes@hp.com)
|
38 aruran.ms 1.22 // Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3614
|
39 vijay.eli 1.23 // Vijay Eli, IBM, (vijayeli@in.ibm.com) for Bug# 3613
|
40 mike 1.2 //
41 //%/////////////////////////////////////////////////////////////////////////////
42
43
44 ///////////////////////////////////////////////////////////////////////////////
|
45 chip 1.20 //
|
46 mike 1.2 // This file has implementation for the default property owner class.
47 //
48 ///////////////////////////////////////////////////////////////////////////////
49
50 #include "DefaultPropertyOwner.h"
51
52
53 PEGASUS_USING_STD;
54
55 PEGASUS_NAMESPACE_BEGIN
56
57
58 ///////////////////////////////////////////////////////////////////////////////
59 // DefaultPropertyOwner
60 //
|
61 chip 1.20 // When a new property is added with the default owner, make sure to add
62 // the property name and the default attributes of that property in
|
63 mike 1.2 // the table below.
64 ///////////////////////////////////////////////////////////////////////////////
65
66 static struct ConfigPropertyRow properties[] =
67 {
|
68 kumpf 1.14 #include "DefaultPropertyTable.h"
|
69 mike 1.2 };
70
71 const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
72
73
74 /** Constructors */
75 DefaultPropertyOwner::DefaultPropertyOwner()
76 {
|
77 a.arora 1.17 _configProperties.reset(new ConfigProperty[NUM_PROPERTIES]);
|
78 mike 1.2 }
79
80
81 /**
82 Initialize the config properties.
83 */
84 void DefaultPropertyOwner::initialize()
85 {
86 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
87 {
|
88 a.arora 1.17 (_configProperties.get())[i].propertyName = properties[i].propertyName;
89 (_configProperties.get())[i].defaultValue = properties[i].defaultValue;
90 (_configProperties.get())[i].currentValue = properties[i].defaultValue;
91 (_configProperties.get())[i].plannedValue = properties[i].defaultValue;
92 (_configProperties.get())[i].dynamic = properties[i].dynamic;
93 (_configProperties.get())[i].domain = properties[i].domain;
94 (_configProperties.get())[i].domainSize = properties[i].domainSize;
95 (_configProperties.get())[i].externallyVisible = properties[i].externallyVisible;
|
96 mike 1.2 }
97 }
98
99
|
100 chip 1.20 /**
|
101 mike 1.2 Get information about the specified property.
102 */
103 void DefaultPropertyOwner::getPropertyInfo(
|
104 chip 1.20 const String& name,
|
105 vijay.eli 1.23 Array<String>& propertyInfo) const
|
106 mike 1.2 {
107 propertyInfo.clear();
108
109 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
110 {
|
111 a.arora 1.17 if (String::equalNoCase((_configProperties.get())[i].propertyName, name))
|
112 mike 1.2 {
|
113 a.arora 1.17 propertyInfo.append((_configProperties.get())[i].propertyName);
114 propertyInfo.append((_configProperties.get())[i].defaultValue);
115 propertyInfo.append((_configProperties.get())[i].currentValue);
116 propertyInfo.append((_configProperties.get())[i].plannedValue);
117 if ((_configProperties.get())[i].dynamic)
|
118 kumpf 1.15 {
119 propertyInfo.append(STRING_TRUE);
120 }
121 else
122 {
123 propertyInfo.append(STRING_FALSE);
124 }
|
125 a.arora 1.17 if ((_configProperties.get())[i].externallyVisible)
|
126 mike 1.2 {
127 propertyInfo.append(STRING_TRUE);
128 }
129 else
130 {
131 propertyInfo.append(STRING_FALSE);
132 }
133 return;
134 }
135 }
136
137 //
138 // specified property name is not found
139 //
140 throw UnrecognizedConfigProperty(name);
141 }
142
|
143 chip 1.20 /**
144 Get default value of the specified property
|
145 mike 1.2 */
|
146 vijay.eli 1.23 String DefaultPropertyOwner::getDefaultValue(const String& name) const
|
147 mike 1.2 {
148 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
149 {
|
150 a.arora 1.17 if (String::equalNoCase((_configProperties.get())[i].propertyName, name))
|
151 mike 1.2 {
|
152 a.arora 1.17 return ((_configProperties.get())[i].defaultValue);
|
153 mike 1.2 }
154 }
155
156 //
157 // Specified property name could not be found
158 //
159 throw UnrecognizedConfigProperty(name);
160 }
161
|
162 chip 1.20 /**
163 Get current value of the specified property
|
164 mike 1.2 */
|
165 vijay.eli 1.23 String DefaultPropertyOwner::getCurrentValue(const String& name) const
|
166 mike 1.2 {
167 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
168 {
|
169 a.arora 1.17 if (String::equalNoCase((_configProperties.get())[i].propertyName, name))
|
170 mike 1.2 {
|
171 a.arora 1.17 return ((_configProperties.get())[i].currentValue);
|
172 mike 1.2 }
173 }
174
175 //
176 // Specified property name could not be found
177 //
178 throw UnrecognizedConfigProperty(name);
179 }
180
|
181 chip 1.20 /**
182 Get planned value of the specified property
|
183 mike 1.2 */
|
184 vijay.eli 1.23 String DefaultPropertyOwner::getPlannedValue(const String& name) const
|
185 mike 1.2 {
186 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
187 {
|
188 a.arora 1.17 if (String::equalNoCase((_configProperties.get())[i].propertyName, name))
|
189 mike 1.2 {
|
190 a.arora 1.17 return ((_configProperties.get())[i].plannedValue);
|
191 mike 1.2 }
192 }
193
194 //
195 // Specified property name could not be found
196 //
197 throw UnrecognizedConfigProperty(name);
198 }
199
|
200 chip 1.20 /**
201 Init current value of the specified property to the specified value
|
202 mike 1.2 */
203 void DefaultPropertyOwner::initCurrentValue(
|
204 chip 1.20 const String& name,
|
205 mike 1.2 const String& value)
206 {
207 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
208 {
|
209 a.arora 1.17 if (String::equalNoCase((_configProperties.get())[i].propertyName, name))
|
210 mike 1.2 {
|
211 a.arora 1.17 (_configProperties.get())[i].currentValue = value;
|
212 mike 1.2 return;
213 }
214 }
215
216 //
217 // Specified property name could not be found
218 //
219 throw UnrecognizedConfigProperty(name);
220 }
221
222
|
223 chip 1.20 /**
224 Init planned value of the specified property to the specified value
|
225 mike 1.2 */
226 void DefaultPropertyOwner::initPlannedValue(
|
227 chip 1.20 const String& name,
|
228 mike 1.2 const String& value)
229 {
230 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
231 {
|
232 a.arora 1.17 if (String::equalNoCase((_configProperties.get())[i].propertyName, name))
|
233 mike 1.2 {
|
234 a.arora 1.17 (_configProperties.get())[i].plannedValue = value;
|
235 mike 1.2 return;
236 }
237 }
238
239 //
240 // Specified property name could not be found
241 //
242 throw UnrecognizedConfigProperty(name);
243 }
244
|
245 chip 1.20 /**
246 Update current value of the specified property to the specified value
|
247 mike 1.2 */
248 void DefaultPropertyOwner::updateCurrentValue(
|
249 chip 1.20 const String& name,
|
250 mike 1.2 const String& value)
251 {
252 //
253 // make sure the property is dynamic before updating the value.
254 //
255 if (!isDynamic(name))
256 {
|
257 chip 1.20 throw NonDynamicConfigProperty(name);
|
258 mike 1.2 }
259
260 //
|
261 chip 1.20 // Since the validations done in initCurrrentValue are sufficient and
262 // no additional validations required for update, we shall call
|
263 mike 1.2 // initCurrrentValue.
264 //
265 initCurrentValue(name, value);
266 }
267
268
|
269 chip 1.20 /**
270 Update planned value of the specified property to the specified value
|
271 mike 1.2 */
272 void DefaultPropertyOwner::updatePlannedValue(
|
273 chip 1.20 const String& name,
|
274 mike 1.2 const String& value)
275 {
276 //
|
277 chip 1.20 // Since the validations done in initPlannedValue are sufficient and
278 // no additional validations required for update, we shall call
|
279 mike 1.2 // initPlannedValue.
280 //
281 initPlannedValue(name, value);
282 }
283
284
|
285 chip 1.20 /**
|
286 mike 1.2 Checks to see if the given value is valid or not.
287 */
288 Boolean DefaultPropertyOwner::isValid(const String& name, const String& value)
|
289 vijay.eli 1.23 const
|
290 mike 1.2 {
291 //
292 // By default, no validation is done. It can optionally be added here
293 // per property.
294 //
|
295 marek 1.25 if (String::equalNoCase(name, "socketWriteTimeout"))
296 {
297 Uint32 timeoutValue;
298 char dummyChar;
299 int numConversions =
300 sscanf(value.getCString(), "%u%c", &timeoutValue, &dummyChar);
301 return ((timeoutValue != 0) && (numConversions == 1));
302 }
|
303 chip 1.20 return(true);
|
304 mike 1.2 }
305
|
306 chip 1.20 /**
|
307 mike 1.2 Checks to see if the specified property is dynamic or not.
308 */
|
309 vijay.eli 1.23 Boolean DefaultPropertyOwner::isDynamic(const String& name) const
|
310 mike 1.2 {
311 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
312 {
|
313 a.arora 1.17 if (String::equalNoCase((_configProperties.get())[i].propertyName, name))
|
314 mike 1.2 {
|
315 konrad.r 1.19 return ((_configProperties.get())[i].dynamic == IS_DYNAMIC);
|
316 mike 1.2 }
317 }
318
319 //
320 // Specified property name could not be found
321 //
322 throw UnrecognizedConfigProperty(name);
323 }
324
325
326 PEGASUS_NAMESPACE_END
|