19 package org.sleuthkit.autopsy.coreutils;
22 import java.io.FileInputStream;
23 import java.io.FileOutputStream;
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.util.HashMap;
28 import java.util.Properties;
30 import java.util.logging.Level;
61 File propPath =
new File(moduleDirPath + File.separator + moduleName +
".properties");
62 File parent =
new File(propPath.getParent());
63 if (!parent.exists()) {
66 Properties props =
new Properties();
68 propPath.createNewFile();
69 FileOutputStream fos =
new FileOutputStream(propPath);
72 }
catch (IOException e) {
89 File f =
new File(moduleDirPath + File.separator + moduleName +
".properties");
93 public static boolean settingExists(String moduleName, String settingName) {
99 return (props.getProperty(settingName) != null);
100 }
catch (IOException e) {
116 return moduleDirPath + File.separator + moduleName +
".properties";
141 return props.getProperty(settingName);
142 }
catch (IOException e) {
168 Set<String> keys = props.stringPropertyNames();
169 Map<String, String> map =
new HashMap<String, String>();
171 for (String s : keys) {
172 map.put(s, props.getProperty(s));
176 }
catch (IOException e) {
189 public static synchronized void setConfigSettings(String moduleName, Map<String, String> settings) {
197 for (Map.Entry<String, String> kvp : settings.entrySet()) {
198 props.setProperty(kvp.getKey(), kvp.getValue());
202 FileOutputStream fos =
new FileOutputStream(path);
203 props.store(fos,
"Changed config settings(batch)");
205 }
catch (IOException e) {
217 public static synchronized void setConfigSetting(String moduleName, String settingName, String settingVal) {
226 props.setProperty(settingName, settingVal);
229 FileOutputStream fos =
new FileOutputStream(path);
230 props.store(fos,
"Changed config settings(single)");
232 }
catch (IOException e) {
250 FileOutputStream fos =
new FileOutputStream(path);
251 props.store(fos,
"Removed " + key);
254 }
catch (IOException e) {
269 InputStream inputStream =
new FileInputStream(
getPropertyPath(moduleName));
270 Properties props =
new Properties();
271 props.load(inputStream);
static final String CURRENT_CASE_TYPE
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)
synchronized static Logger getLogger(String name)
static synchronized void removeProperty(String moduleName, String key)
static boolean settingExists(String moduleName, String settingName)