diff options
Diffstat (limited to 'petascope/src/petascope/ConfigManager.java')
-rw-r--r-- | petascope/src/petascope/ConfigManager.java | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/petascope/src/petascope/ConfigManager.java b/petascope/src/petascope/ConfigManager.java index 0fa0481..c049493 100644 --- a/petascope/src/petascope/ConfigManager.java +++ b/petascope/src/petascope/ConfigManager.java @@ -14,19 +14,16 @@ * You should have received a copy of the GNU General Public License * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / - rasdaman GmbH. + * Copyright 2003 - 2010 Peter Baumann / rasdaman GmbH. * * For more information please see <http://www.rasdaman.org> * or contact Peter Baumann via <baumann@rasdaman.com>. */ package petascope; -//~--- JDK imports ------------------------------------------------------------ import java.io.File; import java.io.FileInputStream; import java.io.IOException; - import java.io.InputStream; import java.net.URI; import java.util.Properties; @@ -34,7 +31,8 @@ import javax.servlet.ServletException; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import petascope.wcs2.server.templates.WcsNamespaceContext; +import petascope.wcs2.templates.WcsNamespaceContext; +import static petascope.util.MsgUtil.*; /** * Configuration Manager class: a single entry point for all server settings. @@ -44,7 +42,7 @@ import petascope.wcs2.server.templates.WcsNamespaceContext; */ public class ConfigManager { - private static Logger LOG = LoggerFactory.getLogger(ConfigManager.class); + private static Logger log = LoggerFactory.getLogger(ConfigManager.class); /* Major version number. This is the first release (1). */ private final static String MAJOR = "1"; @@ -56,11 +54,22 @@ public class ConfigManager { /* Petascope 1.2.0 contains WCS 1.1.0, WCS 2.0, WCS-T 1.0.0 and WCPS 1.0.0 */ public final static String PETASCOPE_VERSION = MAJOR + "." + MINOR + "." + BUGFIX; + public final static String PETASCOPE_LANGUAGE = "en"; /* Settings variables */ public static String WCST_LANGUAGE; public static String WCST_VERSION; + public static String WCPS_LANGUAGE = "en"; + public static String WCPS_VERSION = "1.0.0"; + public static String WPS_LANGUAGE = "en"; + public static String WPS_VERSION = "1.0.0"; + public static String WCS_LANGUAGE = "en"; + public static String WCS_VERSION = "1.1.0"; + public static String WCS2_LANGUAGE = "en"; + public static String WCS2_VERSION = "2.0.0"; public static String RASDAMAN_URL; public static String RASDAMAN_DATABASE; + public static String RASDAMAN_LANGUAGE = "en"; + public static String RASDAMAN_VERSION = "8"; public static String METADATA_DRIVER; public static String METADATA_URL; public static String METADATA_USER; @@ -76,6 +85,7 @@ public class ConfigManager { /* This URL gets initialized automatically when the first request is received. * Its value is used in the Capabilities response */ public static String PETASCOPE_SERVLET_URL; + public static String WCS2_SERVLET_URL; /* WCS-T Settings. Overridden by user-preferences in <code>settings.properties</code> */ public static String WCST_DEFAULT_INTERPOLATION = "none"; @@ -94,12 +104,12 @@ public class ConfigManager { private ConfigManager(String settingsPath, String servletRoot) throws ServletException { props = new Properties(); try { - LOG.info("Loading settings from file: " + settingsPath); + log.info("Loading settings from file: " + settingsPath); props.load(new FileInputStream(settingsPath)); initSettings(servletRoot); } catch (IOException e) { - LOG.error("Failed to load settings. Stack trace: " + e); - throw new ServletException("Failed to load settings file."); + log.error("Failed to load settings. Stack trace: " + e); + throw new ServletException(msg(SETTINGS_FAILED_LOADING)); } } @@ -121,8 +131,7 @@ public class ConfigManager { public static ConfigManager getInstance() { if (instance == null) { - throw new RuntimeException("Could not initialize the ConfigManager " - + "because no settings file path was provided."); + throw new RuntimeException(msg(SETTINGS_INITERROR)); } return instance; } @@ -156,16 +165,10 @@ public class ConfigManager { CCIP_HACK = Boolean.parseBoolean(get("ccip_version")); try { - URI desc = WcsNamespaceContext.class.getResource("DescribeCoverageTemplate.xml").toURI(); - URI getcov = WcsNamespaceContext.class.getResource("GetCoverageTemplate.xml").toURI(); - URI getcap = WcsNamespaceContext.class.getResource("GetCapabilitiesTemplate.xml").toURI(); - WCS2_GET_CAPABILITIES_TEMPLATE = loadFile(getcap); - WCS2_DESCRIBE_COVERAGE_TEMPLATE = loadFile(desc); - WCS2_GET_COVERAGE_TEMPLATE = loadFile(getcov); WCS2_SCHEMA_URL = get("wcs2_schema_url"); } catch (Exception e) { - LOG.warn("Could not read XML template files for WCS 2.0. Therefore, WCS 2.0 will be unable to start."); + log.warn("Could not read XML template files for WCS 2.0. Therefore, WCS 2.0 will be unable to start."); } /* User preferences override default values for WCS-T */ @@ -182,38 +185,35 @@ public class ConfigManager { WCST_DEFAULT_DATATYPE = tmp; } - LOG.info("---------------------------"); + log.info("---------------------------"); if (CCIP_HACK) { - LOG.info("-----------CCIP------------"); + log.info("-----------CCIP------------"); } - LOG.info("---------------------------"); - -// log("Print Log: " + PRINT_LOG); - LOG.info(" *** PETASCOPE *** "); - LOG.info("Rasdaman URL: " + RASDAMAN_URL); - LOG.info("Rasdaman DB: " + RASDAMAN_DATABASE); - LOG.info("Metadata Driver: " + METADATA_DRIVER); - LOG.info("Metadata URL: " + METADATA_URL); - LOG.info("Metadata Username: " + METADATA_USER); -// LOG.info("Metadata Password: " + METADATA_PASS); - LOG.info(" *** WCS-T *** "); - LOG.info("WCS-T Language: " + WCST_LANGUAGE); - LOG.info("WCS-T Version: " + WCST_VERSION); - LOG.info("WCS-T Default Interpolation: " + WCST_DEFAULT_INTERPOLATION); - LOG.info("WCS-T Default Null Resistance: " + WCST_DEFAULT_NULL_RESISTANCE); - LOG.info("WCS-T Default Datatype: " + WCST_DEFAULT_DATATYPE); - LOG.info(" *** WCS 2.0 *** "); - LOG.trace("Get Capabilities Template: " + WCS2_GET_CAPABILITIES_TEMPLATE.substring(0, 100)); - LOG.trace("Describe Coverage Template: " + WCS2_DESCRIBE_COVERAGE_TEMPLATE.substring(0, 100)); - LOG.trace("Get Capabilities Template: " + WCS2_GET_COVERAGE_TEMPLATE.substring(0, 100)); - LOG.info("---------------------------"); + log.info("---------------------------"); + +// log("Print Log: " + PRINT_log); + log.info(" *** PETASCOPE *** "); + log.info("Rasdaman URL: " + RASDAMAN_URL); + log.info("Rasdaman DB: " + RASDAMAN_DATABASE); + log.info("Metadata Driver: " + METADATA_DRIVER); + log.info("Metadata URL: " + METADATA_URL); + log.info("Metadata Username: " + METADATA_USER); +// log.info("Metadata Password: " + METADATA_PASS); + log.info(" *** WCS-T *** "); + log.info("WCS-T Language: " + WCST_LANGUAGE); + log.info("WCS-T Version: " + WCST_VERSION); + log.info("WCS-T Default Interpolation: " + WCST_DEFAULT_INTERPOLATION); + log.info("WCS-T Default Null Resistance: " + WCST_DEFAULT_NULL_RESISTANCE); + log.info("WCS-T Default Datatype: " + WCST_DEFAULT_DATATYPE); + log.info(" *** WCS 2.0 *** "); + log.info("---------------------------"); } private String loadFile(URI fileUri) throws IOException { InputStream is = null; String contents = null; try { - LOG.debug("Loading file: " + fileUri); + log.debug("Loading file: " + fileUri); File f = new File(fileUri); is = new FileInputStream(f); contents = IOUtils.toString(is); |