mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
4556 allow upgrade failure message to indicate that CR is incompatable
This commit is contained in:
parent
52c4aad251
commit
b0a80f0260
@ -3171,7 +3171,7 @@ abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
* @throws EamDbException
|
* @throws EamDbException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void upgradeSchema() throws EamDbException, SQLException {
|
public void upgradeSchema() throws EamDbException, SQLException, IncompatibleCentralRepoException {
|
||||||
|
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
Statement statement = null;
|
Statement statement = null;
|
||||||
@ -3225,7 +3225,7 @@ abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
//we can not use the CaseDbSchemaVersionNumber.isCompatible method
|
//we can not use the CaseDbSchemaVersionNumber.isCompatible method
|
||||||
//because it is specific to case db schema versions only supporting major versions greater than 1
|
//because it is specific to case db schema versions only supporting major versions greater than 1
|
||||||
if (SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() < dbSchemaVersion.getMajor()) {
|
if (SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() < dbSchemaVersion.getMajor()) {
|
||||||
throw new EamDbException("The selected Central Repository is not compatable with the current version of the application, please upgrade the application if you wish to use this Central Repository");
|
throw new IncompatibleCentralRepoException("The selected Central Repository is not compatable with the current version of the application, please upgrade the application if you wish to use this Central Repository");
|
||||||
}
|
}
|
||||||
if (dbSchemaVersion.equals(SOFTWARE_CR_DB_SCHEMA_VERSION)) {
|
if (dbSchemaVersion.equals(SOFTWARE_CR_DB_SCHEMA_VERSION)) {
|
||||||
logger.log(Level.INFO, "Central Repository is up to date");
|
logger.log(Level.INFO, "Central Repository is up to date");
|
||||||
|
@ -710,7 +710,7 @@ public interface EamDb {
|
|||||||
*
|
*
|
||||||
* @throws EamDbException
|
* @throws EamDbException
|
||||||
*/
|
*/
|
||||||
public void upgradeSchema() throws EamDbException, SQLException;
|
public void upgradeSchema() throws EamDbException, SQLException, IncompatibleCentralRepoException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an exclusive lock (if applicable). Will return the lock if
|
* Gets an exclusive lock (if applicable). Will return the lock if
|
||||||
|
@ -25,6 +25,7 @@ import java.sql.SQLException;
|
|||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import org.openide.util.NbBundle.Messages;
|
||||||
import org.sleuthkit.autopsy.coordinationservice.CoordinationService;
|
import org.sleuthkit.autopsy.coordinationservice.CoordinationService;
|
||||||
import org.sleuthkit.autopsy.coordinationservice.CoordinationService.CoordinationServiceException;
|
import org.sleuthkit.autopsy.coordinationservice.CoordinationService.CoordinationServiceException;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
@ -172,9 +173,10 @@ public class EamDbUtil {
|
|||||||
*
|
*
|
||||||
* @return true if the upgrade succeeds, false otherwise.
|
* @return true if the upgrade succeeds, false otherwise.
|
||||||
*/
|
*/
|
||||||
public static boolean upgradeDatabase() {
|
@Messages({"EamDbUtil.centralRepoUpgradeFailed.message=Failed to upgrade central repository. It has been disabled."})
|
||||||
|
public static void upgradeDatabase() throws EamDbException {
|
||||||
if (!EamDb.isEnabled()) {
|
if (!EamDb.isEnabled()) {
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoordinationService.Lock lock = null;
|
CoordinationService.Lock lock = null;
|
||||||
@ -188,7 +190,7 @@ public class EamDbUtil {
|
|||||||
|
|
||||||
db.upgradeSchema();
|
db.upgradeSchema();
|
||||||
|
|
||||||
} catch (EamDbException | SQLException ex) {
|
} catch (EamDbException | SQLException | IncompatibleCentralRepoException ex) {
|
||||||
LOGGER.log(Level.SEVERE, "Error updating central repository", ex);
|
LOGGER.log(Level.SEVERE, "Error updating central repository", ex);
|
||||||
|
|
||||||
// Disable the central repo and clear the current settings.
|
// Disable the central repo and clear the current settings.
|
||||||
@ -196,15 +198,18 @@ public class EamDbUtil {
|
|||||||
if (null != EamDb.getInstance()) {
|
if (null != EamDb.getInstance()) {
|
||||||
EamDb.getInstance().shutdownConnections();
|
EamDb.getInstance().shutdownConnections();
|
||||||
}
|
}
|
||||||
} catch (EamDbException ex2) {
|
} catch (EamDbException ignored) {
|
||||||
LOGGER.log(Level.SEVERE, "Error shutting down central repo connection pool", ex);
|
LOGGER.log(Level.SEVERE, "Error shutting down central repo connection pool", ex);
|
||||||
}
|
}
|
||||||
setUseCentralRepo(false);
|
setUseCentralRepo(false);
|
||||||
|
|
||||||
EamDbPlatformEnum.setSelectedPlatform(EamDbPlatformEnum.DISABLED.name());
|
EamDbPlatformEnum.setSelectedPlatform(EamDbPlatformEnum.DISABLED.name());
|
||||||
EamDbPlatformEnum.saveSelectedPlatform();
|
EamDbPlatformEnum.saveSelectedPlatform();
|
||||||
|
String messageForDialog = Bundle.EamDbUtil_centralRepoUpgradeFailed_message();
|
||||||
return false;
|
if (ex instanceof IncompatibleCentralRepoException) {
|
||||||
|
messageForDialog = ex.getMessage() + "\n\n" + messageForDialog;
|
||||||
|
}
|
||||||
|
throw new EamDbException(messageForDialog);
|
||||||
} finally {
|
} finally {
|
||||||
if (lock != null) {
|
if (lock != null) {
|
||||||
try {
|
try {
|
||||||
@ -214,7 +219,6 @@ public class EamDbUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2018 Basis Technology Corp.
|
||||||
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.sleuthkit.autopsy.centralrepository.datamodel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception to denote that the Central Repo is not compatable with the current version of the software.
|
||||||
|
*/
|
||||||
|
public class IncompatibleCentralRepoException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct an exception with the given message.
|
||||||
|
* @param message error message
|
||||||
|
*/
|
||||||
|
public IncompatibleCentralRepoException(String message){
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct an exception with the given message and inner exception.
|
||||||
|
* @param message error message
|
||||||
|
* @param cause inner exception
|
||||||
|
*/
|
||||||
|
public IncompatibleCentralRepoException(String message, Throwable cause){
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct an exception with the given inner exception.
|
||||||
|
* @param cause inner exception
|
||||||
|
*/
|
||||||
|
public IncompatibleCentralRepoException(Throwable cause){
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
@ -1118,7 +1118,7 @@ final class SqliteEamDb extends AbstractSqlEamDb {
|
|||||||
* @throws EamDbException
|
* @throws EamDbException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void upgradeSchema() throws EamDbException, SQLException {
|
public void upgradeSchema() throws EamDbException, SQLException, IncompatibleCentralRepoException {
|
||||||
try {
|
try {
|
||||||
acquireExclusiveLock();
|
acquireExclusiveLock();
|
||||||
super.upgradeSchema();
|
super.upgradeSchema();
|
||||||
|
@ -23,6 +23,7 @@ import org.openide.modules.ModuleInstall;
|
|||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.openide.windows.WindowManager;
|
import org.openide.windows.WindowManager;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
|
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil;
|
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil;
|
||||||
import org.sleuthkit.autopsy.core.RuntimeProperties;
|
import org.sleuthkit.autopsy.core.RuntimeProperties;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
@ -50,21 +51,20 @@ public class Installer extends ModuleInstall {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NbBundle.Messages({"Installer.centralRepoUpgradeFailed.title=Central repository upgrade failed",
|
@NbBundle.Messages({"Installer.centralRepoUpgradeFailed.title=Central repository upgrade failed"})
|
||||||
"Installer.centralRepoUpgradeFailed.message=Failed to upgrade central repository. It has been disabled."
|
|
||||||
})
|
|
||||||
@Override
|
@Override
|
||||||
public void restored() {
|
public void restored() {
|
||||||
Case.addPropertyChangeListener(pcl);
|
Case.addPropertyChangeListener(pcl);
|
||||||
ieListener.installListeners();
|
ieListener.installListeners();
|
||||||
|
|
||||||
// Perform the database upgrade and inform the user if it fails
|
// Perform the database upgrade and inform the user if it fails
|
||||||
if (!EamDbUtil.upgradeDatabase()) {
|
try {
|
||||||
|
EamDbUtil.upgradeDatabase();
|
||||||
|
} catch (EamDbException ex) {
|
||||||
if (RuntimeProperties.runningWithGUI()) {
|
if (RuntimeProperties.runningWithGUI()) {
|
||||||
WindowManager.getDefault().invokeWhenUIReady(() -> {
|
WindowManager.getDefault().invokeWhenUIReady(() -> {
|
||||||
JOptionPane.showMessageDialog(null,
|
JOptionPane.showMessageDialog(null,
|
||||||
NbBundle.getMessage(this.getClass(),
|
ex.getMessage(),
|
||||||
"Installer.centralRepoUpgradeFailed.message"),
|
|
||||||
NbBundle.getMessage(this.getClass(),
|
NbBundle.getMessage(this.getClass(),
|
||||||
"Installer.centralRepoUpgradeFailed.title"),
|
"Installer.centralRepoUpgradeFailed.title"),
|
||||||
JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
@ -30,6 +30,7 @@ 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.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
|
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||||
import org.sleuthkit.autopsy.corecomponents.OptionsPanel;
|
import org.sleuthkit.autopsy.corecomponents.OptionsPanel;
|
||||||
import org.sleuthkit.autopsy.events.AutopsyEvent;
|
import org.sleuthkit.autopsy.events.AutopsyEvent;
|
||||||
import org.sleuthkit.autopsy.ingest.IngestManager;
|
import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||||
@ -75,9 +76,7 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
ingestStateUpdated(Case.isCaseOpen());
|
ingestStateUpdated(Case.isCaseOpen());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Messages({"GlobalSettingsPanel.updateFailed.title=Update failed",
|
@Messages({"GlobalSettingsPanel.updateFailed.title=Central repository upgrade failed"})
|
||||||
"GlobalSettingsPanel.updateFailed.message=Failed to update database. Central repository has been disabled."
|
|
||||||
})
|
|
||||||
private void updateDatabase() {
|
private void updateDatabase() {
|
||||||
|
|
||||||
if (EamDbPlatformEnum.getSelectedPlatform().equals(DISABLED)) {
|
if (EamDbPlatformEnum.getSelectedPlatform().equals(DISABLED)) {
|
||||||
@ -86,16 +85,15 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boolean result = EamDbUtil.upgradeDatabase();
|
EamDbUtil.upgradeDatabase();
|
||||||
|
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||||
|
} catch (EamDbException ex) {
|
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||||
if (!result) {
|
|
||||||
JOptionPane.showMessageDialog(this,
|
JOptionPane.showMessageDialog(this,
|
||||||
NbBundle.getMessage(this.getClass(),
|
ex.getMessage(),
|
||||||
"GlobalSettingsPanel.updateFailed.message"),
|
|
||||||
NbBundle.getMessage(this.getClass(),
|
NbBundle.getMessage(this.getClass(),
|
||||||
"GlobalSettingsPanel.updateFailed.title"),
|
"GlobalSettingsPanel.updateFailed.title"),
|
||||||
JOptionPane.WARNING_MESSAGE);
|
JOptionPane.WARNING_MESSAGE);
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user