1 martin 1.17 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.18 //
|
3 martin 1.17 // 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.18 //
|
10 martin 1.17 // 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.18 //
|
17 martin 1.17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.18 //
|
20 martin 1.17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.18 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.17 // 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.18 //
|
28 martin 1.17 //////////////////////////////////////////////////////////////////////////
|
29 chip 1.1 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
|
32 venkat.puvvada 1.14 #include<Pegasus/Common/ObjectNormalizer.h>
|
33 kavita.gupta 1.20 #include "ConfigManager.h"
|
34 chip 1.1 #include "NormalizationPropertyOwner.h"
|
35 marek 1.25 #include "ConfigExceptions.h"
36
|
37 chip 1.1
38 PEGASUS_NAMESPACE_BEGIN
39
40 static struct ConfigPropertyRow properties[] =
41 {
|
42 chip 1.7 #ifdef PEGASUS_USE_RELEASE_CONFIG_OPTIONS
|
43 kumpf 1.19 { "enableNormalization", "false", IS_DYNAMIC, IS_VISIBLE },
|
44 chip 1.7 #else
|
45 kumpf 1.19 { "enableNormalization", "true", IS_DYNAMIC, IS_VISIBLE },
|
46 chip 1.7 #endif
|
47 kumpf 1.19 { "excludeModulesFromNormalization", "", IS_STATIC, IS_VISIBLE }
|
48 chip 1.1 };
49
50 const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
51
|
52 kumpf 1.12 NormalizationPropertyOwner::NormalizationPropertyOwner()
|
53 chip 1.1 {
54 _providerObjectNormalizationEnabled.reset(new ConfigProperty());
55 _providerObjectNormalizationModuleExclusions.reset(new ConfigProperty());
56 }
57
|
58 kumpf 1.12 void NormalizationPropertyOwner::initialize()
|
59 chip 1.1 {
|
60 kumpf 1.12 for (Uint8 i = 0; i < NUM_PROPERTIES; i++)
|
61 chip 1.1 {
|
62 kavita.gupta 1.20 if (String::equal(
|
63 kumpf 1.12 properties[i].propertyName, "enableNormalization"))
|
64 chip 1.1 {
|
65 kumpf 1.12 _providerObjectNormalizationEnabled->propertyName =
66 properties[i].propertyName;
67 _providerObjectNormalizationEnabled->defaultValue =
68 properties[i].defaultValue;
69 _providerObjectNormalizationEnabled->currentValue =
70 properties[i].defaultValue;
71 _providerObjectNormalizationEnabled->plannedValue =
72 properties[i].defaultValue;
73 _providerObjectNormalizationEnabled->dynamic =
74 properties[i].dynamic;
75 _providerObjectNormalizationEnabled->externallyVisible =
76 properties[i].externallyVisible;
|
77 venkat.puvvada 1.15 ObjectNormalizer::setEnableNormalization(
|
78 kavita.gupta 1.20 ConfigManager::parseBooleanValue(properties[i].defaultValue));
|
79 chip 1.1 }
|
80 kavita.gupta 1.20 else if (String::equal(properties[i].propertyName,
|
81 kumpf 1.12 "excludeModulesFromNormalization"))
|
82 chip 1.1 {
|
83 kumpf 1.12 _providerObjectNormalizationModuleExclusions->propertyName =
84 properties[i].propertyName;
85 _providerObjectNormalizationModuleExclusions->defaultValue =
86 properties[i].defaultValue;
87 _providerObjectNormalizationModuleExclusions->currentValue =
88 properties[i].defaultValue;
89 _providerObjectNormalizationModuleExclusions->plannedValue =
90 properties[i].defaultValue;
91 _providerObjectNormalizationModuleExclusions->dynamic =
92 properties[i].dynamic;
93 _providerObjectNormalizationModuleExclusions->externallyVisible =
94 properties[i].externallyVisible;
|
95 chip 1.1 }
96 }
97 }
98
|
99 kumpf 1.12 void NormalizationPropertyOwner::getPropertyInfo(
100 const String& name,
101 Array<String>& propertyInfo) const
|
102 chip 1.1 {
|
103 kumpf 1.12 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
104 chip 1.1
|
105 karl 1.24 buildPropertyInfo(name, configProperty, propertyInfo);
|
106 chip 1.1 }
107
|
108 kumpf 1.12 String NormalizationPropertyOwner::getDefaultValue(const String& name) const
|
109 chip 1.1 {
|
110 kumpf 1.12 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
111 chip 1.1
|
112 kumpf 1.12 return configProperty->defaultValue;
|
113 chip 1.1 }
114
|
115 kumpf 1.12 String NormalizationPropertyOwner::getCurrentValue(const String& name) const
|
116 chip 1.1 {
|
117 kumpf 1.12 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
118 chip 1.1
|
119 kumpf 1.12 return configProperty->currentValue;
|
120 chip 1.1 }
121
|
122 kumpf 1.12 String NormalizationPropertyOwner::getPlannedValue(const String& name) const
|
123 chip 1.1 {
|
124 kumpf 1.12 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
125 chip 1.1
|
126 kumpf 1.12 return configProperty->plannedValue;
|
127 chip 1.1 }
128
|
129 kumpf 1.12 void NormalizationPropertyOwner::initCurrentValue(
130 const String& name,
131 const String& value)
|
132 chip 1.1 {
|
133 kumpf 1.12 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
134 chip 1.1
135 configProperty->currentValue = value;
|
136 venkat.puvvada 1.14 ObjectNormalizer::setEnableNormalization(
|
137 kavita.gupta 1.20 ConfigManager::parseBooleanValue(value));
|
138 chip 1.1 }
139
|
140 kumpf 1.12 void NormalizationPropertyOwner::initPlannedValue(
141 const String& name,
142 const String& value)
|
143 chip 1.1 {
144 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
145
146 configProperty->plannedValue = value;
147 }
148
|
149 kumpf 1.12 void NormalizationPropertyOwner::updateCurrentValue(
150 const String& name,
|
151 venkat.puvvada 1.21 const String& value,
|
152 venkat.puvvada 1.22 const String& userName,
153 Uint32 timeoutSeconds)
|
154 chip 1.1 {
|
155 ashok.pathak 1.23 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
156
|
157 chip 1.1 // make sure the property is dynamic before updating the value.
|
158 ashok.pathak 1.23 if (configProperty->dynamic != IS_DYNAMIC)
|
159 chip 1.1 {
160 throw NonDynamicConfigProperty(name);
161 }
|
162 karl 1.24
|
163 ashok.pathak 1.23 configProperty->currentValue = value;
164 ObjectNormalizer::setEnableNormalization(
165 ConfigManager::parseBooleanValue(value));
166
167
|
168 chip 1.1 }
169
|
170 kumpf 1.12 void NormalizationPropertyOwner::updatePlannedValue(
171 const String& name,
172 const String& value)
|
173 chip 1.1 {
|
174 kumpf 1.12 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
175 chip 1.1
176 configProperty->plannedValue = value;
177 }
178
|
179 kumpf 1.12 Boolean NormalizationPropertyOwner::isValid(
180 const String& name,
181 const String& value) const
|
182 chip 1.1 {
|
183 kavita.gupta 1.20 if (String::equal(name, "enableNormalization"))
|
184 chip 1.1 {
185 // valid values are "true" and "false"
|
186 kavita.gupta 1.20 return ConfigManager::isValidBooleanValue(value);
|
187 chip 1.1 }
|
188 kavita.gupta 1.20 else if (String::equal(name, "excludeModulesFromNormalization"))
|
189 chip 1.1 {
190 // valid values must be in the form "n.n.n"
191
192 // TODO: validate value
193
|
194 kumpf 1.12 return true;
|
195 chip 1.1 }
196
|
197 kumpf 1.12 return false;
|
198 chip 1.1 }
199
|
200 kumpf 1.12 Boolean NormalizationPropertyOwner::isDynamic(const String& name) const
|
201 chip 1.1 {
|
202 kumpf 1.12 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
203 chip 1.1
|
204 chip 1.2 return(configProperty->dynamic == IS_DYNAMIC);
|
205 chip 1.1 }
206
|
207 kumpf 1.12 struct ConfigProperty* NormalizationPropertyOwner::_lookupConfigProperty(
208 const String& name) const
|
209 chip 1.1 {
|
210 kavita.gupta 1.20 if (String::equal(
|
211 kumpf 1.12 name, _providerObjectNormalizationEnabled->propertyName))
|
212 chip 1.1 {
|
213 kumpf 1.12 return _providerObjectNormalizationEnabled.get();
|
214 chip 1.1 }
|
215 kavita.gupta 1.20 else if (String::equal(
|
216 kumpf 1.12 name, _providerObjectNormalizationModuleExclusions->propertyName))
|
217 chip 1.1 {
|
218 kumpf 1.12 return _providerObjectNormalizationModuleExclusions.get();
|
219 chip 1.1 }
220 else
221 {
222 throw UnrecognizedConfigProperty(name);
223 }
224 }
225
226 PEGASUS_NAMESPACE_END
|