comparison artifact-database/src/main/java/de/intevation/artifactdatabase/Config.java @ 61:911c684c8a1c

Removed config path of chart template which doesn't belong here from Config. artifacts/trunk@432 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 15 Dec 2009 15:47:16 +0000
parents 8cd770330f1b
children 8447467cef86
comparison
equal deleted inserted replaced
60:85d996328c8a 61:911c684c8a1c
31 new File(new File(System.getProperty("user.home", 31 new File(new File(System.getProperty("user.home",
32 System.getProperty("user.dir", "."))), ".artifactdb"); 32 System.getProperty("user.dir", "."))), ".artifactdb");
33 33
34 public static final String CONFIG_FILE = "conf.xml"; 34 public static final String CONFIG_FILE = "conf.xml";
35 35
36 public static final String CHART_TEMPLATE = "charttemplate.xml";
37
38 public static final String CONFIG_DIR_PLACEHOLDER = "${artifacts.config.dir}"; 36 public static final String CONFIG_DIR_PLACEHOLDER = "${artifacts.config.dir}";
39 37
40 private static Document config; 38 private static Document config;
41 39
42 private Config() { 40 private Config() {
43 } 41 }
44 42
45 public static synchronized final Document getConfig() { 43 public static synchronized final Document getConfig() {
46 if (config == null) { 44 if (config == null) {
47 config = loadConfig(CONFIG_FILE); 45 config = loadConfig();
48 } 46 }
49 return config; 47 return config;
50 }
51
52 public static Document getChartTemplate() {
53 return loadConfig(CHART_TEMPLATE);
54 } 48 }
55 49
56 public static File getConfigDirectory() { 50 public static File getConfigDirectory() {
57 String configDirString = System.getProperty(CONFIG_DIR); 51 String configDirString = System.getProperty(CONFIG_DIR);
58 52
71 public static String replaceConfigDir(String path) { 65 public static String replaceConfigDir(String path) {
72 String configDir = getConfigDirectory().getAbsolutePath(); 66 String configDir = getConfigDirectory().getAbsolutePath();
73 return path.replace(CONFIG_DIR_PLACEHOLDER, configDir); 67 return path.replace(CONFIG_DIR_PLACEHOLDER, configDir);
74 } 68 }
75 69
76 private static Document loadConfig(String config) { 70 private static Document loadConfig() {
77 71
78 File configDir = getConfigDirectory(); 72 File configDir = getConfigDirectory();
79 73
80 File file = new File(configDir, config); 74 File file = new File(configDir, CONFIG_FILE);
81 75
82 if (!file.canRead() && !file.isFile()) { 76 if (!file.canRead() && !file.isFile()) {
83 logger.error("Cannot read config file '" 77 logger.error("Cannot read config file '"
84 + file + "'."); 78 + file + "'.");
85 return null; 79 return null;

http://dive4elements.wald.intevation.org