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

  1 martin 1.23 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.24 //
  3 martin 1.23 // 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.24 //
 10 martin 1.23 // 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.24 //
 17 martin 1.23 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.24 //
 20 martin 1.23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.23 // 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.24 //
 28 martin 1.23 //////////////////////////////////////////////////////////////////////////
 29 konrad.r 1.2  //
 30               //%/////////////////////////////////////////////////////////////////////////////
 31               
 32               
 33               ///////////////////////////////////////////////////////////////////////////////
 34 kumpf    1.15 //
 35 konrad.r 1.2  // This file has implementation for the providerDir 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 "ProviderDirPropertyOwner.h"
 44               
 45               
 46               PEGASUS_NAMESPACE_BEGIN
 47               
 48               ///////////////////////////////////////////////////////////////////////////////
 49               //  ProviderDirPropertyOwner
 50               //
 51               //  When a new ProviderDir property is added, make sure to add the property name
 52               //  and the default attributes of that property in the table below.
 53               ///////////////////////////////////////////////////////////////////////////////
 54               
 55               static struct ConfigPropertyRow properties[] =
 56 konrad.r 1.2  {
 57 a.dunfey 1.16 #if defined(PEGASUS_OS_TYPE_WINDOWS)
 58 kumpf    1.26     {"providerDir", "lib;bin", IS_DYNAMIC, IS_VISIBLE},
 59 r.kieninger 1.20 #elif defined(PEGASUS_OS_ZOS)
 60 kumpf       1.26     {"providerDir", "lib:provider", IS_DYNAMIC, IS_VISIBLE},
 61 ouyang.jian 1.18 #elif defined(PEGASUS_OS_PASE) && defined(PEGASUS_USE_RELEASE_DIRS)
 62 kumpf       1.25     {"providerDir", "/QOpenSys/QIBM/ProdData/UME/Pegasus/provider",
 63 kumpf       1.26         IS_DYNAMIC, IS_VISIBLE}
 64 gs.keenan   1.13 #elif defined(PEGASUS_OS_VMS)
 65 kumpf       1.26     {"providerDir", "/wbem_lib", IS_DYNAMIC, IS_VISIBLE},
 66 konrad.r    1.3  #else
 67 kumpf       1.26     {"providerDir", "lib", IS_DYNAMIC, IS_VISIBLE},
 68 konrad.r    1.3  #endif
 69 konrad.r    1.2  };
 70                  
 71                  const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
 72                  
 73                  
 74                  /** Constructors  */
 75                  ProviderDirPropertyOwner::ProviderDirPropertyOwner()
 76                  {
 77                      _providerDir = new ConfigProperty;
 78                  }
 79                  
 80                  /** Destructor  */
 81                  ProviderDirPropertyOwner::~ProviderDirPropertyOwner()
 82                  {
 83                      delete _providerDir;
 84                  }
 85                  
 86                  /**
 87 kumpf       1.15     Checks if the given directory is existing and writable
 88 konrad.r    1.2  */
 89                  Boolean isProviderDirValid(const String& dirName)
 90                  {
 91 marek       1.14     String path;
 92                      Uint32 pos=0;
 93                      Uint32 token=0;
 94                  
 95                      // make multiple, relative paths absolute for check
 96                      String temp = ConfigManager::getHomedPath(dirName);
 97                      do
 98                      {
 99                          if (( pos = temp.find(FileSystem::getPathDelimiter())) == PEG_NOT_FOUND)
100                          {
101                              pos = temp.size();
102                              token = 0;
103 kumpf       1.15         }
104                          else
105 marek       1.14         {
106                              token = 1;
107                          }
108                          path = temp.subString(0,pos);
109                          if (!FileSystem::isDirectory(path))
110                          {
111 kumpf       1.21             Logger::put_l(
112                                  Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
113                                  MessageLoaderParms(
114                                      "Config.ProviderDirPropertyOwner.NOT_A_DIRECTORY",
115                                      "providerDir configuration value $0 is not a directory.",
116                                      path));
117 marek       1.14             return false;
118                          }
119                          if (!FileSystem::canRead(path))
120                          {
121 kumpf       1.21             Logger::put_l(
122                                  Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
123                                  MessageLoaderParms(
124                                      "Config.ProviderDirPropertyOwner.DIRECTORY_NOT_READABLE",
125                                      "providerDir configuration directory $0 is not readable.",
126                                      path));
127 marek       1.14             return false;
128                          }
129 kumpf       1.15         temp.remove(0,pos+token);
130 marek       1.14     }
131 kumpf       1.15     while ( temp.size() > 0 );
132 konrad.r    1.2      return true;
133                  }
134 kumpf       1.15 
135 konrad.r    1.2  /**
136 kumpf       1.15     Initialize the config properties.
137 konrad.r    1.2  */
138                  void ProviderDirPropertyOwner::initialize()
139                  {
140                      for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
141                      {
142                          //
143                          // Initialize the properties with default values
144                          //
145 kavita.gupta 1.27         if (String::equal(properties[i].propertyName, "providerDir"))
146 konrad.r     1.2          {
147                               _providerDir->propertyName = properties[i].propertyName;
148                               _providerDir->defaultValue = properties[i].defaultValue;
149                               _providerDir->currentValue = properties[i].defaultValue;
150                               _providerDir->plannedValue = properties[i].defaultValue;
151                               _providerDir->dynamic = properties[i].dynamic;
152                               _providerDir->externallyVisible = properties[i].externallyVisible;
153                           }
154                       }
155                   }
156                   
157                   struct ConfigProperty* ProviderDirPropertyOwner::_lookupConfigProperty(
158 aruran.ms    1.10     const String& name) const
159 konrad.r     1.2  {
160 kavita.gupta 1.27     if (String::equal(_providerDir->propertyName, name))
161 konrad.r     1.2      {
162                           return _providerDir;
163                       }
164                       else
165                       {
166                           throw UnrecognizedConfigProperty(name);
167                       }
168                   }
169                   
170 kumpf        1.15 /**
171                       Get information about the specified property.
172 konrad.r     1.2  */
173                   void ProviderDirPropertyOwner::getPropertyInfo(
174 kumpf        1.15     const String& name,
175 vijay.eli    1.9      Array<String>& propertyInfo) const
176 konrad.r     1.2  {
177 aruran.ms    1.10     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
178 konrad.r     1.2  
179 karl         1.31     buildPropertyInfo(name, configProperty, propertyInfo);
180 konrad.r     1.2  }
181                   
182                   /**
183 kumpf        1.15     Get default value of the specified property.
184 konrad.r     1.2  */
185 vijay.eli    1.9  String ProviderDirPropertyOwner::getDefaultValue(const String& name) const
186 konrad.r     1.2  {
187 aruran.ms    1.10     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
188 vijay.eli    1.9  
189 konrad.r     1.2      return configProperty->defaultValue;
190                   }
191                   
192 kumpf        1.15 /**
193                       Get current value of the specified property.
194 konrad.r     1.2  */
195 vijay.eli    1.9  String ProviderDirPropertyOwner::getCurrentValue(const String& name) const
196 konrad.r     1.2  {
197 aruran.ms    1.10     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
198 vijay.eli    1.9  
199 kavita.gupta 1.22     AutoMutex lock(_providerDirMutex);
200 konrad.r     1.2      return configProperty->currentValue;
201                   }
202                   
203 kumpf        1.15 /**
204                       Get planned value of the specified property.
205 konrad.r     1.2  */
206 vijay.eli    1.9  String ProviderDirPropertyOwner::getPlannedValue(const String& name) const
207 konrad.r     1.2  {
208 aruran.ms    1.10    struct ConfigProperty * configProperty = _lookupConfigProperty(name);
209 vijay.eli    1.9  
210 konrad.r     1.2      return configProperty->plannedValue;
211                   }
212                   
213 kumpf        1.15 /**
214                       Init current value of the specified property to the specified value.
215 konrad.r     1.2  */
216                   void ProviderDirPropertyOwner::initCurrentValue(
217 kumpf        1.15     const String& name,
218 konrad.r     1.2      const String& value)
219                   {
220                       struct ConfigProperty* configProperty = _lookupConfigProperty(name);
221 kavita.gupta 1.22     AutoMutex lock(_providerDirMutex);
222 konrad.r     1.2      configProperty->currentValue = value;
223                   }
224                   
225                   
226 kumpf        1.15 /**
227                       Init planned value of the specified property to the specified value.
228 konrad.r     1.2  */
229                   void ProviderDirPropertyOwner::initPlannedValue(
230 kumpf        1.15     const String& name,
231 konrad.r     1.2      const String& value)
232                   {
233                       struct ConfigProperty* configProperty = _lookupConfigProperty(name);
234                       configProperty->plannedValue = value;
235                   }
236                   
237 kumpf        1.15 /**
238                       Update current value of the specified property to the specified value.
239 konrad.r     1.2  */
240                   void ProviderDirPropertyOwner::updateCurrentValue(
241 kumpf        1.15     const String& name,
242 venkat.puvvada 1.28     const String& value,
243 venkat.puvvada 1.29     const String& userName,
244                         Uint32 timeoutSeconds)
245 konrad.r       1.2  {
246 ashok.pathak   1.30    struct ConfigProperty * configProperty = _lookupConfigProperty(name);
247                     
248 konrad.r       1.2      //
249                         // make sure the property is dynamic before updating the value.
250                         //
251 ashok.pathak   1.30     if (configProperty->dynamic != IS_DYNAMIC)
252 konrad.r       1.2      {
253 kumpf          1.15         throw NonDynamicConfigProperty(name);
254 konrad.r       1.2      }
255 ashok.pathak   1.30 
256                         AutoMutex lock(_providerDirMutex);
257                         configProperty->currentValue = value;
258 konrad.r       1.2  }
259                     
260                     
261 kumpf          1.15 /**
262                         Update planned value of the specified property to the specified value.
263 konrad.r       1.2  */
264                     void ProviderDirPropertyOwner::updatePlannedValue(
265 kumpf          1.15     const String& name,
266 konrad.r       1.2      const String& value)
267                     {
268                         struct ConfigProperty* configProperty = _lookupConfigProperty(name);
269                         configProperty->plannedValue = value;
270                     }
271                     
272 kumpf          1.15 /**
273                         Checks to see if the given value is valid or not.
274 konrad.r       1.2  */
275 kumpf          1.15 Boolean ProviderDirPropertyOwner::isValid(
276                         const String& name,
277                         const String& value) const
278 konrad.r       1.2  {
279                     
280                         if (!isProviderDirValid( value ))
281                         {
282                             throw InvalidPropertyValue(name, value);
283                         }
284 kumpf          1.15 
285 konrad.r       1.2      return true;
286                     }
287                     
288 kumpf          1.15 /**
289                         Checks to see if the specified property is dynamic or not.
290 konrad.r       1.2  */
291 vijay.eli      1.9  Boolean ProviderDirPropertyOwner::isDynamic(const String& name) const
292 konrad.r       1.2  {
293 aruran.ms      1.10     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
294 vijay.eli      1.9  
295 kumpf          1.15     return (configProperty->dynamic == IS_DYNAMIC);
296 konrad.r       1.2  }
297                     
298                     
299                     PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2