edu.ucsb.nceas.metacat.properties
Class PropertyService

java.lang.Object
  extended by edu.ucsb.nceas.metacat.shared.BaseService
      extended by edu.ucsb.nceas.metacat.properties.PropertyService

public class PropertyService
extends BaseService

A suite of utility classes for the metadata configuration utility


Field Summary
static java.lang.String BYPASSED
           
static java.lang.String CONFIG_FILE_DIR
           
static java.lang.String CONFIG_FILE_NAME
           
static java.lang.String CONFIG_FILE_PATH
           
static java.lang.String CONFIGURED
           
static java.lang.String TEST_CONFIG_FILE_NAME
           
static java.lang.String UNCONFIGURED
           
 
Fields inherited from class edu.ucsb.nceas.metacat.shared.BaseService
_serviceName
 
Method Summary
static boolean arePropertiesConfigured()
          Reports whether properties are fully configured.
static void bypassConfiguration()
          Reports whether the metacat configuration utility should be run.
static void checkAndSetProperty(javax.servlet.http.HttpServletRequest request, java.lang.String propertyName)
          Take input from the user in an HTTP request about an property to be changed and update the metacat property file with that new value if it has changed from the value that was originally set.
static boolean doBypass()
          Determine if the system is configured to bypass configuration.
 void doRefresh()
           
static edu.ucsb.nceas.utilities.SortedProperties getAuthBackupProperties()
          Get the auth backup properties file.
static edu.ucsb.nceas.utilities.PropertiesMetaData getAuthMetaData()
          Get the auth properties metadata.
static PropertyService getInstance()
          Get the single instance of PropertyService for test purposes.
static PropertyService getInstance(javax.servlet.ServletContext context)
          Get the single instance of PropertyService.
static PropertyService getInstance(java.lang.String testConfigFileDir)
          Get the single instance of PropertyService for test purposes.
static edu.ucsb.nceas.utilities.SortedProperties getMainBackupProperties()
          Get the main backup properties file.
static edu.ucsb.nceas.utilities.PropertiesMetaData getMainMetaData()
          Get the main properties metadata.
static java.util.Map<java.lang.String,java.lang.String> getPropertiesByGroup(java.lang.String groupName)
          Get a Map of all properties that start with the groupName prefix.
static java.lang.String getProperty(java.lang.String propertyName)
          Utility method to get a property value from the properties file
static java.util.Vector<java.lang.String> getPropertyNames()
          Get a set of all property names.
static java.util.Vector<java.lang.String> getPropertyNamesByGroup(java.lang.String groupName)
          Get a Set of all property names that start with the groupName prefix.
static java.lang.String getRecommendedExternalDir()
          Returns the recommended external base directory.
static void persistAuthBackupProperties(javax.servlet.ServletContext servletContext)
          Writes out backup configurable properties to a file.
static void persistMainBackupProperties()
          Writes out backup configurable properties to a file.
static void persistProperties()
          Save the properties to a properties file.
 boolean refreshable()
           
static void setProperty(java.lang.String propertyName, java.lang.String newValue)
          Utility method to set a property value both in memory and to the properties file
static void setPropertyNoPersist(java.lang.String propertyName, java.lang.String newValue)
          Utility method to set a property value in memory.
static void setRecommendedExternalDir(java.lang.String extBaseDir)
          Sets the recommended external directory.
 void stop()
           
 
Methods inherited from class edu.ucsb.nceas.metacat.shared.BaseService
refresh
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIGURED

public static final java.lang.String CONFIGURED
See Also:
Constant Field Values

UNCONFIGURED

public static final java.lang.String UNCONFIGURED
See Also:
Constant Field Values

BYPASSED

public static final java.lang.String BYPASSED
See Also:
Constant Field Values

CONFIG_FILE_DIR

public static java.lang.String CONFIG_FILE_DIR

CONFIG_FILE_NAME

public static java.lang.String CONFIG_FILE_NAME

CONFIG_FILE_PATH

public static java.lang.String CONFIG_FILE_PATH

TEST_CONFIG_FILE_NAME

public static java.lang.String TEST_CONFIG_FILE_NAME
Method Detail

getInstance

