/** * Flush preferences to disk */ public void flushPreferences() { try { userPrefs.flush(); } catch (BackingStoreException e) { log.error(e.toString()); // slf4j migration: toString() } }
private Preferences staticPrefsOrNull() { File staticFile = new File(staticConfigFile); if (!staticFile.exists() || !staticFile.canRead()) { return null; } try { Preferences prefs = new IniFile(staticFile, Mode.RO); return prefs; } catch (BackingStoreException e) { log.error(e.toString()); // slf4j migration: toString() throw new RuntimeException(e); } }
/** * Load given file * * @param userConfigFile the file to load */ public IniFileLoader(File userConfigFile) { staticConfigDirectory = System.getProperty("user.dir") + File.separator + "config"; staticConfigFile = staticConfigDirectory + File.separator + "importer.config"; staticPrefs = staticPrefsOrNull(); // Set up user config file userSettingsDirectory = System.getProperty("user.home") + File.separator + "omero"; if (!new File(userSettingsDirectory).exists()) { new File(userSettingsDirectory).mkdir(); } if (userConfigFile == null) userConfigFile = new File(userSettingsDirectory + File.separator + "importer.ini"); try { userPrefs = new IniFile(userConfigFile, Mode.RW); } catch (BackingStoreException e) { log.error(e.toString()); // slf4j migration: toString() //throw new RuntimeException("Error accessing ini file", e); } }
/** * @see #loadAll() */ public void saveAll() { // Moving to explicit calls // for (Value<?> cv : values()) { // cv.store(); // } savedProject.store(); savedDataset.store(); savedScreen.store(); useCustomImageNaming.store(); useFullPath.store(); numOfDirectories.store(); savedDirectory.store(); sendLogFile.store(); sendFiles.store(); sendReport.store(); try { prefs.flush(); ini.flushPreferences(); } catch (BackingStoreException e) { log.error(e.toString()); // slf4j migration: toString() throw new RuntimeException(e); } }