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

  1 martin 1.22 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.23 //
  3 martin 1.22 // 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.23 //
 10 martin 1.22 // 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.23 //
 17 martin 1.22 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.23 //
 20 martin 1.22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.23 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.22 // 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.23 //
 28 martin 1.22 //////////////////////////////////////////////////////////////////////////
 29 mike   1.2  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             
 33             ///////////////////////////////////////////////////////////////////////////////
 34 kumpf  1.20 //
 35 mike   1.2  // This file has implementation for the repository property owner class.
 36             //
 37             ///////////////////////////////////////////////////////////////////////////////
 38             
 39             #include "RepositoryPropertyOwner.h"
 40 kavita.gupta 1.26 #include "ConfigManager.h"
 41 mike         1.2  
 42                   PEGASUS_USING_STD;
 43                   
 44                   PEGASUS_NAMESPACE_BEGIN
 45                   
 46                   ///////////////////////////////////////////////////////////////////////////////
 47                   //  RepositoryPropertyOwner
 48                   ///////////////////////////////////////////////////////////////////////////////
 49                   
 50                   static struct ConfigPropertyRow properties[] =
 51                   {
 52 denise.eckstein 1.11 #if defined(PEGASUS_OS_LINUX)
 53                      # ifdef PEGASUS_USE_RELEASE_CONFIG_OPTIONS
 54 kumpf           1.24     {"repositoryIsDefaultInstanceProvider", "false", IS_STATIC, IS_HIDDEN},
 55 denise.eckstein 1.11 # else
 56 kumpf           1.24     {"repositoryIsDefaultInstanceProvider", "true", IS_STATIC, IS_VISIBLE},
 57 denise.eckstein 1.11 # endif
 58                      #else
 59 kumpf           1.24     {"repositoryIsDefaultInstanceProvider", "true", IS_STATIC, IS_VISIBLE},
 60 denise.eckstein 1.11 #endif
 61 r.kieninger     1.21 #ifndef PEGASUS_OS_ZOS
 62 kumpf           1.24     {"enableBinaryRepository", "false", IS_STATIC, IS_VISIBLE}
 63 marek           1.19 #else
 64 thilo.boehm     1.25     {"enableBinaryRepository", "true", IS_STATIC, IS_HIDDEN}
 65 marek           1.19 #endif
 66 mike            1.2  };
 67                      
 68                      const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
 69                      
 70                      
 71 kumpf           1.20 /** Constructors */
 72 mike            1.2  RepositoryPropertyOwner::RepositoryPropertyOwner()
 73                      {
 74                          _repositoryIsDefaultInstanceProvider = new ConfigProperty;
 75 kumpf           1.20     _enableBinaryRepository = new ConfigProperty;
 76 mike            1.2  }
 77                      
 78 kumpf           1.20 /** Destructor */
 79 mike            1.2  RepositoryPropertyOwner::~RepositoryPropertyOwner()
 80                      {
 81                          delete _repositoryIsDefaultInstanceProvider;
 82 kumpf           1.20     delete _enableBinaryRepository;
 83 mike            1.2  }
 84                      
 85                      
 86                      /**
 87 kumpf           1.20     Initialize the config properties.
 88 mike            1.2  */
 89                      void RepositoryPropertyOwner::initialize()
 90                      {
 91                          for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
 92                          {
 93                              //
 94                              // Initialize the properties with default values
 95                              //
 96 kavita.gupta    1.26         if (String::equal(properties[i].propertyName,
 97 kumpf           1.20                 "repositoryIsDefaultInstanceProvider"))
 98 mike            1.2          {
 99 kumpf           1.20             _repositoryIsDefaultInstanceProvider->propertyName =
100                                      properties[i].propertyName;
101                                  _repositoryIsDefaultInstanceProvider->defaultValue =
102                                      properties[i].defaultValue;
103                                  _repositoryIsDefaultInstanceProvider->currentValue =
104                                      properties[i].defaultValue;
105                                  _repositoryIsDefaultInstanceProvider->plannedValue =
106                                      properties[i].defaultValue;
107                                  _repositoryIsDefaultInstanceProvider->dynamic =
108                                      properties[i].dynamic;
109                                  _repositoryIsDefaultInstanceProvider->externallyVisible =
110                                      properties[i].externallyVisible;
111 mike            1.2          }
112 kavita.gupta    1.26         else if (String::equal(
113 kumpf           1.20             properties[i].propertyName, "enableBinaryRepository"))
114 dave.sudlik     1.9          {
115                                  _enableBinaryRepository->propertyName = properties[i].propertyName;
116                                  _enableBinaryRepository->defaultValue = properties[i].defaultValue;
117                                  _enableBinaryRepository->currentValue = properties[i].defaultValue;
118                                  _enableBinaryRepository->plannedValue = properties[i].defaultValue;
119                                  _enableBinaryRepository->dynamic = properties[i].dynamic;
120 kumpf           1.20             _enableBinaryRepository->externallyVisible =
121                                      properties[i].externallyVisible;
122 dave.sudlik     1.9          }
123 mike            1.2      }
124                      }
125                      
126 kumpf           1.5  struct ConfigProperty* RepositoryPropertyOwner::_lookupConfigProperty(
127 aruran.ms       1.17     const String& name) const
128 kumpf           1.5  {
129 kavita.gupta    1.26     if (String::equal(
130 kumpf           1.5              _repositoryIsDefaultInstanceProvider->propertyName, name))
131                          {
132                              return _repositoryIsDefaultInstanceProvider;
133                          }
134 kavita.gupta    1.26     else if (String::equal(
135 kumpf           1.20             _enableBinaryRepository->propertyName, name))
136 dave.sudlik     1.9      {
137                              return _enableBinaryRepository;
138                          }
139 kumpf           1.5      else
140                          {
141                              throw UnrecognizedConfigProperty(name);
142                          }
143                      }
144                      
145 kumpf           1.20 /**
146                          Get information about the specified property.
147 mike            1.2  */
148                      void RepositoryPropertyOwner::getPropertyInfo(
149 kumpf           1.20     const String& name,
150 vijay.eli       1.16     Array<String>& propertyInfo) const
151 mike            1.2  {
152                          propertyInfo.clear();
153 aruran.ms       1.17     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
154 kumpf           1.5  
155                          propertyInfo.append(configProperty->propertyName);
156                          propertyInfo.append(configProperty->defaultValue);
157                          propertyInfo.append(configProperty->currentValue);
158                          propertyInfo.append(configProperty->plannedValue);
159                          if (configProperty->dynamic)
160 kumpf           1.7      {
161                              propertyInfo.append(STRING_TRUE);
162                          }
163                          else
164                          {
165                              propertyInfo.append(STRING_FALSE);
166                          }
167                          if (configProperty->externallyVisible)
168 mike            1.2      {
169 kumpf           1.5          propertyInfo.append(STRING_TRUE);
170 mike            1.2      }
171                          else
172                          {
173 kumpf           1.5          propertyInfo.append(STRING_FALSE);
174 mike            1.2      }
175                      }
176                      
177 kumpf           1.20 /**
178                          Get default value of the specified property.
179 mike            1.2  */
180 vijay.eli       1.16 String RepositoryPropertyOwner::getDefaultValue(const String& name) const
181 mike            1.2  {
182 aruran.ms       1.17     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
183 vijay.eli       1.16 
184 kumpf           1.5      return configProperty->defaultValue;
185 mike            1.2  }
186                      
187 kumpf           1.20 /**
188                          Get current value of the specified property.
189 mike            1.2  */
190 vijay.eli       1.16 String RepositoryPropertyOwner::getCurrentValue(const String& name) const
191 mike            1.2  {
192 aruran.ms       1.17     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
193 vijay.eli       1.16 
194 kumpf           1.5      return configProperty->currentValue;
195 mike            1.2  }
196                      
197 kumpf           1.20 /**
198                          Get planned value of the specified property.
199 mike            1.2  */
200 vijay.eli       1.16 String RepositoryPropertyOwner::getPlannedValue(const String& name) const
201 mike            1.2  {
202 aruran.ms       1.17     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
203 vijay.eli       1.16 
204 kumpf           1.5      return configProperty->plannedValue;
205 mike            1.2  }
206                      
207                      
208 kumpf           1.20 /**
209                          Init current value of the specified property to the specified value.
210 mike            1.2  */
211                      void RepositoryPropertyOwner::initCurrentValue(
212 kumpf           1.20     const String& name,
213 mike            1.2      const String& value)
214                      {
215 kumpf           1.5      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
216                          configProperty->currentValue = value;
217 mike            1.2  }
218                      
219                      
220 kumpf           1.20 /**
221                          Init planned value of the specified property to the specified value.
222 mike            1.2  */
223                      void RepositoryPropertyOwner::initPlannedValue(
224 kumpf           1.20     const String& name,
225 mike            1.2      const String& value)
226                      {
227 kumpf           1.5      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
228                          configProperty->plannedValue = value;
229 mike            1.2  }
230                      
231 kumpf           1.20 /**
232                          Update current value of the specified property to the specified value.
233 mike            1.2  */
234                      void RepositoryPropertyOwner::updateCurrentValue(
235 kumpf           1.20     const String& name,
236 venkat.puvvada  1.27     const String& value,
237 venkat.puvvada  1.28     const String& userName,
238                          Uint32 timeoutSeconds)
239 mike            1.2  {
240                          //
241                          // make sure the property is dynamic before updating the value.
242                          //
243                          if (!isDynamic(name))
244                          {
245 kumpf           1.20         throw NonDynamicConfigProperty(name);
246 mike            1.2      }
247                      
248                          //
249 kumpf           1.5      // Update does the same thing as initialization
250 mike            1.2      //
251 kumpf           1.5      initCurrentValue(name, value);
252 mike            1.2  }
253                      
254                      
255 kumpf           1.20 /**
256                          Update planned value of the specified property to the specified value.
257 mike            1.2  */
258                      void RepositoryPropertyOwner::updatePlannedValue(
259 kumpf           1.20     const String& name,
260 mike            1.2      const String& value)
261                      {
262                          //
263 kumpf           1.5      // Update does the same thing as initialization
264 mike            1.2      //
265 kumpf           1.5      initPlannedValue(name, value);
266 mike            1.2  }
267                      
268 kumpf           1.20 /**
269                          Checks to see if the given value is valid or not.
270 mike            1.2  */
271 kumpf           1.20 Boolean RepositoryPropertyOwner::isValid(
272                          const String& name,
273                          const String& value) const
274 mike            1.2  {
275                          Boolean retVal = false;
276                      
277                          //
278                          // Validate the specified value
279                          //
280 kavita.gupta    1.26     if (String::equal(
281                                  _repositoryIsDefaultInstanceProvider->propertyName, name) ||
282                              String::equal(_enableBinaryRepository->propertyName, name))
283 mike            1.2      {
284 kavita.gupta    1.26         retVal = ConfigManager::isValidBooleanValue(value);
285 dave.sudlik     1.9      }
286 mike            1.2      else
287                          {
288                              throw UnrecognizedConfigProperty(name);
289                          }
290                          return retVal;
291                      }
292                      
293 kumpf           1.20 /**
294                          Checks to see if the specified property is dynamic or not.
295 mike            1.2  */
296 vijay.eli       1.16 Boolean RepositoryPropertyOwner::isDynamic(const String& name) const
297 mike            1.2  {
298 aruran.ms       1.17     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
299 vijay.eli       1.16 
300 kumpf           1.20     return (configProperty->dynamic == IS_DYNAMIC);
301 mike            1.2  }
302                      
303                      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2