edu.ucsb.nceas.metacat.properties
Class SkinPropertyService

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

public class SkinPropertyService
extends BaseService

A suite of utility classes for the skin configuration utility


Field Summary
 
Fields inherited from class edu.ucsb.nceas.metacat.shared.BaseService
_serviceName
 
Method Summary
static boolean areSkinsConfigured()
          Reports whether properties are fully configured.
static boolean bypassConfiguration()
          Reports whether the metacat configuration utility should be run.
static void checkAndSetProperty(javax.servlet.http.HttpServletRequest request, java.lang.String skinName, 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 void checkAndSetProperty(java.lang.String newValue, java.lang.String skinName, java.lang.String propertyName)
          Check user input against existing value and update the metacat property file with that new value if it has changed from the value that was originally set.
 void doRefresh()
           
static java.util.HashMap<java.lang.String,edu.ucsb.nceas.utilities.SortedProperties> getBackupProperties()
          Get the main backup properties file.
static edu.ucsb.nceas.utilities.SortedProperties getBackupProperties(java.lang.String skinName)
          Get the main backup properties file.
static SkinPropertyService getInstance()
          Get the single instance of SkinPropertyService.
static java.util.HashMap<java.lang.String,edu.ucsb.nceas.utilities.PropertiesMetaData> getMetaData()
          Get the main properties metadata.
static edu.ucsb.nceas.utilities.PropertiesMetaData getMetaData(java.lang.String skinName)
          Get the main properties metadata.
static java.util.HashMap<java.lang.String,edu.ucsb.nceas.utilities.SortedProperties> getProperties()
          Get the main backup properties file.
static edu.ucsb.nceas.utilities.SortedProperties getProperties(java.lang.String skinName)
          Get the main backup properties file.
static java.lang.String getProperty(java.lang.String skinName, java.lang.String propertyName)
          Utility method to get a property value from the properties file for a specific skin.
static java.util.Vector<java.lang.String> getPropertyNames(java.lang.String skinName)
          Get a set of all property names for a given skin.
static java.util.Vector<java.lang.String> getPropertyNamesByGroup(java.lang.String skinName, java.lang.String groupName)
          Get a Set of all property names that start with the groupName prefix.
static void persistAllProperties()
          Save the properties to a properties file.
static void persistBackupProperties(java.lang.String skinName)
          Writes out backup configurable properties to a file.
static void persistProperties(java.lang.String skinName)
          Save the properties to a properties file.
 boolean refreshable()
           
static void setProperty(java.lang.String skinName, 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 skinName, java.lang.String propertyName, java.lang.String newValue)
          Utility method to set a property value in memory.
 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
 

Method Detail

getInstance

public static SkinPropertyService getInstance()
                                       throws ServiceException
Get the single instance of SkinPropertyService.

Parameters:
servletContext - the context we will use to get relative paths
Returns:
the single instance of SkinPropertyService
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 skinName,
                                           java.lang.String propertyName)
                                    throws edu.ucsb.nceas.utilities.PropertyNotFoundException
Utility method to get a property value from the properties file for a specific skin.

Parameters:
skinName - the skin for which we want to retrieve the property
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(java.lang.String skinName)
                                                           throws edu.ucsb.nceas.utilities.PropertyNotFoundException
Get a set of all property names for a given skin.

Parameters:
skinName - the skin for which we want to retrieve the property names
Returns:
Set of property names
Throws:
edu.ucsb.nceas.utilities.PropertyNotFoundException

getPropertyNamesByGroup

public static java.util.Vector<java.lang.String> getPropertyNamesByGroup(java.lang.String skinName,
                                                                         java.lang.String groupName)
                                                                  throws edu.ucsb.nceas.utilities.PropertyNotFoundException
Get a Set of all property names that start with the groupName prefix.

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

getProperties

public static java.util.HashMap<java.lang.String,edu.ucsb.nceas.utilities.SortedProperties> getProperties()
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

getProperties

public static edu.ucsb.nceas.utilities.SortedProperties getProperties(java.lang.String skinName)
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

getBackupProperties

public static java.util.HashMap<java.lang.String,edu.ucsb.nceas.utilities.SortedProperties> getBackupProperties()
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

getBackupProperties

public static edu.ucsb.nceas.utilities.SortedProperties getBackupProperties(java.lang.String skinName)
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

getMetaData

public static java.util.HashMap<java.lang.String,edu.ucsb.nceas.utilities.PropertiesMetaData> getMetaData()
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

getMetaData

public static edu.ucsb.nceas.utilities.PropertiesMetaData getMetaData(java.lang.String skinName)
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

setProperty

public static void setProperty(java.lang.String skinName,
                               java.lang.String propertyName,
                               java.lang.String newValue)
                        throws java.io.IOException,
                               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:
java.io.IOException
edu.ucsb.nceas.utilities.GeneralPropertyException

setPropertyNoPersist

public static void setPropertyNoPersist(java.lang.String skinName,
                                        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(java.lang.String skinName)
                              throws java.io.IOException,
                                     edu.ucsb.nceas.utilities.GeneralPropertyException
Save the properties to a properties file. Note, the order and comments will be preserved.

Throws:
java.io.IOException
edu.ucsb.nceas.utilities.GeneralPropertyException

persistAllProperties

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

Throws:
java.io.IOException
edu.ucsb.nceas.utilities.GeneralPropertyException

persistBackupProperties

public static void persistBackupProperties(java.lang.String skinName)
                                    throws edu.ucsb.nceas.utilities.GeneralPropertyException
Writes out backup configurable properties to a file.

Throws:
edu.ucsb.nceas.utilities.GeneralPropertyException

areSkinsConfigured

public static boolean areSkinsConfigured()
                                  throws MetacatUtilException
Reports whether properties are fully configured.

Returns:
a boolean that is true if properties are not unconfigured and false otherwise
Throws:
MetacatUtilException

checkAndSetProperty

public static void checkAndSetProperty(javax.servlet.http.HttpServletRequest request,
                                       java.lang.String skinName,
                                       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

checkAndSetProperty

public static void checkAndSetProperty(java.lang.String newValue,
                                       java.lang.String skinName,
                                       java.lang.String propertyName)
                                throws edu.ucsb.nceas.utilities.GeneralPropertyException
Check user input against existing value and update the metacat property file with that new value if it has changed from the value that was originally set.

Parameters:
newValue - the value that was returned by the form
skinname - the skin that we are checking
propertyName - the name of the property to be checked and set
Throws:
edu.ucsb.nceas.utilities.GeneralPropertyException

bypassConfiguration

public static boolean bypassConfiguration()
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.

Returns:
a boolean that is false if dev.runConfiguration is false and the backup properties file exists.


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