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

  1 karl  1.20 //%2006////////////////////////////////////////////////////////////////////////
  2 kumpf 1.1  //
  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.7  // 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.20 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 kumpf 1.1  //
 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.4  // 
 21 kumpf 1.1  // 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: Sushma Fernandes (sushma_fernandes@hp.com)
 33            //
 34 aruran.ms 1.16 // Modified By:  Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3614
 35 vijay.eli 1.17 //              Vijay Eli, IBM, (vijayeli@in.ibm.com) for Bug# 3613
 36 aruran.ms 1.18 //              Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3613
 37 kumpf     1.1  //
 38                //%/////////////////////////////////////////////////////////////////////////////
 39                
 40                
 41                ///////////////////////////////////////////////////////////////////////////////
 42                // 
 43                // This file has implementation for the file system property owner class.
 44                //
 45                ///////////////////////////////////////////////////////////////////////////////
 46                
 47                #include <Pegasus/Common/Config.h>
 48                #include <Pegasus/Common/Tracer.h>
 49                #include <Pegasus/Common/FileSystem.h>
 50                #include <Pegasus/Config/ConfigManager.h>
 51                #include "FileSystemPropertyOwner.h"
 52                
 53                
 54                PEGASUS_USING_STD;
 55                
 56                PEGASUS_NAMESPACE_BEGIN
 57                
 58 kumpf     1.1  ///////////////////////////////////////////////////////////////////////////////
 59                //  FileSystemPropertyOwner
 60                //
 61                //  When a new FileSystem property is added, make sure to add the property name
 62                //  and the default attributes of that property in the table below.
 63                ///////////////////////////////////////////////////////////////////////////////
 64                
 65                static struct ConfigPropertyRow properties[] =
 66                {
 67 marek     1.19 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) && defined(PEGASUS_USE_RELEASE_DIRS)
 68                    {"repositoryDir", "/var/wbem/repository", IS_STATIC, 0, 0, IS_VISIBLE},
 69                #else
 70 konrad.r  1.13     {"repositoryDir", "repository", IS_STATIC, 0, 0, IS_VISIBLE},
 71 marek     1.19 #endif
 72                
 73 humberto  1.15 #ifdef PEGASUS_OS_OS400
 74                    {"messageDir", "/QIBM/ProdData/OS400/CIM/msg", IS_STATIC, 0, 0, IS_VISIBLE},
 75                #else
 76 konrad.r  1.13     {"messageDir", "msg", IS_STATIC, 0, 0, IS_VISIBLE},
 77 humberto  1.15 #endif
 78 kumpf     1.1  };
 79                
 80                const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
 81                
 82                
 83                /** Constructors  */
 84                FileSystemPropertyOwner::FileSystemPropertyOwner()
 85                {
 86 a.arora   1.10     _repositoryDir.reset(new ConfigProperty);
 87                    _messageDir.reset(new ConfigProperty);
 88 kumpf     1.1  }
 89                
 90                
 91                /**
 92                Checks if the given directory is existing and writable
 93                */
 94                Boolean isDirValid(const String& dirName)
 95                {
 96                    if (FileSystem::isDirectory(dirName) && FileSystem::canWrite(dirName))
 97                    {
 98                        return true;
 99                    }
100                    return false;
101                }
102                 
103                /**
104                Initialize the config properties.
105                */
106                void FileSystemPropertyOwner::initialize()
107                {
108                    for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
109 kumpf     1.1      {
110                        //
111                        // Initialize the properties with default values
112                        //
113                        if (String::equalNoCase(properties[i].propertyName, "repositoryDir"))
114                        {
115                            _repositoryDir->propertyName = properties[i].propertyName;
116                            _repositoryDir->defaultValue = properties[i].defaultValue;
117                            _repositoryDir->currentValue = properties[i].defaultValue;
118                            _repositoryDir->plannedValue = properties[i].defaultValue;
119                            _repositoryDir->dynamic = properties[i].dynamic;
120                            _repositoryDir->domain = properties[i].domain;
121                            _repositoryDir->domainSize = properties[i].domainSize;
122 kumpf     1.6              _repositoryDir->externallyVisible = properties[i].externallyVisible;
123 kumpf     1.1          }
124 david     1.9          else if (String::equalNoCase(properties[i].propertyName, "messageDir"))
125                        {
126                            _messageDir->propertyName = properties[i].propertyName;
127                            _messageDir->defaultValue = properties[i].defaultValue;
128                            _messageDir->currentValue = properties[i].defaultValue;
129                            _messageDir->plannedValue = properties[i].defaultValue;
130                            _messageDir->dynamic = properties[i].dynamic;
131                            _messageDir->domain = properties[i].domain;
132                            _messageDir->domainSize = properties[i].domainSize;
133                            _messageDir->externallyVisible = properties[i].externallyVisible;
134                        }
135 kumpf     1.1      }
136                }
137                
138 kumpf     1.3  struct ConfigProperty* FileSystemPropertyOwner::_lookupConfigProperty(
139 aruran.ms 1.18     const String& name) const
140 kumpf     1.1  {
141                    if (String::equalNoCase(_repositoryDir->propertyName, name))
142                    {
143 a.arora   1.10         return _repositoryDir.get();
144 david     1.9      }
145                    if (String::equalNoCase(_messageDir->propertyName, name))
146                    {
147 a.arora   1.10         return _messageDir.get();
148 kumpf     1.1      }
149                    else
150                    {
151                        throw UnrecognizedConfigProperty(name);
152                    }
153                }
154                
155 kumpf     1.3  /** 
156                Get information about the specified property.
157 kumpf     1.1  */
158 kumpf     1.3  void FileSystemPropertyOwner::getPropertyInfo(
159                    const String& name, 
160 vijay.eli 1.17     Array<String>& propertyInfo) const
161 kumpf     1.1  {
162 kumpf     1.3      propertyInfo.clear();
163 aruran.ms 1.18     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
164 kumpf     1.3  
165                    propertyInfo.append(configProperty->propertyName);
166                    propertyInfo.append(configProperty->defaultValue);
167                    propertyInfo.append(configProperty->currentValue);
168                    propertyInfo.append(configProperty->plannedValue);
169                    if (configProperty->dynamic)
170 kumpf     1.6      {
171                        propertyInfo.append(STRING_TRUE);
172                    }
173                    else
174                    {
175                        propertyInfo.append(STRING_FALSE);
176                    }
177                    if (configProperty->externallyVisible)
178 kumpf     1.1      {
179 kumpf     1.3          propertyInfo.append(STRING_TRUE);
180 kumpf     1.1      }
181                    else
182                    {
183 kumpf     1.3          propertyInfo.append(STRING_FALSE);
184 kumpf     1.1      }
185                }
186                
187 kumpf     1.3  
188                /**
189                Get default value of the specified property.
190                */
191 vijay.eli 1.17 String FileSystemPropertyOwner::getDefaultValue(const String& name) const
192 kumpf     1.3  {
193 aruran.ms 1.18     struct ConfigProperty* configProperty = _lookupConfigProperty(name);    
194 vijay.eli 1.17 
195 kumpf     1.3      return configProperty->defaultValue;
196                }
197                
198 kumpf     1.1  /** 
199                Get current value of the specified property.
200                */
201 vijay.eli 1.17 String FileSystemPropertyOwner::getCurrentValue(const String& name) const
202 kumpf     1.1  {
203 aruran.ms 1.18     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
204 vijay.eli 1.17 
205 kumpf     1.3      return configProperty->currentValue;
206 kumpf     1.1  }
207                
208                /** 
209                Get planned value of the specified property.
210                */
211 vijay.eli 1.17 String FileSystemPropertyOwner::getPlannedValue(const String& name) const
212 kumpf     1.1  {
213 aruran.ms 1.18     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
214 vijay.eli 1.17 
215 kumpf     1.3      return configProperty->plannedValue;
216 kumpf     1.1  }
217                
218                /** 
219                Init current value of the specified property to the specified value.
220                */
221                void FileSystemPropertyOwner::initCurrentValue(
222                    const String& name, 
223                    const String& value)
224                {
225 kumpf     1.3      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
226                    configProperty->currentValue = value;
227 kumpf     1.1  }
228                
229                
230                /** 
231                Init planned value of the specified property to the specified value.
232                */
233                void FileSystemPropertyOwner::initPlannedValue(
234                    const String& name, 
235                    const String& value)
236                {
237 kumpf     1.3      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
238                    configProperty->plannedValue = value;
239 kumpf     1.1  }
240                
241                /** 
242                Update current value of the specified property to the specified value.
243                */
244                void FileSystemPropertyOwner::updateCurrentValue(
245                    const String& name, 
246                    const String& value) 
247                {
248                    //
249                    // make sure the property is dynamic before updating the value.
250                    //
251                    if (!isDynamic(name))
252                    {
253                        throw NonDynamicConfigProperty(name); 
254                    }
255 kumpf     1.3  
256                    struct ConfigProperty* configProperty = _lookupConfigProperty(name);
257                    configProperty->currentValue = value;
258 kumpf     1.1  }
259                
260                
261                /** 
262                Update planned value of the specified property to the specified value.
263                */
264                void FileSystemPropertyOwner::updatePlannedValue(
265                    const String& name, 
266                    const String& value)
267                {
268 kumpf     1.3      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
269                    configProperty->plannedValue = value;
270 kumpf     1.1  }
271                
272                /** 
273                Checks to see if the given value is valid or not.
274                */
275 vijay.eli 1.17 Boolean FileSystemPropertyOwner::isValid(const String& name, 
276                                                 const String& value) const
277 kumpf     1.1  {
278                    if (!isDirValid( value ))
279                    {
280                        throw InvalidPropertyValue(name, value);
281                    }
282                 
283                    return true;
284                }
285                
286                /** 
287                Checks to see if the specified property is dynamic or not.
288                */
289 vijay.eli 1.17 Boolean FileSystemPropertyOwner::isDynamic(const String& name) const
290 kumpf     1.1  {
291 aruran.ms 1.18     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
292 vijay.eli 1.17 
293 konrad.r  1.13     return (configProperty->dynamic==IS_DYNAMIC);
294 kumpf     1.1  }
295                
296                
297                PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2