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

  1 karl  1.18 //%2006////////////////////////////////////////////////////////////////////////
  2 mike  1.2  //
  3 karl  1.12 // 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.8  // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.12 // 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.14 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.18 // 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 kumpf 1.6  // 
 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: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 33            //
 34 kumpf 1.7  // Modified By: Sushma Fernandes, Hewlett-Packard Company
 35            //                sushma_fernandes@hp.com
 36 dave.sudlik 1.9  //              Dave Sudlik, IBM (dsudlik@us.ibm.com), for PEP 164
 37 aruran.ms   1.15 //              Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3614
 38 vijay.eli   1.16 //              Vijay Eli, IBM, (vijayeli@in.ibm.com) for Bug# 3613
 39 aruran.ms   1.17 //              Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3613
 40 mike        1.2  //
 41                  //%/////////////////////////////////////////////////////////////////////////////
 42                  
 43                  
 44                  ///////////////////////////////////////////////////////////////////////////////
 45                  // 
 46                  // This file has implementation for the repository property owner class.
 47                  //
 48                  ///////////////////////////////////////////////////////////////////////////////
 49                  
 50                  #include "RepositoryPropertyOwner.h"
 51                  
 52                  
 53                  PEGASUS_USING_STD;
 54                  
 55                  PEGASUS_NAMESPACE_BEGIN
 56                  
 57                  ///////////////////////////////////////////////////////////////////////////////
 58                  //  RepositoryPropertyOwner
 59                  ///////////////////////////////////////////////////////////////////////////////
 60                  
 61 mike        1.2  static struct ConfigPropertyRow properties[] =
 62                  {
 63 denise.eckstein 1.11 #if defined(PEGASUS_OS_LINUX)
 64                      # ifdef PEGASUS_USE_RELEASE_CONFIG_OPTIONS
 65 konrad.r        1.13     {"repositoryIsDefaultInstanceProvider", "false", IS_STATIC, 0, 0, IS_HIDDEN},
 66 denise.eckstein 1.11 # else
 67 konrad.r        1.13     {"repositoryIsDefaultInstanceProvider", "true", IS_STATIC, 0, 0, IS_VISIBLE},
 68 denise.eckstein 1.11 # endif
 69                      #else
 70 konrad.r        1.13     {"repositoryIsDefaultInstanceProvider", "true", IS_STATIC, 0, 0, IS_VISIBLE},
 71 denise.eckstein 1.11 #endif
 72 konrad.r        1.13     {"enableBinaryRepository", "false", IS_STATIC, 0, 0, IS_VISIBLE}  // PEP 164
 73 mike            1.2  };
 74                      
 75                      const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
 76                      
 77                      
 78                      /** Constructors  */
 79                      RepositoryPropertyOwner::RepositoryPropertyOwner()
 80                      {
 81                          _repositoryIsDefaultInstanceProvider = new ConfigProperty;
 82 dave.sudlik     1.9      _enableBinaryRepository = new ConfigProperty; // PEP 164
 83 mike            1.2  }
 84                      
 85                      /** Destructor  */
 86                      RepositoryPropertyOwner::~RepositoryPropertyOwner()
 87                      {
 88                          delete _repositoryIsDefaultInstanceProvider;
 89 dave.sudlik     1.9      delete _enableBinaryRepository;  // PEP 164
 90 mike            1.2  }
 91                      
 92                      
 93                      /**
 94                      Initialize the config properties.
 95                      */
 96                      void RepositoryPropertyOwner::initialize()
 97                      {
 98                          for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
 99                          {
100                              //
101                              // Initialize the properties with default values
102                              //
103                              if (String::equalNoCase(
104                                  properties[i].propertyName, "repositoryIsDefaultInstanceProvider"))
105                              {
106                                  _repositoryIsDefaultInstanceProvider->propertyName = properties[i].propertyName;
107                                  _repositoryIsDefaultInstanceProvider->defaultValue = properties[i].defaultValue;
108                                  _repositoryIsDefaultInstanceProvider->currentValue = properties[i].defaultValue;
109                                  _repositoryIsDefaultInstanceProvider->plannedValue = properties[i].defaultValue;
110                                  _repositoryIsDefaultInstanceProvider->dynamic = properties[i].dynamic;
111 mike            1.2              _repositoryIsDefaultInstanceProvider->domain = properties[i].domain;
112                                  _repositoryIsDefaultInstanceProvider->domainSize = properties[i].domainSize;
113 kumpf           1.7              _repositoryIsDefaultInstanceProvider->externallyVisible = properties[i].externallyVisible;
114 mike            1.2          }
115 dave.sudlik     1.9          else if (String::equalNoCase(
116                                  properties[i].propertyName, "enableBinaryRepository")) // PEP 164
117                              {
118                                  _enableBinaryRepository->propertyName = properties[i].propertyName;
119                                  _enableBinaryRepository->defaultValue = properties[i].defaultValue;
120                                  _enableBinaryRepository->currentValue = properties[i].defaultValue;
121                                  _enableBinaryRepository->plannedValue = properties[i].defaultValue;
122                                  _enableBinaryRepository->dynamic = properties[i].dynamic;
123                                  _enableBinaryRepository->domain = properties[i].domain;
124                                  _enableBinaryRepository->domainSize = properties[i].domainSize;
125                                  _enableBinaryRepository->externallyVisible = properties[i].externallyVisible;
126                              }
127 mike            1.2      }
128                      }
129                      
130 kumpf           1.5  struct ConfigProperty* RepositoryPropertyOwner::_lookupConfigProperty(
131 aruran.ms       1.17     const String& name) const
132 kumpf           1.5  {
133                          if (String::equalNoCase(
134                                  _repositoryIsDefaultInstanceProvider->propertyName, name))
135                          {
136                              return _repositoryIsDefaultInstanceProvider;
137                          }
138 dave.sudlik     1.9      else if (String::equalNoCase(
139                                  _enableBinaryRepository->propertyName, name)) // PEP 164
140                          {
141                              return _enableBinaryRepository;
142                          }
143 kumpf           1.5      else
144                          {
145                              throw UnrecognizedConfigProperty(name);
146                          }
147                      }
148                      
149 mike            1.2  /** 
150                      Get information about the specified property.
151                      */
152                      void RepositoryPropertyOwner::getPropertyInfo(
153                          const String& name, 
154 vijay.eli       1.16     Array<String>& propertyInfo) const
155 mike            1.2  {
156                          propertyInfo.clear();
157 aruran.ms       1.17     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
158 kumpf           1.5  
159                          propertyInfo.append(configProperty->propertyName);
160                          propertyInfo.append(configProperty->defaultValue);
161                          propertyInfo.append(configProperty->currentValue);
162                          propertyInfo.append(configProperty->plannedValue);
163                          if (configProperty->dynamic)
164 kumpf           1.7      {
165                              propertyInfo.append(STRING_TRUE);
166                          }
167                          else
168                          {
169                              propertyInfo.append(STRING_FALSE);
170                          }
171                          if (configProperty->externallyVisible)
172 mike            1.2      {
173 kumpf           1.5          propertyInfo.append(STRING_TRUE);
174 mike            1.2      }
175                          else
176                          {
177 kumpf           1.5          propertyInfo.append(STRING_FALSE);
178 mike            1.2      }
179                      }
180                      
181                      /** 
182                      Get default value of the specified property.
183                      */
184 vijay.eli       1.16 String RepositoryPropertyOwner::getDefaultValue(const String& name) const
185 mike            1.2  {
186 aruran.ms       1.17     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
187 vijay.eli       1.16 
188 kumpf           1.5      return configProperty->defaultValue;
189 mike            1.2  }
190                      
191                      /** 
192                      Get current value of the specified property.
193                      */
194 vijay.eli       1.16 String RepositoryPropertyOwner::getCurrentValue(const String& name) const
195 mike            1.2  {
196 aruran.ms       1.17     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
197 vijay.eli       1.16 
198 kumpf           1.5      return configProperty->currentValue;
199 mike            1.2  }
200                      
201                      /** 
202                      Get planned value of the specified property.
203                      */
204 vijay.eli       1.16 String RepositoryPropertyOwner::getPlannedValue(const String& name) const
205 mike            1.2  {
206 aruran.ms       1.17     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
207 vijay.eli       1.16 
208 kumpf           1.5      return configProperty->plannedValue;
209 mike            1.2  }
210                      
211                      
212                      /** 
213                      Init current value of the specified property to the specified value.
214                      */
215                      void RepositoryPropertyOwner::initCurrentValue(
216                          const String& name, 
217                          const String& value)
218                      {
219 kumpf           1.5      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
220                          configProperty->currentValue = value;
221 mike            1.2  }
222                      
223                      
224                      /** 
225                      Init planned value of the specified property to the specified value.
226                      */
227                      void RepositoryPropertyOwner::initPlannedValue(
228                          const String& name, 
229                          const String& value)
230                      {
231 kumpf           1.5      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
232                          configProperty->plannedValue = value;
233 mike            1.2  }
234                      
235                      /** 
236                      Update current value of the specified property to the specified value.
237                      */
238                      void RepositoryPropertyOwner::updateCurrentValue(
239                          const String& name, 
240                          const String& value) 
241                      {
242                          //
243                          // make sure the property is dynamic before updating the value.
244                          //
245                          if (!isDynamic(name))
246                          {
247                              throw NonDynamicConfigProperty(name); 
248                          }
249                      
250                          //
251 kumpf           1.5      // Update does the same thing as initialization
252 mike            1.2      //
253 kumpf           1.5      initCurrentValue(name, value);
254 mike            1.2  }
255                      
256                      
257                      /** 
258                      Update planned value of the specified property to the specified value.
259                      */
260                      void RepositoryPropertyOwner::updatePlannedValue(
261                          const String& name, 
262                          const String& value)
263                      {
264                          //
265 kumpf           1.5      // Update does the same thing as initialization
266 mike            1.2      //
267 kumpf           1.5      initPlannedValue(name, value);
268 mike            1.2  }
269                      
270                      /** 
271                      Checks to see if the given value is valid or not.
272                      */
273 vijay.eli       1.16 Boolean RepositoryPropertyOwner::isValid(const String& name, 
274                                                     const String& value) const
275 mike            1.2  {
276                          Boolean retVal = false;
277                      
278                          //
279                          // Validate the specified value
280                          //
281                          if (String::equalNoCase(_repositoryIsDefaultInstanceProvider->propertyName, name))
282                          {
283                              if(String::equal(value, "true") || String::equal(value, "false"))
284                              {
285                                  retVal = true;
286                              }
287                          }
288 dave.sudlik     1.9      else if (String::equalNoCase(_enableBinaryRepository->propertyName, name)) // PEP 164
289                          {
290                              if(String::equal(value, "true") || String::equal(value, "false"))
291                              {
292                                  retVal = true;
293                              }
294                          }
295 mike            1.2      else
296                          {
297                              throw UnrecognizedConfigProperty(name);
298                          }
299                          return retVal;
300                      }
301                      
302                      /** 
303                      Checks to see if the specified property is dynamic or not.
304                      */
305 vijay.eli       1.16 Boolean RepositoryPropertyOwner::isDynamic(const String& name) const
306 mike            1.2  {
307 aruran.ms       1.17     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
308 vijay.eli       1.16 
309 konrad.r        1.13     return (configProperty->dynamic==IS_DYNAMIC);
310 mike            1.2  }
311                      
312                      
313                      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2