(file) Return to DefaultPropertyOwner.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Config

  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            //%/////////////////////////////////////////////////////////////////////////////
 33            
 34            
 35            ///////////////////////////////////////////////////////////////////////////////
 36 chip  1.20 //
 37 mike  1.2  // This file has implementation for the default property owner class.
 38            //
 39            ///////////////////////////////////////////////////////////////////////////////
 40            
 41            #include "DefaultPropertyOwner.h"
 42 yi.zhou 1.26 #include "ConfigManager.h"
 43              #include <Pegasus/Common/AuditLogger.h>
 44 kavita.gupta 1.30 #include <Pegasus/Common/StringConversion.h>
 45 mike         1.2  
 46                   PEGASUS_USING_STD;
 47                   
 48                   PEGASUS_NAMESPACE_BEGIN
 49                   
 50                   
 51                   ///////////////////////////////////////////////////////////////////////////////
 52                   //  DefaultPropertyOwner
 53                   //
 54 chip         1.20 //  When a new property is added with the default owner, make sure to add
 55                   //  the property name and the default attributes of that property in
 56 mike         1.2  //  the table below.
 57                   ///////////////////////////////////////////////////////////////////////////////
 58                   
 59                   static struct ConfigPropertyRow properties[] =
 60                   {
 61 kumpf        1.14 #include "DefaultPropertyTable.h"
 62 mike         1.2  };
 63                   
 64                   const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
 65                   
 66                   
 67                   /** Constructors  */
 68                   DefaultPropertyOwner::DefaultPropertyOwner()
 69                   {
 70 a.arora      1.17     _configProperties.reset(new ConfigProperty[NUM_PROPERTIES]);
 71 mike         1.2  }
 72                   
 73                   
 74                   /**
 75 kumpf        1.27     Initialize the config properties.
 76 mike         1.2  */
 77                   void DefaultPropertyOwner::initialize()
 78                   {
 79                       for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
 80                       {
 81 a.arora      1.17         (_configProperties.get())[i].propertyName = properties[i].propertyName;
 82                           (_configProperties.get())[i].defaultValue = properties[i].defaultValue;
 83                           (_configProperties.get())[i].currentValue = properties[i].defaultValue;
 84                           (_configProperties.get())[i].plannedValue = properties[i].defaultValue;
 85                           (_configProperties.get())[i].dynamic = properties[i].dynamic;
 86                           (_configProperties.get())[i].domain = properties[i].domain;
 87                           (_configProperties.get())[i].domainSize = properties[i].domainSize;
 88 kumpf        1.27         (_configProperties.get())[i].externallyVisible =
 89                               properties[i].externallyVisible;
 90 mike         1.2      }
 91                   }
 92                   
 93                   
 94 chip         1.20 /**
 95 kumpf        1.27     Get information about the specified property.
 96 mike         1.2  */
 97                   void DefaultPropertyOwner::getPropertyInfo(
 98 chip         1.20     const String& name,
 99 vijay.eli    1.23     Array<String>& propertyInfo) const
