From a3d6895bf4eed74e2f376eea1d7ea9171e7d7f6c Mon Sep 17 00:00:00 2001 From: esaunders Date: Tue, 15 May 2018 16:03:22 -0400 Subject: [PATCH] Added support for showing case log from dashboard. --- .../autoingest/AutoIngestAdminActions.java | 56 +++++++++++++++++-- .../autoingest/AutoIngestJobsNode.java | 2 +- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestAdminActions.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestAdminActions.java index 0a5e6d0ac0..32d2f0021e 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestAdminActions.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestAdminActions.java @@ -19,8 +19,11 @@ package org.sleuthkit.autopsy.experimental.autoingest; import java.awt.Cursor; +import java.awt.Desktop; import java.awt.EventQueue; import java.awt.event.ActionEvent; +import java.io.IOException; +import java.nio.file.Path; import java.util.logging.Level; import javax.swing.AbstractAction; import javax.swing.JOptionPane; @@ -265,8 +268,8 @@ final class AutoIngestAdminActions { AutoIngestDashboard dashboard = tc.getAutoIngestDashboard(); if (dashboard != null) { /* - * Call setCursor on this to ensure it appears (if there is - * time to see it). + * Call setCursor on this to ensure it appears (if there is time + * to see it). */ dashboard.getCompletedJobsPanel().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); EventQueue.invokeLater(() -> { @@ -359,18 +362,61 @@ final class AutoIngestAdminActions { } } - @NbBundle.Messages({"AutoIngestAdminActions.showCaseLogAction.title=Show Case Log"}) + @NbBundle.Messages({"AutoIngestAdminActions.showCaseLogAction.title=Show Case Log", + "AutoIngestAdminActions.showCaseLogActionFailed.title=Unable to display case log", + "AutoIngestAdminActions.showCaseLogActionFailed.message=Case log file does not exist", + "AutoIngestAdminActions.showCaseLogActionDialog.ok=Okay", + "AutoIngestAdminActions.showCaseLogActionDialog.cannotFindLog=Unable to find the selected case log file", + "AutoIngestAdminActions.showCaseLogActionDialog.unableToShowLogFile=Unable to show log file"}) static final class ShowCaseLogAction extends AbstractAction { private static final long serialVersionUID = 1L; + private final AutoIngestJob job; - ShowCaseLogAction() { + ShowCaseLogAction(AutoIngestJob job) { super(Bundle.AutoIngestAdminActions_showCaseLogAction_title()); + this.job = job; } @Override public void actionPerformed(ActionEvent e) { - //TODO JIRA- + if (job == null) { + return; + } + + final AutoIngestDashboardTopComponent tc = (AutoIngestDashboardTopComponent) WindowManager.getDefault().findTopComponent(AutoIngestDashboardTopComponent.PREFERRED_ID); + if (tc == null) { + return; + } + + AutoIngestDashboard dashboard = tc.getAutoIngestDashboard(); + if (dashboard != null) { + try { + Path caseDirectoryPath = job.getCaseDirectoryPath(); + if (null != caseDirectoryPath) { + Path pathToLog = AutoIngestJobLogger.getLogPath(caseDirectoryPath); + if (pathToLog.toFile().exists()) { + Desktop.getDesktop().edit(pathToLog.toFile()); + } else { + JOptionPane.showMessageDialog(dashboard, Bundle.AutoIngestAdminActions_showCaseLogActionFailed_message(), + Bundle.AutoIngestAdminActions_showCaseLogAction_title(), JOptionPane.ERROR_MESSAGE); + } + } else { + MessageNotifyUtil.Message.warn("The case directory for this job has been deleted."); + } + } catch (IOException ex) { + logger.log(Level.SEVERE, "Dashboard error attempting to display case auto ingest log", ex); + Object[] options = {Bundle.AutoIngestAdminActions_showCaseLogActionDialog_ok()}; + JOptionPane.showOptionDialog(dashboard, + Bundle.AutoIngestAdminActions_showCaseLogActionDialog_cannotFindLog(), + Bundle.AutoIngestAdminActions_showCaseLogActionDialog_unableToShowLogFile(), + JOptionPane.DEFAULT_OPTION, + JOptionPane.PLAIN_MESSAGE, + null, + options, + options[0]); + } + } } @Override diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsNode.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsNode.java index 2e229b4a10..feea741374 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsNode.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsNode.java @@ -208,7 +208,7 @@ final class AutoIngestJobsNode extends AbstractNode { case COMPLETED_JOB: actions.add(new AutoIngestAdminActions.ReprocessJobAction(autoIngestJob)); actions.add(new AutoIngestAdminActions.DeleteCaseAction(autoIngestJob)); - actions.add(new AutoIngestAdminActions.ShowCaseLogAction()); + actions.add(new AutoIngestAdminActions.ShowCaseLogAction(autoIngestJob)); break; default: }