mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
Merge pull request #5087 from wschaeferB/4595-CentralRepoError
4595 central repo error
This commit is contained in:
commit
8bafb796bc
@ -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) {
|
||||
|
@ -1,4 +1,14 @@
|
||||
# {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.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
|
||||
CorrelationType.FILES.displayName=Files
|
||||
@ -23,4 +33,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
|
||||
|
@ -276,9 +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.",
|
||||
"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;
|
||||
@ -286,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_invalidName_message()); // NON-NLS
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,27 +171,61 @@ 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.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;
|
||||
}
|
||||
|
||||
EamDb db = null;
|
||||
CoordinationService.Lock lock = null;
|
||||
String messageForDialog = "";
|
||||
//get connection
|
||||
try {
|
||||
db = EamDb.getInstance();
|
||||
} catch (EamDbException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Error updating central repository, unable to make connection", ex);
|
||||
messageForDialog = Bundle.EamDbUtil_centralRepoConnectionFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message();
|
||||
}
|
||||
//get lock necessary for upgrade
|
||||
if (db != null) {
|
||||
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();
|
||||
|
||||
//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();
|
||||
}
|
||||
|
||||
} else {
|
||||
messageForDialog = Bundle.EamDbUtil_centralRepoConnectionFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message();
|
||||
}
|
||||
// Disable the central repo and clear the current settings.
|
||||
if (!messageForDialog.isEmpty()) {
|
||||
try {
|
||||
if (null != EamDb.getInstance()) {
|
||||
EamDb.getInstance().shutdownConnections();
|
||||
@ -201,19 +235,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user