20 package org.sleuthkit.autopsy.coreutils;
23 import java.io.FileInputStream;
24 import java.io.FileOutputStream;
25 import java.io.IOException;
26 import java.io.InputStream;
27 import java.util.HashMap;
29 import java.util.Properties;
31 import java.util.logging.Level;
54 File propPath =
new File(moduleDirPath + File.separator + moduleName +
".properties");
55 File parent =
new File(propPath.getParent());
56 if(! parent.exists()){
59 Properties props =
new Properties();
61 propPath.createNewFile();
62 FileOutputStream fos =
new FileOutputStream(propPath);
82 File f =
new File(moduleDirPath + File.separator + moduleName +
".properties");
86 public static boolean settingExists(String moduleName, String settingName){
92 return (props.getProperty(settingName) != null);
107 return moduleDirPath + File.separator + moduleName +
".properties";
129 return props.getProperty(settingName);
130 }
catch (IOException e) {
153 Set<String> keys = props.stringPropertyNames();
154 Map<String, String> map =
new HashMap<String, String>();
156 for (String s : keys) {
157 map.put(s, props.getProperty(s));
161 }
catch (IOException e) {
172 public static synchronized void setConfigSettings(String moduleName, Map<String, String> settings) {
180 for (Map.Entry<String, String> kvp : settings.entrySet()) {
181 props.setProperty(kvp.getKey(), kvp.getValue());
185 FileOutputStream fos =
new FileOutputStream(path);
186 props.store(fos,
"Changed config settings(batch)");
188 }
catch (IOException e) {
199 public static synchronized void setConfigSetting(String moduleName, String settingName, String settingVal) {
208 props.setProperty(settingName, settingVal);
211 FileOutputStream fos =
new FileOutputStream(path);
212 props.store(fos,
"Changed config settings(single)");
214 }
catch (IOException e) {
231 FileOutputStream fos =
new FileOutputStream(path);
232 props.store(fos,
"Removed " + key);
236 catch(IOException e ){
248 InputStream inputStream =
new FileInputStream(
getPropertyPath(moduleName));
249 Properties props =
new Properties();
250 props.load(inputStream);
static Map< String, String > getConfigSettings(String moduleName)
static Properties fetchProperties(String moduleName)
static String getPropertyPath(String moduleName)
static boolean makeConfigFile(String moduleName)
static final String DEFAULT_CONTEXT
static final String moduleDirPath
static synchronized void setConfigSetting(String moduleName, String settingName, String settingVal)
static File getPropertyFile(String moduleName)
static synchronized void setConfigSettings(String moduleName, Map< String, String > settings)
static String getConfigSetting(String moduleName, String settingName)
static final String MAIN_SETTINGS
static boolean configExists(String moduleName)
static synchronized void removeProperty(String moduleName, String key)
static boolean settingExists(String moduleName, String settingName)
static Logger getLogger(String name)