100 mike         1.2  {
101                       propertyInfo.clear();
102                   
103                       for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
104                       {
105 kumpf        1.27         if (String::equalNoCase(_configProperties.get()[i].propertyName, name))
106 mike         1.2          {
107 kumpf        1.27             propertyInfo.append(_configProperties.get()[i].propertyName);
108                               propertyInfo.append(_configProperties.get()[i].defaultValue);
109                               propertyInfo.append(_configProperties.get()[i].currentValue);
110                               propertyInfo.append(_configProperties.get()[i].plannedValue);
111                               if (_configProperties.get()[i].dynamic)
112 kumpf        1.15             {
113                                   propertyInfo.append(STRING_TRUE);
114                               }
115                               else
116                               {
117                                   propertyInfo.append(STRING_FALSE);
118                               }
119 kumpf        1.27             if (_configProperties.get()[i].externallyVisible)
120 mike         1.2              {
121                                   propertyInfo.append(STRING_TRUE);
122                               }
123                               else
124                               {
125                                   propertyInfo.append(STRING_FALSE);
126                               }
127                               return;
128                           }
129                       }
130                   
131                       //
132                       // specified property name is not found
133                       //
134                       throw UnrecognizedConfigProperty(name);
135                   }
136                   
137 chip         1.20 /**
138 kumpf        1.27     Get default value of the specified property
139 mike         1.2  */
140 vijay.eli    1.23 String DefaultPropertyOwner::getDefaultValue(const String& name) const
141 mike         1.2  {
142                       for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
143                       {
144 kumpf        1.27         if (String::equalNoCase(_configProperties.get()[i].propertyName, name))
145 mike         1.2          {
146 kumpf        1.27             return _configProperties.get()[i].defaultValue;
147 mike         1.2          }
148                       }
149                   
150                       //
151                       // Specified property name could not be found
152                       //
153                       throw UnrecognizedConfigProperty(name);
154                   }
155                   
156 chip         1.20 /**
157 kumpf        1.27     Get current value of the specified property
158 mike         1.2  */
159 vijay.eli    1.23 String DefaultPropertyOwner::getCurrentValue(const String& name) const
160 mike         1.2  {
161                       for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
162                       {
163 kumpf        1.27         if (String::equalNoCase(_configProperties.get()[i].propertyName, name))
164 mike         1.2          {
165 kumpf        1.27             return _configProperties.get()[i].currentValue;
166 mike         1.2          }
167                       }
168                   
169                       //
170                       // Specified property name could not be found
171                       //
172                       throw UnrecognizedConfigProperty(name);
173                   }
174                   
175 chip         1.20 /**
176 kumpf        1.27     Get planned value of the specified property
177 mike         1.2  */
178 vijay.eli    1.23 String DefaultPropertyOwner::getPlannedValue(const String& name) const
179 mike         1.2  {
180                       for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
181                       {
182 kumpf        1.27         if (String::equalNoCase(_configProperties.get()[i].propertyName, name))
183 mike         1.2          {
184 kumpf        1.27             return _configProperties.get()[i].plannedValue;
185 mike         1.2          }
186                       }
187                   
188                       //
189                       // Specified property name could not be found
190                       //
191                       throw UnrecognizedConfigProperty(name);
192                   }
193                   
194 chip         1.20 /**
195 kumpf        1.27     Init current value of the specified property to the specified value
196 mike         1.2  */
197                   void DefaultPropertyOwner::initCurrentValue(
198 chip         1.20     const String& name,
199 mike         1.2      const String& value)
200                   {
201                       for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
202                       {
203 kumpf        1.27         if (String::equalNoCase(_configProperties.get()[i].propertyName, name))
204 mike         1.2          {
205 kumpf        1.27             _configProperties.get()[i].currentValue = value;
206 mike         1.2              return;
207                           }
208                       }
209                   
210                       //
211                       // Specified property name could not be found
212                       //
213                       throw UnrecognizedConfigProperty(name);
214                   }
215                   
216 chip         1.20 /**
217 kumpf        1.27     Init planned value of the specified property to the specified value
218 mike         1.2  */
219                   void DefaultPropertyOwner::initPlannedValue(
220 chip         1.20     const String& name,
221 mike         1.2      const String& value)
222                   {
223                       for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
224                       {
225 kumpf        1.27         if (String::equalNoCase(_configProperties.get()[i].propertyName, name))
226 mike         1.2          {
227 kumpf        1.27             _configProperties.get()[i].plannedValue = value;
228 mike         1.2              return;
229                           }
230                       }
231                   
232                       //
233                       // Specified property name could not be found
234                       //
235                       throw UnrecognizedConfigProperty(name);
236                   }
237                   
238 chip         1.20 /**
239 kumpf        1.27     Update current value of the specified property to the specified value
240 mike         1.2  */
241                   void DefaultPropertyOwner::updateCurrentValue(
242 chip         1.20     const String& name,
243 mike         1.2      const String& value)
244                   {
245                       //
246                       // make sure the property is dynamic before updating the value.
247                       //
248                       if (!isDynamic(name))
249                       {
250 chip         1.20         throw NonDynamicConfigProperty(name);
251 mike         1.2      }
252                   
253                       //
254 chip         1.20     // Since the validations done in initCurrrentValue are sufficient and
255                       // no additional validations required for update, we shall call
256 mike         1.2      // initCurrrentValue.
257                       //
258                       initCurrentValue(name, value);
259 yi.zhou      1.26 
260 kumpf        1.28 #ifdef PEGASUS_ENABLE_AUDIT_LOGGER
261 yi.zhou      1.26 
262                       if (String::equal(name, "enableAuditLog") && isValid(name, value))
263                       {
264                           Boolean enableAuditLog = ConfigManager::parseBooleanValue(value);
265                           AuditLogger::setEnabled(enableAuditLog);
266                       }
267                   
268                   #endif
269                   
270 mike         1.2  }
271                   
272                   
273 chip         1.20 /**
274 kumpf        1.27     Update planned value of the specified property to the specified value
275 mike         1.2  */
276                   void DefaultPropertyOwner::updatePlannedValue(
277 chip         1.20     const String& name,
278 mike         1.2      const String& value)
279                   {
280                       //
281 chip         1.20     // Since the validations done in initPlannedValue are sufficient and
282                       // no additional validations required for update, we shall call
283 mike         1.2      // initPlannedValue.
284                       //
285                       initPlannedValue(name, value);
286                   }
287                   
288                   
289 chip         1.20 /**
290 mike         1.2  Checks to see if the given value is valid or not.
291                   */
292 kumpf        1.27 Boolean DefaultPropertyOwner::isValid(
293                       const String& name,
294                       const String& value) const
295 mike         1.2  {
296                       //
297                       // By default, no validation is done. It can optionally be added here
298                       // per property.
299                       //
300 dave.sudlik  1.29     if (String::equalNoCase(name, "socketWriteTimeout") ||
301 marek        1.31         String::equalNoCase(name, "idleConnectionTimeout")
302                       {
303                           Uint64 v;
304                           return 
305                               StringConversion::decimalStringToUint64(value.getCString(), v) &&
306                               StringConversion::checkUintBounds(v, CIMTYPE_UINT32) &&
307                               (v != 0);
308                       }
309                       if (String::equalNoCase(name, "maxProviderProcesses"))
310 marek        1.25     {
311 kavita.gupta 1.30         Uint64 v;
312                           return 
313                               StringConversion::decimalStringToUint64(value.getCString(), v) &&
314                               StringConversion::checkUintBounds(v, CIMTYPE_UINT32);
315 marek        1.25     }
316 kumpf        1.28 #ifdef PEGASUS_ENABLE_AUDIT_LOGGER
317 yi.zhou      1.26     else if (String::equal(name, "enableAuditLog"))
318                       {
319                           if (!(String::equalNoCase(value, "true")) &&
320                               !(String::equalNoCase(value, "false")))
321                           {
322 kumpf        1.27             return false;
323 yi.zhou      1.26         }
324                       }
325                   #endif
326                   
327 kumpf        1.27     return true;
328 mike         1.2  }
329                   
330 chip         1.20 /**
331 kumpf        1.27     Checks to see if the specified property is dynamic or not.
332 mike         1.2  */
333 vijay.eli    1.23 Boolean DefaultPropertyOwner::isDynamic(const String& name) const
334 mike         1.2  {
335                       for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
336                       {
337 kumpf        1.27         if (String::equalNoCase(_configProperties.get()[i].propertyName, name))
338 mike         1.2          {
339 kumpf        1.27             return (_configProperties.get()[i].dynamic == IS_DYNAMIC);
340 mike         1.2          }
341                       }
342                   
343                       //
344                       // Specified property name could not be found
345                       //
346                       throw UnrecognizedConfigProperty(name);
347                   }
348                   
349                   PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2