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