comparison artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/Config.java @ 560:2b631f788ce1

modules-Config-Dir introduced
author gernotbelger
date Tue, 04 Sep 2018 16:44:31 +0200
parents 609ced80bcf0
children
comparison
equal deleted inserted replaced
559:06257387b98f 560:2b631f788ce1
74 config = loadConfig(); 74 config = loadConfig();
75 } 75 }
76 return config; 76 return config;
77 } 77 }
78 78
79 public static Properties loadProperties(final String CONFIG_FILE_LOCAL) throws IOException { 79 public static Properties loadProperties(final String CONFIG_FILE_LOCAL, final File configDir) throws IOException {
80 final File configDir = getConfigDirectory();
81 final File configFile = new File(configDir, CONFIG_FILE_LOCAL); 80 final File configFile = new File(configDir, CONFIG_FILE_LOCAL);
82 81
83 InputStream reader = null; 82 InputStream reader = null;
84 try { 83 try {
85 reader = new BufferedInputStream(new FileInputStream(configFile)); 84 reader = new BufferedInputStream(new FileInputStream(configFile));
117 116
118 return configDir; 117 return configDir;
119 } 118 }
120 119
121 /** 120 /**
121 * returns the path to modules-config, which is a subfolder of config
122 */
123 public static File getModulesConfigDirectory() {
124
125 final File configDir = getConfigDirectory();
126 final File modulesCfgFile = new File(configDir, "modules");
127
128 if (!modulesCfgFile.isDirectory()) {
129 logger.warn("'" + modulesCfgFile + "' is not a directory.");
130 return CONFIG_DIR_DEFAULT; // or null?
131 }
132 return modulesCfgFile;
133 }
134
135 /**
122 * Replaces the CONFIG_DIR_PLACEHOLDER alias with the real path 136 * Replaces the CONFIG_DIR_PLACEHOLDER alias with the real path
123 * of the configuration directory. 137 * of the configuration directory.
124 * 138 *
125 * @param path 139 * @param path
126 * The path containing the CONFIG_DIR_PLACEHOLDER placeholder. 140 * The path containing the CONFIG_DIR_PLACEHOLDER placeholder.

http://dive4elements.wald.intevation.org