public static PropertyService getInstance(javax.servlet.ServletContext context)
                                   throws ServiceException
Get the single instance of PropertyService.

Returns:
the single instance of PropertyService
Throws:
ServiceException

getInstance

public static PropertyService getInstance(java.lang.String testConfigFileDir)
                                   throws ServiceException
Get the single instance of PropertyService for test purposes. In this case, we allow the configuration directory to be passed in.

Parameters:
configDir - the configuration directory we need to look in
Returns:
the single instance of PropertyService
Throws:
ServiceException

getInstance

public static PropertyService getInstance()
                                   throws ServiceException
Get the single instance of PropertyService for test purposes. In this case, we allow the configuration directory to be passed in.

Parameters:
configDir - the configuration directory we need to look in
Returns:
the single instance of PropertyService
Throws:
ServiceException

refreshable

public boolean refreshable()
Specified by:
refreshable in class BaseService

doRefresh

public void doRefresh()
               throws ServiceException
Specified by:
doRefresh in class BaseService
Throws:
ServiceException

stop

public void stop()
          throws ServiceException
Specified by:
stop in class BaseService
Throws:
ServiceException

getProperty

public static java.lang.String getProperty(java.lang.String propertyName)
                                    throws edu.ucsb.nceas.utilities.PropertyNotFoundException
Utility method to get a property value from the properties file

Parameters:
propertyName - the name of the property requested
Returns:
the String value for the property
Throws:
edu.ucsb.nceas.utilities.PropertyNotFoundException

getPropertyNames

public static java.util.Vector<java.lang.String> getPropertyNames()
Get a set of all property names.

Returns:
Set of property names

getPropertyNamesByGroup

public static java.util.Vector<java.lang.String> getPropertyNamesByGroup(java.lang.String groupName)
Get a Set of all property names that start with the groupName prefix.

Parameters:
groupName - the prefix of the keys to search for.
Returns:
enumeration of property names

getPropertiesByGroup

public static java.util.Map<java.lang.String,java.lang.String> getPropertiesByGroup(java.lang.String groupName)
                                                                             throws edu.ucsb.nceas.utilities.PropertyNotFoundException
Get a Map of all properties that start with the groupName prefix.

Parameters:
groupName - the prefix of the keys to search for.
Returns:
Map of property names
Throws:
edu.ucsb.nceas.utilities.PropertyNotFoundException

setProperty

public static void setProperty(java.lang.String propertyName,
                               java.lang.String newValue)
                        throws edu.ucsb.nceas.utilities.GeneralPropertyException
Utility method to set a property value both in memory and to the properties file

Parameters:
propertyName - the name of the property requested
newValue - the new value for the property
Throws:
edu.ucsb.nceas.utilities.GeneralPropertyException

setPropertyNoPersist

public static void setPropertyNoPersist(java.lang.String propertyName,
                                        java.lang.String newValue)
                                 throws edu.ucsb.nceas.utilities.GeneralPropertyException
Utility method to set a property value in memory. This will NOT cause the property to be written to disk. Use this method to set multiple properties in a row without causing excessive I/O. You must call persistProperties() once you're done setting properties to have them written to disk.

Parameters:
propertyName - the name of the property requested
newValue - the new value for the property
Throws:
edu.ucsb.nceas.utilities.GeneralPropertyException

persistProperties

public static void persistProperties()
                              throws edu.ucsb.nceas.utilities.GeneralPropertyException
Save the properties to a properties file. Note, the order and comments will be preserved.

Throws:
edu.ucsb.nceas.utilities.GeneralPropertyException

getMainBackupProperties

public static edu.ucsb.nceas.utilities.SortedProperties getMainBackupProperties()
                                                                         throws edu.ucsb.nceas.utilities.GeneralPropertyException
Get the main backup properties file. These are configurable properties that are stored outside the metacat install directories so the user does not need to re-enter all the configuration information every time they do an upgrade.

Returns:
a SortedProperties object with the backup properties
Throws:
edu.ucsb.nceas.utilities.GeneralPropertyException

getAuthBackupProperties

public static edu.ucsb.nceas.utilities.SortedProperties getAuthBackupProperties()
                                                                         throws edu.ucsb.nceas.utilities.GeneralPropertyException
