mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
5373 finish using AutopsyException for purposes of 4595
This commit is contained in:
parent
0966948b5e
commit
f7e1b845ba
@ -3246,10 +3246,10 @@ abstract class AbstractSqlEamDb implements EamDb {
|
||||
try {
|
||||
minorVersion = Integer.parseInt(minorVersionStr);
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new EamDbException(Bundle.AbstractSqlEamDb_badMinorSchema_message(minorVersionStr), ex);
|
||||
throw new EamDbException("Bad value for schema minor version (" + minorVersionStr + ") - database is corrupt", Bundle.AbstractSqlEamDb_badMinorSchema_message(minorVersionStr), ex);
|
||||
}
|
||||
} else {
|
||||
throw new EamDbException(Bundle.AbstractSqlEamDb_failedToReadMinorVersion_message());
|
||||
throw new EamDbException("Failed to read schema minor version from db_info table", Bundle.AbstractSqlEamDb_failedToReadMinorVersion_message());
|
||||
}
|
||||
|
||||
int majorVersion = 0;
|
||||
@ -3260,10 +3260,10 @@ abstract class AbstractSqlEamDb implements EamDb {
|
||||
try {
|
||||
majorVersion = Integer.parseInt(majorVersionStr);
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new EamDbException(Bundle.AbstractSqlEamDb_badMajorSchema_message(majorVersionStr), ex);
|
||||
throw new EamDbException("Bad value for schema version (" + majorVersionStr + ") - database is corrupt", Bundle.AbstractSqlEamDb_badMajorSchema_message(majorVersionStr), ex);
|
||||
}
|
||||
} else {
|
||||
throw new EamDbException(Bundle.AbstractSqlEamDb_failedToReadMajorVersion_message());
|
||||
throw new EamDbException("Failed to read schema major version from db_info table", Bundle.AbstractSqlEamDb_failedToReadMajorVersion_message());
|
||||
}
|
||||
|
||||
/*
|
||||
@ -3341,7 +3341,7 @@ abstract class AbstractSqlEamDb implements EamDb {
|
||||
addObjectIdIndexTemplate = SqliteEamDbSettings.getAddObjectIdIndexTemplate();
|
||||
break;
|
||||
default:
|
||||
throw new EamDbException(Bundle.AbstractSqlEamDb_cannotUpgrage_message(selectedPlatform.name()));
|
||||
throw new EamDbException("Currently selected database platform \"" + selectedPlatform.name() + "\" can not be upgraded.", Bundle.AbstractSqlEamDb_cannotUpgrage_message(selectedPlatform.name()));
|
||||
}
|
||||
final String dataSourcesTableName = "data_sources";
|
||||
final String dataSourceObjectIdColumnName = "datasource_obj_id";
|
||||
@ -3501,7 +3501,7 @@ abstract class AbstractSqlEamDb implements EamDb {
|
||||
statement.execute("DROP TABLE old_data_sources");
|
||||
break;
|
||||
default:
|
||||
throw new EamDbException(Bundle.AbstractSqlEamDb_cannotUpgrage_message(selectedPlatform.name()));
|
||||
throw new EamDbException("Currently selected database platform \"" + selectedPlatform.name() + "\" can not be upgraded.", Bundle.AbstractSqlEamDb_cannotUpgrage_message(selectedPlatform.name()));
|
||||
}
|
||||
}
|
||||
updateSchemaVersion(conn);
|
||||
|
@ -31,6 +31,7 @@ import org.sleuthkit.autopsy.coordinationservice.CoordinationService.Coordinatio
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractSqlEamDb.SOFTWARE_CR_DB_SCHEMA_VERSION;
|
||||
import org.sleuthkit.autopsy.exceptions.AutopsyException;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -181,32 +182,39 @@ public class EamDbUtil {
|
||||
}
|
||||
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 {
|
||||
// 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
|
||||
db = EamDb.getInstance();
|
||||
} catch (EamDbException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Error updating central repository, unable to make connection", ex);
|
||||
throw new EamDbException("Error updating central repository, unable to make connection", Bundle.EamDbUtil_centralRepoConnectionFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message(), ex);
|
||||
}
|
||||
//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();
|
||||
//perform upgrade
|
||||
} catch (EamDbException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Error updating central repository, unable to acquire exclusive lock", ex);
|
||||
throw new EamDbException("Error updating central repository, unable to acquire exclusive lock", Bundle.EamDbUtil_exclusiveLockAquisitionFailure_message() + Bundle.EamDbUtil_centralRepoDisabled_message(), ex);
|
||||
}
|
||||
|
||||
try {
|
||||
db.upgradeSchema();
|
||||
} catch (EamDbException | SQLException | IncompatibleCentralRepoException ex) {
|
||||
} catch (EamDbException 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();
|
||||
}
|
||||
throw new EamDbException("Error updating central repository", ex.getUserMessage() + Bundle.EamDbUtil_centralRepoDisabled_message(), ex);
|
||||
} catch (SQLException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Error updating central repository", ex);
|
||||
throw new EamDbException("Error updating central repository", Bundle.EamDbUtil_centralRepoUpgradeFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message(), ex);
|
||||
} catch (IncompatibleCentralRepoException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Error updating central repository", ex);
|
||||
throw new EamDbException("Error updating central repository", ex.getMessage() + "\n\n" + Bundle.EamDbUtil_centralRepoUpgradeFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message(), ex);
|
||||
} finally {
|
||||
if (lock != null) {
|
||||
try {
|
||||
@ -216,16 +224,11 @@ public class EamDbUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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 {
|
||||
throw new EamDbException("Unable to connect to database", Bundle.EamDbUtil_centralRepoConnectionFailed_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()) {
|
||||
} catch (EamDbException ex) {
|
||||
// Disable the central repo and clear the current settings.
|
||||
try {
|
||||
if (null != EamDb.getInstance()) {
|
||||
EamDb.getInstance().shutdownConnections();
|
||||
@ -235,8 +238,7 @@ public class EamDbUtil {
|
||||
}
|
||||
EamDbPlatformEnum.setSelectedPlatform(EamDbPlatformEnum.DISABLED.name());
|
||||
EamDbPlatformEnum.saveSelectedPlatform();
|
||||
|
||||
throw new EamDbException(messageForDialog, messageForDialog);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
ingestStateUpdated(Case.isCaseOpen());
|
||||
}
|
||||
|
||||
@Messages({"GlobalSettingsPanel.updateFailed.title=Central repository upgrade failed"})
|
||||
@Messages({"GlobalSettingsPanel.updateFailed.title=Central repository disabled"})
|
||||
private void updateDatabase() {
|
||||
|
||||
if (EamDbPlatformEnum.getSelectedPlatform().equals(DISABLED)) {
|
||||
@ -90,7 +90,7 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
} catch (EamDbException ex) {
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
JOptionPane.showMessageDialog(this,
|
||||
ex.getMessage(),
|
||||
ex.getUserMessage(),
|
||||
NbBundle.getMessage(this.getClass(),
|
||||
"GlobalSettingsPanel.updateFailed.title"),
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.exceptions;
|
||||
|
||||
public class AutopsyException extends Exception {
|
||||
public abstract class AutopsyException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user