From ea150c72229764eb2b837c9892606146a5e2062f Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Tue, 30 Jul 2019 17:24:21 -0400 Subject: [PATCH 1/5] 4595 make errors cover more possible scenarios when cr config fails --- .../datamodel/EamDbUtil.java | 73 ++++++++++++------- .../eventlisteners/Installer.java | 2 +- 2 files changed, 47 insertions(+), 28 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbUtil.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbUtil.java index 213222a2d0..d7e51c73f5 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbUtil.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbUtil.java @@ -171,27 +171,57 @@ public class EamDbUtil { * upgrade fails, the Central Repository will be disabled and the current * settings will be cleared. */ - @Messages({"EamDbUtil.centralRepoUpgradeFailed.message=Failed to upgrade central repository. It has been disabled."}) + @Messages({"EamDbUtil.centralRepoUpgradeFailed.message=Failed to upgrade central repository. It has been disabled.", + "EamDbUtil.centralRepoConnectionFailed.message=Unable to connect to central repository. It has been disabled.", + "EamDbUtil.exclusiveLockAquisitionFailure.message=Unable to acquire exclusive lock for central repository. It has been disabled."}) public static void upgradeDatabase() throws EamDbException { if (!EamDb.isEnabled()) { return; } - + EamDb db = null; CoordinationService.Lock lock = null; + String messageForDialog = ""; + //get connection try { - EamDb db = EamDb.getInstance(); - - // 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 - // (meaning the database is in use by another user) - lock = db.getExclusiveMultiUserDbLock(); - - db.upgradeSchema(); - - } catch (EamDbException | SQLException | IncompatibleCentralRepoException ex) { - LOGGER.log(Level.SEVERE, "Error updating central repository", ex); - - // Disable the central repo and clear the current settings. + db = EamDb.getInstance(); + } catch (EamDbException ex) { + LOGGER.log(Level.SEVERE, "Error updating central repository, unable to make connection", ex); + messageForDialog = Bundle.EamDbUtil_centralRepoConnectionFailed_message(); + } + //get lock necessary for upgrade + if (db != null) { + 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 + // (meaning the database is in use by another user) + lock = db.getExclusiveMultiUserDbLock(); + } catch (EamDbException ex) { + LOGGER.log(Level.SEVERE, "Error updating central repository, unable to acquire exclusive lock", ex); + messageForDialog = Bundle.EamDbUtil_exclusiveLockAquisitionFailure_message(); + } + //perform upgrade + try { + if (lock != null) { + db.upgradeSchema(); + } + } catch (EamDbException | SQLException | IncompatibleCentralRepoException ex) { + LOGGER.log(Level.SEVERE, "Error updating central repository", ex); + messageForDialog = Bundle.EamDbUtil_centralRepoUpgradeFailed_message(); + if (ex instanceof IncompatibleCentralRepoException) { + messageForDialog = ex.getMessage() + "\n\n" + messageForDialog; + } + } finally { + if (lock != null) { + try { + lock.release(); + } catch (CoordinationServiceException ex) { + LOGGER.log(Level.SEVERE, "Error releasing database lock", ex); + } + } + } + } + // Disable the central repo and clear the current settings. + if (!messageForDialog.isEmpty()) { try { if (null != EamDb.getInstance()) { EamDb.getInstance().shutdownConnections(); @@ -201,19 +231,8 @@ public class EamDbUtil { } EamDbPlatformEnum.setSelectedPlatform(EamDbPlatformEnum.DISABLED.name()); EamDbPlatformEnum.saveSelectedPlatform(); - String messageForDialog = Bundle.EamDbUtil_centralRepoUpgradeFailed_message(); - if (ex instanceof IncompatibleCentralRepoException) { - messageForDialog = ex.getMessage() + "\n\n" + messageForDialog; - } + throw new EamDbException(messageForDialog); - } finally { - if (lock != null) { - try { - lock.release(); - } catch (CoordinationServiceException ex) { - LOGGER.log(Level.SEVERE, "Error releasing database lock", ex); - } - } } } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java index b887dea359..a96f09fa78 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java @@ -51,7 +51,7 @@ public class Installer extends ModuleInstall { super(); } - @NbBundle.Messages({"Installer.centralRepoUpgradeFailed.title=Central repository upgrade failed"}) + @NbBundle.Messages({"Installer.centralRepoUpgradeFailed.title=Central repository disabled"}) @Override public void restored() { Case.addPropertyChangeListener(pcl); From 36a08b8c6a1dfa8363dca1d338256f4d54f7b7f3 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Wed, 31 Jul 2019 18:50:42 -0400 Subject: [PATCH 2/5] 4595 use error message for user feedback when handling cr config --- .../datamodel/AbstractSqlEamDb.java | 23 ++++++++++++------- .../datamodel/Bundle.properties-MERGED | 19 ++++++++++++++- .../CorrelationAttributeInstance.java | 1 + .../datamodel/EamDbUtil.java | 21 +++++++++-------- .../datamodel/PostgresEamDb.java | 7 ++++-- .../datamodel/SqliteEamDb.java | 18 ++++++++++----- .../eventlisteners/Bundle.properties-MERGED | 2 +- 7 files changed, 64 insertions(+), 27 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java index 8d59b6959f..f1be6fab1f 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java @@ -3215,7 +3215,15 @@ abstract class AbstractSqlEamDb implements EamDb { * * @throws EamDbException */ - @Messages({"AbstractSqlEamDb.upgradeSchema.incompatible=The selected Central Repository is not compatible with the current version of the application, please upgrade the application if you wish to use this Central Repository."}) + @Messages({"AbstractSqlEamDb.upgradeSchema.incompatible=The selected Central Repository is not compatible with the current version of the application, please upgrade the application if you wish to use this Central Repository.", + "# {0} - minorVersion", + "AbstractSqlEamDb.badMinorSchema.message=Bad value for schema minor version ({0}) - database is corrupt.", + "AbstractSqlEamDb.failedToReadMinorVersion.message=Failed to read schema minor version for Central Repository.", + "# {0} - majorVersion", + "AbstractSqlEamDb.badMajorSchema.message=Bad value for schema version ({0}) - database is corrupt.", + "AbstractSqlEamDb.failedToReadMajorVersion.message=Failed to read schema version for Central Repository.", + "# {0} - platformName", + "AbstractSqlEamDb.cannotUpgrage.message=Currently selected database platform \"{0}\" can not be upgraded."}) @Override public void upgradeSchema() throws EamDbException, SQLException, IncompatibleCentralRepoException { @@ -3238,10 +3246,10 @@ abstract class AbstractSqlEamDb implements EamDb { try { minorVersion = Integer.parseInt(minorVersionStr); } catch (NumberFormatException ex) { - throw new EamDbException("Bad value for schema minor version (" + minorVersionStr + ") - database is corrupt", ex); + throw new EamDbException(Bundle.AbstractSqlEamDb_badMinorSchema_message(minorVersionStr), ex); } } else { - throw new EamDbException("Failed to read schema minor version from db_info table"); + throw new EamDbException(Bundle.AbstractSqlEamDb_failedToReadMinorVersion_message()); } int majorVersion = 0; @@ -3252,10 +3260,10 @@ abstract class AbstractSqlEamDb implements EamDb { try { majorVersion = Integer.parseInt(majorVersionStr); } catch (NumberFormatException ex) { - throw new EamDbException("Bad value for schema version (" + majorVersionStr + ") - database is corrupt", ex); + throw new EamDbException(Bundle.AbstractSqlEamDb_badMajorSchema_message(majorVersionStr), ex); } } else { - throw new EamDbException("Failed to read schema major version from db_info table"); + throw new EamDbException(Bundle.AbstractSqlEamDb_failedToReadMajorVersion_message()); } /* @@ -3333,7 +3341,7 @@ abstract class AbstractSqlEamDb implements EamDb { addObjectIdIndexTemplate = SqliteEamDbSettings.getAddObjectIdIndexTemplate(); break; default: - throw new EamDbException("Currently selected database platform \"" + selectedPlatform.name() + "\" can not be upgraded."); + throw new EamDbException(Bundle.AbstractSqlEamDb_cannotUpgrage_message(selectedPlatform.name())); } final String dataSourcesTableName = "data_sources"; final String dataSourceObjectIdColumnName = "datasource_obj_id"; @@ -3493,13 +3501,12 @@ abstract class AbstractSqlEamDb implements EamDb { statement.execute("DROP TABLE old_data_sources"); break; default: - throw new EamDbException("Currently selected database platform \"" + selectedPlatform.name() + "\" can not be upgraded."); + throw new EamDbException(Bundle.AbstractSqlEamDb_cannotUpgrage_message(selectedPlatform.name())); } } updateSchemaVersion(conn); conn.commit(); logger.log(Level.INFO, String.format("Central Repository schema updated to version %s", SOFTWARE_CR_DB_SCHEMA_VERSION)); - } catch (SQLException | EamDbException ex) { try { if (conn != null) { diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/Bundle.properties-MERGED index 26b5dd6887..07e9e34bcf 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/Bundle.properties-MERGED @@ -1,4 +1,13 @@ +# {0} - majorVersion +AbstractSqlEamDb.badMajorSchema.message=Bad value for schema version ({0}) - database is corrupt. +# {0} - minorVersion +AbstractSqlEamDb.badMinorSchema.message=Bad value for schema minor version ({0}) - database is corrupt. +# {0} - platformName +AbstractSqlEamDb.cannotUpgrage.message=Currently selected database platform "{0}" can not be upgraded. +AbstractSqlEamDb.failedToReadMajorVersion.message=Failed to read schema version for Central Repository. +AbstractSqlEamDb.failedToReadMinorVersion.message=Failed to read schema minor version for Central Repository. AbstractSqlEamDb.upgradeSchema.incompatible=The selected Central Repository is not compatible with the current version of the application, please upgrade the application if you wish to use this Central Repository. +CorrelationAttributeInstance.nullName.message=Database name is null. CorrelationType.DOMAIN.displayName=Domains CorrelationType.EMAIL.displayName=Email Addresses CorrelationType.FILES.displayName=Files @@ -23,4 +32,12 @@ EamCase.title.examinerName=Examiner Name: EamCase.title.examinerPhone=Examiner Phone: EamCase.title.notes=Notes: EamCase.title.org=Organization: -EamDbUtil.centralRepoUpgradeFailed.message=Failed to upgrade central repository. It has been disabled. +EamDbUtil.centralRepoConnectionFailed.message=Unable to connect to Central Repository. +EamDbUtil.centralRepoDisabled.message=\ The Central Repository has been disabled. +EamDbUtil.centralRepoUpgradeFailed.message=Failed to upgrade Central Repository. +EamDbUtil.exclusiveLockAquisitionFailure.message=Unable to acquire exclusive lock for Central Repository. +PostgresEamDb.centralRepoDisabled.message=Central Repository module is not enabled. +PostgresEamDb.connectionFailed.message=Error getting connection to database. +SqliteEamDb.centralRepositoryDisabled.message=Central Repository module is not enabled. +SqliteEamDb.connectionFailedMessage.message=Error getting connection to database. +SqliteEamDb.databaseMissing.message=Central repository database missing diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java index f5885f9ce4..a67148e771 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java @@ -276,6 +276,7 @@ public class CorrelationAttributeInstance implements Serializable { * @param supported Is this Type currently supported * @param enabled Is this Type currently enabled. */ + @Messages({"CorrelationAttributeInstance.nullName.message=Database name is null."}) public Type(int typeId, String displayName, String dbTableName, Boolean supported, Boolean enabled) throws EamDbException { if (dbTableName == null) { throw new EamDbException("dbTableName is null"); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbUtil.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbUtil.java index d7e51c73f5..9896f1618a 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbUtil.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbUtil.java @@ -171,9 +171,10 @@ public class EamDbUtil { * upgrade fails, the Central Repository will be disabled and the current * settings will be cleared. */ - @Messages({"EamDbUtil.centralRepoUpgradeFailed.message=Failed to upgrade central repository. It has been disabled.", - "EamDbUtil.centralRepoConnectionFailed.message=Unable to connect to central repository. It has been disabled.", - "EamDbUtil.exclusiveLockAquisitionFailure.message=Unable to acquire exclusive lock for central repository. It has been disabled."}) + @Messages({"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 EamDbException { if (!EamDb.isEnabled()) { return; @@ -186,7 +187,7 @@ public class EamDbUtil { db = EamDb.getInstance(); } catch (EamDbException ex) { LOGGER.log(Level.SEVERE, "Error updating central repository, unable to make connection", ex); - messageForDialog = Bundle.EamDbUtil_centralRepoConnectionFailed_message(); + messageForDialog = Bundle.EamDbUtil_centralRepoConnectionFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message(); } //get lock necessary for upgrade if (db != null) { @@ -197,18 +198,18 @@ public class EamDbUtil { lock = db.getExclusiveMultiUserDbLock(); } catch (EamDbException ex) { LOGGER.log(Level.SEVERE, "Error updating central repository, unable to acquire exclusive lock", ex); - messageForDialog = Bundle.EamDbUtil_exclusiveLockAquisitionFailure_message(); + messageForDialog = Bundle.EamDbUtil_exclusiveLockAquisitionFailure_message() + Bundle.EamDbUtil_centralRepoDisabled_message(); } //perform upgrade try { - if (lock != null) { - db.upgradeSchema(); - } + db.upgradeSchema(); } catch (EamDbException | SQLException | IncompatibleCentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error updating central repository", ex); - messageForDialog = Bundle.EamDbUtil_centralRepoUpgradeFailed_message(); + messageForDialog = Bundle.EamDbUtil_centralRepoUpgradeFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message(); if (ex instanceof IncompatibleCentralRepoException) { messageForDialog = ex.getMessage() + "\n\n" + messageForDialog; + } else if (ex instanceof EamDbException) { + messageForDialog = ex.getMessage() + Bundle.EamDbUtil_centralRepoDisabled_message(); } } finally { if (lock != null) { @@ -219,6 +220,8 @@ public class EamDbUtil { } } } + } else { + messageForDialog = Bundle.EamDbUtil_centralRepoConnectionFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message(); } // Disable the central repo and clear the current settings. if (!messageForDialog.isEmpty()) { diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDb.java index 89382289f0..c6b0d15669 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDb.java @@ -25,6 +25,7 @@ import java.sql.Statement; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import org.apache.commons.dbcp2.BasicDataSource; +import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.coordinationservice.CoordinationService; import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.coreutils.Logger; @@ -183,11 +184,13 @@ final class PostgresEamDb extends AbstractSqlEamDb { * * @throws EamDbException */ + @Messages({"PostgresEamDb.centralRepoDisabled.message=Central Repository module is not enabled.", + "PostgresEamDb.connectionFailed.message=Error getting connection to database."}) @Override protected Connection connect() throws EamDbException { synchronized (this) { if (!EamDb.isEnabled()) { - throw new EamDbException("Central Repository module is not enabled"); // NON-NLS + throw new EamDbException(Bundle.PostgresEamDb_centralRepoDisabled_message()); // NON-NLS } if (connectionPool == null) { @@ -197,7 +200,7 @@ final class PostgresEamDb extends AbstractSqlEamDb { try { return connectionPool.getConnection(); } catch (SQLException ex) { - throw new EamDbException("Error getting connection from connection pool.", ex); // NON-NLS + throw new EamDbException(Bundle.PostgresEamDb_connectionFailed_message(), ex); // NON-NLS } } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java index 6136a9c85c..b2df5f0fd9 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java @@ -28,6 +28,7 @@ import java.util.Set; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.logging.Level; import org.apache.commons.dbcp2.BasicDataSource; +import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.TskData; import org.sleuthkit.autopsy.casemodule.Case; @@ -153,10 +154,11 @@ final class SqliteEamDb extends AbstractSqlEamDb { * Setup a connection pool for db connections. * */ + @Messages({"SqliteEamDb.databaseMissing.message=Central repository database missing"}) private void setupConnectionPool(boolean foreignKeysEnabled) throws EamDbException { if (dbSettings.dbFileExists() == false) { - throw new EamDbException("Central repository database missing"); + throw new EamDbException(Bundle.SqliteEamDb_databaseMissing_message()); } connectionPool = new BasicDataSource(); @@ -179,17 +181,20 @@ final class SqliteEamDb extends AbstractSqlEamDb { /** * Lazily setup Singleton connection on first request. * - * @param foreignKeys determines if foreign keys should be enforced during this connection for SQLite + * @param foreignKeys determines if foreign keys should be enforced during + * this connection for SQLite * * @return A connection from the connection pool. * * @throws EamDbException */ + @Messages({"SqliteEamDb.connectionFailedMessage.message=Error getting connection to database.", + "SqliteEamDb.centralRepositoryDisabled.message=Central Repository module is not enabled."}) @Override protected Connection connect(boolean foreignKeys) throws EamDbException { synchronized (this) { if (!EamDb.isEnabled()) { - throw new EamDbException("Central Repository module is not enabled"); // NON-NLS + throw new EamDbException(Bundle.SqliteEamDb_centralRepositoryDisabled_message()); // NON-NLS } if (connectionPool == null) { setupConnectionPool(foreignKeys); @@ -197,13 +202,14 @@ final class SqliteEamDb extends AbstractSqlEamDb { try { return connectionPool.getConnection(); } catch (SQLException ex) { - throw new EamDbException("Error getting connection from connection pool.", ex); // NON-NLS + throw new EamDbException(Bundle.SqliteEamDb_connectionFailedMessage_message(), ex); // NON-NLS } } } /** - * Lazily setup Singleton connection on first request with foreign keys enforced. + * Lazily setup Singleton connection on first request with foreign keys + * enforced. * * @return A connection from the connection pool. * @@ -213,7 +219,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { protected Connection connect() throws EamDbException { return connect(true); } - + @Override protected String getConflictClause() { // For sqlite, our conflict clause is part of the table schema diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Bundle.properties-MERGED index c5f64a70eb..b7c3df2c53 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Bundle.properties-MERGED @@ -6,4 +6,4 @@ IngestEventsListener.prevCaseComment.text=Previous Case: IngestEventsListener.prevCount.text=Number of previous {0}: {1} IngestEventsListener.prevExists.text=Previously Seen Devices (Central Repository) IngestEventsListener.prevTaggedSet.text=Previously Tagged As Notable (Central Repository) -Installer.centralRepoUpgradeFailed.title=Central repository upgrade failed +Installer.centralRepoUpgradeFailed.title=Central repository disabled From 76004fca141cbad0cb068011cd4dd0653f47c7a7 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Fri, 2 Aug 2019 11:18:23 -0400 Subject: [PATCH 3/5] 4595 fix upgrade after locking failure bug --- .../datamodel/EamDbUtil.java | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbUtil.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbUtil.java index 9896f1618a..ad198b1744 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbUtil.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbUtil.java @@ -196,30 +196,31 @@ public class EamDbUtil { // throw an exception if locking is supported but we can't get the lock // (meaning the database is in use by another user) lock = db.getExclusiveMultiUserDbLock(); + //perform upgrade + try { + db.upgradeSchema(); + } catch (EamDbException | SQLException | IncompatibleCentralRepoException ex) { + LOGGER.log(Level.SEVERE, "Error updating central repository", ex); + messageForDialog = Bundle.EamDbUtil_centralRepoUpgradeFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message(); + if (ex instanceof IncompatibleCentralRepoException) { + messageForDialog = ex.getMessage() + "\n\n" + messageForDialog; + } else if (ex instanceof EamDbException) { + messageForDialog = ex.getMessage() + Bundle.EamDbUtil_centralRepoDisabled_message(); + } + } finally { + if (lock != null) { + try { + lock.release(); + } catch (CoordinationServiceException ex) { + LOGGER.log(Level.SEVERE, "Error releasing database lock", ex); + } + } + } } catch (EamDbException ex) { LOGGER.log(Level.SEVERE, "Error updating central repository, unable to acquire exclusive lock", ex); messageForDialog = Bundle.EamDbUtil_exclusiveLockAquisitionFailure_message() + Bundle.EamDbUtil_centralRepoDisabled_message(); } - //perform upgrade - try { - db.upgradeSchema(); - } catch (EamDbException | SQLException | IncompatibleCentralRepoException ex) { - LOGGER.log(Level.SEVERE, "Error updating central repository", ex); - messageForDialog = Bundle.EamDbUtil_centralRepoUpgradeFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message(); - if (ex instanceof IncompatibleCentralRepoException) { - messageForDialog = ex.getMessage() + "\n\n" + messageForDialog; - } else if (ex instanceof EamDbException) { - messageForDialog = ex.getMessage() + Bundle.EamDbUtil_centralRepoDisabled_message(); - } - } finally { - if (lock != null) { - try { - lock.release(); - } catch (CoordinationServiceException ex) { - LOGGER.log(Level.SEVERE, "Error releasing database lock", ex); - } - } - } + } else { messageForDialog = Bundle.EamDbUtil_centralRepoConnectionFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message(); } From a87bdf88528c84ba54a69128f4987d94938f79ce Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Fri, 2 Aug 2019 11:33:28 -0400 Subject: [PATCH 4/5] 4595 include bundle messages for two additional messages that may be displayed --- .../centralrepository/datamodel/Bundle.properties-MERGED | 1 + .../datamodel/CorrelationAttributeInstance.java | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/Bundle.properties-MERGED index 07e9e34bcf..c94c442588 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/Bundle.properties-MERGED @@ -7,6 +7,7 @@ AbstractSqlEamDb.cannotUpgrage.message=Currently selected database platform "{0} AbstractSqlEamDb.failedToReadMajorVersion.message=Failed to read schema version for Central Repository. AbstractSqlEamDb.failedToReadMinorVersion.message=Failed to read schema minor version for Central Repository. AbstractSqlEamDb.upgradeSchema.incompatible=The selected Central Repository is not compatible with the current version of the application, please upgrade the application if you wish to use this Central Repository. +CorrelationAttributeInstance.invalidName.message=Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'. CorrelationAttributeInstance.nullName.message=Database name is null. CorrelationType.DOMAIN.displayName=Domains CorrelationType.EMAIL.displayName=Email Addresses diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java index a67148e771..efc8d13de2 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java @@ -276,10 +276,11 @@ public class CorrelationAttributeInstance implements Serializable { * @param supported Is this Type currently supported * @param enabled Is this Type currently enabled. */ - @Messages({"CorrelationAttributeInstance.nullName.message=Database name is null."}) + @Messages({"CorrelationAttributeInstance.nullName.message=Database name is null.", + "CorrelationAttributeInstance.invalidName.message=Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'."}) public Type(int typeId, String displayName, String dbTableName, Boolean supported, Boolean enabled) throws EamDbException { if (dbTableName == null) { - throw new EamDbException("dbTableName is null"); + throw new EamDbException(Bundle.CorrelationAttributeInstance_nullName_message()); } this.typeId = typeId; this.displayName = displayName; @@ -287,7 +288,7 @@ public class CorrelationAttributeInstance implements Serializable { this.supported = supported; this.enabled = enabled; if (!Pattern.matches(DB_NAMES_REGEX, dbTableName)) { - throw new EamDbException("Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'."); // NON-NLS + throw new EamDbException(Bundle.CorrelationAttributeInstance_nullName_message()); // NON-NLS } } From d0ca5dc98a057763af3bde5d2cd7aca2d55fc8d9 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Fri, 2 Aug 2019 13:48:17 -0400 Subject: [PATCH 5/5] 4595 use correct bundle message --- .../datamodel/CorrelationAttributeInstance.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java index efc8d13de2..3cbc510e4c 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java @@ -288,7 +288,7 @@ public class CorrelationAttributeInstance implements Serializable { this.supported = supported; this.enabled = enabled; if (!Pattern.matches(DB_NAMES_REGEX, dbTableName)) { - throw new EamDbException(Bundle.CorrelationAttributeInstance_nullName_message()); // NON-NLS + throw new EamDbException(Bundle.CorrelationAttributeInstance_invalidName_message()); // NON-NLS } }