mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 07:56:16 +00:00
updates to spacing
This commit is contained in:
parent
cace957153
commit
56f3546bae
@ -39,40 +39,25 @@ public class CentralRepoDbManager {
|
||||
private static final String CENTRAL_REPO_DB_NAME = "central_repository";
|
||||
private static final String CENTRAL_REPOSITORY_SETTINGS_KEY = "CentralRepository";
|
||||
private static final String DB_SELECTED_PLATFORM_KEY = "db.selectedPlatform";
|
||||
private static final String DISABLED_DUE_TO_FAILURE_KEY = "disabledDueToFailure";
|
||||
|
||||
private static volatile CentralRepoDbChoice savedChoice = null;
|
||||
|
||||
private static CentralRepoDbManager instance = null;
|
||||
private static final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(CentralRepoDbManager.class);
|
||||
|
||||
public static CentralRepoDbManager getInstance() {
|
||||
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.
|
||||
@ -80,8 +65,12 @@ public class CentralRepoDbManager {
|
||||
* @param clearDisabledDueToError Whether or not to clear the 'disabledDueToFailure' settings key.
|
||||
* @return The newly saved choice.
|
||||
*/
|
||||
public CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice) {
|
||||
public static CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice, boolean clearDisabledDueToError) {
|
||||
synchronized(dbChoiceLock) {
|
||||
// clear disabling due to a failure
|
||||
if (clearDisabledDueToError)
|
||||
setDisabledDueToFailure(false);
|
||||
|
||||
// change the settings
|
||||
CentralRepoDbChoice newChoice = (choice == null) ? CentralRepoDbChoice.DISABLED : choice;
|
||||
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.
|
||||
* @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 (!UserPreferences.getIsMultiUserModeEnabled())
|
||||
return false;
|
||||
@ -113,7 +102,7 @@ public class CentralRepoDbManager {
|
||||
/**
|
||||
* This method loads the selectedPlatform boolean from the config file if it is set.
|
||||
*/
|
||||
public CentralRepoDbChoice getSavedDbChoice() {
|
||||
public static CentralRepoDbChoice getSavedDbChoice() {
|
||||
synchronized(dbChoiceLock) {
|
||||
if (savedChoice == null) {
|
||||
String selectedPlatformString = ModuleSettings.getConfigSetting(CENTRAL_REPOSITORY_SETTINGS_KEY, DB_SELECTED_PLATFORM_KEY); // NON-NLS
|
||||
@ -124,14 +113,48 @@ 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.
|
||||
* NOTE: currently only listening for changes in currently saved db choice and disabling due to failure.
|
||||
*
|
||||
* @param listener The listener for the event.
|
||||
*/
|
||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||
public static void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||
propertyChangeSupport.addPropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
@ -139,13 +162,13 @@ public class CentralRepoDbManager {
|
||||
* This method removes a propert change listener.
|
||||
* @param listener The listener to remove.
|
||||
*/
|
||||
public void removePropertyChangeListener(PropertyChangeListener listener) {
|
||||
public static void removePropertyChangeListener(PropertyChangeListener listener) {
|
||||
propertyChangeSupport.removePropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private CentralRepoDbChoice fromKey(String keyName) {
|
||||
private static CentralRepoDbChoice fromKey(String keyName) {
|
||||
for (CentralRepoDbChoice dbChoice : CentralRepoDbChoice.values()) {
|
||||
if (dbChoice.getSettingKey().equalsIgnoreCase(keyName)) {
|
||||
return dbChoice;
|
||||
@ -163,7 +186,7 @@ public class CentralRepoDbManager {
|
||||
* @return The CentralRepository object that will be used for connection.
|
||||
* @throws CentralRepoException
|
||||
*/
|
||||
private CentralRepository obtainCentralRepository() throws CentralRepoException {
|
||||
private static CentralRepository obtainCentralRepository() throws CentralRepoException {
|
||||
//get connection
|
||||
try {
|
||||
return CentralRepository.getInstance();
|
||||
@ -184,7 +207,7 @@ public class CentralRepoDbManager {
|
||||
* @return The lock if acquired.
|
||||
* @throws CentralRepoException
|
||||
*/
|
||||
private CoordinationService.Lock obtainCentralRepoLock(CentralRepository db) throws CentralRepoException {
|
||||
private static CoordinationService.Lock obtainCentralRepoLock(CentralRepository db) throws CentralRepoException {
|
||||
try {
|
||||
// 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
|
||||
@ -208,7 +231,7 @@ public class CentralRepoDbManager {
|
||||
* @param lock The acquired lock.
|
||||
* @throws CentralRepoException
|
||||
*/
|
||||
private void updatedDbSchema(CentralRepository db, CoordinationService.Lock lock) throws CentralRepoException {
|
||||
private static void updatedDbSchema(CentralRepository db, CoordinationService.Lock lock) throws CentralRepoException {
|
||||
try {
|
||||
db.upgradeSchema();
|
||||
} catch (CentralRepoException ex) {
|
||||
@ -239,7 +262,7 @@ public class CentralRepoDbManager {
|
||||
* 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."})
|
||||
public void upgradeDatabase() throws CentralRepoException {
|
||||
public static void upgradeDatabase() throws CentralRepoException {
|
||||
if (!CentralRepository.isEnabled()) {
|
||||
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.
|
||||
try {
|
||||
if (null != CentralRepository.getInstance()) {
|
||||
@ -265,7 +288,7 @@ public class CentralRepoDbManager {
|
||||
} catch (CentralRepoException ex2) {
|
||||
logger.log(Level.SEVERE, "Error shutting down central repo connection pool", ex2);
|
||||
}
|
||||
saveDbChoice(CentralRepoDbChoice.DISABLED);
|
||||
saveDbChoice(CentralRepoDbChoice.DISABLED, false);
|
||||
if (innerException == null) {
|
||||
throw new CentralRepoException(message, desc);
|
||||
} 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();
|
||||
}
|
||||
|
||||
private CentralRepoDbConnectivityManager getSelectedSettings() throws CentralRepoException {
|
||||
return getSettings(getSelectedDbChoice());
|
||||
/**
|
||||
* 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 getSavedSettings() throws CentralRepoException {
|
||||
return getSettings(getSavedDbChoice());
|
||||
}
|
||||
|
||||
private CentralRepoDbConnectivityManager getSettings(CentralRepoDbChoice dbChoice) throws CentralRepoException {
|
||||
if (dbChoice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER)
|
||||
private CentralRepoDbConnectivityManager getSelectedSettings() throws CentralRepoException {
|
||||
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER)
|
||||
return dbSettingsMultiUser;
|
||||
if (dbChoice == CentralRepoDbChoice.POSTGRESQL_CUSTOM)
|
||||
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_CUSTOM)
|
||||
return dbSettingsPostgres;
|
||||
if (dbChoice == CentralRepoDbChoice.SQLITE)
|
||||
if (selectedDbChoice == CentralRepoDbChoice.SQLITE)
|
||||
return dbSettingsSqlite;
|
||||
if (dbChoice == CentralRepoDbChoice.DISABLED)
|
||||
if (selectedDbChoice == CentralRepoDbChoice.DISABLED)
|
||||
return null;
|
||||
|
||||
throw new CentralRepoException("Unknown database type: " + dbChoice);
|
||||
throw new CentralRepoException("Unknown database type: " + selectedDbChoice);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private RdbmsCentralRepoFactory getDbFactory() throws CentralRepoException {
|
||||
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER)
|
||||
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."})
|
||||
public void saveNewCentralRepo() throws CentralRepoException {
|
||||
@ -444,6 +484,7 @@ public class CentralRepoDbManager {
|
||||
try {
|
||||
logger.info("Saving central repo settings for db: " + selectedDbSettings);
|
||||
CentralRepository.getInstance().updateSettings();
|
||||
configurationChanged = true;
|
||||
} catch (CentralRepoException ex) {
|
||||
logger.log(Level.SEVERE, Bundle.CentralRepoDbManager_connectionErrorMsg_text(), ex); //NON-NLS
|
||||
return;
|
||||
@ -475,14 +516,6 @@ public class CentralRepoDbManager {
|
||||
public void clearStatus() {
|
||||
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.
|
||||
@ -522,38 +555,19 @@ 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.
|
||||
*/
|
||||
public DatabaseTestResult testStatus() {
|
||||
CentralRepoDbConnectivityManager manager = null;
|
||||
try {
|
||||
manager = getSelectedSettings();
|
||||
CentralRepoDbConnectivityManager manager = getSelectedSettings();
|
||||
if (manager != null)
|
||||
testingStatus = manager.testStatus();
|
||||
}
|
||||
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)
|
||||
testingStatus = manager.testStatus();
|
||||
|
||||
return testingStatus;
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class CentralRepoDbUpgrader13To14 implements CentralRepoDbUpgrader {
|
||||
|
||||
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
|
||||
statement.execute(RdbmsCentralRepoFactory.getCreateAccountTypesTableStatement(selectedPlatform));
|
||||
|
@ -42,7 +42,7 @@ public interface CentralRepository {
|
||||
|
||||
CentralRepoPlatforms selectedPlatform = CentralRepoPlatforms.DISABLED;
|
||||
if (CentralRepoDbUtil.allowUseOfCentralRepository()) {
|
||||
selectedPlatform = CentralRepoDbManager.getInstance().getSavedDbChoice().getDbPlatform();
|
||||
selectedPlatform = CentralRepoDbManager.getSavedDbChoice().getDbPlatform();
|
||||
}
|
||||
switch (selectedPlatform) {
|
||||
case POSTGRESQL:
|
||||
@ -93,7 +93,7 @@ public interface CentralRepository {
|
||||
*/
|
||||
static boolean isEnabled() {
|
||||
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 {
|
||||
try {
|
||||
CentralRepoDbManager.getInstance().upgradeDatabase();
|
||||
CentralRepoDbManager.upgradeDatabase();
|
||||
} catch (CentralRepoException 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 static PostgresSettingsLoader getLoaderFromSaved() throws CentralRepoException {
|
||||
CentralRepoDbChoice choice = CentralRepoDbManager.getInstance().getSavedDbChoice();
|
||||
CentralRepoDbChoice choice = CentralRepoDbManager.getSavedDbChoice();
|
||||
if (choice == CentralRepoDbChoice.POSTGRESQL_CUSTOM)
|
||||
return PostgresSettingsLoader.CUSTOM_SETTINGS_LOADER;
|
||||
else if (choice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER)
|
||||
|
@ -3528,7 +3528,7 @@ abstract class RdbmsCentralRepo implements CentralRepository {
|
||||
conn = connect(false);
|
||||
conn.setAutoCommit(false);
|
||||
statement = conn.createStatement();
|
||||
selectedPlatform = CentralRepoDbManager.getInstance().getSavedDbChoice().getDbPlatform();
|
||||
selectedPlatform = CentralRepoDbManager.getSavedDbChoice().getDbPlatform();
|
||||
int minorVersion = 0;
|
||||
String minorVersionStr = null;
|
||||
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.
|
||||
*/
|
||||
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
|
||||
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.");
|
||||
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 TextBoxChangedListener textBoxChangedListener;
|
||||
private final CentralRepoDbManager manager = CentralRepoDbManager.getInstance();
|
||||
private final CentralRepoDbManager manager = new CentralRepoDbManager();
|
||||
private final DbChoiceRenderer DB_CHOICE_RENDERER = new DbChoiceRenderer();
|
||||
|
||||
public EamDbSettingsDialog() {
|
||||
@ -586,9 +586,20 @@ public class EamDbSettingsDialog extends JDialog {
|
||||
parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
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
|
||||
manager.resetSelectedDbChoice();
|
||||
dispose();
|
||||
}//GEN-LAST:event_bnCancelActionPerformed
|
||||
|
||||
|
@ -253,6 +253,12 @@
|
||||
<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}")"/>
|
||||
</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>
|
||||
</Component>
|
||||
</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 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 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() {
|
||||
ingestJobEventListener = new IngestJobEventPropertyChangeListener();
|
||||
manager = CentralRepoDbManager.getInstance();
|
||||
|
||||
|
||||
// listen for change events in currently saved choice
|
||||
manager.addPropertyChangeListener((PropertyChangeEvent evt) -> {
|
||||
CentralRepoDbManager.addPropertyChangeListener((PropertyChangeEvent evt) -> {
|
||||
//ingestStateUpdated(Case.isCaseOpen());
|
||||
|
||||
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.
|
||||
*/
|
||||
private static void invokeCrChoice(Component parent, CentralRepoDbChoice initialSelection) {
|
||||
private static boolean invokeCrChoice(Component parent, CentralRepoDbChoice initialSelection) {
|
||||
EamDbSettingsDialog dialog = (initialSelection != null)
|
||||
? new EamDbSettingsDialog(initialSelection)
|
||||
: new EamDbSettingsDialog();
|
||||
? new EamDbSettingsDialog(initialSelection)
|
||||
: 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."
|
||||
})
|
||||
public static void onMultiUserChange(Component parent, boolean muPreviouslySelected, boolean muCurrentlySelected) {
|
||||
CentralRepoDbManager manager = CentralRepoDbManager.getInstance();
|
||||
boolean crEnabled = CentralRepoDbUtil.allowUseOfCentralRepository();
|
||||
boolean crMultiUser = manager.getSavedDbChoice() == CentralRepoDbChoice.POSTGRESQL_MULTIUSER;
|
||||
boolean crMultiUser = CentralRepoDbManager.getSavedDbChoice() == CentralRepoDbChoice.POSTGRESQL_MULTIUSER;
|
||||
|
||||
if (!muPreviouslySelected && muCurrentlySelected) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
@ -154,8 +152,8 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
|
||||
// setup database for CR
|
||||
CentralRepoDbUtil.setUseCentralRepo(true);
|
||||
manager.saveDbChoice(CentralRepoDbChoice.POSTGRESQL_MULTIUSER);
|
||||
checkStatusAndCreateDb(manager, parent);
|
||||
CentralRepoDbManager.saveDbChoice(CentralRepoDbChoice.POSTGRESQL_MULTIUSER);
|
||||
checkStatusAndCreateDb(parent);
|
||||
}
|
||||
});
|
||||
} // 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 &&
|
||||
// central repo either enabled or was disabled due to error
|
||||
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.
|
||||
* @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(() -> {
|
||||
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.",
|
||||
})
|
||||
private boolean testCurrentConfiguration() {
|
||||
CentralRepoDbManager manager = new CentralRepoDbManager();
|
||||
DatabaseTestResult testResult = manager.testStatus();
|
||||
// if database doesn't exist, prompt user to create database
|
||||
if (testResult == DatabaseTestResult.DB_DOES_NOT_EXIST) {
|
||||
@ -251,7 +250,7 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
}
|
||||
|
||||
private boolean showStatusOkay() {
|
||||
return setStatus(goodIcon, null);
|
||||
return setStatus(goodIcon, " ");
|
||||
}
|
||||
|
||||
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));
|
||||
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.setMaximumSize(new java.awt.Dimension(387, 40));
|
||||
testStatusLabel.setPreferredSize(new java.awt.Dimension(387, 16));
|
||||
|
||||
javax.swing.GroupLayout pnDatabaseConfigurationLayout = new javax.swing.GroupLayout(pnDatabaseConfiguration);
|
||||
pnDatabaseConfiguration.setLayout(pnDatabaseConfigurationLayout);
|
||||
@ -644,7 +645,7 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
public void load() {
|
||||
tbOops.setText("");
|
||||
enableButtonSubComponents(false);
|
||||
CentralRepoDbChoice selectedChoice = manager.getSavedDbChoice();
|
||||
CentralRepoDbChoice selectedChoice = CentralRepoDbManager.getSavedDbChoice();
|
||||
cbUseCentralRepo.setSelected(CentralRepoDbUtil.allowUseOfCentralRepository()); // NON-NLS
|
||||
|
||||
lbDbPlatformValue.setText(selectedChoice.getTitle());
|
||||
|
Loading…
x
Reference in New Issue
Block a user