mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 07:56:16 +00:00
commit
c287fc0a9a
@ -25,7 +25,7 @@ import javax.swing.Action;
|
||||
import org.openide.util.Utilities;
|
||||
import org.openide.util.lookup.ServiceProvider;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb;
|
||||
import org.sleuthkit.autopsy.corecomponentinterfaces.ContextMenuActionsProvider;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
|
||||
@ -46,7 +46,7 @@ public class CentralRepoContextMenuActionsProvider implements ContextMenuActions
|
||||
}
|
||||
|
||||
for (AbstractFile file : selectedFiles) {
|
||||
if (EamDbUtil.useCentralRepo() && EamArtifactUtil.isSupportedAbstractFileType(file) && file.isFile()) {
|
||||
if (EamDb.isEnabled() && EamArtifactUtil.isSupportedAbstractFileType(file) && file.isFile()) {
|
||||
AddEditCentralRepoCommentAction action = new AddEditCentralRepoCommentAction(file);
|
||||
if (action.getCorrelationAttribute() == null) {
|
||||
action.setEnabled(false);
|
||||
|
@ -71,7 +71,6 @@ import org.sleuthkit.datamodel.ContentTag;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
import org.sleuthkit.datamodel.TskException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
import org.sleuthkit.datamodel.TskData;
|
||||
|
||||
@ -891,7 +890,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
|
||||
private void rightClickPopupMenuPopupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_rightClickPopupMenuPopupMenuWillBecomeVisible
|
||||
boolean enableCentralRepoActions = false;
|
||||
|
||||
if (EamDbUtil.useCentralRepo() && otherCasesTable.getSelectedRowCount() == 1) {
|
||||
if (EamDb.isEnabled() && otherCasesTable.getSelectedRowCount() == 1) {
|
||||
int rowIndex = otherCasesTable.getSelectedRow();
|
||||
OtherOccurrenceNodeData selectedNode = (OtherOccurrenceNodeData) tableModel.getRow(rowIndex);
|
||||
if (selectedNode instanceof OtherOccurrenceNodeInstanceData) {
|
||||
|
@ -40,6 +40,7 @@ import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import static org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil.updateSchemaVersion;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
@ -60,7 +61,7 @@ abstract class AbstractSqlEamDb implements EamDb {
|
||||
static final String SCHEMA_MINOR_VERSION_KEY = "SCHEMA_MINOR_VERSION";
|
||||
static final String CREATION_SCHEMA_MAJOR_VERSION_KEY = "CREATION_SCHEMA_MAJOR_VERSION";
|
||||
static final String CREATION_SCHEMA_MINOR_VERSION_KEY = "CREATION_SCHEMA_MINOR_VERSION";
|
||||
static final CaseDbSchemaVersionNumber CURRENT_DB_SCHEMA_VERSION = new CaseDbSchemaVersionNumber(1, 2);
|
||||
static final CaseDbSchemaVersionNumber SOFTWARE_CR_DB_SCHEMA_VERSION = new CaseDbSchemaVersionNumber(1, 2);
|
||||
|
||||
protected final List<CorrelationAttributeInstance.Type> defaultCorrelationTypes;
|
||||
|
||||
@ -3170,8 +3171,9 @@ 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."})
|
||||
@Override
|
||||
public void upgradeSchema() throws EamDbException, SQLException {
|
||||
public void upgradeSchema() throws EamDbException, SQLException, IncompatibleCentralRepoException {
|
||||
|
||||
ResultSet resultSet = null;
|
||||
Statement statement = null;
|
||||
@ -3220,11 +3222,18 @@ abstract class AbstractSqlEamDb implements EamDb {
|
||||
* schema updates that may already have been done once.
|
||||
*/
|
||||
CaseDbSchemaVersionNumber dbSchemaVersion = new CaseDbSchemaVersionNumber(majorVersion, minorVersion);
|
||||
if (dbSchemaVersion.equals(CURRENT_DB_SCHEMA_VERSION)) {
|
||||
|
||||
//compare the major versions for compatability
|
||||
//we can not use the CaseDbSchemaVersionNumber.isCompatible method
|
||||
//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()) {
|
||||
throw new IncompatibleCentralRepoException(Bundle.AbstractSqlEamDb_upgradeSchema_incompatible());
|
||||
}
|
||||
if (dbSchemaVersion.equals(SOFTWARE_CR_DB_SCHEMA_VERSION)) {
|
||||
logger.log(Level.INFO, "Central Repository is up to date");
|
||||
return;
|
||||
}
|
||||
if (dbSchemaVersion.compareTo(CURRENT_DB_SCHEMA_VERSION) > 0) {
|
||||
if (dbSchemaVersion.compareTo(SOFTWARE_CR_DB_SCHEMA_VERSION) > 0) {
|
||||
logger.log(Level.INFO, "Central Repository is of newer version than software creates");
|
||||
return;
|
||||
}
|
||||
@ -3386,8 +3395,8 @@ abstract class AbstractSqlEamDb implements EamDb {
|
||||
* column having a UNIQUE constraint. The name column could now
|
||||
* be used as the primary key, but the essentially useless id
|
||||
* column is retained for the sake of backwards compatibility.
|
||||
* Note that the creation schema version number is set to 0.0
|
||||
* to indicate that it is unknown.
|
||||
* Note that the creation schema version number is set to 0.0 to
|
||||
* indicate that it is unknown.
|
||||
*/
|
||||
String creationMajorVer;
|
||||
resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name = '" + AbstractSqlEamDb.CREATION_SCHEMA_MAJOR_VERSION_KEY + "'");
|
||||
@ -3417,7 +3426,7 @@ abstract class AbstractSqlEamDb implements EamDb {
|
||||
|
||||
updateSchemaVersion(conn);
|
||||
conn.commit();
|
||||
logger.log(Level.INFO, String.format("Central Repository schema updated to version %s", CURRENT_DB_SCHEMA_VERSION));
|
||||
logger.log(Level.INFO, String.format("Central Repository schema updated to version %s", SOFTWARE_CR_DB_SCHEMA_VERSION));
|
||||
|
||||
} catch (SQLException | EamDbException ex) {
|
||||
try {
|
||||
@ -3425,7 +3434,7 @@ abstract class AbstractSqlEamDb implements EamDb {
|
||||
conn.rollback();
|
||||
}
|
||||
} catch (SQLException ex2) {
|
||||
logger.log(Level.SEVERE, String.format("Central Repository rollback of failed schema update to %s failed", CURRENT_DB_SCHEMA_VERSION), ex2);
|
||||
logger.log(Level.SEVERE, String.format("Central Repository rollback of failed schema update to %s failed", SOFTWARE_CR_DB_SCHEMA_VERSION), ex2);
|
||||
}
|
||||
throw ex;
|
||||
} finally {
|
||||
|
@ -98,7 +98,7 @@ public class CorrelationDataSource implements Serializable {
|
||||
}
|
||||
|
||||
CorrelationDataSource correlationDataSource = null;
|
||||
boolean useCR = EamDbUtil.useCentralRepo();
|
||||
boolean useCR = EamDb.isEnabled();
|
||||
if (useCR) {
|
||||
correlationDataSource = EamDb.getInstance().getDataSource(correlationCase, dataSource.getId());
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class DataSourceUpdateService implements AutopsyService {
|
||||
//ResultSet.getLong has a value of 0 when the value is null
|
||||
if (correlationDataSource.getCaseID() == correlationCase.getID() && correlationDataSource.getDataSourceObjectID() == 0) {
|
||||
for (Content dataSource : context.getCase().getDataSources()) {
|
||||
if (((DataSource) dataSource).getDeviceId().equals(correlationDataSource.getDeviceID())) {
|
||||
if (((DataSource) dataSource).getDeviceId().equals(correlationDataSource.getDeviceID()) && dataSource.getName().equals(correlationDataSource.getName())) {
|
||||
centralRepository.addDataSourceObjectId(correlationDataSource.getID(), dataSource.getId());
|
||||
break;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public interface EamDb {
|
||||
static EamDb getInstance() throws EamDbException {
|
||||
|
||||
EamDbPlatformEnum selectedPlatform = EamDbPlatformEnum.DISABLED;
|
||||
if (EamDbUtil.useCentralRepo()) {
|
||||
if (EamDbUtil.allowUseOfCentralRepository()) {
|
||||
selectedPlatform = EamDbPlatformEnum.getSelectedPlatform();
|
||||
}
|
||||
switch (selectedPlatform) {
|
||||
@ -92,7 +92,7 @@ public interface EamDb {
|
||||
* @return Is the database enabled
|
||||
*/
|
||||
static boolean isEnabled() {
|
||||
return EamDbUtil.useCentralRepo()
|
||||
return EamDbUtil.allowUseOfCentralRepository()
|
||||
&& EamDbPlatformEnum.getSelectedPlatform() != EamDbPlatformEnum.DISABLED;
|
||||
}
|
||||
|
||||
@ -710,7 +710,7 @@ public interface EamDb {
|
||||
*
|
||||
* @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
|
||||
|
@ -25,11 +25,12 @@ import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractSqlEamDb.CURRENT_DB_SCHEMA_VERSION;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.sleuthkit.autopsy.coordinationservice.CoordinationService;
|
||||
import org.sleuthkit.autopsy.coordinationservice.CoordinationService.CoordinationServiceException;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -134,8 +135,8 @@ public class EamDbUtil {
|
||||
*/
|
||||
static void updateSchemaVersion(Connection conn) throws SQLException {
|
||||
try (Statement statement = conn.createStatement()) {
|
||||
statement.execute("UPDATE db_info SET value = '" + CURRENT_DB_SCHEMA_VERSION.getMajor() + "' WHERE name = '" + AbstractSqlEamDb.SCHEMA_MAJOR_VERSION_KEY + "'");
|
||||
statement.execute("UPDATE db_info SET value = '" + CURRENT_DB_SCHEMA_VERSION.getMinor() + "' WHERE name = '" + AbstractSqlEamDb.SCHEMA_MINOR_VERSION_KEY + "'");
|
||||
statement.execute("UPDATE db_info SET value = '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "' WHERE name = '" + AbstractSqlEamDb.SCHEMA_MAJOR_VERSION_KEY + "'");
|
||||
statement.execute("UPDATE db_info SET value = '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "' WHERE name = '" + AbstractSqlEamDb.SCHEMA_MINOR_VERSION_KEY + "'");
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,9 +173,10 @@ public class EamDbUtil {
|
||||
*
|
||||
* @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()) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
CoordinationService.Lock lock = null;
|
||||
@ -188,7 +190,7 @@ public class EamDbUtil {
|
||||
|
||||
db.upgradeSchema();
|
||||
|
||||
} catch (EamDbException | SQLException ex) {
|
||||
} catch (EamDbException | SQLException | IncompatibleCentralRepoException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Error updating central repository", ex);
|
||||
|
||||
// Disable the central repo and clear the current settings.
|
||||
@ -197,13 +199,17 @@ public class EamDbUtil {
|
||||
EamDb.getInstance().shutdownConnections();
|
||||
}
|
||||
} catch (EamDbException ex2) {
|
||||
LOGGER.log(Level.SEVERE, "Error shutting down central repo connection pool", ex);
|
||||
LOGGER.log(Level.SEVERE, "Error shutting down central repo connection pool", ex2);
|
||||
}
|
||||
setUseCentralRepo(false);
|
||||
|
||||
EamDbPlatformEnum.setSelectedPlatform(EamDbPlatformEnum.DISABLED.name());
|
||||
EamDbPlatformEnum.saveSelectedPlatform();
|
||||
|
||||
return false;
|
||||
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 {
|
||||
@ -213,7 +219,6 @@ public class EamDbUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -268,12 +273,16 @@ public class EamDbUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Central Repos use has been enabled.
|
||||
* If the option to use a central repository has been selected, does not
|
||||
* indicate the central repository is configured for use simply that the
|
||||
* checkbox allowing configuration is checked on the options panel.
|
||||
*
|
||||
* @return true if the Central Repo may be configured, false if it should
|
||||
* not be able to be
|
||||
*/
|
||||
public static boolean useCentralRepo() {
|
||||
public static boolean allowUseOfCentralRepository() {
|
||||
//In almost all situations EamDb.isEnabled() should be used instead of this method
|
||||
//as EamDb.isEnabled() will call this method as well as checking that the selected type of central repository is not DISABLED
|
||||
return Boolean.parseBoolean(ModuleSettings.getConfigSetting(CENTRAL_REPO_NAME, CENTRAL_REPO_USE_KEY));
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -28,11 +28,11 @@ import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractSqlEamDb.CURRENT_DB_SCHEMA_VERSION;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
import org.sleuthkit.autopsy.coreutils.TextConverter;
|
||||
import org.sleuthkit.autopsy.coreutils.TextConverterException;
|
||||
import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractSqlEamDb.SOFTWARE_CR_DB_SCHEMA_VERSION;
|
||||
|
||||
/**
|
||||
* Settings for the Postgres implementation of the Central Repository database
|
||||
@ -437,10 +437,10 @@ public final class PostgresEamDbSettings {
|
||||
* name column could be the primary key.
|
||||
*/
|
||||
stmt.execute("CREATE TABLE db_info (id SERIAL, name TEXT UNIQUE NOT NULL, value TEXT NOT NULL)");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.SCHEMA_MAJOR_VERSION_KEY + "', '" + CURRENT_DB_SCHEMA_VERSION.getMajor() + "')");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.SCHEMA_MINOR_VERSION_KEY + "', '" + CURRENT_DB_SCHEMA_VERSION.getMinor() + "')");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.CREATION_SCHEMA_MAJOR_VERSION_KEY + "', '" + CURRENT_DB_SCHEMA_VERSION.getMajor() + "')");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.CREATION_SCHEMA_MINOR_VERSION_KEY + "', '" + CURRENT_DB_SCHEMA_VERSION.getMinor() + "')");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.CREATION_SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.CREATION_SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')");
|
||||
|
||||
// Create a separate instance and reference table for each correlation type
|
||||
List<CorrelationAttributeInstance.Type> DEFAULT_CORRELATION_TYPES = CorrelationAttributeInstance.getDefaultCorrelationTypes();
|
||||
|
@ -1118,7 +1118,7 @@ final class SqliteEamDb extends AbstractSqlEamDb {
|
||||
* @throws EamDbException
|
||||
*/
|
||||
@Override
|
||||
public void upgradeSchema() throws EamDbException, SQLException {
|
||||
public void upgradeSchema() throws EamDbException, SQLException, IncompatibleCentralRepoException {
|
||||
try {
|
||||
acquireExclusiveLock();
|
||||
super.upgradeSchema();
|
||||
|
@ -29,10 +29,10 @@ import java.sql.Statement;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractSqlEamDb.CURRENT_DB_SCHEMA_VERSION;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
import org.sleuthkit.autopsy.coreutils.PlatformUtil;
|
||||
import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractSqlEamDb.SOFTWARE_CR_DB_SCHEMA_VERSION;
|
||||
|
||||
/**
|
||||
* Settings for the sqlite implementation of the Central Repository database
|
||||
@ -386,10 +386,10 @@ public final class SqliteEamDbSettings {
|
||||
* name column could be the primary key.
|
||||
*/
|
||||
stmt.execute("CREATE TABLE db_info (id INTEGER PRIMARY KEY, name TEXT UNIQUE NOT NULL, value TEXT NOT NULL)");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.SCHEMA_MAJOR_VERSION_KEY + "', '" + CURRENT_DB_SCHEMA_VERSION.getMajor() + "')");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.SCHEMA_MINOR_VERSION_KEY + "', '" + CURRENT_DB_SCHEMA_VERSION.getMinor() + "')");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.CREATION_SCHEMA_MAJOR_VERSION_KEY + "', '" + CURRENT_DB_SCHEMA_VERSION.getMajor() + "')");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.CREATION_SCHEMA_MINOR_VERSION_KEY + "', '" + CURRENT_DB_SCHEMA_VERSION.getMinor() + "')");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.CREATION_SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')");
|
||||
stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.CREATION_SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')");
|
||||
|
||||
// Create a separate instance and reference table for each artifact type
|
||||
List<CorrelationAttributeInstance.Type> DEFAULT_CORRELATION_TYPES = CorrelationAttributeInstance.getDefaultCorrelationTypes();
|
||||
|
@ -23,6 +23,7 @@ import org.openide.modules.ModuleInstall;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.windows.WindowManager;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil;
|
||||
import org.sleuthkit.autopsy.core.RuntimeProperties;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
@ -50,21 +51,20 @@ public class Installer extends ModuleInstall {
|
||||
super();
|
||||
}
|
||||
|
||||
@NbBundle.Messages({"Installer.centralRepoUpgradeFailed.title=Central repository upgrade failed",
|
||||
"Installer.centralRepoUpgradeFailed.message=Failed to upgrade central repository. It has been disabled."
|
||||
})
|
||||
@NbBundle.Messages({"Installer.centralRepoUpgradeFailed.title=Central repository upgrade failed"})
|
||||
@Override
|
||||
public void restored() {
|
||||
Case.addPropertyChangeListener(pcl);
|
||||
ieListener.installListeners();
|
||||
|
||||
// Perform the database upgrade and inform the user if it fails
|
||||
if (!EamDbUtil.upgradeDatabase()) {
|
||||
try {
|
||||
EamDbUtil.upgradeDatabase();
|
||||
} catch (EamDbException ex) {
|
||||
if (RuntimeProperties.runningWithGUI()) {
|
||||
WindowManager.getDefault().invokeWhenUIReady(() -> {
|
||||
JOptionPane.showMessageDialog(null,
|
||||
NbBundle.getMessage(this.getClass(),
|
||||
"Installer.centralRepoUpgradeFailed.message"),
|
||||
ex.getMessage(),
|
||||
NbBundle.getMessage(this.getClass(),
|
||||
"Installer.centralRepoUpgradeFailed.title"),
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
|
@ -90,7 +90,7 @@ public class EamDbSettingsDialog extends JDialog {
|
||||
initComponents();
|
||||
fcDatabasePath.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
|
||||
fcDatabasePath.setAcceptAllFileFilterUsed(false);
|
||||
fcDatabasePath.setDialogTitle(Bundle.EamDbSettingsDialog_fcDatabasePath_title());
|
||||
fcDatabasePath.setDialogTitle(Bundle.EamDbSettingsDialog_fcDatabasePath_title());
|
||||
fcDatabasePath.setFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
@ -369,7 +369,7 @@ public class EamDbSettingsDialog extends JDialog {
|
||||
case POSTGRESQL:
|
||||
if (dbSettingsPostgres.verifyConnection()) {
|
||||
if (dbSettingsPostgres.verifyDatabaseExists()) {
|
||||
if( dbSettingsPostgres.verifyDatabaseSchema()) {
|
||||
if (dbSettingsPostgres.verifyDatabaseSchema()) {
|
||||
testingStatus = DatabaseTestResult.TESTEDOK;
|
||||
} else {
|
||||
testingStatus = DatabaseTestResult.SCHEMA_INVALID;
|
||||
@ -382,8 +382,8 @@ public class EamDbSettingsDialog extends JDialog {
|
||||
}
|
||||
break;
|
||||
case SQLITE:
|
||||
if (dbSettingsSqlite.dbFileExists()){
|
||||
if(dbSettingsSqlite.verifyConnection()) {
|
||||
if (dbSettingsSqlite.dbFileExists()) {
|
||||
if (dbSettingsSqlite.verifyConnection()) {
|
||||
if (dbSettingsSqlite.verifyDatabaseSchema()) {
|
||||
testingStatus = DatabaseTestResult.TESTEDOK;
|
||||
} else {
|
||||
@ -418,7 +418,7 @@ public class EamDbSettingsDialog extends JDialog {
|
||||
}
|
||||
if (!result) {
|
||||
// Remove the incomplete database
|
||||
if(dbCreated){
|
||||
if (dbCreated) {
|
||||
dbSettingsPostgres.deleteDatabase();
|
||||
}
|
||||
|
||||
@ -439,7 +439,7 @@ public class EamDbSettingsDialog extends JDialog {
|
||||
&& dbSettingsSqlite.insertDefaultDatabaseContent();
|
||||
}
|
||||
if (!result) {
|
||||
if(dbCreated){
|
||||
if (dbCreated) {
|
||||
dbSettingsSqlite.deleteDatabase();
|
||||
}
|
||||
|
||||
@ -455,10 +455,13 @@ public class EamDbSettingsDialog extends JDialog {
|
||||
testingStatus = DatabaseTestResult.TESTEDOK;
|
||||
valid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if changes to the central repository configuration were successfully applied
|
||||
* Returns if changes to the central repository configuration were
|
||||
* successfully applied
|
||||
*
|
||||
* @return true if the database configuration was successfully changed false if it was not
|
||||
* @return true if the database configuration was successfully changed false
|
||||
* if it was not
|
||||
*/
|
||||
boolean wasConfigurationChanged() {
|
||||
return configurationChanged;
|
||||
@ -481,7 +484,7 @@ public class EamDbSettingsDialog extends JDialog {
|
||||
Bundle.EamDbSettingsDialog_okButton_databaseConnectionFailed_message(),
|
||||
Bundle.EamDbSettingsDialog_okButton_databaseConnectionFailed_title(),
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
} else if (testingStatus == DatabaseTestResult.SCHEMA_INVALID){
|
||||
} else if (testingStatus == DatabaseTestResult.SCHEMA_INVALID) {
|
||||
// There's an existing database or file, but it's not in our format.
|
||||
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
|
||||
Bundle.EamDbSettingsDialog_okButton_corruptDatabaseExists_message(),
|
||||
@ -580,7 +583,7 @@ public class EamDbSettingsDialog extends JDialog {
|
||||
customizeComponents();
|
||||
}//GEN-LAST:event_cbDatabaseTypeActionPerformed
|
||||
|
||||
private void updateFullDbPath(){
|
||||
private void updateFullDbPath() {
|
||||
lbFullDbPath.setText(tfDatabasePath.getText() + File.separator + CENTRAL_REPO_DB_NAME + CENTRAL_REPO_SQLITE_EXT);
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbUseCentralRepoActionPerformed"/>
|
||||
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="useCentralRepoStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="pnDatabaseConfiguration">
|
||||
|
@ -30,6 +30,7 @@ import org.netbeans.spi.options.OptionsPanelController;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||
import org.sleuthkit.autopsy.corecomponents.OptionsPanel;
|
||||
import org.sleuthkit.autopsy.events.AutopsyEvent;
|
||||
import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||
@ -75,9 +76,7 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
ingestStateUpdated(Case.isCaseOpen());
|
||||
}
|
||||
|
||||
@Messages({"GlobalSettingsPanel.updateFailed.title=Update failed",
|
||||
"GlobalSettingsPanel.updateFailed.message=Failed to update database. Central repository has been disabled."
|
||||
})
|
||||
@Messages({"GlobalSettingsPanel.updateFailed.title=Central repository upgrade failed"})
|
||||
private void updateDatabase() {
|
||||
|
||||
if (EamDbPlatformEnum.getSelectedPlatform().equals(DISABLED)) {
|
||||
@ -86,16 +85,15 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
|
||||
try {
|
||||
boolean result = EamDbUtil.upgradeDatabase();
|
||||
EamDbUtil.upgradeDatabase();
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
if (!result) {
|
||||
JOptionPane.showMessageDialog(this,
|
||||
NbBundle.getMessage(this.getClass(),
|
||||
"GlobalSettingsPanel.updateFailed.message"),
|
||||
NbBundle.getMessage(this.getClass(),
|
||||
"GlobalSettingsPanel.updateFailed.title"),
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
} catch (EamDbException ex) {
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
JOptionPane.showMessageDialog(this,
|
||||
ex.getMessage(),
|
||||
NbBundle.getMessage(this.getClass(),
|
||||
"GlobalSettingsPanel.updateFailed.title"),
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
} finally {
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
@ -149,9 +147,9 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
org.openide.awt.Mnemonics.setLocalizedText(lbCentralRepository, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.lbCentralRepository.text")); // NOI18N
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(cbUseCentralRepo, org.openide.util.NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.cbUseCentralRepo.text")); // NOI18N
|
||||
cbUseCentralRepo.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
cbUseCentralRepoActionPerformed(evt);
|
||||
cbUseCentralRepo.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||
public void stateChanged(javax.swing.event.ChangeEvent evt) {
|
||||
useCentralRepoStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
@ -433,15 +431,6 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
}
|
||||
}//GEN-LAST:event_bnDbConfigureActionPerformed
|
||||
|
||||
private void cbUseCentralRepoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbUseCentralRepoActionPerformed
|
||||
//if saved setting is disabled checkbox should be disabled already
|
||||
store();
|
||||
updateDatabase();
|
||||
load();
|
||||
this.ingestStateUpdated(Case.isCaseOpen());
|
||||
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
||||
}//GEN-LAST:event_cbUseCentralRepoActionPerformed
|
||||
|
||||
private void manageOrganizationButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manageOrganizationButtonActionPerformed
|
||||
store();
|
||||
ManageOrganizationsDialog manageOrganizationsDialog = new ManageOrganizationsDialog();
|
||||
@ -452,13 +441,22 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
ManageCasesDialog.displayManageCasesDialog();
|
||||
}//GEN-LAST:event_showCasesButtonActionPerformed
|
||||
|
||||
private void useCentralRepoStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_useCentralRepoStateChanged
|
||||
//if saved setting is disabled checkbox should be disabled already
|
||||
store();
|
||||
updateDatabase();
|
||||
load();
|
||||
this.ingestStateUpdated(Case.isCaseOpen());
|
||||
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
||||
}//GEN-LAST:event_useCentralRepoStateChanged
|
||||
|
||||
@Override
|
||||
@Messages({"GlobalSettingsPanel.validationerrMsg.mustConfigure=Configure the database to enable this module."})
|
||||
public void load() {
|
||||
tbOops.setText("");
|
||||
enableButtonSubComponents(false);
|
||||
EamDbPlatformEnum selectedPlatform = EamDbPlatformEnum.getSelectedPlatform();
|
||||
cbUseCentralRepo.setSelected(EamDbUtil.useCentralRepo()); // NON-NLS
|
||||
cbUseCentralRepo.setSelected(EamDbUtil.allowUseOfCentralRepository()); // NON-NLS
|
||||
switch (selectedPlatform) {
|
||||
case POSTGRESQL:
|
||||
PostgresEamDbSettings dbSettingsPg = new PostgresEamDbSettings();
|
||||
|
@ -24,7 +24,6 @@ import java.util.logging.Level;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openide.nodes.Sheet;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil;
|
||||
import org.sleuthkit.autopsy.core.UserPreferences;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode;
|
||||
@ -74,12 +73,12 @@ final class RelationshipNode extends BlackboardArtifactNode {
|
||||
addScoreProperty(sheetSet, tags);
|
||||
|
||||
CorrelationAttributeInstance correlationAttribute = null;
|
||||
if (EamDbUtil.useCentralRepo() && UserPreferences.hideCentralRepoCommentsAndOccurrences()== false) {
|
||||
if (UserPreferences.hideCentralRepoCommentsAndOccurrences()== false) {
|
||||
correlationAttribute = getCorrelationAttributeInstance();
|
||||
}
|
||||
addCommentProperty(sheetSet, tags, correlationAttribute);
|
||||
|
||||
if (EamDbUtil.useCentralRepo() && UserPreferences.hideCentralRepoCommentsAndOccurrences()== false) {
|
||||
if (UserPreferences.hideCentralRepoCommentsAndOccurrences()== false) {
|
||||
addCountProperty(sheetSet, correlationAttribute);
|
||||
}
|
||||
final BlackboardArtifact artifact = getArtifact();
|
||||
|
@ -38,16 +38,12 @@ import org.openide.nodes.Node;
|
||||
import org.openide.nodes.Sheet;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.lookup.ServiceProvider;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil;
|
||||
import org.sleuthkit.autopsy.core.UserPreferences;
|
||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultPanel;
|
||||
import org.sleuthkit.autopsy.corecomponents.TableFilterNode;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.datamodel.AbstractAbstractFileNode;
|
||||
import org.sleuthkit.autopsy.datamodel.FileNode;
|
||||
import org.sleuthkit.autopsy.datamodel.NodeProperty;
|
||||
import org.sleuthkit.autopsy.directorytree.DataResultFilterNode;
|
||||
import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
@ -71,7 +67,6 @@ import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHO
|
||||
import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
|
||||
import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT;
|
||||
import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEXT;
|
||||
import org.sleuthkit.datamodel.ContentTag;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,7 @@ import javax.swing.JPanel;
|
||||
import org.netbeans.spi.options.OptionsPanelController;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.CasePreferences;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb;
|
||||
import org.sleuthkit.autopsy.core.UserPreferences;
|
||||
import org.sleuthkit.autopsy.coreutils.TimeZoneUtils;
|
||||
import org.sleuthkit.autopsy.directorytree.DirectoryTreeTopComponent;
|
||||
@ -75,8 +75,8 @@ public class ViewPreferencesPanel extends JPanel implements OptionsPanel {
|
||||
dataSourcesHideSlackCheckbox.setSelected(UserPreferences.hideSlackFilesInDataSourcesTree());
|
||||
viewsHideSlackCheckbox.setSelected(UserPreferences.hideSlackFilesInViewsTree());
|
||||
|
||||
commentsOccurencesColumnsCheckbox.setEnabled(EamDbUtil.useCentralRepo());
|
||||
commentsOccurencesColumnWrapAroundText.setEnabled(EamDbUtil.useCentralRepo());
|
||||
commentsOccurencesColumnsCheckbox.setEnabled(EamDb.isEnabled());
|
||||
commentsOccurencesColumnWrapAroundText.setEnabled(EamDb.isEnabled());
|
||||
commentsOccurencesColumnsCheckbox.setSelected(UserPreferences.hideCentralRepoCommentsAndOccurrences());
|
||||
|
||||
hideOtherUsersTagsCheckbox.setSelected(UserPreferences.showOnlyCurrentUserTags());
|
||||
|
@ -48,7 +48,6 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNor
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil;
|
||||
import org.sleuthkit.autopsy.core.UserPreferences;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable.HasCommentStatus;
|
||||
@ -572,7 +571,7 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
|
||||
|
||||
CorrelationAttributeInstance getCorrelationAttributeInstance() {
|
||||
CorrelationAttributeInstance attribute = null;
|
||||
if (EamDbUtil.useCentralRepo() && !UserPreferences.hideCentralRepoCommentsAndOccurrences()) {
|
||||
if (EamDb.isEnabled() && !UserPreferences.hideCentralRepoCommentsAndOccurrences()) {
|
||||
attribute = EamArtifactUtil.getInstanceFromContent(content);
|
||||
}
|
||||
return attribute;
|
||||
|
@ -54,7 +54,6 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNor
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil;
|
||||
import org.sleuthkit.autopsy.core.UserPreferences;
|
||||
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable.Score;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
@ -572,7 +571,7 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
|
||||
|
||||
protected final CorrelationAttributeInstance getCorrelationAttributeInstance() {
|
||||
CorrelationAttributeInstance correlationAttribute = null;
|
||||
if (EamDbUtil.useCentralRepo()) {
|
||||
if (EamDb.isEnabled()) {
|
||||
correlationAttribute = EamArtifactUtil.getInstanceFromContent(associated);
|
||||
}
|
||||
return correlationAttribute;
|
||||
|
@ -18,11 +18,14 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.experimental.autoingest;
|
||||
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.EventQueue;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestMonitor.AutoIngestNodeState;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.sleuthkit.autopsy.healthmonitor.HealthMonitorDashboard;
|
||||
|
||||
/**
|
||||
@ -33,12 +36,18 @@ final class AinStatusDashboard extends javax.swing.JPanel implements Observer {
|
||||
|
||||
private final AutoIngestMonitor autoIngestMonitor;
|
||||
private final AinStatusPanel nodesPanel;
|
||||
private final static String AIN_REFRESH_THREAD_NAME = "AID-refresh-jobs-%d";
|
||||
private final static int AIN_REFRESH_INTERVAL_SECS = 30;
|
||||
private final static int AIN_DELAY_BEFORE_FIRST_REFRESH = 0;
|
||||
private final ScheduledThreadPoolExecutor scheduledRefreshThreadPoolExecutor;
|
||||
private AtomicBoolean scheduledRefreshStarted = new AtomicBoolean(false);
|
||||
|
||||
/**
|
||||
* Creates new form AutoIngestNodeStatus
|
||||
*/
|
||||
AinStatusDashboard(AutoIngestMonitor monitor) {
|
||||
initComponents();
|
||||
scheduledRefreshThreadPoolExecutor = new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat(AIN_REFRESH_THREAD_NAME).build());
|
||||
autoIngestMonitor = monitor;
|
||||
nodesPanel = new AinStatusPanel();
|
||||
nodesPanel.setSize(nodesPanel.getSize());
|
||||
@ -172,10 +181,12 @@ final class AinStatusDashboard extends javax.swing.JPanel implements Observer {
|
||||
|
||||
@Override
|
||||
public void update(Observable o, Object arg) {
|
||||
if (arg instanceof AutoIngestNodeState) {
|
||||
EventQueue.invokeLater(() -> {
|
||||
refreshTables();
|
||||
});
|
||||
if (!scheduledRefreshStarted.getAndSet(true)) {
|
||||
scheduledRefreshThreadPoolExecutor.scheduleWithFixedDelay(() -> {
|
||||
EventQueue.invokeLater(() -> {
|
||||
refreshTables();
|
||||
});
|
||||
}, AIN_DELAY_BEFORE_FIRST_REFRESH, AIN_REFRESH_INTERVAL_SECS, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,8 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.experimental.autoingest;
|
||||
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import java.awt.Cursor;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import java.util.logging.Level;
|
||||
import java.awt.Color;
|
||||
import java.awt.EventQueue;
|
||||
@ -29,8 +28,13 @@ import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashSet;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.UIManager;
|
||||
@ -49,12 +53,17 @@ final class AutoIngestDashboard extends JPanel implements Observer {
|
||||
|
||||
private final static String ADMIN_ACCESS_FILE_NAME = "_aiaa"; // NON-NLS
|
||||
private final static String ADMIN_ACCESS_FILE_PATH = Paths.get(PlatformUtil.getUserConfigDirectory(), ADMIN_ACCESS_FILE_NAME).toString();
|
||||
private final static String AID_REFRESH_THREAD_NAME = "AID-refresh-jobs-%d";
|
||||
private final static int AID_REFRESH_INTERVAL_SECS = 30;
|
||||
private final static int AID_DELAY_BEFORE_FIRST_REFRESH = 0;
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger LOGGER = Logger.getLogger(AutoIngestDashboard.class.getName());
|
||||
private AutoIngestMonitor autoIngestMonitor;
|
||||
private AutoIngestJobsPanel pendingJobsPanel;
|
||||
private AutoIngestJobsPanel runningJobsPanel;
|
||||
private AutoIngestJobsPanel completedJobsPanel;
|
||||
private final ScheduledThreadPoolExecutor scheduledRefreshThreadPoolExecutor;
|
||||
private AtomicBoolean scheduledRefreshStarted = new AtomicBoolean(false);
|
||||
|
||||
/**
|
||||
* Maintain a mapping of each service to it's last status update.
|
||||
@ -88,7 +97,7 @@ final class AutoIngestDashboard extends JPanel implements Observer {
|
||||
|
||||
private AutoIngestDashboard() {
|
||||
this.statusByService = new ConcurrentHashMap<>();
|
||||
|
||||
scheduledRefreshThreadPoolExecutor = new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat(AID_REFRESH_THREAD_NAME).build());
|
||||
initComponents();
|
||||
statusByService.put(ServicesMonitor.Service.REMOTE_CASE_DATABASE.toString(), NbBundle.getMessage(AutoIngestDashboard.class, "AutoIngestDashboard.tbServicesStatusMessage.Message.Down"));
|
||||
statusByService.put(ServicesMonitor.Service.REMOTE_KEYWORD_SEARCH.toString(), NbBundle.getMessage(AutoIngestDashboard.class, "AutoIngestDashboard.tbServicesStatusMessage.Message.Down"));
|
||||
@ -240,6 +249,7 @@ final class AutoIngestDashboard extends JPanel implements Observer {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
autoIngestMonitor.startUp();
|
||||
|
||||
} catch (AutoIngestMonitor.AutoIngestMonitorException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Unable to start up Auto Ingest Monitor", ex);
|
||||
}
|
||||
@ -257,18 +267,19 @@ final class AutoIngestDashboard extends JPanel implements Observer {
|
||||
|
||||
@Override
|
||||
public void update(Observable observable, Object arg) {
|
||||
if (arg == null ) {
|
||||
EventQueue.invokeLater(() -> {
|
||||
refreshTables();
|
||||
});
|
||||
if (!scheduledRefreshStarted.getAndSet(true)) {
|
||||
scheduledRefreshThreadPoolExecutor.scheduleWithFixedDelay(() -> {
|
||||
EventQueue.invokeLater(() -> {
|
||||
refreshTables();
|
||||
});
|
||||
}, AID_DELAY_BEFORE_FIRST_REFRESH, AID_REFRESH_INTERVAL_SECS, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the table models using a jobs snapshot and refreshes the JTables
|
||||
* Reloads the table models using a RefreshChildrenEvent and refreshes the JTables
|
||||
* that use the models.
|
||||
*
|
||||
* @param nodeStateSnapshot The jobs snapshot.
|
||||
*/
|
||||
void refreshTables() {
|
||||
pendingJobsPanel.refresh(new RefreshChildrenEvent(autoIngestMonitor));
|
||||
|
@ -164,7 +164,7 @@ final class AutoIngestJobsPanel extends javax.swing.JPanel implements ExplorerMa
|
||||
* Update the contents of this AutoIngestJobsPanel while retaining currently
|
||||
* selected node.
|
||||
*
|
||||
* @param jobsSnapshot - the JobsSnapshot which will provide the new
|
||||
* @param refreshEvent - the AutoIngestRefreshEvent which will provide the new
|
||||
* contents
|
||||
*/
|
||||
void refresh(AutoIngestRefreshEvent refreshEvent) {
|
||||
|
@ -198,6 +198,7 @@ final class AutoIngestMonitor extends Observable implements PropertyChangeListen
|
||||
runningJob.setModuleRuntimesSnapshot(job.getModuleRunTimes());
|
||||
runningJob.setProcessingStage(job.getProcessingStage(), job.getProcessingStageStartDate());
|
||||
runningJob.setProcessingStatus(job.getProcessingStatus());
|
||||
break;
|
||||
}
|
||||
}
|
||||
setChanged();
|
||||
@ -734,7 +735,7 @@ final class AutoIngestMonitor extends Observable implements PropertyChangeListen
|
||||
stopWatch.start();
|
||||
eventPublisher.publishRemotely(new AutoIngestCaseDeletedEvent(caseName, LOCAL_HOST_NAME, AutoIngestManager.getSystemUserNameProperty()));
|
||||
stopWatch.stop();
|
||||
LOGGER.log(Level.INFO, String.format("Used %d s to publish job deletion event for case %s at %s", stopWatch.getElapsedTimeSecs(), caseName,caseDirectoryPath));
|
||||
LOGGER.log(Level.INFO, String.format("Used %d s to publish job deletion event for case %s at %s", stopWatch.getElapsedTimeSecs(), caseName, caseDirectoryPath));
|
||||
}
|
||||
|
||||
return CaseDeletionResult.FULLY_DELETED;
|
||||
|
Loading…
x
Reference in New Issue
Block a user