mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 08:26:15 +00:00
updates to spacing
This commit is contained in:
parent
cace957153
commit
56f3546bae
@ -39,49 +39,38 @@ public class CentralRepoDbManager {
|
|||||||
private static final String CENTRAL_REPO_DB_NAME = "central_repository";
|
private static final String CENTRAL_REPO_DB_NAME = "central_repository";
|
||||||
private static final String CENTRAL_REPOSITORY_SETTINGS_KEY = "CentralRepository";
|
private static final String CENTRAL_REPOSITORY_SETTINGS_KEY = "CentralRepository";
|
||||||
private static final String DB_SELECTED_PLATFORM_KEY = "db.selectedPlatform";
|
private static final String DB_SELECTED_PLATFORM_KEY = "db.selectedPlatform";
|
||||||
|
private static final String DISABLED_DUE_TO_FAILURE_KEY = "disabledDueToFailure";
|
||||||
|
|
||||||
private static CentralRepoDbManager instance = null;
|
private static volatile CentralRepoDbChoice savedChoice = null;
|
||||||
|
|
||||||
public static CentralRepoDbManager getInstance() {
|
private static final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(CentralRepoDbManager.class);
|
||||||
if (instance == null)
|
|
||||||
instance = new CentralRepoDbManager();
|
|
||||||
|
|
||||||
return instance;
|
private static final Object dbChoiceLock = new Object();
|
||||||
|
private static final Object disabledDueToFailureLock = new Object();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This saves the currently selected database choice and clears any disabledDueToFailure flag.
|
||||||
|
* @param choice The choice to save.
|
||||||
|
* @return The newly saved choice.
|
||||||
|
*/
|
||||||
|
public static CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice) {
|
||||||
|
return saveDbChoice(choice, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(CentralRepoDbManager.class);
|
|
||||||
private final Object dbChoiceLock = new Object();
|
|
||||||
|
|
||||||
// The currently saved db choice.
|
|
||||||
private volatile CentralRepoDbChoice savedChoice = null;
|
|
||||||
|
|
||||||
// The currently selected (but not necessarily saved) central repo db choice.
|
|
||||||
private CentralRepoDbChoice selectedDbChoice;
|
|
||||||
private DatabaseTestResult testingStatus;
|
|
||||||
|
|
||||||
private final PostgresCentralRepoSettings dbSettingsPostgres;
|
|
||||||
private final PostgresCentralRepoSettings dbSettingsMultiUser;
|
|
||||||
private final SqliteCentralRepoSettings dbSettingsSqlite;
|
|
||||||
|
|
||||||
private CentralRepoDbManager() {
|
|
||||||
selectedDbChoice = getSavedDbChoice();
|
|
||||||
dbSettingsPostgres = new PostgresCentralRepoSettings(PostgresSettingsLoader.CUSTOM_SETTINGS_LOADER);
|
|
||||||
dbSettingsMultiUser = new PostgresCentralRepoSettings(PostgresSettingsLoader.MULTIUSER_SETTINGS_LOADER);
|
|
||||||
dbSettingsSqlite = new SqliteCentralRepoSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This saves the currently selected database choice.
|
* This saves the currently selected database choice.
|
||||||
* @param choice The choice to save.
|
* @param choice The choice to save.
|
||||||
* @param clearDisabledDueToError Whether or not to clear the 'disabledDueToFailure' settings key.
|
* @param clearDisabledDueToError Whether or not to clear the 'disabledDueToFailure' settings key.
|
||||||
* @return The newly saved choice.
|
* @return The newly saved choice.
|
||||||
*/
|
*/
|
||||||
public CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice) {
|
public static CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice, boolean clearDisabledDueToError) {
|
||||||
synchronized(dbChoiceLock) {
|
synchronized(dbChoiceLock) {
|
||||||
|
// clear disabling due to a failure
|
||||||
|
if (clearDisabledDueToError)
|
||||||
|
setDisabledDueToFailure(false);
|
||||||
|
|
||||||
// change the settings
|
// change the settings
|
||||||
CentralRepoDbChoice newChoice = (choice == null) ? CentralRepoDbChoice.DISABLED : choice;
|
CentralRepoDbChoice newChoice = (choice == null) ? CentralRepoDbChoice.DISABLED : choice;
|
||||||
CentralRepoDbChoice oldChoice = savedChoice;
|
CentralRepoDbChoice oldChoice = savedChoice;
|
||||||
@ -97,7 +86,7 @@ public class CentralRepoDbManager {
|
|||||||
* This method indicates whether or not 'PostgreSQL using multi-user settings' is a valid option.
|
* This method indicates whether or not 'PostgreSQL using multi-user settings' is a valid option.
|
||||||
* @return True if 'PostgreSQL using multi-user settings' is valid.
|
* @return True if 'PostgreSQL using multi-user settings' is valid.
|
||||||
*/
|
*/
|
||||||
public boolean isPostgresMultiuserAllowed() {
|
public static boolean isPostgresMultiuserAllowed() {
|
||||||
// if multi user mode is not enabled, then this cannot be used
|
// if multi user mode is not enabled, then this cannot be used
|
||||||
if (!UserPreferences.getIsMultiUserModeEnabled())
|
if (!UserPreferences.getIsMultiUserModeEnabled())
|
||||||
return false;
|
return false;
|
||||||
@ -113,7 +102,7 @@ public class CentralRepoDbManager {
|
|||||||
/**
|
/**
|
||||||
* This method loads the selectedPlatform boolean from the config file if it is set.
|
* This method loads the selectedPlatform boolean from the config file if it is set.
|
||||||
*/
|
*/
|
||||||
public CentralRepoDbChoice getSavedDbChoice() {
|
public static CentralRepoDbChoice getSavedDbChoice() {
|
||||||
synchronized(dbChoiceLock) {
|
synchronized(dbChoiceLock) {
|
||||||
if (savedChoice == null) {
|
if (savedChoice == null) {
|
||||||
String selectedPlatformString = ModuleSettings.getConfigSetting(CENTRAL_REPOSITORY_SETTINGS_KEY, DB_SELECTED_PLATFORM_KEY); // NON-NLS
|
String selectedPlatformString = ModuleSettings.getConfigSetting(CENTRAL_REPOSITORY_SETTINGS_KEY, DB_SELECTED_PLATFORM_KEY); // NON-NLS
|
||||||
@ -124,6 +113,40 @@ public class CentralRepoDbManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method disables the central repository and indicates through a flag that this was due to a failure during database setup.
|
||||||
|
* This is used when re-enabling multi-user as a flag to determine whether or not CR should be re-enabled.
|
||||||
|
*/
|
||||||
|
public static void disableDueToFailure() {
|
||||||
|
CentralRepoDbUtil.setUseCentralRepo(false);
|
||||||
|
setDisabledDueToFailure(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method sets whether or not the repository has been disabled due to a database setup issue;
|
||||||
|
* This is used when re-enabling multi-user as a flag to determine whether or not CR should be re-enabled.
|
||||||
|
*
|
||||||
|
* @param disabledDueToFailure Whether or not the repository has been disabled due to a database setup issue.
|
||||||
|
*/
|
||||||
|
private static void setDisabledDueToFailure(boolean disabledDueToFailure) {
|
||||||
|
synchronized(disabledDueToFailureLock) {
|
||||||
|
boolean oldValue = isDisabledDueToFailure();
|
||||||
|
ModuleSettings.setConfigSetting(CENTRAL_REPOSITORY_SETTINGS_KEY, DISABLED_DUE_TO_FAILURE_KEY, Boolean.toString(disabledDueToFailure));
|
||||||
|
propertyChangeSupport.firePropertyChange("disabledDueToFailure", oldValue, disabledDueToFailure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method retrieves setting whether or not the repository has been disabled due to a database setup issue;
|
||||||
|
* this is used when re-enabling multi-user as a flag to determine whether or not CR should be re-enabled.
|
||||||
|
*
|
||||||
|
* @return Whether or not the repository has been disabled due to a database setup issue.
|
||||||
|
*/
|
||||||
|
public static boolean isDisabledDueToFailure() {
|
||||||
|
synchronized(disabledDueToFailureLock) {
|
||||||
|
return Boolean.toString(true).equals(ModuleSettings.getConfigSetting(CENTRAL_REPOSITORY_SETTINGS_KEY, DISABLED_DUE_TO_FAILURE_KEY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method adds a property change listener.
|
* This method adds a property change listener.
|
||||||
@ -131,7 +154,7 @@ public class CentralRepoDbManager {
|
|||||||
*
|
*
|
||||||
* @param listener The listener for the event.
|
* @param listener The listener for the event.
|
||||||
*/
|
*/
|
||||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
public static void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||||
propertyChangeSupport.addPropertyChangeListener(listener);
|
propertyChangeSupport.addPropertyChangeListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,13 +162,13 @@ public class CentralRepoDbManager {
|
|||||||
* This method removes a propert change listener.
|
* This method removes a propert change listener.
|
||||||
* @param listener The listener to remove.
|
* @param listener The listener to remove.
|
||||||
*/
|
*/
|
||||||
public void removePropertyChangeListener(PropertyChangeListener listener) {
|
public static void removePropertyChangeListener(PropertyChangeListener listener) {
|
||||||
propertyChangeSupport.removePropertyChangeListener(listener);
|
propertyChangeSupport.removePropertyChangeListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private CentralRepoDbChoice fromKey(String keyName) {
|
private static CentralRepoDbChoice fromKey(String keyName) {
|
||||||
for (CentralRepoDbChoice dbChoice : CentralRepoDbChoice.values()) {
|
for (CentralRepoDbChoice dbChoice : CentralRepoDbChoice.values()) {
|
||||||
if (dbChoice.getSettingKey().equalsIgnoreCase(keyName)) {
|
if (dbChoice.getSettingKey().equalsIgnoreCase(keyName)) {
|
||||||
return dbChoice;
|
return dbChoice;
|
||||||
@ -163,7 +186,7 @@ public class CentralRepoDbManager {
|
|||||||
* @return The CentralRepository object that will be used for connection.
|
* @return The CentralRepository object that will be used for connection.
|
||||||
* @throws CentralRepoException
|
* @throws CentralRepoException
|
||||||
*/
|
*/
|
||||||
private CentralRepository obtainCentralRepository() throws CentralRepoException {
|
private static CentralRepository obtainCentralRepository() throws CentralRepoException {
|
||||||
//get connection
|
//get connection
|
||||||
try {
|
try {
|
||||||
return CentralRepository.getInstance();
|
return CentralRepository.getInstance();
|
||||||
@ -184,7 +207,7 @@ public class CentralRepoDbManager {
|
|||||||
* @return The lock if acquired.
|
* @return The lock if acquired.
|
||||||
* @throws CentralRepoException
|
* @throws CentralRepoException
|
||||||
*/
|
*/
|
||||||
private CoordinationService.Lock obtainCentralRepoLock(CentralRepository db) throws CentralRepoException {
|
private static CoordinationService.Lock obtainCentralRepoLock(CentralRepository db) throws CentralRepoException {
|
||||||
try {
|
try {
|
||||||
// This may return null if locking isn't supported, which is fine. It will
|
// This may return null if locking isn't supported, which is fine. It will
|
||||||
// throw an exception if locking is supported but we can't get the lock
|
// throw an exception if locking is supported but we can't get the lock
|
||||||
@ -208,7 +231,7 @@ public class CentralRepoDbManager {
|
|||||||
* @param lock The acquired lock.
|
* @param lock The acquired lock.
|
||||||
* @throws CentralRepoException
|
* @throws CentralRepoException
|
||||||
*/
|
*/
|
||||||
private void updatedDbSchema(CentralRepository db, CoordinationService.Lock lock) throws CentralRepoException {
|
private static void updatedDbSchema(CentralRepository db, CoordinationService.Lock lock) throws CentralRepoException {
|
||||||
try {
|
try {
|
||||||
db.upgradeSchema();
|
db.upgradeSchema();
|
||||||
} catch (CentralRepoException ex) {
|
} catch (CentralRepoException ex) {
|
||||||
@ -239,7 +262,7 @@ public class CentralRepoDbManager {
|
|||||||
* settings will be cleared.
|
* settings will be cleared.
|
||||||
*/
|
*/
|
||||||
@NbBundle.Messages(value = {"EamDbUtil.centralRepoDisabled.message= The Central Repository has been disabled.", "EamDbUtil.centralRepoUpgradeFailed.message=Failed to upgrade Central Repository.", "EamDbUtil.centralRepoConnectionFailed.message=Unable to connect to Central Repository.", "EamDbUtil.exclusiveLockAquisitionFailure.message=Unable to acquire exclusive lock for Central Repository."})
|
@NbBundle.Messages(value = {"EamDbUtil.centralRepoDisabled.message= The Central Repository has been disabled.", "EamDbUtil.centralRepoUpgradeFailed.message=Failed to upgrade Central Repository.", "EamDbUtil.centralRepoConnectionFailed.message=Unable to connect to Central Repository.", "EamDbUtil.exclusiveLockAquisitionFailure.message=Unable to acquire exclusive lock for Central Repository."})
|
||||||
public void upgradeDatabase() throws CentralRepoException {
|
public static void upgradeDatabase() throws CentralRepoException {
|
||||||
if (!CentralRepository.isEnabled()) {
|
if (!CentralRepository.isEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -256,7 +279,7 @@ public class CentralRepoDbManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUpgradeError(String message, String desc, Exception innerException) throws CentralRepoException {
|
private static void onUpgradeError(String message, String desc, Exception innerException) throws CentralRepoException {
|
||||||
// Disable the central repo and clear the current settings.
|
// Disable the central repo and clear the current settings.
|
||||||
try {
|
try {
|
||||||
if (null != CentralRepository.getInstance()) {
|
if (null != CentralRepository.getInstance()) {
|
||||||
@ -265,7 +288,7 @@ public class CentralRepoDbManager {
|
|||||||
} catch (CentralRepoException ex2) {
|
} catch (CentralRepoException ex2) {
|
||||||
logger.log(Level.SEVERE, "Error shutting down central repo connection pool", ex2);
|
logger.log(Level.SEVERE, "Error shutting down central repo connection pool", ex2);
|
||||||
}
|
}
|
||||||
saveDbChoice(CentralRepoDbChoice.DISABLED);
|
saveDbChoice(CentralRepoDbChoice.DISABLED, false);
|
||||||
if (innerException == null) {
|
if (innerException == null) {
|
||||||
throw new CentralRepoException(message, desc);
|
throw new CentralRepoException(message, desc);
|
||||||
} else {
|
} else {
|
||||||
@ -275,6 +298,21 @@ public class CentralRepoDbManager {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private DatabaseTestResult testingStatus;
|
||||||
|
private CentralRepoDbChoice selectedDbChoice;
|
||||||
|
|
||||||
|
private final PostgresCentralRepoSettings dbSettingsPostgres;
|
||||||
|
private final PostgresCentralRepoSettings dbSettingsMultiUser;
|
||||||
|
private final SqliteCentralRepoSettings dbSettingsSqlite;
|
||||||
|
|
||||||
|
private boolean configurationChanged = false;
|
||||||
|
|
||||||
|
public CentralRepoDbManager() {
|
||||||
|
selectedDbChoice = getSavedDbChoice();
|
||||||
|
dbSettingsPostgres = new PostgresCentralRepoSettings(PostgresSettingsLoader.CUSTOM_SETTINGS_LOADER);
|
||||||
|
dbSettingsMultiUser = new PostgresCentralRepoSettings(PostgresSettingsLoader.MULTIUSER_SETTINGS_LOADER);
|
||||||
|
dbSettingsSqlite = new SqliteCentralRepoSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -327,28 +365,30 @@ public class CentralRepoDbManager {
|
|||||||
saveNewCentralRepo();
|
saveNewCentralRepo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns if changes to the central repository configuration were
|
||||||
|
* successfully applied.
|
||||||
|
*
|
||||||
|
* @return Returns true if the database configuration was successfully changed false
|
||||||
|
* if it was not.
|
||||||
|
*/
|
||||||
|
public boolean wasConfigurationChanged() {
|
||||||
|
return configurationChanged;
|
||||||
|
}
|
||||||
|
|
||||||
private CentralRepoDbConnectivityManager getSelectedSettings() throws CentralRepoException {
|
private CentralRepoDbConnectivityManager getSelectedSettings() throws CentralRepoException {
|
||||||
return getSettings(getSelectedDbChoice());
|
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER)
|
||||||
}
|
|
||||||
|
|
||||||
private CentralRepoDbConnectivityManager getSavedSettings() throws CentralRepoException {
|
|
||||||
return getSettings(getSavedDbChoice());
|
|
||||||
}
|
|
||||||
|
|
||||||
private CentralRepoDbConnectivityManager getSettings(CentralRepoDbChoice dbChoice) throws CentralRepoException {
|
|
||||||
if (dbChoice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER)
|
|
||||||
return dbSettingsMultiUser;
|
return dbSettingsMultiUser;
|
||||||
if (dbChoice == CentralRepoDbChoice.POSTGRESQL_CUSTOM)
|
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_CUSTOM)
|
||||||
return dbSettingsPostgres;
|
return dbSettingsPostgres;
|
||||||
if (dbChoice == CentralRepoDbChoice.SQLITE)
|
if (selectedDbChoice == CentralRepoDbChoice.SQLITE)
|
||||||
return dbSettingsSqlite;
|
return dbSettingsSqlite;
|
||||||
if (dbChoice == CentralRepoDbChoice.DISABLED)
|
if (selectedDbChoice == CentralRepoDbChoice.DISABLED)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
throw new CentralRepoException("Unknown database type: " + dbChoice);
|
throw new CentralRepoException("Unknown database type: " + selectedDbChoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private RdbmsCentralRepoFactory getDbFactory() throws CentralRepoException {
|
private RdbmsCentralRepoFactory getDbFactory() throws CentralRepoException {
|
||||||
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER)
|
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER)
|
||||||
return new RdbmsCentralRepoFactory(CentralRepoPlatforms.POSTGRESQL, dbSettingsMultiUser);
|
return new RdbmsCentralRepoFactory(CentralRepoPlatforms.POSTGRESQL, dbSettingsMultiUser);
|
||||||
@ -405,7 +445,7 @@ public class CentralRepoDbManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method saves a new central repository based on current selected settings.
|
* This method saves a new central repository based on current settings.
|
||||||
*/
|
*/
|
||||||
@NbBundle.Messages({"CentralRepoDbManager.connectionErrorMsg.text=Failed to connect to central repository database."})
|
@NbBundle.Messages({"CentralRepoDbManager.connectionErrorMsg.text=Failed to connect to central repository database."})
|
||||||
public void saveNewCentralRepo() throws CentralRepoException {
|
public void saveNewCentralRepo() throws CentralRepoException {
|
||||||
@ -444,6 +484,7 @@ public class CentralRepoDbManager {
|
|||||||
try {
|
try {
|
||||||
logger.info("Saving central repo settings for db: " + selectedDbSettings);
|
logger.info("Saving central repo settings for db: " + selectedDbSettings);
|
||||||
CentralRepository.getInstance().updateSettings();
|
CentralRepository.getInstance().updateSettings();
|
||||||
|
configurationChanged = true;
|
||||||
} catch (CentralRepoException ex) {
|
} catch (CentralRepoException ex) {
|
||||||
logger.log(Level.SEVERE, Bundle.CentralRepoDbManager_connectionErrorMsg_text(), ex); //NON-NLS
|
logger.log(Level.SEVERE, Bundle.CentralRepoDbManager_connectionErrorMsg_text(), ex); //NON-NLS
|
||||||
return;
|
return;
|
||||||
@ -476,14 +517,6 @@ public class CentralRepoDbManager {
|
|||||||
testingStatus = DatabaseTestResult.UNTESTED;
|
testingStatus = DatabaseTestResult.UNTESTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets selected db choice to currently saved choice.
|
|
||||||
*/
|
|
||||||
public void resetSelectedDbChoice() {
|
|
||||||
setSelctedDbChoice(getSavedDbChoice());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method sets the currently selected database choice and sets the testing status to untested.
|
* This method sets the currently selected database choice and sets the testing status to untested.
|
||||||
* @param newSelected The new database choice.
|
* @param newSelected The new database choice.
|
||||||
@ -522,37 +555,18 @@ public class CentralRepoDbManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method tests the current selected (not necessarily saved) database settings to see if a valid connection can be made.
|
* This method tests the current database settings to see if a valid connection can be made.
|
||||||
* @return The result of testing the connection.
|
* @return The result of testing the connection.
|
||||||
*/
|
*/
|
||||||
public DatabaseTestResult testStatus() {
|
public DatabaseTestResult testStatus() {
|
||||||
CentralRepoDbConnectivityManager manager = null;
|
|
||||||
try {
|
try {
|
||||||
manager = getSelectedSettings();
|
CentralRepoDbConnectivityManager manager = getSelectedSettings();
|
||||||
}
|
|
||||||
catch (CentralRepoException e) {
|
|
||||||
logger.log(Level.WARNING, "unable to test status of db connection in central repo", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return testStatus(manager);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public DatabaseTestResult testSavedStatus() {
|
|
||||||
CentralRepoDbConnectivityManager manager = null;
|
|
||||||
try {
|
|
||||||
manager = getSavedSettings();
|
|
||||||
}
|
|
||||||
catch (CentralRepoException e) {
|
|
||||||
logger.log(Level.WARNING, "unable to test status of db connection in central repo", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return testStatus(manager);
|
|
||||||
}
|
|
||||||
|
|
||||||
private DatabaseTestResult testStatus(CentralRepoDbConnectivityManager manager) {
|
|
||||||
if (manager != null)
|
if (manager != null)
|
||||||
testingStatus = manager.testStatus();
|
testingStatus = manager.testStatus();
|
||||||
|
}
|
||||||
|
catch (CentralRepoException e) {
|
||||||
|
logger.log(Level.WARNING, "unable to test status of db connection in central repo", e);
|
||||||
|
}
|
||||||
|
|
||||||
return testingStatus;
|
return testingStatus;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class CentralRepoDbUpgrader13To14 implements CentralRepoDbUpgrader {
|
|||||||
|
|
||||||
try (Statement statement = connection.createStatement();) {
|
try (Statement statement = connection.createStatement();) {
|
||||||
|
|
||||||
CentralRepoPlatforms selectedPlatform = CentralRepoDbManager.getInstance().getSavedDbChoice().getDbPlatform();
|
CentralRepoPlatforms selectedPlatform = CentralRepoDbManager.getSavedDbChoice().getDbPlatform();
|
||||||
|
|
||||||
// Create account_types and accounts tables which are referred by X_instances tables
|
// Create account_types and accounts tables which are referred by X_instances tables
|
||||||
statement.execute(RdbmsCentralRepoFactory.getCreateAccountTypesTableStatement(selectedPlatform));
|
statement.execute(RdbmsCentralRepoFactory.getCreateAccountTypesTableStatement(selectedPlatform));
|
||||||
|
@ -42,7 +42,7 @@ public interface CentralRepository {
|
|||||||
|
|
||||||
CentralRepoPlatforms selectedPlatform = CentralRepoPlatforms.DISABLED;
|
CentralRepoPlatforms selectedPlatform = CentralRepoPlatforms.DISABLED;
|
||||||
if (CentralRepoDbUtil.allowUseOfCentralRepository()) {
|
if (CentralRepoDbUtil.allowUseOfCentralRepository()) {
|
||||||
selectedPlatform = CentralRepoDbManager.getInstance().getSavedDbChoice().getDbPlatform();
|
selectedPlatform = CentralRepoDbManager.getSavedDbChoice().getDbPlatform();
|
||||||
}
|
}
|
||||||
switch (selectedPlatform) {
|
switch (selectedPlatform) {
|
||||||
case POSTGRESQL:
|
case POSTGRESQL:
|
||||||
@ -93,7 +93,7 @@ public interface CentralRepository {
|
|||||||
*/
|
*/
|
||||||
static boolean isEnabled() {
|
static boolean isEnabled() {
|
||||||
return CentralRepoDbUtil.allowUseOfCentralRepository()
|
return CentralRepoDbUtil.allowUseOfCentralRepository()
|
||||||
&& CentralRepoDbManager.getInstance().getSavedDbChoice() != CentralRepoDbChoice.DISABLED;
|
&& CentralRepoDbManager.getSavedDbChoice() != CentralRepoDbChoice.DISABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,7 +69,7 @@ public class CentralRepositoryService implements AutopsyService {
|
|||||||
*/
|
*/
|
||||||
private void updateSchema() throws AutopsyServiceException {
|
private void updateSchema() throws AutopsyServiceException {
|
||||||
try {
|
try {
|
||||||
CentralRepoDbManager.getInstance().upgradeDatabase();
|
CentralRepoDbManager.upgradeDatabase();
|
||||||
} catch (CentralRepoException ex) {
|
} catch (CentralRepoException ex) {
|
||||||
throw new AutopsyServiceException("Failed to update the Central Repository schema", ex);
|
throw new AutopsyServiceException("Failed to update the Central Repository schema", ex);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public final class PostgresCentralRepoSettings implements CentralRepoDbConnectiv
|
|||||||
private PostgresConnectionSettings connSettings;
|
private PostgresConnectionSettings connSettings;
|
||||||
|
|
||||||
private static PostgresSettingsLoader getLoaderFromSaved() throws CentralRepoException {
|
private static PostgresSettingsLoader getLoaderFromSaved() throws CentralRepoException {
|
||||||
CentralRepoDbChoice choice = CentralRepoDbManager.getInstance().getSavedDbChoice();
|
CentralRepoDbChoice choice = CentralRepoDbManager.getSavedDbChoice();
|
||||||
if (choice == CentralRepoDbChoice.POSTGRESQL_CUSTOM)
|
if (choice == CentralRepoDbChoice.POSTGRESQL_CUSTOM)
|
||||||
return PostgresSettingsLoader.CUSTOM_SETTINGS_LOADER;
|
return PostgresSettingsLoader.CUSTOM_SETTINGS_LOADER;
|
||||||
else if (choice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER)
|
else if (choice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER)
|
||||||
|
@ -3528,7 +3528,7 @@ abstract class RdbmsCentralRepo implements CentralRepository {
|
|||||||
conn = connect(false);
|
conn = connect(false);
|
||||||
conn.setAutoCommit(false);
|
conn.setAutoCommit(false);
|
||||||
statement = conn.createStatement();
|
statement = conn.createStatement();
|
||||||
selectedPlatform = CentralRepoDbManager.getInstance().getSavedDbChoice().getDbPlatform();
|
selectedPlatform = CentralRepoDbManager.getSavedDbChoice().getDbPlatform();
|
||||||
int minorVersion = 0;
|
int minorVersion = 0;
|
||||||
String minorVersionStr = null;
|
String minorVersionStr = null;
|
||||||
resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name='" + RdbmsCentralRepo.SCHEMA_MINOR_VERSION_KEY + "'");
|
resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name='" + RdbmsCentralRepo.SCHEMA_MINOR_VERSION_KEY + "'");
|
||||||
|
@ -181,7 +181,8 @@ public class Installer extends ModuleInstall {
|
|||||||
* repository.
|
* repository.
|
||||||
*/
|
*/
|
||||||
private void setupDefaultSqliteCentralRepo() throws CentralRepoException {
|
private void setupDefaultSqliteCentralRepo() throws CentralRepoException {
|
||||||
CentralRepoDbManager.getInstance().setupDefaultSqliteDb();
|
CentralRepoDbManager manager = new CentralRepoDbManager();
|
||||||
|
manager.setupDefaultSqliteDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -275,7 +275,7 @@ final class CentralRepoIngestModule implements FileIngestModule {
|
|||||||
|
|
||||||
// Don't allow sqlite central repo databases to be used for multi user cases
|
// Don't allow sqlite central repo databases to be used for multi user cases
|
||||||
if ((autopsyCase.getCaseType() == Case.CaseType.MULTI_USER_CASE)
|
if ((autopsyCase.getCaseType() == Case.CaseType.MULTI_USER_CASE)
|
||||||
&& (CentralRepoDbManager.getInstance().getSavedDbChoice().getDbPlatform() == CentralRepoPlatforms.SQLITE)) {
|
&& (CentralRepoDbManager.getSavedDbChoice().getDbPlatform() == CentralRepoPlatforms.SQLITE)) {
|
||||||
logger.log(Level.SEVERE, "Cannot run correlation engine on a multi-user case with a SQLite central repository.");
|
logger.log(Level.SEVERE, "Cannot run correlation engine on a multi-user case with a SQLite central repository.");
|
||||||
throw new IngestModuleException("Cannot run on a multi-user case with a SQLite central repository."); // NON-NLS
|
throw new IngestModuleException("Cannot run on a multi-user case with a SQLite central repository."); // NON-NLS
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ public class EamDbSettingsDialog extends JDialog {
|
|||||||
|
|
||||||
private final Collection<JTextField> textBoxes;
|
private final Collection<JTextField> textBoxes;
|
||||||
private final TextBoxChangedListener textBoxChangedListener;
|
private final TextBoxChangedListener textBoxChangedListener;
|
||||||
private final CentralRepoDbManager manager = CentralRepoDbManager.getInstance();
|
private final CentralRepoDbManager manager = new CentralRepoDbManager();
|
||||||
private final DbChoiceRenderer DB_CHOICE_RENDERER = new DbChoiceRenderer();
|
private final DbChoiceRenderer DB_CHOICE_RENDERER = new DbChoiceRenderer();
|
||||||
|
|
||||||
public EamDbSettingsDialog() {
|
public EamDbSettingsDialog() {
|
||||||
@ -587,8 +587,19 @@ public class EamDbSettingsDialog extends JDialog {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns if changes to the central repository configuration were
|
||||||
|
* successfully applied.
|
||||||
|
*
|
||||||
|
* @return True if the database configuration was successfully changed; false
|
||||||
|
* if it was not.
|
||||||
|
*/
|
||||||
|
public boolean wasConfigurationChanged() {
|
||||||
|
return manager.wasConfigurationChanged();
|
||||||
|
}
|
||||||
|
|
||||||
private void bnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnCancelActionPerformed
|
private void bnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnCancelActionPerformed
|
||||||
manager.resetSelectedDbChoice();
|
|
||||||
dispose();
|
dispose();
|
||||||
}//GEN-LAST:event_bnCancelActionPerformed
|
}//GEN-LAST:event_bnCancelActionPerformed
|
||||||
|
|
||||||
|
@ -253,6 +253,12 @@
|
|||||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||||
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="GlobalSettingsPanel.testStatusLabel.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="GlobalSettingsPanel.testStatusLabel.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||||
</Property>
|
</Property>
|
||||||
|
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||||
|
<Dimension value="[387, 40]"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||||
|
<Dimension value="[387, 16]"/>
|
||||||
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
|
@ -61,7 +61,6 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
private static final Set<IngestManager.IngestJobEvent> INGEST_JOB_EVENTS_OF_INTEREST = EnumSet.of(IngestManager.IngestJobEvent.STARTED, IngestManager.IngestJobEvent.CANCELLED, IngestManager.IngestJobEvent.COMPLETED);
|
private static final Set<IngestManager.IngestJobEvent> INGEST_JOB_EVENTS_OF_INTEREST = EnumSet.of(IngestManager.IngestJobEvent.STARTED, IngestManager.IngestJobEvent.CANCELLED, IngestManager.IngestJobEvent.COMPLETED);
|
||||||
|
|
||||||
private final IngestJobEventPropertyChangeListener ingestJobEventListener;
|
private final IngestJobEventPropertyChangeListener ingestJobEventListener;
|
||||||
private final CentralRepoDbManager manager;
|
|
||||||
|
|
||||||
private final ImageIcon goodIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/good.png", false));
|
private final ImageIcon goodIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/good.png", false));
|
||||||
private final ImageIcon badIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/bad.png", false));
|
private final ImageIcon badIcon = new ImageIcon(ImageUtilities.loadImage("org/sleuthkit/autopsy/images/bad.png", false));
|
||||||
@ -71,10 +70,9 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
*/
|
*/
|
||||||
public GlobalSettingsPanel() {
|
public GlobalSettingsPanel() {
|
||||||
ingestJobEventListener = new IngestJobEventPropertyChangeListener();
|
ingestJobEventListener = new IngestJobEventPropertyChangeListener();
|
||||||
manager = CentralRepoDbManager.getInstance();
|
|
||||||
|
|
||||||
// listen for change events in currently saved choice
|
// listen for change events in currently saved choice
|
||||||
manager.addPropertyChangeListener((PropertyChangeEvent evt) -> {
|
CentralRepoDbManager.addPropertyChangeListener((PropertyChangeEvent evt) -> {
|
||||||
//ingestStateUpdated(Case.isCaseOpen());
|
//ingestStateUpdated(Case.isCaseOpen());
|
||||||
|
|
||||||
load(); // reload db settings content and update buttons
|
load(); // reload db settings content and update buttons
|
||||||
@ -111,10 +109,11 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
*
|
*
|
||||||
* @return True if there was a change.
|
* @return True if there was a change.
|
||||||
*/
|
*/
|
||||||
private static void invokeCrChoice(Component parent, CentralRepoDbChoice initialSelection) {
|
private static boolean invokeCrChoice(Component parent, CentralRepoDbChoice initialSelection) {
|
||||||
EamDbSettingsDialog dialog = (initialSelection != null)
|
EamDbSettingsDialog dialog = (initialSelection != null)
|
||||||
? new EamDbSettingsDialog(initialSelection)
|
? new EamDbSettingsDialog(initialSelection)
|
||||||
: new EamDbSettingsDialog();
|
: new EamDbSettingsDialog();
|
||||||
|
return dialog.wasConfigurationChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -136,9 +135,8 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
"GlobalSettingsPanel.onMultiUserChange.enable.description2=The Central Repository stores hash values and accounts from past cases."
|
"GlobalSettingsPanel.onMultiUserChange.enable.description2=The Central Repository stores hash values and accounts from past cases."
|
||||||
})
|
})
|
||||||
public static void onMultiUserChange(Component parent, boolean muPreviouslySelected, boolean muCurrentlySelected) {
|
public static void onMultiUserChange(Component parent, boolean muPreviouslySelected, boolean muCurrentlySelected) {
|
||||||
CentralRepoDbManager manager = CentralRepoDbManager.getInstance();
|
|
||||||
boolean crEnabled = CentralRepoDbUtil.allowUseOfCentralRepository();
|
boolean crEnabled = CentralRepoDbUtil.allowUseOfCentralRepository();
|
||||||
boolean crMultiUser = manager.getSavedDbChoice() == CentralRepoDbChoice.POSTGRESQL_MULTIUSER;
|
boolean crMultiUser = CentralRepoDbManager.getSavedDbChoice() == CentralRepoDbChoice.POSTGRESQL_MULTIUSER;
|
||||||
|
|
||||||
if (!muPreviouslySelected && muCurrentlySelected) {
|
if (!muPreviouslySelected && muCurrentlySelected) {
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
@ -154,8 +152,8 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
|
|
||||||
// setup database for CR
|
// setup database for CR
|
||||||
CentralRepoDbUtil.setUseCentralRepo(true);
|
CentralRepoDbUtil.setUseCentralRepo(true);
|
||||||
manager.saveDbChoice(CentralRepoDbChoice.POSTGRESQL_MULTIUSER);
|
CentralRepoDbManager.saveDbChoice(CentralRepoDbChoice.POSTGRESQL_MULTIUSER);
|
||||||
checkStatusAndCreateDb(manager, parent);
|
checkStatusAndCreateDb(parent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} // moving from selected to not selected && 'PostgreSQL using multi-user settings' is selected
|
} // moving from selected to not selected && 'PostgreSQL using multi-user settings' is selected
|
||||||
@ -166,7 +164,7 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
} // changing multi-user settings connection && 'PostgreSQL using multi-user settings' is selected &&
|
} // changing multi-user settings connection && 'PostgreSQL using multi-user settings' is selected &&
|
||||||
// central repo either enabled or was disabled due to error
|
// central repo either enabled or was disabled due to error
|
||||||
else if (muPreviouslySelected && muCurrentlySelected && crEnabled && crMultiUser) {
|
else if (muPreviouslySelected && muCurrentlySelected && crEnabled && crMultiUser) {
|
||||||
checkStatusAndCreateDb(manager, parent);
|
checkStatusAndCreateDb(parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,9 +174,9 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
* database if cr database is absent.
|
* database if cr database is absent.
|
||||||
* @param parent the parent component to which the dialogs will be associated.
|
* @param parent the parent component to which the dialogs will be associated.
|
||||||
*/
|
*/
|
||||||
private static void checkStatusAndCreateDb(CentralRepoDbManager manager, Component parent) {
|
private static void checkStatusAndCreateDb(Component parent) {
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
EamDbSettingsDialog.testStatusAndCreate(parent, manager);
|
EamDbSettingsDialog.testStatusAndCreate(parent, new CentralRepoDbManager());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,6 +229,7 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
"GlobalSettingsPanel.testCurrentConfiguration.dbDoesNotExist.message=Database does not exist.",
|
"GlobalSettingsPanel.testCurrentConfiguration.dbDoesNotExist.message=Database does not exist.",
|
||||||
})
|
})
|
||||||
private boolean testCurrentConfiguration() {
|
private boolean testCurrentConfiguration() {
|
||||||
|
CentralRepoDbManager manager = new CentralRepoDbManager();
|
||||||
DatabaseTestResult testResult = manager.testStatus();
|
DatabaseTestResult testResult = manager.testStatus();
|
||||||
// if database doesn't exist, prompt user to create database
|
// if database doesn't exist, prompt user to create database
|
||||||
if (testResult == DatabaseTestResult.DB_DOES_NOT_EXIST) {
|
if (testResult == DatabaseTestResult.DB_DOES_NOT_EXIST) {
|
||||||
@ -251,7 +250,7 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean showStatusOkay() {
|
private boolean showStatusOkay() {
|
||||||
return setStatus(goodIcon, null);
|
return setStatus(goodIcon, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showStatusFail(String message) {
|
private boolean showStatusFail(String message) {
|
||||||
@ -351,6 +350,8 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
testStatusLabel.setFont(testStatusLabel.getFont().deriveFont(testStatusLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
|
testStatusLabel.setFont(testStatusLabel.getFont().deriveFont(testStatusLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
|
||||||
org.openide.awt.Mnemonics.setLocalizedText(testStatusLabel, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.testStatusLabel.text")); // NOI18N
|
org.openide.awt.Mnemonics.setLocalizedText(testStatusLabel, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.testStatusLabel.text")); // NOI18N
|
||||||
testStatusLabel.setToolTipText(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.testStatusLabel.toolTipText")); // NOI18N
|
testStatusLabel.setToolTipText(org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.testStatusLabel.toolTipText")); // NOI18N
|
||||||
|
testStatusLabel.setMaximumSize(new java.awt.Dimension(387, 40));
|
||||||
|
testStatusLabel.setPreferredSize(new java.awt.Dimension(387, 16));
|
||||||
|
|
||||||
javax.swing.GroupLayout pnDatabaseConfigurationLayout = new javax.swing.GroupLayout(pnDatabaseConfiguration);
|
javax.swing.GroupLayout pnDatabaseConfigurationLayout = new javax.swing.GroupLayout(pnDatabaseConfiguration);
|
||||||
pnDatabaseConfiguration.setLayout(pnDatabaseConfigurationLayout);
|
pnDatabaseConfiguration.setLayout(pnDatabaseConfigurationLayout);
|
||||||
@ -644,7 +645,7 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
public void load() {
|
public void load() {
|
||||||
tbOops.setText("");
|
tbOops.setText("");
|
||||||
enableButtonSubComponents(false);
|
enableButtonSubComponents(false);
|
||||||
CentralRepoDbChoice selectedChoice = manager.getSavedDbChoice();
|
CentralRepoDbChoice selectedChoice = CentralRepoDbManager.getSavedDbChoice();
|
||||||
cbUseCentralRepo.setSelected(CentralRepoDbUtil.allowUseOfCentralRepository()); // NON-NLS
|
cbUseCentralRepo.setSelected(CentralRepoDbUtil.allowUseOfCentralRepository()); // NON-NLS
|
||||||
|
|
||||||
lbDbPlatformValue.setText(selectedChoice.getTitle());
|
lbDbPlatformValue.setText(selectedChoice.getTitle());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user