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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2