diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbChoice.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbChoice.java index 92f0af775b..574408b619 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbChoice.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbChoice.java @@ -18,23 +18,22 @@ */ package org.sleuthkit.autopsy.centralrepository.datamodel; +import org.openide.util.NbBundle.Messages; + /** * the database choices available for central repo */ -public class CentralRepoDbChoice { - public static final CentralRepoDbChoice DISABLED = new CentralRepoDbChoice("Disabled", CentralRepoPlatforms.DISABLED); - - public static final CentralRepoDbChoice SQLITE = new CentralRepoDbChoice("Sqlite", "SQLite", CentralRepoPlatforms.SQLITE); - - public static final CentralRepoDbChoice POSTGRESQL_MULTIUSER = - new CentralRepoDbChoice("PostgreSQL_Multiuser", "PostgreSQL using multi-user settings", CentralRepoPlatforms.POSTGRESQL); - - public static final CentralRepoDbChoice POSTGRESQL_CUSTOM = - new CentralRepoDbChoice("PostgreSQL", "Custom PostgreSQL", CentralRepoPlatforms.POSTGRESQL); - - public static final CentralRepoDbChoice[] CHOICES = new CentralRepoDbChoice[]{ - DISABLED, SQLITE, POSTGRESQL_MULTIUSER, POSTGRESQL_CUSTOM - }; +@Messages({ + "CentralRepoDbChoice.Disabled.Text=Disabled", + "CentralRepoDbChoice.Sqlite.Text=SQLite", + "CentralRepoDbChoice.PostgreSQL_Multiuser.Text=PostgreSQL using multi-user settings", + "CentralRepoDbChoice.PostgreSQL.Text=Custom PostgreSQL", +}) +public enum CentralRepoDbChoice { + DISABLED("Disabled", Bundle.CentralRepoDbChoice_Disabled_Text(), CentralRepoPlatforms.DISABLED), + SQLITE("Sqlite", Bundle.CentralRepoDbChoice_Sqlite_Text(), CentralRepoPlatforms.SQLITE), + POSTGRESQL_MULTIUSER("PostgreSQL_Multiuser", Bundle.CentralRepoDbChoice_PostgreSQL_Multiuser_Text(), CentralRepoPlatforms.POSTGRESQL), + POSTGRESQL_CUSTOM("PostgreSQL", Bundle.CentralRepoDbChoice_PostgreSQL_Text(), CentralRepoPlatforms.POSTGRESQL); public static final CentralRepoDbChoice[] DB_CHOICES = new CentralRepoDbChoice[]{ SQLITE, POSTGRESQL_MULTIUSER, POSTGRESQL_CUSTOM @@ -50,10 +49,6 @@ public class CentralRepoDbChoice { this.title = title; this.platform = platform; } - - CentralRepoDbChoice(String key, CentralRepoPlatforms platform) { - this(key, key, platform); - } public String getSettingKey() { return settingKey; diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbManager.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbManager.java index 07e024d431..20309fca7b 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbManager.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbManager.java @@ -37,14 +37,14 @@ public class CentralRepoDbManager { - private static volatile CentralRepoDbChoice SAVED_CHOICE = null; + private static volatile CentralRepoDbChoice savedChoice = null; /** * Save the selected platform to the config file. */ public static synchronized CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice) { choice = (choice == null) ? CentralRepoDbChoice.DISABLED : choice; - SAVED_CHOICE = choice; + savedChoice = choice; ModuleSettings.setConfigSetting("CentralRepository", "db.selectedPlatform", choice.getSettingKey()); return choice; } @@ -53,17 +53,17 @@ public class CentralRepoDbManager { * Load the selectedPlatform boolean from the config file, if it is set. */ public static synchronized CentralRepoDbChoice getSavedDbChoice() { - if (SAVED_CHOICE == null) { + if (savedChoice == null) { String selectedPlatformString = ModuleSettings.getConfigSetting("CentralRepository", "db.selectedPlatform"); // NON-NLS - SAVED_CHOICE = fromKey(selectedPlatformString); + savedChoice = fromKey(selectedPlatformString); } - return SAVED_CHOICE; + return savedChoice; } private static CentralRepoDbChoice fromKey(String keyName) { - for (CentralRepoDbChoice dbChoice : CentralRepoDbChoice.CHOICES) { + for (CentralRepoDbChoice dbChoice : CentralRepoDbChoice.values()) { if (dbChoice.getSettingKey().equalsIgnoreCase(keyName)) { return dbChoice; } @@ -201,8 +201,8 @@ public class CentralRepoDbManager { public CentralRepoDbManager() { selectedDbChoice = getSavedDbChoice(); - dbSettingsPostgres = new PostgresCentralRepoSettings(PostgresSettingsLoader.CUSTOM_LOADER); - dbSettingsMultiUser = new PostgresCentralRepoSettings(PostgresSettingsLoader.MULTIUSER_LOADER); + dbSettingsPostgres = new PostgresCentralRepoSettings(PostgresSettingsLoader.CUSTOM_SETTINGS_LOADER); + dbSettingsMultiUser = new PostgresCentralRepoSettings(PostgresSettingsLoader.MULTIUSER_SETTINGS_LOADER); dbSettingsSqlite = new SqliteCentralRepoSettings(); } @@ -236,7 +236,7 @@ public class CentralRepoDbManager { } // the only successful setup status is tested ok - if (curStatus != DatabaseTestResult.TESTEDOK) { + if (curStatus != DatabaseTestResult.TESTED_OK) { throw new CentralRepoException("Unable to successfully create sqlite database"); } @@ -320,7 +320,7 @@ public class CentralRepoDbManager { throw new CentralRepoException(schemaError); } - testingStatus = DatabaseTestResult.TESTEDOK; + testingStatus = DatabaseTestResult.TESTED_OK; return true; } @@ -360,7 +360,7 @@ public class CentralRepoDbManager { selectedDbSettings.saveSettings(); // Load those newly saved settings into the postgres db manager instance // in case we are still using the same instance. - if (selectedDbChoice != null && selectedDbSettings != CentralRepoDbChoice.DISABLED) { + if (selectedDbChoice != null && selectedDbChoice != CentralRepoDbChoice.DISABLED) { try { logger.info("Saving central repo settings for db: " + selectedDbSettings); CentralRepository.getInstance().updateSettings(); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoPostgresSettingsUtil.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoPostgresSettingsUtil.java index 2aa7ca6e29..69e50768a5 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoPostgresSettingsUtil.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoPostgresSettingsUtil.java @@ -81,7 +81,7 @@ public class CentralRepoPostgresSettingsUtil { } } - private static void handleTry(TryHandler handler) { + private static void logException(TryHandler handler) { try { handler.operation(); } @@ -109,14 +109,14 @@ public class CentralRepoPostgresSettingsUtil { return settings; } - handleTry(() -> settings.setHost(valOrDefault(muConn.getHost(), DEFAULT_HOST))); - handleTry(() -> settings.setDbName(DEFAULT_DBNAME)); - handleTry(() -> settings.setUserName(valOrDefault(muConn.getUserName(), DEFAULT_USERNAME))); + logException(() -> settings.setHost(valOrDefault(muConn.getHost(), DEFAULT_HOST))); + logException(() -> settings.setDbName(DEFAULT_DBNAME)); + logException(() -> settings.setUserName(valOrDefault(muConn.getUserName(), DEFAULT_USERNAME))); - handleTry(() -> settings.setPort(valOrDefault(muConn.getPort(), DEFAULT_PORT, 1, 65535))); - handleTry(() -> settings.setBulkThreshold(RdbmsCentralRepo.DEFAULT_BULK_THRESHHOLD)); + logException(() -> settings.setPort(valOrDefault(muConn.getPort(), DEFAULT_PORT, 1, 65535))); + logException(() -> settings.setBulkThreshold(RdbmsCentralRepo.DEFAULT_BULK_THRESHHOLD)); - handleTry(() -> settings.setPassword(valOrDefault(muConn.getPassword(), DEFAULT_PASSWORD))); + logException(() -> settings.setPassword(valOrDefault(muConn.getPassword(), DEFAULT_PASSWORD))); return settings; } @@ -127,12 +127,12 @@ public class CentralRepoPostgresSettingsUtil { Map keyVals = ModuleSettings.getConfigSettings(MODULE_KEY); - handleTry(() -> settings.setHost(valOrDefault(keyVals.get(HOST_KEY), DEFAULT_HOST))); - handleTry(() -> settings.setDbName(valOrDefault(keyVals.get(DBNAME_KEY), DEFAULT_DBNAME))); - handleTry(() -> settings.setUserName(valOrDefault(keyVals.get(USER_KEY), DEFAULT_USERNAME))); + logException(() -> settings.setHost(valOrDefault(keyVals.get(HOST_KEY), DEFAULT_HOST))); + logException(() -> settings.setDbName(valOrDefault(keyVals.get(DBNAME_KEY), DEFAULT_DBNAME))); + logException(() -> settings.setUserName(valOrDefault(keyVals.get(USER_KEY), DEFAULT_USERNAME))); - handleTry(() -> settings.setPort(valOrDefault(keyVals.get(PORT_KEY), DEFAULT_PORT, 1, 65535))); - handleTry(() -> settings.setBulkThreshold(valOrDefault(keyVals.get(BULK_THRESHOLD_KEY), RdbmsCentralRepo.DEFAULT_BULK_THRESHHOLD, 1, null))); + logException(() -> settings.setPort(valOrDefault(keyVals.get(PORT_KEY), DEFAULT_PORT, 1, 65535))); + logException(() -> settings.setBulkThreshold(valOrDefault(keyVals.get(BULK_THRESHOLD_KEY), RdbmsCentralRepo.DEFAULT_BULK_THRESHHOLD, 1, null))); String passwordHex = keyVals.get(PASSWORD_KEY); String password; @@ -145,7 +145,7 @@ public class CentralRepoPostgresSettingsUtil { final String finalPassword = password; - handleTry(() -> settings.setPassword(finalPassword)); + logException(() -> settings.setPassword(finalPassword)); return settings; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/DatabaseTestResult.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/DatabaseTestResult.java index 27a7b16278..b18a8a28cd 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/DatabaseTestResult.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/DatabaseTestResult.java @@ -26,6 +26,6 @@ public enum DatabaseTestResult { CONNECTION_FAILED, SCHEMA_INVALID, DB_DOES_NOT_EXIST, - TESTEDOK; + TESTED_OK; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepoSettings.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepoSettings.java index 2bb275bef6..df37a3fec2 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepoSettings.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepoSettings.java @@ -48,9 +48,9 @@ public final class PostgresCentralRepoSettings implements CentralRepoDbConnectiv private static PostgresSettingsLoader getLoaderFromSaved() throws CentralRepoException { CentralRepoDbChoice choice = CentralRepoDbManager.getSavedDbChoice(); if (choice == CentralRepoDbChoice.POSTGRESQL_CUSTOM) - return PostgresSettingsLoader.CUSTOM_LOADER; + return PostgresSettingsLoader.CUSTOM_SETTINGS_LOADER; else if (choice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER) - return PostgresSettingsLoader.MULTIUSER_LOADER; + return PostgresSettingsLoader.MULTIUSER_SETTINGS_LOADER; else throw new CentralRepoException("cannot load or save postgres settings for selection: " + choice); } @@ -362,7 +362,7 @@ public final class PostgresCentralRepoSettings implements CentralRepoDbConnectiv if (verifyConnection()) { if (verifyDatabaseExists()) { if (verifyDatabaseSchema()) { - return DatabaseTestResult.TESTEDOK; + return DatabaseTestResult.TESTED_OK; } else { return DatabaseTestResult.SCHEMA_INVALID; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresSettingsLoader.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresSettingsLoader.java index e293f8bece..611cf25f2d 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresSettingsLoader.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresSettingsLoader.java @@ -25,8 +25,8 @@ public interface PostgresSettingsLoader { PostgresConnectionSettings loadSettings(); void saveSettings(PostgresConnectionSettings settings); - PostgresSettingsLoader CUSTOM_LOADER = new Custom(); - PostgresSettingsLoader MULTIUSER_LOADER = new MultiUser(); + PostgresSettingsLoader CUSTOM_SETTINGS_LOADER = new Custom(); + PostgresSettingsLoader MULTIUSER_SETTINGS_LOADER = new MultiUser(); /** diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepoSettings.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepoSettings.java index f2e8dac25c..a938dd166a 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepoSettings.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepoSettings.java @@ -358,7 +358,7 @@ public final class SqliteCentralRepoSettings implements CentralRepoDbConnectivit if (dbFileExists()) { if (verifyConnection()) { if (verifyDatabaseSchema()) { - return DatabaseTestResult.TESTEDOK; + return DatabaseTestResult.TESTED_OK; } else { return DatabaseTestResult.SCHEMA_INVALID; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/EamDbSettingsDialog.java b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/EamDbSettingsDialog.java index a3a19fe811..7474f3618a 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/EamDbSettingsDialog.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/EamDbSettingsDialog.java @@ -197,7 +197,7 @@ public class EamDbSettingsDialog extends JDialog { } } - return (manager.getStatus() == DatabaseTestResult.TESTEDOK); + return (manager.getStatus() == DatabaseTestResult.TESTED_OK); } diff --git a/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java b/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java index 116f212dd9..409e27f080 100644 --- a/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java +++ b/Core/src/org/sleuthkit/autopsy/core/UserPreferences.java @@ -75,7 +75,6 @@ public final class UserPreferences { public static final String SHOW_ONLY_CURRENT_USER_TAGS = "ShowOnlyCurrentUserTags"; public static final String HIDE_SCO_COLUMNS = "HideCentralRepoCommentsAndOccurrences"; //The key for this setting pre-dates the settings current functionality //NON-NLS public static final String DISPLAY_TRANSLATED_NAMES = "DisplayTranslatedNames"; - private static final boolean DISPLAY_TRANSLATED_NAMES_DEFAULT = true; public static final String EXTERNAL_HEX_EDITOR_PATH = "ExternalHexEditorPath"; public static final String SOLR_MAX_JVM_SIZE = "SolrMaxJVMSize"; public static final String RESULTS_TABLE_PAGE_SIZE = "ResultsTablePageSize"; @@ -266,7 +265,7 @@ public final class UserPreferences { } public static boolean displayTranslatedFileNames() { - return preferences.getBoolean(DISPLAY_TRANSLATED_NAMES, DISPLAY_TRANSLATED_NAMES_DEFAULT); + return preferences.getBoolean(DISPLAY_TRANSLATED_NAMES, false); } /**