6225 second attempt at fixing screenshot 2

This commit is contained in:
William Schaefer 2020-04-13 14:20:53 -04:00
parent 32e536d9a2
commit 26b7094e18
3 changed files with 306 additions and 241 deletions

View File

@ -30,7 +30,8 @@ import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.ModuleSettings;
/** /**
* This class contains business logic for saving and validating settings for central repository. * This class contains business logic for saving and validating settings for
* central repository.
*/ */
public class CentralRepoDbManager { public class CentralRepoDbManager {
@ -48,11 +49,12 @@ public class CentralRepoDbManager {
private static final Object dbChoiceLock = new Object(); private static final Object dbChoiceLock = new Object();
private static final Object disabledDueToFailureLock = new Object(); private static final Object disabledDueToFailureLock = new Object();
/** /**
* This saves the currently selected database choice and clears any disabledDueToFailure flag. * This saves the currently selected database choice and clears any
* disabledDueToFailure flag.
*
* @param choice The choice to save. * @param choice The choice to save.
*
* @return The newly saved choice. * @return The newly saved choice.
*/ */
public static CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice) { public static CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice) {
@ -61,15 +63,19 @@ public class CentralRepoDbManager {
/** /**
* 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 static CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice, boolean clearDisabledDueToError) { public static CentralRepoDbChoice saveDbChoice(CentralRepoDbChoice choice, boolean clearDisabledDueToError) {
synchronized(dbChoiceLock) { synchronized (dbChoiceLock) {
// clear disabling due to a failure // clear disabling due to a failure
if (clearDisabledDueToError) if (clearDisabledDueToError) {
setDisabledDueToFailure(false); setDisabledDueToFailure(false);
}
// change the settings // change the settings
CentralRepoDbChoice newChoice = (choice == null) ? CentralRepoDbChoice.DISABLED : choice; CentralRepoDbChoice newChoice = (choice == null) ? CentralRepoDbChoice.DISABLED : choice;
@ -83,27 +89,29 @@ 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 static 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;
}
// also validate the connection as well // also validate the connection as well
PostgresCentralRepoSettings multiUserSettings = PostgresCentralRepoSettings multiUserSettings
new PostgresCentralRepoSettings(PostgresSettingsLoader.MULTIUSER_SETTINGS_LOADER); = new PostgresCentralRepoSettings(PostgresSettingsLoader.MULTIUSER_SETTINGS_LOADER);
return multiUserSettings.testStatus() == DatabaseTestResult.TESTED_OK; return multiUserSettings.testStatus() == DatabaseTestResult.TESTED_OK;
} }
/** /**
* 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 static 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
savedChoice = fromKey(selectedPlatformString); savedChoice = fromKey(selectedPlatformString);
@ -114,8 +122,10 @@ 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 method disables the central repository and indicates through a flag
* This is used when re-enabling multi-user as a flag to determine whether or not CR should be re-enabled. * 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() { public static void disableDueToFailure() {
CentralRepoDbUtil.setUseCentralRepo(false); CentralRepoDbUtil.setUseCentralRepo(false);
@ -123,13 +133,15 @@ public class CentralRepoDbManager {
} }
/** /**
* This method sets whether or not the repository has been disabled due to a database setup issue; * This method sets whether or not the repository has been disabled due to a
* This is used when re-enabling multi-user as a flag to determine whether or not CR should be re-enabled. * 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. * @param disabledDueToFailure Whether or not the repository has been
* disabled due to a database setup issue.
*/ */
private static void setDisabledDueToFailure(boolean disabledDueToFailure) { private static void setDisabledDueToFailure(boolean disabledDueToFailure) {
synchronized(disabledDueToFailureLock) { synchronized (disabledDueToFailureLock) {
boolean oldValue = isDisabledDueToFailure(); boolean oldValue = isDisabledDueToFailure();
ModuleSettings.setConfigSetting(CENTRAL_REPOSITORY_SETTINGS_KEY, DISABLED_DUE_TO_FAILURE_KEY, Boolean.toString(disabledDueToFailure)); ModuleSettings.setConfigSetting(CENTRAL_REPOSITORY_SETTINGS_KEY, DISABLED_DUE_TO_FAILURE_KEY, Boolean.toString(disabledDueToFailure));
propertyChangeSupport.firePropertyChange("disabledDueToFailure", oldValue, disabledDueToFailure); propertyChangeSupport.firePropertyChange("disabledDueToFailure", oldValue, disabledDueToFailure);
@ -137,20 +149,23 @@ public class CentralRepoDbManager {
} }
/** /**
* This method retrieves setting whether or not the repository has been disabled due to a database setup issue; * This method retrieves setting whether or not the repository has been
* this is used when re-enabling multi-user as a flag to determine whether or not CR should be re-enabled. * 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. * @return Whether or not the repository has been disabled due to a database
* setup issue.
*/ */
public static boolean isDisabledDueToFailure() { public static boolean isDisabledDueToFailure() {
synchronized(disabledDueToFailureLock) { synchronized (disabledDueToFailureLock) {
return Boolean.toString(true).equals(ModuleSettings.getConfigSetting(CENTRAL_REPOSITORY_SETTINGS_KEY, DISABLED_DUE_TO_FAILURE_KEY)); 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. NOTE: currently only
* NOTE: currently only listening for changes in currently saved db choice and disabling due to failure. * listening for changes in currently saved db choice and disabling due to
* failure.
* *
* @param listener The listener for the event. * @param listener The listener for the event.
*/ */
@ -160,14 +175,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 static void removePropertyChangeListener(PropertyChangeListener listener) { public static void removePropertyChangeListener(PropertyChangeListener listener) {
propertyChangeSupport.removePropertyChangeListener(listener); propertyChangeSupport.removePropertyChangeListener(listener);
} }
private static 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)) {
@ -178,12 +192,11 @@ public class CentralRepoDbManager {
return CentralRepoDbChoice.DISABLED; return CentralRepoDbChoice.DISABLED;
} }
/** /**
* This method obtains the database connectivity for central repository. * This method obtains the database connectivity for central repository.
* *
* @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 static CentralRepository obtainCentralRepository() throws CentralRepoException { private static CentralRepository obtainCentralRepository() throws CentralRepoException {
@ -204,7 +217,9 @@ public class CentralRepoDbManager {
* This method obtains a central repository lock. * This method obtains a central repository lock.
* *
* @param db The database connection. * @param db The database connection.
*
* @return The lock if acquired. * @return The lock if acquired.
*
* @throws CentralRepoException * @throws CentralRepoException
*/ */
private static CoordinationService.Lock obtainCentralRepoLock(CentralRepository db) throws CentralRepoException { private static CoordinationService.Lock obtainCentralRepoLock(CentralRepository db) throws CentralRepoException {
@ -229,6 +244,7 @@ public class CentralRepoDbManager {
* *
* @param db The database connectivity object. * @param db The database connectivity object.
* @param lock The acquired lock. * @param lock The acquired lock.
*
* @throws CentralRepoException * @throws CentralRepoException
*/ */
private static void updatedDbSchema(CentralRepository db, CoordinationService.Lock lock) throws CentralRepoException { private static void updatedDbSchema(CentralRepository db, CoordinationService.Lock lock) throws CentralRepoException {
@ -257,9 +273,9 @@ public class CentralRepoDbManager {
} }
/** /**
* This method upgrades the current Central Reposity schema to the newest version. If the * This method upgrades the current Central Reposity schema to the newest
* upgrade fails, the Central Repository will be disabled and the current * version. If the upgrade fails, the Central Repository will be disabled
* settings will be cleared. * and the current 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 static void upgradeDatabase() throws CentralRepoException { public static void upgradeDatabase() throws CentralRepoException {
@ -296,8 +312,6 @@ public class CentralRepoDbManager {
} }
} }
private DatabaseTestResult testingStatus; private DatabaseTestResult testingStatus;
private CentralRepoDbChoice selectedDbChoice; private CentralRepoDbChoice selectedDbChoice;
@ -314,9 +328,9 @@ public class CentralRepoDbManager {
dbSettingsSqlite = new SqliteCentralRepoSettings(); dbSettingsSqlite = new SqliteCentralRepoSettings();
} }
/** /**
* This method retrieves the current multi-user database settings. * This method retrieves the current multi-user database settings.
*
* @return The current multi-user database settings. * @return The current multi-user database settings.
*/ */
public PostgresCentralRepoSettings getDbSettingsMultiUser() { public PostgresCentralRepoSettings getDbSettingsMultiUser() {
@ -325,6 +339,7 @@ public class CentralRepoDbManager {
/** /**
* This method retrieves the current custom postgres database settings. * This method retrieves the current custom postgres database settings.
*
* @return The current custom postgres database settings. * @return The current custom postgres database settings.
*/ */
public PostgresCentralRepoSettings getDbSettingsPostgres() { public PostgresCentralRepoSettings getDbSettingsPostgres() {
@ -332,7 +347,9 @@ public class CentralRepoDbManager {
} }
/** /**
* This method returns the current SQLite database settings for central repository. * This method returns the current SQLite database settings for central
* repository.
*
* @return The current SQLite database settings * @return The current SQLite database settings
*/ */
public SqliteCentralRepoSettings getDbSettingsSqlite() { public SqliteCentralRepoSettings getDbSettingsSqlite() {
@ -341,6 +358,7 @@ public class CentralRepoDbManager {
/** /**
* This method sets up the sqlite database with default settings. * This method sets up the sqlite database with default settings.
*
* @throws CentralRepoException if unable to successfully set up database. * @throws CentralRepoException if unable to successfully set up database.
*/ */
public void setupDefaultSqliteDb() throws CentralRepoException { public void setupDefaultSqliteDb() throws CentralRepoException {
@ -366,51 +384,62 @@ public class CentralRepoDbManager {
} }
/** /**
* This method returns if changes to the central repository configuration were * This method returns if changes to the central repository configuration
* successfully applied. * were successfully applied.
* *
* @return Returns true if the database configuration was successfully changed false * @return Returns true if the database configuration was successfully
* if it was not. * changed false if it was not.
*/ */
public boolean wasConfigurationChanged() { public boolean wasConfigurationChanged() {
return configurationChanged; return configurationChanged;
} }
private CentralRepoDbConnectivityManager getSelectedSettings() throws CentralRepoException { private CentralRepoDbConnectivityManager getSelectedSettings() throws CentralRepoException {
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER) if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER) {
return dbSettingsMultiUser; return dbSettingsMultiUser;
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_CUSTOM) }
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_CUSTOM) {
return dbSettingsPostgres; return dbSettingsPostgres;
if (selectedDbChoice == CentralRepoDbChoice.SQLITE) }
if (selectedDbChoice == CentralRepoDbChoice.SQLITE) {
return dbSettingsSqlite; return dbSettingsSqlite;
if (selectedDbChoice == CentralRepoDbChoice.DISABLED) }
if (selectedDbChoice == CentralRepoDbChoice.DISABLED) {
return null; return null;
}
throw new CentralRepoException("Unknown database type: " + selectedDbChoice); 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);
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_CUSTOM) }
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_CUSTOM) {
return new RdbmsCentralRepoFactory(CentralRepoPlatforms.POSTGRESQL, dbSettingsPostgres); return new RdbmsCentralRepoFactory(CentralRepoPlatforms.POSTGRESQL, dbSettingsPostgres);
if (selectedDbChoice == CentralRepoDbChoice.SQLITE) }
if (selectedDbChoice == CentralRepoDbChoice.SQLITE) {
return new RdbmsCentralRepoFactory(CentralRepoPlatforms.SQLITE, dbSettingsSqlite); return new RdbmsCentralRepoFactory(CentralRepoPlatforms.SQLITE, dbSettingsSqlite);
if (selectedDbChoice == CentralRepoDbChoice.DISABLED) }
if (selectedDbChoice == CentralRepoDbChoice.DISABLED) {
return null; return null;
}
throw new CentralRepoException("Unknown database type: " + selectedDbChoice); throw new CentralRepoException("Unknown database type: " + selectedDbChoice);
} }
/** /**
* This method creates a central repo database if it does not already exist. * This method creates a central repo database if it does not already exist.
*
* @return True if successful; false if unsuccessful. * @return True if successful; false if unsuccessful.
*
* @throws CentralRepoException * @throws CentralRepoException
*/ */
public boolean createDb() throws CentralRepoException { public boolean createDb() throws CentralRepoException {
CentralRepoDbConnectivityManager selectedDbSettings = getSelectedSettings(); CentralRepoDbConnectivityManager selectedDbSettings = getSelectedSettings();
if (selectedDbSettings == null) if (selectedDbSettings == null) {
throw new CentralRepoException("Unable to derive connectivity manager from settings: " + selectedDbChoice); throw new CentralRepoException("Unable to derive connectivity manager from settings: " + selectedDbChoice);
}
boolean result = false; boolean result = false;
boolean dbCreated = true; boolean dbCreated = true;
@ -493,8 +522,9 @@ public class CentralRepoDbManager {
} }
/** /**
* This method retrieves the current status. * This method retrieves the current status. Note: this could be a dirty
* Note: this could be a dirty value if testing of the connection has not been performed. * value if testing of the connection has not been performed.
*
* @return The current status of the database connection. * @return The current status of the database connection.
*/ */
public DatabaseTestResult getStatus() { public DatabaseTestResult getStatus() {
@ -502,8 +532,9 @@ public class CentralRepoDbManager {
} }
/** /**
* This method retrieves the currently selected database choice. * This method retrieves the currently selected database choice. NOTE: This
* NOTE: This choice may not align with the saved setting. * choice may not align with the saved setting.
*
* @return The currently selected database choice. * @return The currently selected database choice.
*/ */
public CentralRepoDbChoice getSelectedDbChoice() { public CentralRepoDbChoice getSelectedDbChoice() {
@ -518,7 +549,9 @@ public class CentralRepoDbManager {
} }
/** /**
* 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.
*/ */
public void setSelctedDbChoice(CentralRepoDbChoice newSelected) { public void setSelctedDbChoice(CentralRepoDbChoice newSelected) {
@ -527,8 +560,8 @@ public class CentralRepoDbManager {
} }
/** /**
* This method tests whether or not the settings have been filled in for the UI. * This method tests whether or not the settings have been filled in for the
* NOTE: This does not check the connectivity status of these settings. * UI. NOTE: This does not check the connectivity status of these settings.
* *
* @return True if database settings are valid. * @return True if database settings are valid.
*/ */
@ -541,13 +574,11 @@ public class CentralRepoDbManager {
dbSettingsPostgres.setDbName(CENTRAL_REPO_DB_NAME); dbSettingsPostgres.setDbName(CENTRAL_REPO_DB_NAME);
dbSettingsPostgres.setUserName(tbDbUsername); dbSettingsPostgres.setUserName(tbDbUsername);
dbSettingsPostgres.setPassword(jpDbPassword); dbSettingsPostgres.setPassword(jpDbPassword);
} } else if (selectedDbChoice == CentralRepoDbChoice.SQLITE) {
else if (selectedDbChoice == CentralRepoDbChoice.SQLITE) {
File databasePath = new File(tfDatabasePath); File databasePath = new File(tfDatabasePath);
dbSettingsSqlite.setDbName(SqliteCentralRepoSettings.DEFAULT_DBNAME); dbSettingsSqlite.setDbName(SqliteCentralRepoSettings.DEFAULT_DBNAME);
dbSettingsSqlite.setDbDirectory(databasePath.getPath()); dbSettingsSqlite.setDbDirectory(databasePath.getPath());
} } else if (selectedDbChoice != CentralRepoDbChoice.POSTGRESQL_MULTIUSER) {
else if (selectedDbChoice != CentralRepoDbChoice.POSTGRESQL_MULTIUSER) {
throw new IllegalStateException("Central Repo has an unknown selected platform: " + selectedDbChoice); throw new IllegalStateException("Central Repo has an unknown selected platform: " + selectedDbChoice);
} }
@ -555,16 +586,18 @@ public class CentralRepoDbManager {
} }
/** /**
* This method tests the current 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() {
try { try {
CentralRepoDbConnectivityManager manager = getSelectedSettings(); CentralRepoDbConnectivityManager manager = getSelectedSettings();
if (manager != null) if (manager != null) {
testingStatus = manager.testStatus(); testingStatus = manager.testStatus();
} }
catch (CentralRepoException e) { } catch (CentralRepoException e) {
logger.log(Level.WARNING, "unable to test status of db connection in central repo", e); logger.log(Level.WARNING, "unable to test status of db connection in central repo", e);
} }

View File

@ -38,7 +38,7 @@
<EmptySpace min="-2" pref="11" max="-2" attributes="0"/> <EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
<Component id="bnCancel" linkSize="2" min="-2" max="-2" attributes="0"/> <Component id="bnCancel" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Component id="pnSQLiteSettings" alignment="0" max="32767" attributes="0"/> <Component id="pnSQLiteSettings" alignment="0" pref="648" max="32767" attributes="0"/>
</Group> </Group>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
</Group> </Group>
@ -94,8 +94,11 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbDatabasePath.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbDatabasePath.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[191, 16]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/> <Dimension value="[100, 14]"/>
</Property> </Property>
</Properties> </Properties>
<Constraints> <Constraints>
@ -109,8 +112,11 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbHostName.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbHostName.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[195, 16]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/> <Dimension value="[110, 14]"/>
</Property> </Property>
</Properties> </Properties>
<Constraints> <Constraints>
@ -127,7 +133,7 @@
</Properties> </Properties>
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="3" gridWidth="1" gridHeight="2" fill="0" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/> <GridBagConstraints gridX="2" gridY="3" gridWidth="1" gridHeight="2" fill="2" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint> </Constraint>
</Constraints> </Constraints>
</Component> </Component>
@ -136,8 +142,11 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbPort.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbPort.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[132, 16]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/> <Dimension value="[90, 14]"/>
</Property> </Property>
</Properties> </Properties>
<Constraints> <Constraints>
@ -154,7 +163,7 @@
</Properties> </Properties>
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="5" gridWidth="1" gridHeight="2" fill="0" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/> <GridBagConstraints gridX="2" gridY="5" gridWidth="1" gridHeight="2" fill="2" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint> </Constraint>
</Constraints> </Constraints>
</Component> </Component>
@ -163,8 +172,11 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbUserName.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbUserName.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[172, 16]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/> <Dimension value="[100, 14]"/>
</Property> </Property>
</Properties> </Properties>
<Constraints> <Constraints>
@ -181,7 +193,7 @@
</Properties> </Properties>
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="7" gridWidth="1" gridHeight="2" fill="0" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/> <GridBagConstraints gridX="2" gridY="7" gridWidth="1" gridHeight="2" fill="2" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint> </Constraint>
</Constraints> </Constraints>
</Component> </Component>
@ -190,8 +202,11 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbUserPassword.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbUserPassword.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[194, 16]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/> <Dimension value="[110, 14]"/>
</Property> </Property>
</Properties> </Properties>
<Constraints> <Constraints>
@ -208,7 +223,7 @@
</Properties> </Properties>
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="9" gridWidth="1" gridHeight="2" fill="0" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/> <GridBagConstraints gridX="2" gridY="9" gridWidth="1" gridHeight="2" fill="2" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint> </Constraint>
</Constraints> </Constraints>
</Component> </Component>
@ -218,13 +233,13 @@
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbDatabaseType.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbDatabaseType.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/> <Dimension value="[180, 14]"/>
</Property> </Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/> <Dimension value="[80, 14]"/>
</Property> </Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/> <Dimension value="[100, 14]"/>
</Property> </Property>
</Properties> </Properties>
<Constraints> <Constraints>
@ -238,8 +253,11 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbDatabaseDesc.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/centralrepository/optionspanel/Bundle.properties" key="EamDbSettingsDialog.lbDatabaseDesc.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[182, 16]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 14]"/> <Dimension value="[100, 14]"/>
</Property> </Property>
</Properties> </Properties>
<Constraints> <Constraints>
@ -296,7 +314,7 @@
<Container class="javax.swing.JPanel" name="pathPanel"> <Container class="javax.swing.JPanel" name="pathPanel">
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="1" gridWidth="1" gridHeight="2" fill="0" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/> <GridBagConstraints gridX="2" gridY="1" gridWidth="1" gridHeight="2" fill="2" ipadX="0" ipadY="0" insetsTop="7" insetsLeft="10" insetsBottom="0" insetsRight="6" anchor="18" weightX="0.0" weightY="0.0"/>
</Constraint> </Constraint>
</Constraints> </Constraints>
@ -304,11 +322,11 @@
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/> <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="tfDatabasePath" min="-2" max="-2" attributes="0"/> <Component id="tfDatabasePath" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="bnDatabasePathFileOpen" min="-2" max="-2" attributes="0"/> <Component id="bnDatabasePathFileOpen" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/> <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -362,10 +380,10 @@
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/> <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="cbDatabaseType" min="-2" pref="210" max="-2" attributes="0"/> <Component id="cbDatabaseType" pref="210" max="32767" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/> <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="lbSingleUserSqLite" pref="318" max="32767" attributes="0"/> <Component id="lbSingleUserSqLite" pref="303" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/> <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>

View File

@ -41,7 +41,6 @@ import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileFilter;
import org.netbeans.spi.options.OptionsPanelController;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.openide.windows.WindowManager; import org.openide.windows.WindowManager;
@ -65,9 +64,11 @@ public class EamDbSettingsDialog extends JDialog {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* This class handles displaying and rendering drop down menu for database choices in central repo. * This class handles displaying and rendering drop down menu for database
* choices in central repo.
*/ */
private class DbChoiceRenderer extends JLabel implements ListCellRenderer<CentralRepoDbChoice>, Serializable { private class DbChoiceRenderer extends JLabel implements ListCellRenderer<CentralRepoDbChoice>, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Override @Override
@ -83,7 +84,6 @@ 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 = new CentralRepoDbManager(); private final CentralRepoDbManager manager = new CentralRepoDbManager();
@ -94,10 +94,9 @@ public class EamDbSettingsDialog extends JDialog {
} }
private boolean isDbChoiceSelectable(CentralRepoDbChoice item) { private boolean isDbChoiceSelectable(CentralRepoDbChoice item) {
return (item != CentralRepoDbChoice.POSTGRESQL_MULTIUSER || manager.isPostgresMultiuserAllowed()); return (item != CentralRepoDbChoice.POSTGRESQL_MULTIUSER || CentralRepoDbManager.isPostgresMultiuserAllowed());
} }
/** /**
* Creates new form EamDbSettingsDialog * Creates new form EamDbSettingsDialog
*/ */
@ -137,26 +136,28 @@ public class EamDbSettingsDialog extends JDialog {
display(); display();
} }
private void setupDbChoice(CentralRepoDbChoice initialMenuItem) { private void setupDbChoice(CentralRepoDbChoice initialMenuItem) {
// setup initially selected item // setup initially selected item
CentralRepoDbChoice toSelect = (initialMenuItem == null) ? CentralRepoDbChoice toSelect = (initialMenuItem == null)
(Arrays.asList(CentralRepoDbChoice.DB_CHOICES).contains(manager.getSelectedDbChoice())) ? ? (Arrays.asList(CentralRepoDbChoice.DB_CHOICES).contains(manager.getSelectedDbChoice()))
manager.getSelectedDbChoice() : ? manager.getSelectedDbChoice()
CentralRepoDbChoice.DB_CHOICES[0] : : CentralRepoDbChoice.DB_CHOICES[0]
initialMenuItem; : initialMenuItem;
cbDatabaseType.setRenderer(DB_CHOICE_RENDERER); cbDatabaseType.setRenderer(DB_CHOICE_RENDERER);
changeDbSelection(toSelect); changeDbSelection(toSelect);
} }
/** /**
* This method prompts user based on testing status (i.e. failure to connect, invalid schema, db does not exist, etc.). * This method prompts user based on testing status (i.e. failure to
* connect, invalid schema, db does not exist, etc.).
*
* @param manager The manager to use when setting up the database. * @param manager The manager to use when setting up the database.
* @param dialog If non-null value, validates settings and updates 'okay' button enabled state. * @param dialog If non-null value, validates settings and updates 'okay'
* @return Whether or not the ultimate status after prompts is okay to continue. * button enabled state.
*
* @return Whether or not the ultimate status after prompts is okay to
* continue.
*/ */
@NbBundle.Messages({"EamDbSettingsDialog.okButton.corruptDatabaseExists.title=Error Loading Central Repository Database", @NbBundle.Messages({"EamDbSettingsDialog.okButton.corruptDatabaseExists.title=Error Loading Central Repository Database",
"EamDbSettingsDialog.okButton.corruptDatabaseExists.message=Central Repository Database exists but is not the right format. Manually delete it or choose a different path (if applicable).", "EamDbSettingsDialog.okButton.corruptDatabaseExists.message=Central Repository Database exists but is not the right format. Manually delete it or choose a different path (if applicable).",
@ -186,10 +187,10 @@ public class EamDbSettingsDialog extends JDialog {
return (manager.getStatus() == DatabaseTestResult.TESTED_OK); return (manager.getStatus() == DatabaseTestResult.TESTED_OK);
} }
/** /**
* This method prompts the user whether or not they would like to create a database in the instance that * This method prompts the user whether or not they would like to create a
* it doesn't exist. * database in the instance that it doesn't exist.
*
* @param manager The manager to use when setting up the database. * @param manager The manager to use when setting up the database.
* @param dialog If non-null value, validates settings and updates 'okay' * @param dialog If non-null value, validates settings and updates 'okay'
* button enabled state. * button enabled state.
@ -219,10 +220,12 @@ public class EamDbSettingsDialog extends JDialog {
return manager.testStatus() == DatabaseTestResult.TESTED_OK; return manager.testStatus() == DatabaseTestResult.TESTED_OK;
} }
/** /**
* When an error occurs while going through promptTestStatusWarning, this method is called. * When an error occurs while going through promptTestStatusWarning, this
* method is called.
*
* @param manager1 The manager to use as service class. * @param manager1 The manager to use as service class.
*
* @throws HeadlessException * @throws HeadlessException
*/ */
private static void onPromptStatusError(CentralRepoDbManager manager1) { private static void onPromptStatusError(CentralRepoDbManager manager1) {
@ -241,7 +244,6 @@ public class EamDbSettingsDialog extends JDialog {
JOptionPane.WARNING_MESSAGE); JOptionPane.WARNING_MESSAGE);
} }
/** /**
* This method is called from within the constructor to initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always * WARNING: Do NOT modify this code. The content of this method is always
@ -296,7 +298,8 @@ public class EamDbSettingsDialog extends JDialog {
pnSQLiteSettings.setLayout(new java.awt.GridBagLayout()); pnSQLiteSettings.setLayout(new java.awt.GridBagLayout());
org.openide.awt.Mnemonics.setLocalizedText(lbDatabasePath, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbDatabasePath.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(lbDatabasePath, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbDatabasePath.text")); // NOI18N
lbDatabasePath.setPreferredSize(new java.awt.Dimension(80, 14)); lbDatabasePath.setMaximumSize(new java.awt.Dimension(191, 16));
lbDatabasePath.setPreferredSize(new java.awt.Dimension(100, 14));
gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0; gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1; gridBagConstraints.gridy = 1;
@ -307,7 +310,8 @@ public class EamDbSettingsDialog extends JDialog {
pnSQLiteSettings.add(lbDatabasePath, gridBagConstraints); pnSQLiteSettings.add(lbDatabasePath, gridBagConstraints);
org.openide.awt.Mnemonics.setLocalizedText(lbHostName, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbHostName.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(lbHostName, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbHostName.text")); // NOI18N
lbHostName.setPreferredSize(new java.awt.Dimension(80, 14)); lbHostName.setMaximumSize(new java.awt.Dimension(195, 16));
lbHostName.setPreferredSize(new java.awt.Dimension(110, 14));
gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0; gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3; gridBagConstraints.gridy = 3;
@ -322,12 +326,14 @@ public class EamDbSettingsDialog extends JDialog {
gridBagConstraints.gridx = 2; gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 3; gridBagConstraints.gridy = 3;
gridBagConstraints.gridheight = 2; gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 6); gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 6);
pnSQLiteSettings.add(tbDbHostname, gridBagConstraints); pnSQLiteSettings.add(tbDbHostname, gridBagConstraints);
org.openide.awt.Mnemonics.setLocalizedText(lbPort, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbPort.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(lbPort, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbPort.text")); // NOI18N
lbPort.setPreferredSize(new java.awt.Dimension(80, 14)); lbPort.setMaximumSize(new java.awt.Dimension(132, 16));
lbPort.setPreferredSize(new java.awt.Dimension(90, 14));
gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0; gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 5; gridBagConstraints.gridy = 5;
@ -342,12 +348,14 @@ public class EamDbSettingsDialog extends JDialog {
gridBagConstraints.gridx = 2; gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 5; gridBagConstraints.gridy = 5;
gridBagConstraints.gridheight = 2; gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 6); gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 6);
pnSQLiteSettings.add(tbDbPort, gridBagConstraints); pnSQLiteSettings.add(tbDbPort, gridBagConstraints);
org.openide.awt.Mnemonics.setLocalizedText(lbUserName, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbUserName.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(lbUserName, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbUserName.text")); // NOI18N
lbUserName.setPreferredSize(new java.awt.Dimension(80, 14)); lbUserName.setMaximumSize(new java.awt.Dimension(172, 16));
lbUserName.setPreferredSize(new java.awt.Dimension(100, 14));
gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0; gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 7; gridBagConstraints.gridy = 7;
@ -362,12 +370,14 @@ public class EamDbSettingsDialog extends JDialog {
gridBagConstraints.gridx = 2; gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 7; gridBagConstraints.gridy = 7;
gridBagConstraints.gridheight = 2; gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 6); gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 6);
pnSQLiteSettings.add(tbDbUsername, gridBagConstraints); pnSQLiteSettings.add(tbDbUsername, gridBagConstraints);
org.openide.awt.Mnemonics.setLocalizedText(lbUserPassword, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbUserPassword.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(lbUserPassword, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbUserPassword.text")); // NOI18N
lbUserPassword.setPreferredSize(new java.awt.Dimension(80, 14)); lbUserPassword.setMaximumSize(new java.awt.Dimension(194, 16));
lbUserPassword.setPreferredSize(new java.awt.Dimension(110, 14));
gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0; gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 9; gridBagConstraints.gridy = 9;
@ -382,14 +392,15 @@ public class EamDbSettingsDialog extends JDialog {
gridBagConstraints.gridx = 2; gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 9; gridBagConstraints.gridy = 9;
gridBagConstraints.gridheight = 2; gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 6); gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 6);
pnSQLiteSettings.add(jpDbPassword, gridBagConstraints); pnSQLiteSettings.add(jpDbPassword, gridBagConstraints);
org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseType, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbDatabaseType.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseType, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbDatabaseType.text")); // NOI18N
lbDatabaseType.setMaximumSize(new java.awt.Dimension(80, 14)); lbDatabaseType.setMaximumSize(new java.awt.Dimension(180, 14));
lbDatabaseType.setMinimumSize(new java.awt.Dimension(80, 14)); lbDatabaseType.setMinimumSize(new java.awt.Dimension(80, 14));
lbDatabaseType.setPreferredSize(new java.awt.Dimension(80, 14)); lbDatabaseType.setPreferredSize(new java.awt.Dimension(100, 14));
gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0; gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0; gridBagConstraints.gridy = 0;
@ -400,7 +411,8 @@ public class EamDbSettingsDialog extends JDialog {
pnSQLiteSettings.add(lbDatabaseType, gridBagConstraints); pnSQLiteSettings.add(lbDatabaseType, gridBagConstraints);
org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseDesc, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbDatabaseDesc.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(lbDatabaseDesc, org.openide.util.NbBundle.getMessage(EamDbSettingsDialog.class, "EamDbSettingsDialog.lbDatabaseDesc.text")); // NOI18N
lbDatabaseDesc.setPreferredSize(new java.awt.Dimension(80, 14)); lbDatabaseDesc.setMaximumSize(new java.awt.Dimension(182, 16));
lbDatabaseDesc.setPreferredSize(new java.awt.Dimension(100, 14));
gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0; gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 11; gridBagConstraints.gridy = 11;
@ -452,7 +464,7 @@ public class EamDbSettingsDialog extends JDialog {
pathPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) pathPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pathPanelLayout.createSequentialGroup() .addGroup(pathPanelLayout.createSequentialGroup()
.addGap(0, 0, 0) .addGap(0, 0, 0)
.addComponent(tfDatabasePath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(tfDatabasePath, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(bnDatabasePathFileOpen) .addComponent(bnDatabasePathFileOpen)
.addGap(0, 0, 0)) .addGap(0, 0, 0))
@ -471,6 +483,7 @@ public class EamDbSettingsDialog extends JDialog {
gridBagConstraints.gridx = 2; gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 1; gridBagConstraints.gridy = 1;
gridBagConstraints.gridheight = 2; gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 6); gridBagConstraints.insets = new java.awt.Insets(7, 10, 0, 6);
pnSQLiteSettings.add(pathPanel, gridBagConstraints); pnSQLiteSettings.add(pathPanel, gridBagConstraints);
@ -492,9 +505,9 @@ public class EamDbSettingsDialog extends JDialog {
typePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) typePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(typePanelLayout.createSequentialGroup() .addGroup(typePanelLayout.createSequentialGroup()
.addGap(0, 0, 0) .addGap(0, 0, 0)
.addComponent(cbDatabaseType, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cbDatabaseType, 0, 210, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lbSingleUserSqLite, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE) .addComponent(lbSingleUserSqLite, javax.swing.GroupLayout.DEFAULT_SIZE, 303, Short.MAX_VALUE)
.addGap(0, 0, 0)) .addGap(0, 0, 0))
); );
typePanelLayout.setVerticalGroup( typePanelLayout.setVerticalGroup(
@ -545,7 +558,7 @@ public class EamDbSettingsDialog extends JDialog {
.addComponent(bnOk) .addComponent(bnOk)
.addGap(11, 11, 11) .addGap(11, 11, 11)
.addComponent(bnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(bnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(pnSQLiteSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(pnSQLiteSettings, javax.swing.GroupLayout.DEFAULT_SIZE, 648, Short.MAX_VALUE))
.addContainerGap()) .addContainerGap())
); );
@ -575,12 +588,10 @@ public class EamDbSettingsDialog extends JDialog {
if (manager.getSelectedDbChoice() == CentralRepoDbChoice.SQLITE) { if (manager.getSelectedDbChoice() == CentralRepoDbChoice.SQLITE) {
updatePostgresFields(false); updatePostgresFields(false);
updateSqliteFields(true); updateSqliteFields(true);
} } else if (manager.getSelectedDbChoice() == CentralRepoDbChoice.POSTGRESQL_CUSTOM) {
else if (manager.getSelectedDbChoice() == CentralRepoDbChoice.POSTGRESQL_CUSTOM) {
updatePostgresFields(true); updatePostgresFields(true);
updateSqliteFields(false); updateSqliteFields(false);
} } else {
else {
updatePostgresFields(false); updatePostgresFields(false);
updateSqliteFields(false); updateSqliteFields(false);
} }
@ -615,35 +626,46 @@ public class EamDbSettingsDialog extends JDialog {
"EamDbSettingsDialog.okButton.errorMsg.text=Please restart Autopsy to begin using the new database platform.", "EamDbSettingsDialog.okButton.errorMsg.text=Please restart Autopsy to begin using the new database platform.",
"EamDbSettingsDialog.okButton.connectionErrorMsg.text=Failed to connect to central repository database."}) "EamDbSettingsDialog.okButton.connectionErrorMsg.text=Failed to connect to central repository database."})
private void bnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnOkActionPerformed private void bnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnOkActionPerformed
if (testStatusAndCreate(this, manager, this)) if (testStatusAndCreate(this, manager, this)) {
dispose(); dispose();
}
}//GEN-LAST:event_bnOkActionPerformed }//GEN-LAST:event_bnOkActionPerformed
/** /**
* This method tests status for central repo db / creation and prompts user accordingly. * This method tests status for central repo db / creation and prompts user
* accordingly.
*
* @param parent The parent component (the anchor for displaying dialogs). * @param parent The parent component (the anchor for displaying dialogs).
* @param manager The central repo db manager with settings to be tested and saved. * @param manager The central repo db manager with settings to be tested and
* @return Whether or not central repo db was successfully be created or found. * saved.
*
* @return Whether or not central repo db was successfully be created or
* found.
*/ */
public static boolean testStatusAndCreate(Component parent, CentralRepoDbManager manager) { public static boolean testStatusAndCreate(Component parent, CentralRepoDbManager manager) {
return testStatusAndCreate(parent, manager, null); return testStatusAndCreate(parent, manager, null);
} }
/** /**
* This method tests status for central repo db / creation and prompts user accordingly. * This method tests status for central repo db / creation and prompts user
* accordingly.
*
* @param parent The parent component (the anchor for displaying dialogs). * @param parent The parent component (the anchor for displaying dialogs).
* @param manager The central repo db manager with settings to be tested and saved. * @param manager The central repo db manager with settings to be tested and
* @param dialog The db settings dialog; if non-null, will validate okay button state. * saved.
* @return Whether or not central repo db was successfully be created or found. * @param dialog The db settings dialog; if non-null, will validate okay
* button state.
*
* @return Whether or not central repo db was successfully be created or
* found.
*/ */
private static boolean testStatusAndCreate(Component parent, CentralRepoDbManager manager, EamDbSettingsDialog dialog) { private static boolean testStatusAndCreate(Component parent, CentralRepoDbManager manager, EamDbSettingsDialog dialog) {
parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
manager.testStatus(); manager.testStatus();
if (dialog != null) if (dialog != null) {
dialog.valid(); dialog.valid();
}
boolean testedOk = promptTestStatusWarnings(manager, dialog); boolean testedOk = promptTestStatusWarnings(manager, dialog);
if (!testedOk) { if (!testedOk) {
@ -651,10 +673,9 @@ public class EamDbSettingsDialog extends JDialog {
return false; return false;
} }
try{ try {
manager.saveNewCentralRepo(); manager.saveNewCentralRepo();
} } catch (CentralRepoException e) {
catch (CentralRepoException e) {
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(parent, JOptionPane.showMessageDialog(parent,
Bundle.EamDbSettingsDialog_okButton_errorMsg_text(), Bundle.EamDbSettingsDialog_okButton_errorMsg_text(),
@ -670,13 +691,12 @@ public class EamDbSettingsDialog extends JDialog {
return true; return true;
} }
/** /**
* This method returns if changes to the central repository configuration were * This method returns if changes to the central repository configuration
* successfully applied. * were successfully applied.
* *
* @return True if the database configuration was successfully changed; false * @return True if the database configuration was successfully changed;
* if it was not. * false if it was not.
*/ */
public boolean wasConfigurationChanged() { public boolean wasConfigurationChanged() {
return manager.wasConfigurationChanged(); return manager.wasConfigurationChanged();
@ -696,8 +716,7 @@ public class EamDbSettingsDialog extends JDialog {
if (isDbChoiceSelectable(selectedItem)) { if (isDbChoiceSelectable(selectedItem)) {
manager.setSelctedDbChoice(selectedItem); manager.setSelctedDbChoice(selectedItem);
cbDatabaseType.setSelectedItem(selectedItem); cbDatabaseType.setSelectedItem(selectedItem);
} } else {
else {
cbDatabaseType.setSelectedItem(manager.getSelectedDbChoice()); cbDatabaseType.setSelectedItem(manager.getSelectedDbChoice());
} }
@ -823,8 +842,7 @@ public class EamDbSettingsDialog extends JDialog {
// && !tbDbName.getText().trim().isEmpty() // && !tbDbName.getText().trim().isEmpty()
&& !tbDbUsername.getText().trim().isEmpty() && !tbDbUsername.getText().trim().isEmpty()
&& 0 < jpDbPassword.getPassword().length; && 0 < jpDbPassword.getPassword().length;
} } else if (manager.getSelectedDbChoice() == CentralRepoDbChoice.SQLITE) {
else if (manager.getSelectedDbChoice() == CentralRepoDbChoice.SQLITE) {
result = !tfDatabasePath.getText().trim().isEmpty(); result = !tfDatabasePath.getText().trim().isEmpty();
} }
@ -841,7 +859,6 @@ public class EamDbSettingsDialog extends JDialog {
&& databaseSettingsAreValid(); && databaseSettingsAreValid();
} }
/** /**
* Validates that the form is filled out correctly for our usage. * Validates that the form is filled out correctly for our usage.
* *
@ -868,8 +885,6 @@ public class EamDbSettingsDialog extends JDialog {
} }
/** /**
* Tests whether or not the database settings are valid. * Tests whether or not the database settings are valid.
* *
@ -883,8 +898,7 @@ public class EamDbSettingsDialog extends JDialog {
tbDbUsername.getText().trim(), tbDbUsername.getText().trim(),
tfDatabasePath.getText().trim(), tfDatabasePath.getText().trim(),
new String(jpDbPassword.getPassword())); new String(jpDbPassword.getPassword()));
} } catch (CentralRepoException | NumberFormatException | IllegalStateException e) {
catch (CentralRepoException | NumberFormatException | IllegalStateException e) {
return false; return false;
} }