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

  1 martin 1.30 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.31 //
  3 martin 1.30 // 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.31 //
 10 martin 1.30 // 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.31 //
 17 martin 1.30 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.31 //
 20 martin 1.30 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.31 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.30 // 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.31 //
 28 martin 1.30 //////////////////////////////////////////////////////////////////////////
 29 kumpf  1.1  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             
 33             ///////////////////////////////////////////////////////////////////////////////
 34 kumpf  1.23 //
 35 kumpf  1.1  // This file has implementation for the file system property owner class.
 36             //
 37             ///////////////////////////////////////////////////////////////////////////////
 38             
 39             #include <Pegasus/Common/Config.h>
 40             #include <Pegasus/Common/Tracer.h>
 41             #include <Pegasus/Common/FileSystem.h>
 42             #include <Pegasus/Config/ConfigManager.h>
 43             #include "FileSystemPropertyOwner.h"
 44             
 45             
 46             PEGASUS_USING_STD;
 47             
 48             PEGASUS_NAMESPACE_BEGIN
 49             
 50             ///////////////////////////////////////////////////////////////////////////////
 51             //  FileSystemPropertyOwner
 52             //
 53             //  When a new FileSystem property is added, make sure to add the property name
 54             //  and the default attributes of that property in the table below.
 55             ///////////////////////////////////////////////////////////////////////////////
 56 kumpf  1.1  
 57             static struct ConfigPropertyRow properties[] =
 58             {
 59 kumpf  1.21     {"repositoryDir", PEGASUS_REPOSITORY_DIR, IS_STATIC, 0, 0, IS_VISIBLE},
 60 ouyang.jian 1.25 #if defined(PEGASUS_OS_PASE)
 61 kumpf       1.32     {"messageDir", "/QOpenSys/QIBM/ProdData/UME/Pegasus/msg", IS_STATIC,
 62 ouyang.jian 1.25         0, 0, IS_VISIBLE},
 63                  #else
 64 konrad.r    1.13     {"messageDir", "msg", IS_STATIC, 0, 0, IS_VISIBLE},
 65 ouyang.jian 1.25 #endif
 66 b.whiteley  1.26 #if defined(PEGASUS_OS_TYPE_WINDOWS)
 67 marek       1.27     {"providerManagerDir", "bin", IS_STATIC, 0, 0, IS_VISIBLE},
 68 r.kieninger 1.28 #elif defined(PEGASUS_OS_ZOS)
 69 marek       1.27     {"providerManagerDir", "lib", IS_STATIC, 0, 0, IS_VISIBLE},
 70 b.whiteley  1.26 #elif defined(PEGASUS_OS_PASE) && defined(PEGASUS_USE_RELEASE_DIRS)
 71 kumpf       1.32     {"providerManagerDir",
 72                          "/QOpenSys/QIBM/ProdData/UME/Pegasus/lib",
 73 b.whiteley  1.26         IS_STATIC, 0, 0, IS_VISIBLE}
 74                  #elif defined(PEGASUS_OS_VMS)
 75                      {"providerManagerDir", "/wbem_lib", IS_STATIC, 0, 0, IS_VISIBLE},
 76                  #else
 77                      {"providerManagerDir", "lib", IS_STATIC, 0, 0, IS_VISIBLE},
 78                  #endif
 79 kumpf       1.1  };
 80                  
 81                  const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
 82                  
 83                  
 84                  /** Constructors  */
 85                  FileSystemPropertyOwner::FileSystemPropertyOwner()
 86                  {
 87 a.arora     1.10     _repositoryDir.reset(new ConfigProperty);
 88                      _messageDir.reset(new ConfigProperty);
 89 b.whiteley  1.26     _providerManagerDir.reset(new ConfigProperty);
 90 kumpf       1.1  }
 91                  
 92                  
 93                  /**
 94 kumpf       1.23     Checks if the given directory is existing and writable
 95 kumpf       1.1  */
 96                  Boolean isDirValid(const String& dirName)
 97                  {
 98 marek       1.22     String directoryName(ConfigManager::getHomedPath(dirName));
 99 kumpf       1.23     if (FileSystem::isDirectory(directoryName) &&
100 marek       1.22         FileSystem::canWrite(directoryName))
101 kumpf       1.1      {
102                          return true;
103                      }
104                      return false;
105                  }
106 kumpf       1.23 
107 kumpf       1.1  /**
108 kumpf       1.23     Initialize the config properties.
109 kumpf       1.1  */
110                  void FileSystemPropertyOwner::initialize()
111                  {
112                      for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
113                      {
114                          //
115                          // Initialize the properties with default values
116                          //
117                          if (String::equalNoCase(properties[i].propertyName, "repositoryDir"))
118                          {
119                              _repositoryDir->propertyName = properties[i].propertyName;
120                              _repositoryDir->defaultValue = properties[i].defaultValue;
121                              _repositoryDir->currentValue = properties[i].defaultValue;
122                              _repositoryDir->plannedValue = properties[i].defaultValue;
123                              _repositoryDir->dynamic = properties[i].dynamic;
124                              _repositoryDir->domain = properties[i].domain;
125                              _repositoryDir->domainSize = properties[i].domainSize;
126 kumpf       1.6              _repositoryDir->externallyVisible = properties[i].externallyVisible;
127 kumpf       1.1          }
128 david       1.9          else if (String::equalNoCase(properties[i].propertyName, "messageDir"))
129                          {
130                              _messageDir->propertyName = properties[i].propertyName;
131                              _messageDir->defaultValue = properties[i].defaultValue;
132                              _messageDir->currentValue = properties[i].defaultValue;
133                              _messageDir->plannedValue = properties[i].defaultValue;
134                              _messageDir->dynamic = properties[i].dynamic;
135                              _messageDir->domain = properties[i].domain;
136                              _messageDir->domainSize = properties[i].domainSize;
137                              _messageDir->externallyVisible = properties[i].externallyVisible;
138                          }
139 kumpf       1.32         else if (String::equalNoCase(properties[i].propertyName,
140 b.whiteley  1.26                  "providerManagerDir"))
141                          {
142                              _providerManagerDir->propertyName = properties[i].propertyName;
143                              _providerManagerDir->defaultValue = properties[i].defaultValue;
144                              _providerManagerDir->currentValue = properties[i].defaultValue;
145                              _providerManagerDir->plannedValue = properties[i].defaultValue;
146                              _providerManagerDir->dynamic = properties[i].dynamic;
147                              _providerManagerDir->domain = properties[i].domain;
148                              _providerManagerDir->domainSize = properties[i].domainSize;
149 kumpf       1.32             _providerManagerDir->externallyVisible =
150 b.whiteley  1.26                                            properties[i].externallyVisible;
151                          }
152 kumpf       1.1      }
153                  }
154                  
155 kumpf       1.3  struct ConfigProperty* FileSystemPropertyOwner::_lookupConfigProperty(
156 aruran.ms   1.18     const String& name) const
157 kumpf       1.1  {
158                      if (String::equalNoCase(_repositoryDir->propertyName, name))
159                      {
160 a.arora     1.10         return _repositoryDir.get();
161 david       1.9      }
162                      if (String::equalNoCase(_messageDir->propertyName, name))
163                      {
164 a.arora     1.10         return _messageDir.get();
165 kumpf       1.1      }
166 b.whiteley  1.26     if (String::equalNoCase(_providerManagerDir->propertyName, name))
167 kumpf       1.1      {
168 b.whiteley  1.26         return _providerManagerDir.get();
169 kumpf       1.1      }
170 b.whiteley  1.26     throw UnrecognizedConfigProperty(name);
171 kumpf       1.1  }
172                  
173 kumpf       1.23 /**
174                      Get information about the specified property.
175 kumpf       1.1  */
176 kumpf       1.3  void FileSystemPropertyOwner::getPropertyInfo(
177 kumpf       1.23     const String& name,
178 vijay.eli   1.17     Array<String>& propertyInfo) const
179 kumpf       1.1  {
180 kumpf       1.3      propertyInfo.clear();
181 aruran.ms   1.18     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
182 kumpf       1.3  
183                      propertyInfo.append(configProperty->propertyName);
184                      propertyInfo.append(configProperty->defaultValue);
185                      propertyInfo.append(configProperty->currentValue);
186                      propertyInfo.append(configProperty->plannedValue);
187                      if (configProperty->dynamic)
188 kumpf       1.6      {
189                          propertyInfo.append(STRING_TRUE);
190                      }
191                      else
192                      {
193                          propertyInfo.append(STRING_FALSE);
194                      }
195                      if (configProperty->externallyVisible)
196 kumpf       1.1      {
197 kumpf       1.3          propertyInfo.append(STRING_TRUE);
198 kumpf       1.1      }
199                      else
200                      {
201 kumpf       1.3          propertyInfo.append(STRING_FALSE);
202 kumpf       1.1      }
203                  }
204                  
205 kumpf       1.3  
206                  /**
207 kumpf       1.23     Get default value of the specified property.
208 kumpf       1.3  */
209 vijay.eli   1.17 String FileSystemPropertyOwner::getDefaultValue(const String& name) const
210 kumpf       1.3  {
211 kumpf       1.23     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
212 vijay.eli   1.17 
213 kumpf       1.3      return configProperty->defaultValue;
214                  }
215                  
216 kumpf       1.23 /**
217                      Get current value of the specified property.
218 kumpf       1.1  */
219 vijay.eli   1.17 String FileSystemPropertyOwner::getCurrentValue(const String& name) const
220 kumpf       1.1  {
221 aruran.ms   1.18     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
222 vijay.eli   1.17 
223 kumpf       1.3      return configProperty->currentValue;
224 kumpf       1.1  }
225                  
226 kumpf       1.23 /**
227                      Get planned value of the specified property.
228 kumpf       1.1  */
229 vijay.eli   1.17 String FileSystemPropertyOwner::getPlannedValue(const String& name) const
230 kumpf       1.1  {
231 aruran.ms   1.18     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
232 vijay.eli   1.17 
233 kumpf       1.3      return configProperty->plannedValue;
234 kumpf       1.1  }
235                  
236 kumpf       1.23 /**
237                      Init current value of the specified property to the specified value.
238 kumpf       1.1  */
239                  void FileSystemPropertyOwner::initCurrentValue(
240 kumpf       1.23     const String& name,
241 kumpf       1.1      const String& value)
242                  {
243 kumpf       1.3      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
244                      configProperty->currentValue = value;
245 kumpf       1.1  }
246                  
247                  
248 kumpf       1.23 /**
249                      Init planned value of the specified property to the specified value.
250 kumpf       1.1  */
251                  void FileSystemPropertyOwner::initPlannedValue(
252 kumpf       1.23     const String& name,
253 kumpf       1.1      const String& value)
254                  {
255 kumpf       1.3      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
256                      configProperty->plannedValue = value;
257 kumpf       1.1  }
258                  
259 kumpf       1.23 /**
260                      Update current value of the specified property to the specified value.
261 kumpf       1.1  */
262                  void FileSystemPropertyOwner::updateCurrentValue(
263 kumpf       1.23     const String& name,
264                      const String& value)
265 kumpf       1.1  {
266                      //
267                      // make sure the property is dynamic before updating the value.
268                      //
269                      if (!isDynamic(name))
270                      {
271 kumpf       1.23         throw NonDynamicConfigProperty(name);
272 kumpf       1.1      }
273 kumpf       1.3  
274                      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
275                      configProperty->currentValue = value;
276 kumpf       1.1  }
277                  
278                  
279 kumpf       1.23 /**
280                      Update planned value of the specified property to the specified value.
281 kumpf       1.1  */
282                  void FileSystemPropertyOwner::updatePlannedValue(
283 kumpf       1.23     const String& name,
284 kumpf       1.1      const String& value)
285                  {
286 kumpf       1.3      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
287                      configProperty->plannedValue = value;
288 kumpf       1.1  }
289                  
290 kumpf       1.23 /**
291                      Checks to see if the given value is valid or not.
292 kumpf       1.1  */
293 kumpf       1.23 Boolean FileSystemPropertyOwner::isValid(
294                      const String& name,
295                      const String& value) const
296 kumpf       1.1  {
297 kumpf       1.23     if (!isDirValid(value))
298 kumpf       1.1      {
299                          throw InvalidPropertyValue(name, value);
300                      }
301 kumpf       1.23 
302 kumpf       1.1      return true;
303                  }
304                  
305 kumpf       1.23 /**
306                      Checks to see if the specified property is dynamic or not.
307 kumpf       1.1  */
308 vijay.eli   1.17 Boolean FileSystemPropertyOwner::isDynamic(const String& name) const
309 kumpf       1.1  {
310 aruran.ms   1.18     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
311 vijay.eli   1.17 
312 kumpf       1.23     return (configProperty->dynamic == IS_DYNAMIC);
313 kumpf       1.1  }
314                  
315                  
316                  PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2