(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.33     {"repositoryDir", PEGASUS_REPOSITORY_DIR, IS_STATIC, 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 kumpf       1.33         IS_VISIBLE},
 63 ouyang.jian 1.25 #else
 64 kumpf       1.33     {"messageDir", "msg", IS_STATIC, IS_VISIBLE},
 65 ouyang.jian 1.25 #endif
 66 b.whiteley  1.26 #if defined(PEGASUS_OS_TYPE_WINDOWS)
 67 kumpf       1.33     {"providerManagerDir", "bin", IS_STATIC, IS_VISIBLE},
 68 r.kieninger 1.28 #elif defined(PEGASUS_OS_ZOS)
 69 kumpf       1.33     {"providerManagerDir", "lib", IS_STATIC, IS_VISIBLE},
 70 b.whiteley  1.26 #elif defined(PEGASUS_OS_PASE) && defined(PEGASUS_USE_RELEASE_DIRS)
 71 kumpf       1.33     {"providerManagerDir", "/QOpenSys/QIBM/ProdData/UME/Pegasus/lib",
 72 cheng.sp    1.35         IS_STATIC, IS_VISIBLE},
 73                  #elif defined(PEGASUS_OS_AIX) && defined(PEGASUS_USE_RELEASE_DIRS)
 74                      {"providerManagerDir", "/usr/lib", IS_STATIC, IS_VISIBLE},
 75 b.whiteley  1.26 #elif defined(PEGASUS_OS_VMS)
 76 kumpf       1.33     {"providerManagerDir", "/wbem_lib", IS_STATIC, IS_VISIBLE},
 77 b.whiteley  1.26 #else
 78 kumpf       1.33     {"providerManagerDir", "lib", IS_STATIC, IS_VISIBLE},
 79 b.whiteley  1.26 #endif
 80 kumpf       1.1  };
 81                  
 82                  const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
 83                  
 84                  
 85                  /** Constructors  */
 86                  FileSystemPropertyOwner::FileSystemPropertyOwner()
 87                  {
 88 a.arora     1.10     _repositoryDir.reset(new ConfigProperty);
 89                      _messageDir.reset(new ConfigProperty);
 90 b.whiteley  1.26     _providerManagerDir.reset(new ConfigProperty);
 91 kumpf       1.1  }
 92                  
 93                  
 94                  /**
 95 kumpf       1.23     Checks if the given directory is existing and writable
 96 kumpf       1.1  */
 97                  Boolean isDirValid(const String& dirName)
 98                  {
 99 marek       1.22     String directoryName(ConfigManager::getHomedPath(dirName));
100 kumpf       1.23     if (FileSystem::isDirectory(directoryName) &&
101 marek       1.22         FileSystem::canWrite(directoryName))
102 kumpf       1.1      {
103                          return true;
104                      }
105                      return false;
106                  }
107 kumpf       1.23 
108 kumpf       1.1  /**
109 kumpf       1.23     Initialize the config properties.
110 kumpf       1.1  */
111                  void FileSystemPropertyOwner::initialize()
112                  {
113                      for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
114                      {
115                          //
116                          // Initialize the properties with default values
117                          //
118 kavita.gupta 1.36         if (String::equal(properties[i].propertyName, "repositoryDir"))
119 kumpf        1.1          {
120                               _repositoryDir->propertyName = properties[i].propertyName;
121                               _repositoryDir->defaultValue = properties[i].defaultValue;
122                               _repositoryDir->currentValue = properties[i].defaultValue;
123                               _repositoryDir->plannedValue = properties[i].defaultValue;
124                               _repositoryDir->dynamic = properties[i].dynamic;
125 kumpf        1.6              _repositoryDir->externallyVisible = properties[i].externallyVisible;
126 kumpf        1.1          }
127 kavita.gupta 1.36         else if (String::equal(properties[i].propertyName, "messageDir"))
128 david        1.9          {
129                               _messageDir->propertyName = properties[i].propertyName;
130                               _messageDir->defaultValue = properties[i].defaultValue;
131                               _messageDir->currentValue = properties[i].defaultValue;
132                               _messageDir->plannedValue = properties[i].defaultValue;
133                               _messageDir->dynamic = properties[i].dynamic;
134                               _messageDir->externallyVisible = properties[i].externallyVisible;
135                           }
136 kavita.gupta 1.36         else if (String::equal(properties[i].propertyName,
137 b.whiteley   1.26                  "providerManagerDir"))
138                           {
139                               _providerManagerDir->propertyName = properties[i].propertyName;
140                               _providerManagerDir->defaultValue = properties[i].defaultValue;
141                               _providerManagerDir->currentValue = properties[i].defaultValue;
142                               _providerManagerDir->plannedValue = properties[i].defaultValue;
143                               _providerManagerDir->dynamic = properties[i].dynamic;
144 kumpf        1.32             _providerManagerDir->externallyVisible =
145 b.whiteley   1.26                                            properties[i].externallyVisible;
146                           }
147 kumpf        1.1      }
148                   }
149                   
150 kumpf        1.3  struct ConfigProperty* FileSystemPropertyOwner::_lookupConfigProperty(
151 aruran.ms    1.18     const String& name) const
152 kumpf        1.1  {
153 kavita.gupta 1.36     if (String::equal(_repositoryDir->propertyName, name))
154 kumpf        1.1      {
155 a.arora      1.10         return _repositoryDir.get();
156 david        1.9      }
157 kavita.gupta 1.36     if (String::equal(_messageDir->propertyName, name))
158 david        1.9      {
159 a.arora      1.10         return _messageDir.get();
160 kumpf        1.1      }
161 kavita.gupta 1.36     if (String::equal(_providerManagerDir->propertyName, name))
162 kumpf        1.1      {
163 b.whiteley   1.26         return _providerManagerDir.get();
164 kumpf        1.1      }
165 b.whiteley   1.26     throw UnrecognizedConfigProperty(name);
166 kumpf        1.1  }
167                   
168 kumpf        1.23 /**
169                       Get information about the specified property.
170 kumpf        1.1  */
171 kumpf        1.3  void FileSystemPropertyOwner::getPropertyInfo(
172 kumpf        1.23     const String& name,
173 vijay.eli    1.17     Array<String>& propertyInfo) const
174 kumpf        1.1  {
175 kumpf        1.3      propertyInfo.clear();
176 aruran.ms    1.18     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
177 kumpf        1.3  
178                       propertyInfo.append(configProperty->propertyName);
179                       propertyInfo.append(configProperty->defaultValue);
180                       propertyInfo.append(configProperty->currentValue);
181                       propertyInfo.append(configProperty->plannedValue);
182                       if (configProperty->dynamic)
183 kumpf        1.6      {
184                           propertyInfo.append(STRING_TRUE);
185                       }
186                       else
187                       {
188                           propertyInfo.append(STRING_FALSE);
189                       }
190                       if (configProperty->externallyVisible)
191 kumpf        1.1      {
192 kumpf        1.3          propertyInfo.append(STRING_TRUE);
193 kumpf        1.1      }
194                       else
195                       {
196 kumpf        1.3          propertyInfo.append(STRING_FALSE);
197 kumpf        1.1      }
198                   }
199                   
200 kumpf        1.3  
201                   /**
202 kumpf        1.23     Get default value of the specified property.
203 kumpf        1.3  */
204 vijay.eli    1.17 String FileSystemPropertyOwner::getDefaultValue(const String& name) const
205 kumpf        1.3  {
206 kumpf        1.23     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
207 vijay.eli    1.17 
208 kumpf        1.3      return configProperty->defaultValue;
209                   }
210                   
211 kumpf        1.23 /**
212                       Get current value of the specified property.
213 kumpf        1.1  */
214 vijay.eli    1.17 String FileSystemPropertyOwner::getCurrentValue(const String& name) const
215 kumpf        1.1  {
216 aruran.ms    1.18     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
217 vijay.eli    1.17 
218 kumpf        1.3      return configProperty->currentValue;
219 kumpf        1.1  }
220                   
221 kumpf        1.23 /**
222                       Get planned value of the specified property.
223 kumpf        1.1  */
224 vijay.eli    1.17 String FileSystemPropertyOwner::getPlannedValue(const String& name) const
225 kumpf        1.1  {
226 aruran.ms    1.18     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
227 vijay.eli    1.17 
228 kumpf        1.3      return configProperty->plannedValue;
229 kumpf        1.1  }
230                   
231 kumpf        1.23 /**
232                       Init current value of the specified property to the specified value.
233 kumpf        1.1  */
234                   void FileSystemPropertyOwner::initCurrentValue(
235 kumpf        1.23     const String& name,
236 kumpf        1.1      const String& value)
237                   {
238 kumpf        1.3      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
239                       configProperty->currentValue = value;
240 kumpf        1.1  }
241                   
242                   
243 kumpf        1.23 /**
244                       Init planned value of the specified property to the specified value.
245 kumpf        1.1  */
246                   void FileSystemPropertyOwner::initPlannedValue(
247 kumpf        1.23     const String& name,
248 kumpf        1.1      const String& value)
249                   {
250 kumpf        1.3      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
251                       configProperty->plannedValue = value;
252 kumpf        1.1  }
253                   
254 kumpf        1.23 /**
255                       Update current value of the specified property to the specified value.
256 kumpf        1.1  */
257                   void FileSystemPropertyOwner::updateCurrentValue(
258 kumpf        1.23     const String& name,
259 venkat.puvvada 1.37     const String& value,
260 venkat.puvvada 1.38     const String& userName,
261                         Uint32 timeoutSeconds)
262 kumpf          1.1  {
263                         //
264                         // make sure the property is dynamic before updating the value.
265                         //
266                         if (!isDynamic(name))
267                         {
268 kumpf          1.23         throw NonDynamicConfigProperty(name);
269 kumpf          1.1      }
270 kumpf          1.3  
271                         struct ConfigProperty* configProperty = _lookupConfigProperty(name);
272                         configProperty->currentValue = value;
273 kumpf          1.1  }
274                     
275                     
276 kumpf          1.23 /**
277                         Update planned value of the specified property to the specified value.
278 kumpf          1.1  */
279                     void FileSystemPropertyOwner::updatePlannedValue(
280 kumpf          1.23     const String& name,
281 kumpf          1.1      const String& value)
282                     {
283 kumpf          1.3      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
284                         configProperty->plannedValue = value;
285 kumpf          1.1  }
286                     
287 kumpf          1.23 /**
288                         Checks to see if the given value is valid or not.
289 kumpf          1.1  */
290 kumpf          1.23 Boolean FileSystemPropertyOwner::isValid(
291                         const String& name,
292                         const String& value) const
293 kumpf          1.1  {
294 kumpf          1.23     if (!isDirValid(value))
295 kumpf          1.1      {
296 thilo.boehm    1.34         throw InvalidDirectoryPropertyValue(name, value);
297 kumpf          1.1      }
298 kumpf          1.23 
299 kumpf          1.1      return true;
300                     }
301                     
302 kumpf          1.23 /**
303                         Checks to see if the specified property is dynamic or not.
304 kumpf          1.1  */
305 vijay.eli      1.17 Boolean FileSystemPropertyOwner::isDynamic(const String& name) const
306 kumpf          1.1  {
307 aruran.ms      1.18     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
308 vijay.eli      1.17 
309 kumpf          1.23     return (configProperty->dynamic == IS_DYNAMIC);
310 kumpf          1.1  }
311                     
312                     
313                     PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2