Get the auth backup properties file. These are configurable properties that are stored outside the metacat install directories so the user does not need to re-enter all the configuration information every time they do an upgrade.

Returns:
a SortedProperties object with the backup properties
Throws:
edu.ucsb.nceas.utilities.GeneralPropertyException

getMainMetaData

public static edu.ucsb.nceas.utilities.PropertiesMetaData getMainMetaData()
                                                                   throws edu.ucsb.nceas.utilities.GeneralPropertyException
Get the main properties metadata. This is retrieved from an xml file that describes the attributes of configurable properties.

Returns:
a PropertiesMetaData object with the main properties metadata
Throws:
edu.ucsb.nceas.utilities.GeneralPropertyException

getAuthMetaData

public static edu.ucsb.nceas.utilities.PropertiesMetaData getAuthMetaData()
                                                                   throws edu.ucsb.nceas.utilities.GeneralPropertyException
Get the auth properties metadata. This is retrieved from an xml file that describes the attributes of configurable properties.

Returns:
a PropertiesMetaData object with the organization properties metadata
Throws:
edu.ucsb.nceas.utilities.GeneralPropertyException

persistMainBackupProperties

public static void persistMainBackupProperties()
                                        throws edu.ucsb.nceas.utilities.GeneralPropertyException
Writes out backup configurable properties to a file.

Throws:
edu.ucsb.nceas.utilities.GeneralPropertyException

persistAuthBackupProperties

public static void persistAuthBackupProperties(javax.servlet.ServletContext servletContext)
                                        throws edu.ucsb.nceas.utilities.GeneralPropertyException
Writes out backup configurable properties to a file.

Throws:
edu.ucsb.nceas.utilities.GeneralPropertyException

arePropertiesConfigured

public static boolean arePropertiesConfigured()
                                       throws edu.ucsb.nceas.utilities.GeneralPropertyException
Reports whether properties are fully configured.

Returns:
a boolean that is true if properties are not unconfigured and false otherwise
Throws:
edu.ucsb.nceas.utilities.GeneralPropertyException

doBypass

public static boolean doBypass()
                        throws edu.ucsb.nceas.utilities.GeneralPropertyException
Determine if the system is configured to bypass configuration. If so, the system will look for backup configuration files at startup time and use those to configure metacat. The bypass options should only be set by developers. Production code should never bypass confguration.

Returns:
true if dev.runConfiguration is set to true in metacat.properties and we have not already checked for bypass, false otherwise.
Throws:
edu.ucsb.nceas.utilities.GeneralPropertyException

bypassConfiguration

public static void bypassConfiguration()
                                throws edu.ucsb.nceas.utilities.GeneralPropertyException
Reports whether the metacat configuration utility should be run. Returns false if -- dev.runConfiguration=false and -- backup properties file exists Note that dev.runConfiguration should only be set to false when reinstalling the same version of the application in developement.

Throws:
edu.ucsb.nceas.utilities.GeneralPropertyException

checkAndSetProperty

public static void checkAndSetProperty(javax.servlet.http.HttpServletRequest request,
                                       java.lang.String propertyName)
                                throws edu.ucsb.nceas.utilities.GeneralPropertyException
Take input from the user in an HTTP request about an property to be changed and update the metacat property file with that new value if it has changed from the value that was originally set.

Parameters:
request - that was generated by the user
response - to send output back to the user
propertyName - the name of the property to be checked and set
Throws:
edu.ucsb.nceas.utilities.GeneralPropertyException

setRecommendedExternalDir

public static void setRecommendedExternalDir(java.lang.String extBaseDir)
Sets the recommended external directory. This is populated during initialization time using the SystemUtil.discoverExternalDir() method. This directory will be used to suggest external user directories when the user configures metacat for the first time.


getRecommendedExternalDir

public static java.lang.String getRecommendedExternalDir()
Returns the recommended external base directory. This is populated during initialization time using the SystemUtil.discoverExternalBaseDir() method. This directory will be used to suggest external user directories when the user configures metacat for the first time.

Returns:
a String holding the recommended external directory


Copyright © 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.