From 81966fabb088c8b0ea26cada4b6e7a5780ef5bd0 Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Fri, 4 Oct 2019 11:39:50 -0400 Subject: [PATCH] Fix backwards compatibility issue for reports --- .../CommandLineIngestManager.java | 63 ++- .../autopsy/report/Bundle.properties | 15 +- .../autopsy/report/Bundle.properties-MERGED | 15 +- .../autopsy/report/Bundle_ja.properties | 4 + .../autopsy/report/ReportBranding.java | 2 +- ...ssDialog.form => ReportProgressPanel.form} | 8 +- .../autopsy/report/ReportProgressPanel.java | 349 ++++++++++++++- .../report/infrastructure/Bundle.properties | 13 - .../infrastructure/Bundle.properties-MERGED | 19 +- .../infrastructure/Bundle_ja.properties | 4 - .../infrastructure/ReportGenerationPanel.java | 14 +- .../infrastructure/ReportGenerator.java | 129 +++--- .../infrastructure/ReportProgressDialog.java | 405 ------------------ .../ReportProgressIndicator.java | 140 ++++++ .../infrastructure/ReportProgressLogger.java | 172 -------- .../infrastructure/ReportWizardAction.java | 20 +- .../infrastructure/ReportingConfigLoader.java | 48 ++- .../infrastructure/TableReportGenerator.java | 16 +- .../modules/bodyfile/BodyFileReport.java | 2 +- .../caseuco/CaseUcoFormatExporter.java | 2 +- .../autopsy/report/modules/kml/KMLReport.java | 2 +- .../PortableCaseReportModule.java | 2 +- .../report/modules/stix/STIXReportModule.java | 2 +- .../SaveTaggedHashesToHashDb.java | 2 +- 24 files changed, 693 insertions(+), 755 deletions(-) rename Core/src/org/sleuthkit/autopsy/report/{infrastructure/ReportProgressDialog.form => ReportProgressPanel.form} (86%) mode change 100755 => 100644 Core/src/org/sleuthkit/autopsy/report/ReportProgressPanel.java delete mode 100644 Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportProgressDialog.java create mode 100755 Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportProgressIndicator.java delete mode 100755 Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportProgressLogger.java diff --git a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java index 9768547546..578ffd5ef3 100755 --- a/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java +++ b/Core/src/org/sleuthkit/autopsy/commandlineingest/CommandLineIngestManager.java @@ -62,15 +62,16 @@ import org.sleuthkit.autopsy.ingest.IngestModuleError; import org.sleuthkit.autopsy.ingest.IngestProfiles; import org.sleuthkit.autopsy.modules.interestingitems.FilesSet; import org.sleuthkit.autopsy.modules.interestingitems.FilesSetsManager; -import org.sleuthkit.autopsy.report.infrastructure.ReportProgressLogger; +import org.sleuthkit.autopsy.progress.LoggingProgressIndicator; import org.sleuthkit.autopsy.report.infrastructure.ReportGenerator; +import org.sleuthkit.autopsy.report.infrastructure.ReportProgressIndicator; import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.TskCoreException; /** - * Allows Autopsy to be invoked with a command line arguments. Causes Autopsy to - * create a case, add a specified data source, run ingest on that data source, - * list all data source in a case, generate reports. + * Allows Autopsy to be invoked with a command line arguments. Arguments exist + * to cause Autopsy to create a case, add a specified data source, run ingest on + * that data source, list all data sources in a case, and generate reports. */ public class CommandLineIngestManager { @@ -285,7 +286,8 @@ public class CommandLineIngestManager { } // generate reports - ReportGenerator generator = new ReportGenerator(CommandLineIngestSettingsPanel.getReportingConfigName(), new ReportProgressLogger()); //NON-NLS + ReportProgressIndicator progressIndicator = new ReportProgressIndicator(new LoggingProgressIndicator()); + ReportGenerator generator = new ReportGenerator(CommandLineIngestSettingsPanel.getReportingConfigName(), progressIndicator); //NON-NLS generator.generateReports(); } catch (CaseActionException ex) { String caseDirPath = command.getInputs().get(CommandLineCommand.InputType.CASE_FOLDER_PATH.name()); @@ -332,9 +334,10 @@ public class CommandLineIngestManager { * Creates a new case using arguments passed in from command line * CREATE_CASE command. * - * @param baseCaseName Case name + * @param baseCaseName Case name * @param rootOutputDirectory Full path to directory in which case - * output folder will be created + * output folder will be created + * * @throws CaseActionException */ private void openCase(String baseCaseName, String rootOutputDirectory) throws CaseActionException { @@ -363,6 +366,7 @@ public class CommandLineIngestManager { * Opens existing case. * * @param caseFolderPath full path to case directory + * * @throws CaseActionException */ private void openCase(String caseFolderPath) throws CaseActionException { @@ -415,11 +419,34 @@ public class CommandLineIngestManager { * @param dataSource The data source. * * @throws - * AutoIngestDataSourceProcessor.AutoIngestDataSourceProcessorException if - * there was a DSP processing error + * AutoIngestDataSourceProcessor.AutoIngestDataSourceProcessorExceptioif + * there + * was + * a + * DSP + * processing + * error * - * @throws InterruptedException if the thread running the job processing - * task is interrupted while blocked, i.e., if auto ingest is shutting down. + * @throws + * InterruptedException if + * the + * thread + * running + * the + * job + * processing + * task + * is + * interrupted + * while + * blocked, + * i.e., + * if + * auto + * ingest + * is + * shutting + * down. */ private void runDataSourceProcessor(Case caseForJob, AutoIngestDataSource dataSource) throws InterruptedException, AutoIngestDataSourceProcessor.AutoIngestDataSourceProcessorException { @@ -520,14 +547,15 @@ public class CommandLineIngestManager { * profile (profile = ingest context + ingest filter) for ingest. * Otherwise use baseline configuration. * - * @param dataSource The data source to analyze. + * @param dataSource The data source to analyze. * @param ingestProfileName Name of ingest profile to use (optional) * * @throws AnalysisStartupException if there is an error analyzing the - * data source. - * @throws InterruptedException if the thread running the job processing - * task is interrupted while blocked, i.e., if auto ingest is shutting - * down. + * data source. + * @throws InterruptedException if the thread running the job + * processing task is interrupted while + * blocked, i.e., if auto ingest is + * shutting down. */ private void analyze(AutoIngestDataSource dataSource, String ingestProfileName) throws AnalysisStartupException, InterruptedException { @@ -628,6 +656,7 @@ public class CommandLineIngestManager { * ingest profiles. * * @param ingestProfileName Ingest profile name + * * @return IngestProfile object, or NULL if the profile doesn't exist */ private IngestProfiles.IngestProfile getSelectedProfile(String ingestProfileName) { @@ -649,6 +678,7 @@ public class CommandLineIngestManager { * filters (custom and standard). * * @param filterName Name of the file filter + * * @return FilesSet object, or NULL if the filter doesn't exist */ private FilesSet getSelectedFilter(String filterName) { @@ -711,6 +741,7 @@ public class CommandLineIngestManager { * Returns full path to directory where command outputs should be saved. * * @param caseForJob Case object + * * @return Full path to directory where command outputs should be saved */ private String getOutputDirPath(Case caseForJob) { diff --git a/Core/src/org/sleuthkit/autopsy/report/Bundle.properties b/Core/src/org/sleuthkit/autopsy/report/Bundle.properties index 2a296c830d..7ad1d6fca4 100644 --- a/Core/src/org/sleuthkit/autopsy/report/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/report/Bundle.properties @@ -1,4 +1,17 @@ OpenIDE-Module-Name=Report DefaultReportConfigurationPanel.infoLabel.text=This report will be configured on the next screen. ReportBranding.defaultReportTitle.text=Autopsy Forensic Report -ReportBranding.defaultReportFooter.text=Powered by Autopsy Open Source Digital Forensics Platform - www.sleuthkit.org \ No newline at end of file +ReportBranding.defaultReportFooter.text=Powered by Autopsy Open Source Digital Forensics Platform - www.sleuthkit.org +ReportProgressPanel.pathLabel.text=pathLabel +ReportProgressPanel.reportLabel.text=reportLabel +ReportProgressPanel.statusMessageLabel.text=processingLabel +ReportProgressPanel.separationLabel.text=: +ReportProgressPanel.progress.queuing=Queuing... +ReportProgressPanel.initPathLabel.noFile=No report file +ReportProgressPanel.start.cancelButton.text=Cancel +ReportProgressPanel.start.progress.text=Starting report... +ReportProgressPanel.complete.processLbl.text=Complete +ReportProgressPanel.complete.processLb2.text=Completed with error +ReportProgressPanel.complete.cancelButton.text=Complete +ReportProgressPanel.cancel.cancelButton.toolTipText=Canceled +ReportProgressPanel.cancel.procLbl.text=Canceled diff --git a/Core/src/org/sleuthkit/autopsy/report/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/report/Bundle.properties-MERGED index 2a296c830d..7ad1d6fca4 100755 --- a/Core/src/org/sleuthkit/autopsy/report/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/report/Bundle.properties-MERGED @@ -1,4 +1,17 @@ OpenIDE-Module-Name=Report DefaultReportConfigurationPanel.infoLabel.text=This report will be configured on the next screen. ReportBranding.defaultReportTitle.text=Autopsy Forensic Report -ReportBranding.defaultReportFooter.text=Powered by Autopsy Open Source Digital Forensics Platform - www.sleuthkit.org \ No newline at end of file +ReportBranding.defaultReportFooter.text=Powered by Autopsy Open Source Digital Forensics Platform - www.sleuthkit.org +ReportProgressPanel.pathLabel.text=pathLabel +ReportProgressPanel.reportLabel.text=reportLabel +ReportProgressPanel.statusMessageLabel.text=processingLabel +ReportProgressPanel.separationLabel.text=: +ReportProgressPanel.progress.queuing=Queuing... +ReportProgressPanel.initPathLabel.noFile=No report file +ReportProgressPanel.start.cancelButton.text=Cancel +ReportProgressPanel.start.progress.text=Starting report... +ReportProgressPanel.complete.processLbl.text=Complete +ReportProgressPanel.complete.processLb2.text=Completed with error +ReportProgressPanel.complete.cancelButton.text=Complete +ReportProgressPanel.cancel.cancelButton.toolTipText=Canceled +ReportProgressPanel.cancel.procLbl.text=Canceled diff --git a/Core/src/org/sleuthkit/autopsy/report/Bundle_ja.properties b/Core/src/org/sleuthkit/autopsy/report/Bundle_ja.properties index 3e5659464f..f666513e92 100644 --- a/Core/src/org/sleuthkit/autopsy/report/Bundle_ja.properties +++ b/Core/src/org/sleuthkit/autopsy/report/Bundle_ja.properties @@ -2,3 +2,7 @@ OpenIDE-Module-Name=\u30ec\u30dd\u30fc\u30c8 DefaultReportConfigurationPanel.infoLabel.text=\u3053\u306e\u30ec\u30dd\u30fc\u30c8\u306f\u6b21\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u3067\u8a2d\u5b9a\u3055\u308c\u307e\u3059\u3002 ReportBranding.defaultReportTitle.text=Autopsy\u30d5\u30a9\u30ec\u30f3\u30b8\u30c3\u30af\u30ec\u30dd\u30fc\u30c8 ReportBranding.defaultReportFooter.text=Autopsy\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9\u30fb\u30c7\u30b8\u30bf\u30eb\u30fb\u30d5\u30a9\u30ec\u30f3\u30b8\u30c3\u30af\u30fb\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u306b\u3088\u308a\u63d0\u4f9b - www.sleuthkit.org +ReportProgressPanel.pathLabel.text=\u30d1\u30b9\u30e9\u30d9\u30eb +ReportProgressPanel.reportLabel.text=\u30ec\u30dd\u30fc\u30c8\u30e9\u30d9\u30eb +ReportProgressPanel.statusMessageLabel.text=\u30d7\u30ed\u30bb\u30b7\u30f3\u30b0\u30e9\u30d9\u30eb +ReportProgressPanel.separationLabel.text=: diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportBranding.java b/Core/src/org/sleuthkit/autopsy/report/ReportBranding.java index ba50f34726..93b4ee0081 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportBranding.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportBranding.java @@ -63,7 +63,7 @@ public final class ReportBranding implements ReportBrandingProviderI { //initialize with extracting of resource files if needed, ensure 1 writer at a time synchronized (ReportBranding.class) { - reportsBrandingDir = PlatformUtil.getUserConfigDirectory() + File.separator + ReportGenerator.REPORTS_DIR + File.separator + reportsBrandingDir = PlatformUtil.getUserConfigDirectory() + File.separator + ReportGenerator.getReportsDirectory() + File.separator + "branding"; //NON-NLS File brandingDir = new File(reportsBrandingDir); if (!brandingDir.exists()) { diff --git a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportProgressDialog.form b/Core/src/org/sleuthkit/autopsy/report/ReportProgressPanel.form similarity index 86% rename from Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportProgressDialog.form rename to Core/src/org/sleuthkit/autopsy/report/ReportProgressPanel.form index 08cd8ec3f4..597dd89df4 100644 --- a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportProgressDialog.form +++ b/Core/src/org/sleuthkit/autopsy/report/ReportProgressPanel.form @@ -79,7 +79,7 @@ - + @@ -91,7 +91,7 @@ - + @@ -104,14 +104,14 @@ - + - + diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportProgressPanel.java b/Core/src/org/sleuthkit/autopsy/report/ReportProgressPanel.java old mode 100755 new mode 100644 index 486e54789f..f3128a7290 --- a/Core/src/org/sleuthkit/autopsy/report/ReportProgressPanel.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportProgressPanel.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2019 Basis Technology Corp. + * Copyright 2012-2019 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,11 +18,30 @@ */ package org.sleuthkit.autopsy.report; +import org.openide.util.NbBundle; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Desktop; +import java.awt.EventQueue; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.File; +import java.io.IOException; +import java.util.logging.Level; +import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.report.infrastructure.ReportProgressIndicator; + /** - * This interface is necessary in order to not break backwards compatibility of - * GeneralReportModule interface. See JIRA-5354. + * A panel used by a report generation module to show progress. */ -public interface ReportProgressPanel { +@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives +public class ReportProgressPanel extends javax.swing.JPanel { + + private static final long serialVersionUID = 1L; + private static final Logger logger = Logger.getLogger(ReportProgressPanel.class.getName()); + private static final Color GREEN = new Color(50, 205, 50); + private static final Color RED = new Color(178, 34, 34); + private volatile ReportStatus status; /** * Used by a report generation module to communicate report generation @@ -37,46 +56,155 @@ public interface ReportProgressPanel { ERROR } + /** + * Constructs a panel used by report generation module to show progress. + */ + public ReportProgressPanel() { + initComponents(); + reportProgressBar.setIndeterminate(true); + reportProgressBar.setMaximum(100); + statusMessageLabel.setText(NbBundle.getMessage(this.getClass(), "ReportProgressPanel.progress.queuing")); + status = ReportStatus.QUEUING; + reportLabel.setText(""); + pathLabel.setText(""); //NON-NLS + } + + /** + * Sets label text. + * + * @param reportName The name of the report being generated. + * @param reportPath The path to the report file. + */ + public void setLabels(String reportName, String reportPath) { + reportLabel.setText(reportName); + if (null != reportPath) { + pathLabel.setText("" + shortenPath(reportPath) + ""); //NON-NLS + pathLabel.setToolTipText(reportPath); + String linkPath = reportPath; + pathLabel.addMouseListener(new MouseListener() { + + @Override + public void mouseClicked(MouseEvent mouseEvent) { + } + + @Override + public void mousePressed(MouseEvent mouseEvent) { + } + + @Override + public void mouseReleased(MouseEvent mouseEvent) { + File file = new File(linkPath); + try { + Desktop.getDesktop().open(file); + } catch (IOException ioex) { + logger.log(Level.SEVERE, "Error opening report file", ioex); + } catch (IllegalArgumentException iaEx) { + logger.log(Level.SEVERE, "Error opening report file", iaEx); + try { + Desktop.getDesktop().open(file.getParentFile()); + } catch (IOException ioEx2) { + logger.log(Level.SEVERE, "Error opening report file parent", ioEx2); + } + } + } + + @Override + public void mouseEntered(MouseEvent e3) { + pathLabel.setForeground(Color.DARK_GRAY); + setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + } + + @Override + public void mouseExited(MouseEvent e4) { + pathLabel.setForeground(Color.BLACK); + setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + }); + } else { + pathLabel.setText(NbBundle.getMessage(this.getClass(), "ReportProgressPanel.initPathLabel.noFile")); + } + } + /** * Gets the current status of the generation of the report. * * @return The report generation status as a ReportStatus enum. */ - public ReportStatus getStatus(); + public ReportStatus getStatus() { + return status; + } + + /** + * Sets the current status of the generation of the report. + * + * @param status The current status. + */ + protected void setStatus(ReportStatus status) { + this.status = status; + } /** * Starts the progress bar component of this panel. */ - public void start(); + public void start() { + EventQueue.invokeLater(() -> { + statusMessageLabel.setText(NbBundle.getMessage(this.getClass(), "ReportProgressPanel.start.progress.text")); + status = ReportStatus.RUNNING; + }); + } /** * Sets the maximum value of the progress bar component of this panel. * * @param max The maximum value. */ - public void setMaximumProgress(int max); + public void setMaximumProgress(int max) { + EventQueue.invokeLater(() -> { + if (status != ReportStatus.CANCELED) { + reportProgressBar.setMaximum(max); + } + }); + } /** * Increments the current value of the progress bar component of this panel * by one unit. */ - public void increment(); + public void increment() { + EventQueue.invokeLater(() -> { + if (status != ReportStatus.CANCELED) { + reportProgressBar.setValue(reportProgressBar.getValue() + 1); + } + }); + } /** * Sets the current value of the progress bar component of this panel. * * @param value The value to be set. */ - public void setProgress(int value); + public void setProgress(int value) { + EventQueue.invokeLater(() -> { + if (status != ReportStatus.CANCELED) { + reportProgressBar.setValue(value); + } + }); + } /** * Changes the the progress bar component of this panel to be determinate or * indeterminate. * * @param indeterminate True if the progress bar should be set to - * indeterminate. + * indeterminate. */ - public void setIndeterminate(boolean indeterminate); + public void setIndeterminate(boolean indeterminate) { + EventQueue.invokeLater(() -> { + if (status != ReportStatus.CANCELED) { + reportProgressBar.setIndeterminate(indeterminate); + } + }); + } /** * Changes the status message label component of this panel to show a given @@ -85,7 +213,13 @@ public interface ReportProgressPanel { * * @param statusMessage String to use as label text. */ - public void updateStatusLabel(String statusMessage); + public void updateStatusLabel(String statusMessage) { + EventQueue.invokeLater(() -> { + if (status != ReportStatus.CANCELED) { + statusMessageLabel.setText(statusMessage); + } + }); + } /** * Makes the components of this panel indicate the final status of @@ -93,16 +227,196 @@ public interface ReportProgressPanel { * * @param reportStatus The final status, must be COMPLETE or ERROR. */ - public void complete(ReportStatus reportStatus); + public void complete(ReportStatus reportStatus) { + + switch (reportStatus) { + case COMPLETE: + complete(reportStatus, NbBundle.getMessage(this.getClass(), "ReportProgressPanel.complete.processLbl.text")); + break; + case ERROR: + complete(reportStatus, NbBundle.getMessage(this.getClass(), "ReportProgressPanel.complete.processLb2.text")); + break; + default: + complete(reportStatus, ""); + break; + } + } /** * Makes the components of this panel indicate the final status of * generation of the report. * - * @param reportStatus The final status, must be COMPLETE or ERROR. + * @param reportStatus The final status, must be COMPLETE or ERROR. * @param statusMessage String to use as label or error text. */ - public void complete(ReportStatus reportStatus, String statusMessage); + public void complete(ReportStatus reportStatus, String statusMessage) { + EventQueue.invokeLater(() -> { + reportProgressBar.setIndeterminate(false); + if (status != ReportStatus.CANCELED) { + switch (reportStatus) { + case COMPLETE: { + ReportStatus oldValue = status; + status = ReportStatus.COMPLETE; + statusMessageLabel.setForeground(Color.BLACK); + statusMessageLabel.setText(statusMessage); + reportProgressBar.setValue(reportProgressBar.getMaximum()); + reportProgressBar.setStringPainted(true); + reportProgressBar.setForeground(GREEN); + reportProgressBar.setString("Complete"); //NON-NLS + firePropertyChange(ReportStatus.COMPLETE.toString(), oldValue, status); + break; + } + case ERROR: { + ReportStatus oldValue = status; + status = ReportStatus.ERROR; + statusMessageLabel.setForeground(RED); + statusMessageLabel.setText(statusMessage); + reportProgressBar.setValue(reportProgressBar.getMaximum()); + reportProgressBar.setStringPainted(true); + reportProgressBar.setForeground(RED); + reportProgressBar.setString("Error"); //NON-NLS + firePropertyChange(ReportStatus.COMPLETE.toString(), oldValue, status); + break; + } + default: { + break; + } + } + } + }); + } + + /** + * Makes the components of this panel indicate generation of the report was + * cancelled. + */ + public void cancel() { + switch (status) { + case COMPLETE: + break; + case CANCELED: + break; + case ERROR: + break; + default: + ReportStatus oldValue = status; + status = ReportStatus.CANCELED; + reportProgressBar.setIndeterminate(false); + reportProgressBar.setValue(0); + reportProgressBar.setStringPainted(true); + reportProgressBar.setForeground(RED); // Red + reportProgressBar.setString("Cancelled"); //NON-NLS + firePropertyChange(ReportStatus.CANCELED.toString(), oldValue, status); + statusMessageLabel.setForeground(RED); + statusMessageLabel.setText(NbBundle.getMessage(this.getClass(), "ReportProgressPanel.cancel.procLbl.text")); + break; + } + } + + /** + * Gets a shortened version of a file path. + * + * @param path The path to shorten. + * + * @return The shortened path. + */ + private String shortenPath(String path) { + if (path.length() > 100) { + return path.substring(0, 10 + path.substring(10).indexOf(File.separator) + 1) + "..." + + path.substring((path.length() - 70) + path.substring(path.length() - 70).indexOf(File.separator)); + } else { + return path; + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + reportProgressBar = new javax.swing.JProgressBar(); + reportLabel = new javax.swing.JLabel(); + pathLabel = new javax.swing.JLabel(); + separationLabel = new javax.swing.JLabel(); + statusMessageLabel = new javax.swing.JLabel(); + + setFont(getFont().deriveFont(getFont().getStyle() & ~java.awt.Font.BOLD, 11)); + setMinimumSize(new java.awt.Dimension(486, 68)); + + reportProgressBar.setFont(reportProgressBar.getFont().deriveFont(reportProgressBar.getFont().getStyle() & ~java.awt.Font.BOLD, 11)); + + reportLabel.setFont(reportLabel.getFont().deriveFont(reportLabel.getFont().getStyle() | java.awt.Font.BOLD, 11)); + org.openide.awt.Mnemonics.setLocalizedText(reportLabel, org.openide.util.NbBundle.getMessage(ReportProgressPanel.class, "ReportProgressPanel.reportLabel.text")); // NOI18N + + pathLabel.setFont(pathLabel.getFont().deriveFont(pathLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11)); + org.openide.awt.Mnemonics.setLocalizedText(pathLabel, org.openide.util.NbBundle.getMessage(ReportProgressPanel.class, "ReportProgressPanel.pathLabel.text")); // NOI18N + pathLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP); + + separationLabel.setFont(separationLabel.getFont().deriveFont(separationLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11)); + org.openide.awt.Mnemonics.setLocalizedText(separationLabel, org.openide.util.NbBundle.getMessage(ReportProgressPanel.class, "ReportProgressPanel.separationLabel.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(statusMessageLabel, org.openide.util.NbBundle.getMessage(ReportProgressPanel.class, "ReportProgressPanel.statusMessageLabel.text")); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(statusMessageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(reportProgressBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addComponent(reportLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(separationLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(pathLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 548, Short.MAX_VALUE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(reportProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(reportLabel) + .addComponent(pathLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(separationLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(statusMessageLabel) + .addGap(13, 13, 13)) + ); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel pathLabel; + private javax.swing.JLabel reportLabel; + private javax.swing.JProgressBar reportProgressBar; + private javax.swing.JLabel separationLabel; + private javax.swing.JLabel statusMessageLabel; + // End of variables declaration//GEN-END:variables + + /** + * Constructs a panel used by a report generation module to show progress. + * + * @param reportName The report name. + * @param reportPath The report path. + * + * @deprecated Use {@link #ReportProgressPanel()} and {@link #setLabels()} + * instead. + */ + @Deprecated + public ReportProgressPanel(String reportName, String reportPath) { + this(); + setLabels(reportName, reportPath); + } /** * Makes the components of this panel indicate the generation of the report @@ -111,5 +425,8 @@ public interface ReportProgressPanel { * @deprecated Use {@link #complete(ReportStatus)} */ @Deprecated - public void complete(); + public void complete() { + complete(ReportStatus.COMPLETE); + } + } diff --git a/Core/src/org/sleuthkit/autopsy/report/infrastructure/Bundle.properties b/Core/src/org/sleuthkit/autopsy/report/infrastructure/Bundle.properties index 38c1f3696d..c6f840be32 100755 --- a/Core/src/org/sleuthkit/autopsy/report/infrastructure/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/report/infrastructure/Bundle.properties @@ -6,10 +6,6 @@ ReportWizardFileOptionsVisualPanel.selectAllButton.text=Select All ReportWizardPortableCaseOptionsVisualPanel.errorLabel.text=Windows only ReportWizardPortableCaseOptionsVisualPanel.compressCheckbox.toolTipText= ReportWizardPortableCaseOptionsVisualPanel.compressCheckbox.text=Package case into an archive: -ReportProgressDialog.reportLabel.text=reportLabel -ReportProgressDialog.statusMessageLabel.text=processingLabel -ReportProgressDialog.separationLabel.text=: -ReportProgressDialog.pathLabel.text=pathLabel PortableCaseTagsListPanel.jAllTagsCheckBox.text=All Tagged Results PortableCaseTagsListPanel.deselectButton.text=Deselect All PortableCaseTagsListPanel.selectButton.text=Select All @@ -151,15 +147,6 @@ ReportGenerator.artTableColHdr.localPath=Local path ReportGenerator.artTableColHdr.remotePath=Remote path ReportGenerator.errors.reportErrorTitle=Error generating report ReportGenerator.errors.reportErrorText=Error generating report: -ReportProgressDialog.progress.queuing=Queuing... -ReportProgressDialog.initPathLabel.noFile=No report file -ReportProgressDialog.start.cancelButton.text=Cancel -ReportProgressDialog.start.progress.text=Starting report... -ReportProgressDialog.complete.processLbl.text=Complete -ReportProgressDialog.complete.processLb2.text=Completed with error -ReportProgressDialog.complete.cancelButton.text=Complete -ReportProgressDialog.cancel.cancelButton.toolTipText=Canceled -ReportProgressDialog.cancel.procLbl.text=Canceled ReportVisualPanel1.getName.text=Select and Configure Report Modules ReportVisualPanel2.getName.text=Configure Report ReportWizardAction.actionName.text=Generate Report diff --git a/Core/src/org/sleuthkit/autopsy/report/infrastructure/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/report/infrastructure/Bundle.properties-MERGED index b2ca427081..c3bca8db45 100755 --- a/Core/src/org/sleuthkit/autopsy/report/infrastructure/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/report/infrastructure/Bundle.properties-MERGED @@ -9,16 +9,18 @@ PortableCaseTagsListPanel.error.noOpenCase=There is no case open ReportGenerator.artTableColHdr.comment=Comment ReportGenerator.errList.noOpenCase=No open case available. ReportGenerator.tagTable.header.userName=User Name +ReportProgressIndicator.cancelledMessage=Report generation cancelled +ReportProgressIndicator.completedMessage=Report generation completed +ReportProgressIndicator.completedWithErrorsMessage=Report generation completed with errors +ReportProgressIndicator.startMessage=Report generation started +ReportProgressIndicator.switchToDeterminateMessage=Report generation progress switched to determinate +ReportProgressIndicator.switchToIndeterminateMessage=Report generation progress switched to indeterminate ReportWizardFileOptionsVisualPanel.jLabel1.text=Select items to include in File Report: ReportWizardFileOptionsVisualPanel.deselectAllButton.text=Deselect All ReportWizardFileOptionsVisualPanel.selectAllButton.text=Select All ReportWizardPortableCaseOptionsVisualPanel.errorLabel.text=Windows only ReportWizardPortableCaseOptionsVisualPanel.compressCheckbox.toolTipText= ReportWizardPortableCaseOptionsVisualPanel.compressCheckbox.text=Package case into an archive: -ReportProgressDialog.reportLabel.text=reportLabel -ReportProgressDialog.statusMessageLabel.text=processingLabel -ReportProgressDialog.separationLabel.text=: -ReportProgressDialog.pathLabel.text=pathLabel PortableCaseTagsListPanel.jAllTagsCheckBox.text=All Tagged Results PortableCaseTagsListPanel.deselectButton.text=Deselect All PortableCaseTagsListPanel.selectButton.text=Select All @@ -160,15 +162,6 @@ ReportGenerator.artTableColHdr.localPath=Local path ReportGenerator.artTableColHdr.remotePath=Remote path ReportGenerator.errors.reportErrorTitle=Error generating report ReportGenerator.errors.reportErrorText=Error generating report: -ReportProgressDialog.progress.queuing=Queuing... -ReportProgressDialog.initPathLabel.noFile=No report file -ReportProgressDialog.start.cancelButton.text=Cancel -ReportProgressDialog.start.progress.text=Starting report... -ReportProgressDialog.complete.processLbl.text=Complete -ReportProgressDialog.complete.processLb2.text=Completed with error -ReportProgressDialog.complete.cancelButton.text=Complete -ReportProgressDialog.cancel.cancelButton.toolTipText=Canceled -ReportProgressDialog.cancel.procLbl.text=Canceled ReportVisualPanel1.getName.text=Select and Configure Report Modules ReportVisualPanel2.getName.text=Configure Report ReportWizardAction.actionName.text=Generate Report diff --git a/Core/src/org/sleuthkit/autopsy/report/infrastructure/Bundle_ja.properties b/Core/src/org/sleuthkit/autopsy/report/infrastructure/Bundle_ja.properties index 6aefb4b05b..c911dd381d 100755 --- a/Core/src/org/sleuthkit/autopsy/report/infrastructure/Bundle_ja.properties +++ b/Core/src/org/sleuthkit/autopsy/report/infrastructure/Bundle_ja.properties @@ -2,10 +2,6 @@ CTL_ReportWizardAction=\u30ec\u30dd\u30fc\u30c8\u3092\u5b9f\u884c ReportWizardFileOptionsVisualPanel.selectAllButton.text=\u5168\u3066\u9078\u629e ReportWizardFileOptionsVisualPanel.jLabel1.text=\u30d5\u30a1\u30a4\u30eb\u30ec\u30dd\u30fc\u30c8\u306b\u542b\u3081\u308b\u30a2\u30a4\u30c6\u30e0\u3092\u9078\u629e\u3057\u3066\u4e0b\u3055\u3044\uff1a ReportWizardFileOptionsVisualPanel.deselectAllButton.text=\u5168\u3066\u9078\u629e\u89e3\u9664 -ReportProgressDialog.pathLabel.text=\u30d1\u30b9\u30e9\u30d9\u30eb -ReportProgressDialog.reportLabel.text=\u30ec\u30dd\u30fc\u30c8\u30e9\u30d9\u30eb -ReportProgressDialog.statusMessageLabel.text=\u30d7\u30ed\u30bb\u30b7\u30f3\u30b0\u30e9\u30d9\u30eb -ReportProgressDialog.separationLabel.text=: ReportGenerationPanel.closeButton.text=\u9589\u3058\u308b ReportGenerationPanel.cancelButton.actionCommand=\u30ad\u30e3\u30f3\u30bb\u30eb ReportGenerationPanel.cancelButton.text=\u30ad\u30e3\u30f3\u30bb\u30eb diff --git a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportGenerationPanel.java b/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportGenerationPanel.java index ec391d6d93..021c330372 100644 --- a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportGenerationPanel.java +++ b/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportGenerationPanel.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2018 Basis Technology Corp. + * Copyright 2012-2018 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,21 +25,21 @@ import javax.swing.Box; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import org.openide.util.NbBundle; -import org.sleuthkit.autopsy.report.ReportProgressPanel; import org.sleuthkit.autopsy.report.ReportProgressPanel.ReportStatus; +import org.sleuthkit.autopsy.report.ReportProgressPanel; /** * A panel that displays a panel used by a report generation module to show * progress. It provides OK and Cancel buttons. */ @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives -class ReportGenerationPanel extends javax.swing.JPanel { +final class ReportGenerationPanel extends javax.swing.JPanel { private static final long serialVersionUID = 1L; private final GridBagConstraints constraints; private final Component glue; private ActionListener actionListener; - ReportProgressDialog progressPanel; + private final ReportProgressPanel progressPanel; /** * Constructs a panel that displays a panel used by a report generation @@ -54,10 +54,10 @@ class ReportGenerationPanel extends javax.swing.JPanel { constraints.gridy = 0; constraints.weightx = 1.0; glue = Box.createVerticalGlue(); - progressPanel = new ReportProgressDialog(); + progressPanel = new ReportProgressPanel(); } - - ReportProgressDialog getProgressPanel() { + + ReportProgressPanel getProgressPanel() { return progressPanel; } diff --git a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportGenerator.java b/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportGenerator.java index 68d69ed88f..8e21086b55 100644 --- a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportGenerator.java +++ b/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportGenerator.java @@ -41,7 +41,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.logging.Level; import javax.swing.JDialog; -import javax.swing.JFrame; import org.openide.filesystems.FileUtil; import org.openide.util.NbBundle; import org.openide.windows.WindowManager; @@ -55,24 +54,33 @@ import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskData; +/** + * A report generator that generates one or more reports by running + * user-selected report modules. + */ public class ReportGenerator { private static final Logger logger = Logger.getLogger(ReportGenerator.class.getName()); - - private ReportProgressPanel progressPanel = null; - private ReportGenerationPanel reportGenerationPanel = null; - private static final String REPORT_PATH_FMT_STR = "%s" + File.separator + "%s %s %s" + File.separator; - + private static final String REPORTS_DIR = "Reports"; //NON-NLS private final String configName; - - public static final String REPORTS_DIR = "Reports"; //NON-NLS - - private List errorList; + private final ReportGenerationPanel reportGenerationPanel; + private final ReportProgressPanel progressIndicator; + private List errorList = new ArrayList<>(); /** - * Displays the list of errors during report generation in user-friendly - * way. + * Gets the name of the reports directory within the case direcotry + * hierarchy. + * + * @return The directory name. + */ + public static String getReportsDirectory() { + return REPORTS_DIR; + } + + /** + * Displays a list of errors emitted by report modules during report + * generation using this report generator's report progress indicator. */ private void displayReportErrors() { if (!errorList.isEmpty()) { @@ -80,41 +88,41 @@ public class ReportGenerator { for (String error : errorList) { errorString += error + "\n"; } - progressPanel.updateStatusLabel(errorString); + progressIndicator.updateStatusLabel(errorString); } } /** - * Creates a report generator. This constructor uses a logger instead of UI - * panel. + * Constructs a report generator that generates one or more reports by + * running user-selected report modules and uses a report generation panel + * to display progress. * - * @param configName Name of the reporting configuration to use - * @param progress Fully instantiated progress logger - */ - public ReportGenerator(String configName, ReportProgressLogger progress) { - this.errorList = new ArrayList<>(); - this.progressPanel = progress; - this.reportGenerationPanel = null; - this.configName = configName; - } - - /** - * Creates a report generator. This constructor uses UI panel to display - * progress. - * - * @param configName Name of the reporting configuration to use - * @param panel Fully instantiated progress panel + * @param configName The name of the reporting configuration to use. + * @param panel The report generation panel. */ public ReportGenerator(String configName, ReportGenerationPanel panel) { - this.errorList = new ArrayList<>(); - this.reportGenerationPanel = panel; - this.progressPanel = panel.getProgressPanel(); this.configName = configName; + this.reportGenerationPanel = panel; + this.progressIndicator = panel.getProgressPanel(); } /** - * Generate reports according to previously specified reporting - * configuration. + * Constructs a report generator that generates one or more reports by + * running user-selected report modules and uses a report progress indicator + * to display progress. + * + * @param configName The name of the reporting configuration to use. + * @param progressIndicator The report progress indicator. + */ + public ReportGenerator(String configName, ReportProgressIndicator progressIndicator) { + this.configName = configName; + this.reportGenerationPanel = null; + this.progressIndicator = progressIndicator; + } + + /** + * Generates the reports specified by the reporting configuration passed in + * via the constructor. */ public void generateReports() { ReportingConfig config = null; @@ -122,13 +130,13 @@ public class ReportGenerator { config = ReportingConfigLoader.loadConfig(configName); } catch (ReportConfigException ex) { logger.log(Level.SEVERE, "Unable to load reporting configuration " + configName + ". Exiting", ex); - progressPanel.updateStatusLabel("Unable to load reporting configuration " + configName + ". Exiting"); + progressIndicator.updateStatusLabel("Unable to load reporting configuration " + configName + ". Exiting"); return; } if (config == null) { logger.log(Level.SEVERE, "Unable to load reporting configuration {0}. Exiting", configName); - progressPanel.updateStatusLabel("Unable to load reporting configuration " + configName + ". Exiting"); + progressIndicator.updateStatusLabel("Unable to load reporting configuration " + configName + ". Exiting"); return; } @@ -162,7 +170,7 @@ public class ReportGenerator { ReportModule module = modules.get(moduleName); if (module == null) { logger.log(Level.SEVERE, "Report module {0} not found", moduleName); - progressPanel.updateStatusLabel("Report module " + moduleName + " not found"); + progressIndicator.updateStatusLabel("Report module " + moduleName + " not found"); continue; } @@ -189,7 +197,7 @@ public class ReportGenerator { TableReportSettings tableSettings = config.getTableReportSettings(); if (tableSettings == null) { logger.log(Level.SEVERE, "No table report settings for report module {0}", moduleName); - progressPanel.updateStatusLabel("No table report settings for report module " + moduleName); + progressIndicator.updateStatusLabel("No table report settings for report module " + moduleName); continue; } @@ -201,7 +209,7 @@ public class ReportGenerator { FileReportSettings fileSettings = config.getFileReportSettings(); if (fileSettings == null) { logger.log(Level.SEVERE, "No file report settings for report module {0}", moduleName); - progressPanel.updateStatusLabel("No file report settings for report module " + moduleName); + progressIndicator.updateStatusLabel("No file report settings for report module " + moduleName); continue; } @@ -213,7 +221,7 @@ public class ReportGenerator { settings = new PortableCaseReportModuleSettings(); } else if (!(settings instanceof PortableCaseReportModuleSettings)) { logger.log(Level.SEVERE, "Invalid settings for report module {0}", moduleName); - progressPanel.updateStatusLabel("Invalid settings for report module " + moduleName); + progressIndicator.updateStatusLabel("Invalid settings for report module " + moduleName); continue; } @@ -221,12 +229,11 @@ public class ReportGenerator { } else { logger.log(Level.SEVERE, "Report module {0} has unsupported report module type", moduleName); - progressPanel.updateStatusLabel("Report module " + moduleName + " has unsupported report module type"); - continue; + progressIndicator.updateStatusLabel("Report module " + moduleName + " has unsupported report module type"); } } catch (IOException e) { logger.log(Level.SEVERE, "Exception while running report module {0}: {1}", new Object[]{moduleName, e.getMessage()}); - progressPanel.updateStatusLabel("Exception while running report module " + moduleName); + progressIndicator.updateStatusLabel("Exception while running report module " + moduleName); } } } finally { @@ -244,7 +251,7 @@ public class ReportGenerator { return; } - final JDialog dialog = new JDialog((JFrame) WindowManager.getDefault().getMainWindow(), true); + final JDialog dialog = new JDialog(WindowManager.getDefault().getMainWindow(), true); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.setTitle(NbBundle.getMessage(this.getClass(), "ReportGenerator.displayProgress.title.text")); dialog.add(this.reportGenerationPanel); @@ -275,7 +282,7 @@ public class ReportGenerator { if (generalReportModule != null) { String reportDir = createReportDirectory(generalReportModule); setupProgressPanel(generalReportModule, reportDir); - generalReportModule.generateReport(reportDir, progressPanel); + generalReportModule.generateReport(reportDir, progressIndicator); } } @@ -290,11 +297,11 @@ public class ReportGenerator { String reportDir = createReportDirectory(tableReport); setupProgressPanel(tableReport, reportDir); tableReport.startReport(reportDir); - TableReportGenerator generator = new TableReportGenerator(tableReportSettings, progressPanel, tableReport); + TableReportGenerator generator = new TableReportGenerator(tableReportSettings, progressIndicator, tableReport); generator.execute(); tableReport.endReport(); // finish progress, wrap up - progressPanel.complete(ReportProgressPanel.ReportStatus.COMPLETE); + progressIndicator.complete(ReportProgressPanel.ReportStatus.COMPLETE); errorList = generator.getErrorList(); } } @@ -315,34 +322,34 @@ public class ReportGenerator { } } setupProgressPanel(fileReportModule, reportDir); - if (progressPanel.getStatus() != ReportStatus.CANCELED) { - progressPanel.start(); - progressPanel.updateStatusLabel( + if (progressIndicator.getStatus() != ReportStatus.CANCELED) { + progressIndicator.start(); + progressIndicator.updateStatusLabel( NbBundle.getMessage(this.getClass(), "ReportGenerator.progress.queryingDb.text")); } List files = getFiles(); int numFiles = files.size(); - if (progressPanel.getStatus() != ReportStatus.CANCELED) { + if (progressIndicator.getStatus() != ReportStatus.CANCELED) { fileReportModule.startReport(reportDir); fileReportModule.startTable(enabled); } - progressPanel.setIndeterminate(false); - progressPanel.setMaximumProgress(numFiles); + progressIndicator.setIndeterminate(false); + progressIndicator.setMaximumProgress(numFiles); int i = 0; // Add files to report. for (AbstractFile file : files) { // Check to see if any reports have been cancelled. - if (progressPanel.getStatus() == ReportStatus.CANCELED) { + if (progressIndicator.getStatus() == ReportStatus.CANCELED) { return; } else { fileReportModule.addRow(file, enabled); - progressPanel.increment(); + progressIndicator.increment(); } if ((i % 100) == 0) { - progressPanel.updateStatusLabel( + progressIndicator.updateStatusLabel( NbBundle.getMessage(this.getClass(), "ReportGenerator.progress.processingFile.text", file.getName())); } @@ -351,7 +358,7 @@ public class ReportGenerator { fileReportModule.endTable(); fileReportModule.endReport(); - progressPanel.complete(ReportStatus.COMPLETE); + progressIndicator.complete(ReportStatus.COMPLETE); } } @@ -362,7 +369,7 @@ public class ReportGenerator { if (portableCaseReportModule != null) { String reportDir = createReportDirectory(portableCaseReportModule); setupProgressPanel(portableCaseReportModule, reportDir); - portableCaseReportModule.generateReport(reportDir, settings, progressPanel); + portableCaseReportModule.generateReport(reportDir, settings, progressIndicator); } } @@ -378,7 +385,7 @@ public class ReportGenerator { absFiles = skCase.findAllFilesWhere("meta_type != " + TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_DIR.getValue()); //NON-NLS return absFiles; } catch (TskCoreException | NoCurrentCaseException ex) { - progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportGenerator.errors.reportErrorText") + ex.getLocalizedMessage()); + progressIndicator.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportGenerator.errors.reportErrorText") + ex.getLocalizedMessage()); logger.log(Level.SEVERE, "failed to generate reports. Unable to get all files in the image.", ex); //NON-NLS return Collections.emptyList(); } diff --git a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportProgressDialog.java b/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportProgressDialog.java deleted file mode 100644 index 6116edc3d0..0000000000 --- a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportProgressDialog.java +++ /dev/null @@ -1,405 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2011-2019 Basis Technology Corp. - * Contact: carrier sleuthkit 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.report.infrastructure; - -import org.openide.util.NbBundle; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Desktop; -import java.awt.EventQueue; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.io.File; -import java.io.IOException; -import java.util.logging.Level; -import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.report.ReportProgressPanel; - -/** - * A panel used by a report generation module to show progress. - */ -@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives -class ReportProgressDialog extends javax.swing.JPanel implements ReportProgressPanel { - - private static final long serialVersionUID = 1L; - private static final Logger logger = Logger.getLogger(ReportProgressDialog.class.getName()); - private static final Color GREEN = new Color(50, 205, 50); - private static final Color RED = new Color(178, 34, 34); - private volatile ReportProgressPanel.ReportStatus status; - - /** - * Constructs a panel used by report generation module to show progress. - */ - ReportProgressDialog() { - initComponents(); - reportProgressBar.setIndeterminate(true); - reportProgressBar.setMaximum(100); - statusMessageLabel.setText(NbBundle.getMessage(this.getClass(), "ReportProgressDialog.progress.queuing")); - status = ReportStatus.QUEUING; - reportLabel.setText(""); - pathLabel.setText(""); //NON-NLS - } - - /** - * Sets label text. - * - * @param reportName The name of the report being generated. - * @param reportPath The path to the report file. - */ - void setLabels(String reportName, String reportPath) { - reportLabel.setText(reportName); - if (null != reportPath) { - pathLabel.setText("" + shortenPath(reportPath) + ""); //NON-NLS - pathLabel.setToolTipText(reportPath); - String linkPath = reportPath; - pathLabel.addMouseListener(new MouseListener() { - - @Override - public void mouseClicked(MouseEvent mouseEvent) { - } - - @Override - public void mousePressed(MouseEvent mouseEvent) { - } - - @Override - public void mouseReleased(MouseEvent mouseEvent) { - File file = new File(linkPath); - try { - Desktop.getDesktop().open(file); - } catch (IOException ioex) { - logger.log(Level.SEVERE, "Error opening report file", ioex); - } catch (IllegalArgumentException iaEx) { - logger.log(Level.SEVERE, "Error opening report file", iaEx); - try { - Desktop.getDesktop().open(file.getParentFile()); - } catch (IOException ioEx2) { - logger.log(Level.SEVERE, "Error opening report file parent", ioEx2); - } - } - } - - @Override - public void mouseEntered(MouseEvent e3) { - pathLabel.setForeground(Color.DARK_GRAY); - setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - } - - @Override - public void mouseExited(MouseEvent e4) { - pathLabel.setForeground(Color.BLACK); - setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } - }); - } else { - pathLabel.setText(NbBundle.getMessage(this.getClass(), "ReportProgressDialog.initPathLabel.noFile")); - } - } - - /** - * Gets the current status of the generation of the report. - * - * @return The report generation status as a ReportStatus enum. - */ - @Override - public ReportStatus getStatus() { - return status; - } - - /** - * Starts the progress bar component of this panel. - */ - @Override - public void start() { - EventQueue.invokeLater(() -> { - statusMessageLabel.setText(NbBundle.getMessage(this.getClass(), "ReportProgressDialog.start.progress.text")); - status = ReportStatus.RUNNING; - }); - } - - /** - * Sets the maximum value of the progress bar component of this panel. - * - * @param max The maximum value. - */ - @Override - public void setMaximumProgress(int max) { - EventQueue.invokeLater(() -> { - if (status != ReportStatus.CANCELED) { - reportProgressBar.setMaximum(max); - } - }); - } - - /** - * Increments the current value of the progress bar component of this panel - * by one unit. - */ - @Override - public void increment() { - EventQueue.invokeLater(() -> { - if (status != ReportStatus.CANCELED) { - reportProgressBar.setValue(reportProgressBar.getValue() + 1); - } - }); - } - - /** - * Sets the current value of the progress bar component of this panel. - * - * @param value The value to be set. - */ - @Override - public void setProgress(int value) { - EventQueue.invokeLater(() -> { - if (status != ReportStatus.CANCELED) { - reportProgressBar.setValue(value); - } - }); - } - - /** - * Changes the the progress bar component of this panel to be determinate or - * indeterminate. - * - * @param indeterminate True if the progress bar should be set to - * indeterminate. - */ - @Override - public void setIndeterminate(boolean indeterminate) { - EventQueue.invokeLater(() -> { - if (status != ReportStatus.CANCELED) { - reportProgressBar.setIndeterminate(indeterminate); - } - }); - } - - /** - * Changes the status message label component of this panel to show a given - * processing status message. For example, updateStatusLabel("Now processing - * files...") sets the label text to "Now processing files..." - * - * @param statusMessage String to use as label text. - */ - @Override - public void updateStatusLabel(String statusMessage) { - EventQueue.invokeLater(() -> { - if (status != ReportStatus.CANCELED) { - statusMessageLabel.setText(statusMessage); - } - }); - } - - /** - * Makes the components of this panel indicate the final status of - * generation of the report. - * - * @param reportStatus The final status, must be COMPLETE or ERROR. - */ - @Override - public void complete(ReportStatus reportStatus) { - - switch (reportStatus) { - case COMPLETE: - complete(reportStatus, NbBundle.getMessage(this.getClass(), "ReportProgressDialog.complete.processLbl.text")); - break; - case ERROR: - complete(reportStatus, NbBundle.getMessage(this.getClass(), "ReportProgressDialog.complete.processLb2.text")); - break; - default: - complete(reportStatus, ""); - break; - } - } - - /** - * Makes the components of this panel indicate the final status of - * generation of the report. - * - * @param reportStatus The final status, must be COMPLETE or ERROR. - * @param statusMessage String to use as label or error text. - */ - @Override - public void complete(ReportStatus reportStatus, String statusMessage) { - EventQueue.invokeLater(() -> { - reportProgressBar.setIndeterminate(false); - if (status != ReportStatus.CANCELED) { - switch (reportStatus) { - case COMPLETE: { - ReportStatus oldValue = status; - status = ReportStatus.COMPLETE; - statusMessageLabel.setForeground(Color.BLACK); - statusMessageLabel.setText(statusMessage); - reportProgressBar.setValue(reportProgressBar.getMaximum()); - reportProgressBar.setStringPainted(true); - reportProgressBar.setForeground(GREEN); - reportProgressBar.setString("Complete"); //NON-NLS - firePropertyChange(ReportStatus.COMPLETE.toString(), oldValue, status); - break; - } - case ERROR: { - ReportStatus oldValue = status; - status = ReportStatus.ERROR; - statusMessageLabel.setForeground(RED); - statusMessageLabel.setText(statusMessage); - reportProgressBar.setValue(reportProgressBar.getMaximum()); - reportProgressBar.setStringPainted(true); - reportProgressBar.setForeground(RED); - reportProgressBar.setString("Error"); //NON-NLS - firePropertyChange(ReportStatus.COMPLETE.toString(), oldValue, status); - break; - } - default: { - break; - } - } - } - }); - } - - /** - * Makes the components of this panel indicate generation of the report was - * cancelled. - */ - void cancel() { - switch (status) { - case COMPLETE: - break; - case CANCELED: - break; - case ERROR: - break; - default: - ReportStatus oldValue = status; - status = ReportStatus.CANCELED; - reportProgressBar.setIndeterminate(false); - reportProgressBar.setValue(0); - reportProgressBar.setStringPainted(true); - reportProgressBar.setForeground(RED); // Red - reportProgressBar.setString("Cancelled"); //NON-NLS - firePropertyChange(ReportStatus.CANCELED.toString(), oldValue, status); - statusMessageLabel.setForeground(RED); - statusMessageLabel.setText(NbBundle.getMessage(this.getClass(), "ReportProgressDialog.cancel.procLbl.text")); - break; - } - } - - /** - * Gets a shortened version of a file path. - * - * @param path The path to shorten. - * - * @return The shortened path. - */ - private String shortenPath(String path) { - if (path.length() > 100) { - return path.substring(0, 10 + path.substring(10).indexOf(File.separator) + 1) + "..." - + path.substring((path.length() - 70) + path.substring(path.length() - 70).indexOf(File.separator)); - } else { - return path; - } - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - reportProgressBar = new javax.swing.JProgressBar(); - reportLabel = new javax.swing.JLabel(); - pathLabel = new javax.swing.JLabel(); - separationLabel = new javax.swing.JLabel(); - statusMessageLabel = new javax.swing.JLabel(); - - setFont(getFont().deriveFont(getFont().getStyle() & ~java.awt.Font.BOLD, 11)); - setMinimumSize(new java.awt.Dimension(486, 68)); - - reportProgressBar.setFont(reportProgressBar.getFont().deriveFont(reportProgressBar.getFont().getStyle() & ~java.awt.Font.BOLD, 11)); - - reportLabel.setFont(reportLabel.getFont().deriveFont(reportLabel.getFont().getStyle() | java.awt.Font.BOLD, 11)); - org.openide.awt.Mnemonics.setLocalizedText(reportLabel, org.openide.util.NbBundle.getMessage(ReportProgressDialog.class, "ReportProgressDialog.reportLabel.text")); // NOI18N - - pathLabel.setFont(pathLabel.getFont().deriveFont(pathLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11)); - org.openide.awt.Mnemonics.setLocalizedText(pathLabel, org.openide.util.NbBundle.getMessage(ReportProgressDialog.class, "ReportProgressDialog.pathLabel.text")); // NOI18N - pathLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP); - - separationLabel.setFont(separationLabel.getFont().deriveFont(separationLabel.getFont().getStyle() & ~java.awt.Font.BOLD, 11)); - org.openide.awt.Mnemonics.setLocalizedText(separationLabel, org.openide.util.NbBundle.getMessage(ReportProgressDialog.class, "ReportProgressDialog.separationLabel.text")); // NOI18N - - org.openide.awt.Mnemonics.setLocalizedText(statusMessageLabel, org.openide.util.NbBundle.getMessage(ReportProgressDialog.class, "ReportProgressDialog.statusMessageLabel.text")); // NOI18N - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(statusMessageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(reportProgressBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() - .addComponent(reportLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(separationLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(pathLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 548, Short.MAX_VALUE))) - .addContainerGap()) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(reportProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(reportLabel) - .addComponent(pathLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(separationLabel)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(statusMessageLabel) - .addGap(13, 13, 13)) - ); - }// //GEN-END:initComponents - - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JLabel pathLabel; - private javax.swing.JLabel reportLabel; - private javax.swing.JProgressBar reportProgressBar; - private javax.swing.JLabel separationLabel; - private javax.swing.JLabel statusMessageLabel; - // End of variables declaration//GEN-END:variables - - /** - * Makes the components of this panel indicate the generation of the report - * is completed. - * - * @deprecated Use {@link #complete(ReportStatus)} - */ - @Deprecated - @Override - public void complete() { - complete(ReportStatus.COMPLETE); - } - -} diff --git a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportProgressIndicator.java b/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportProgressIndicator.java new file mode 100755 index 0000000000..a3f0ec17d4 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportProgressIndicator.java @@ -0,0 +1,140 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2019 Basis Technology Corp. + * Contact: carrier sleuthkit 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.report.infrastructure; + +import org.openide.util.NbBundle; +import org.sleuthkit.autopsy.progress.ProgressIndicator; +import org.sleuthkit.autopsy.report.ReportProgressPanel; + +/** + * An adapter that adapts the ReportProgressPanel interface to the + * ProgressIndicator interface so that a given progress indicator can be used + * where a ReportProgressPanel is expected. + */ +public class ReportProgressIndicator extends ReportProgressPanel { + + private static final long serialVersionUID = 1L; + private final ProgressIndicator progressIndicator; + + /** + * Constructs an adapter that adapts the ReportProgressPanel interface to + * the ProgressIndicator interface so that a given progress indicator can be + * used where a ReportProgressPanel is expected. + * + * @param progressIndicator The progress indicator tobe adapted. + */ + public ReportProgressIndicator(ProgressIndicator progressIndicator) { + this.progressIndicator = progressIndicator; + } + + @Override + public void setLabels(String reportName, String reportPath) { + /* + * Not expected to be called, method exists for ReportGenerationPanel, + * which is not expected to be instantiated when this class is used. + */ + } + + @Override + @NbBundle.Messages({ + "ReportProgressIndicator.startMessage=Report generation started" + }) + public void start() { + setStatus(ReportStatus.RUNNING); + progressIndicator.start(Bundle.ReportProgressIndicator_startMessage()); + } + + @Override + @NbBundle.Messages({ + "ReportProgressIndicator.switchToDeterminateMessage=Report generation progress switched to determinate" + }) + public void setMaximumProgress(int max) { + progressIndicator.switchToDeterminate(Bundle.ReportProgressIndicator_switchToDeterminateMessage(), 0, max); + } + + @Override + public void setProgress(int value) { + progressIndicator.progress(value); + } + + @Override + @NbBundle.Messages({ + "ReportProgressIndicator.switchToIndeterminateMessage=Report generation progress switched to indeterminate" + }) + public void setIndeterminate(boolean indeterminate) { + progressIndicator.switchToIndeterminate(Bundle.ReportProgressIndicator_switchToIndeterminateMessage()); + } + + @Override + public void updateStatusLabel(String statusMessage) { + if (getStatus() != ReportStatus.CANCELED) { + progressIndicator.progress(statusMessage); + } + } + + @Override + @NbBundle.Messages({ + "ReportProgressIndicator.completedMessage=Report generation completed", + "ReportProgressIndicator.completedWithErrorsMessage=Report generation completed with errors",}) + public void complete(ReportStatus reportStatus) { + if (getStatus() != ReportStatus.CANCELED) { + switch (reportStatus) { + case COMPLETE: { + progressIndicator.progress(Bundle.ReportProgressIndicator_completedMessage()); + break; + } + case ERROR: { + progressIndicator.progress(Bundle.ReportProgressIndicator_completedWithErrorsMessage()); + break; + } + default: { + break; + } + } + } + progressIndicator.finish(); + } + + @Override + public void complete(ReportStatus reportStatus, String statusMessage) { + if (getStatus() != ReportStatus.CANCELED) { + progressIndicator.progress(statusMessage); + } + complete(reportStatus); + } + + @Override + @NbBundle.Messages({ + "ReportProgressIndicator.cancelledMessage=Report generation cancelled",}) + public void cancel() { + switch (getStatus()) { + case COMPLETE: + break; + case CANCELED: + break; + case ERROR: + break; + default: + setStatus(ReportStatus.CANCELED); + progressIndicator.progress(Bundle.ReportProgressIndicator_cancelledMessage()); + break; + } + } + +} diff --git a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportProgressLogger.java b/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportProgressLogger.java deleted file mode 100755 index 697050052c..0000000000 --- a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportProgressLogger.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2019 Basis Technology Corp. - * Contact: carrier sleuthkit 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.report.infrastructure; - -import java.util.logging.Level; -import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.report.ReportProgressPanel; - -/** - * Writes progress and status messages to the application log. - */ -public class ReportProgressLogger implements ReportProgressPanel { - - private static final Logger logger = Logger.getLogger(ReportProgressLogger.class.getName()); - private volatile ReportProgressPanel.ReportStatus status; - - public ReportProgressLogger() { - status = ReportStatus.QUEUING; - } - - /** - * Gets the current status of the generation of the report. - * - * @return The report generation status as a ReportStatus enum. - */ - @Override - public ReportStatus getStatus() { - return status; - } - - /** - * Logs that the report has been started. - */ - @Override - public void start() { - status = ReportStatus.RUNNING; - logger.log(Level.INFO, "Report started"); - } - - /** - * NO-OP. - * - * @param max The maximum value. - */ - @Override - public void setMaximumProgress(int max) { - } - - /** - * NO-OP. - */ - @Override - public void increment() { - } - - /** - * NO-OP. - * - * @param value The value to be set. - */ - @Override - public void setProgress(int value) { - } - - /** - * NO-OP. - * - * @param indeterminate True if the progress bar should be set to - * indeterminate. - */ - @Override - public void setIndeterminate(boolean indeterminate) { - } - - /** - * Logs the status message. - * - * @param statusMessage String to use as label text. - */ - @Override - public void updateStatusLabel(String statusMessage) { - if (status != ReportStatus.CANCELED) { - logger.log(Level.INFO, statusMessage); - } - } - - /** - * Logs the final status of the report generation. - * - * @param reportStatus The final status, must be COMPLETE or ERROR. - * @param statusMessage String to use as label or error text. - */ - @Override - public void complete(ReportStatus reportStatus, String statusMessage) { - if (!statusMessage.isEmpty()) { - logger.log(Level.INFO, statusMessage); - } - if (status != ReportStatus.CANCELED) { - switch (reportStatus) { - case COMPLETE: { - status = ReportStatus.COMPLETE; - logger.log(Level.INFO, "Report completed"); - break; - } - case ERROR: { - status = ReportStatus.ERROR; - logger.log(Level.INFO, "Report completed with errors"); - break; - } - default: { - break; - } - } - } - } - - /** - * Logs the final status of the report generation. - * - * @param reportStatus The final status, must be COMPLETE or ERROR. - */ - @Override - public void complete(ReportStatus reportStatus) { - complete(reportStatus, ""); - } - - /** - * Logs that the generation of the report was cancelled. - */ - void cancel() { - switch (status) { - case COMPLETE: - break; - case CANCELED: - break; - case ERROR: - break; - default: - status = ReportStatus.CANCELED; - logger.log(Level.INFO, "Report cancelled"); - break; - } - } - - /** - * Logs the final status of the report generation. - * - * @deprecated Use {@link #complete(ReportStatus)} - */ - @Deprecated - @Override - public void complete() { - complete(ReportStatus.COMPLETE); - } - -} diff --git a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportWizardAction.java b/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportWizardAction.java index 1e5ffea430..1058c4d382 100644 --- a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportWizardAction.java +++ b/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportWizardAction.java @@ -1,19 +1,19 @@ /* * * Autopsy Forensic Browser - * + * * Copyright 2013-2018 Basis Technology Corp. - * + * * Copyright 2012 42six Solutions. * Contact: aebadirad 42six com * Project Contact/Architect: carrier sleuthkit 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. @@ -74,10 +74,11 @@ public final class ReportWizardAction extends CallableSystemAction implements Pr * reporting wizard. When the wizard is finished, create a ReportGenerator * with the wizard information, and start all necessary reports. * - * @param configName Name of the reporting configuration to use + * @param configName Name of the reporting configuration to use * @param displayCaseSpecificData Flag whether to use case specific data in - * UI panels or to use all possible result types - * @param runReports Flag whether to produce report(s) + * UI panels or to use all possible result + * types + * @param runReports Flag whether to produce report(s) */ @SuppressWarnings("unchecked") public static void doReportWizard(String configName, boolean displayCaseSpecificData, boolean runReports) { @@ -92,7 +93,7 @@ public final class ReportWizardAction extends CallableSystemAction implements Pr } catch (ReportConfigException ex) { logger.log(Level.SEVERE, "Failed to save reporting configuration " + configName, ex); //NON-NLS NotifyDescriptor descriptor = new NotifyDescriptor.Message( - NbBundle.getMessage(ReportWizardAction.class, "ReportWizardAction.unableToSaveConfig.errorLabel.text"), + NbBundle.getMessage(ReportWizardAction.class, "ReportWizardAction.unableToSaveConfig.errorLabel.text"), NotifyDescriptor.ERROR_MESSAGE); DialogDisplayer.getDefault().notify(descriptor); } @@ -110,6 +111,7 @@ public final class ReportWizardAction extends CallableSystemAction implements Pr } } + @SuppressWarnings(value = "unchecked") private static void saveReportingConfiguration(String configName, WizardDescriptor wiz) throws ReportConfigException { ReportingConfig reportingConfig = new ReportingConfig(configName); diff --git a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportingConfigLoader.java b/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportingConfigLoader.java index 6ab57f8578..6472105888 100755 --- a/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportingConfigLoader.java +++ b/Core/src/org/sleuthkit/autopsy/report/infrastructure/ReportingConfigLoader.java @@ -55,11 +55,14 @@ final class ReportingConfigLoader { * an atomic, thread safe way. * * @param configName Name of the reporting configuration + * * @return ReportingConfig object if a persisted configuration exists, null - * otherwise + * otherwise + * * @throws ReportConfigException if an error occurred while reading the - * configuration + * configuration */ + @SuppressWarnings("unchecked") static synchronized ReportingConfig loadConfig(String configName) throws ReportConfigException { // construct the configuration directory path @@ -77,7 +80,7 @@ final class ReportingConfigLoader { // read in the configuration ReportingConfig config = new ReportingConfig(configName); - + // read table report settings String filePath = reportDirPath.toString() + File.separator + TABLE_REPORT_CONFIG_FILE; try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(filePath))) { @@ -85,7 +88,7 @@ final class ReportingConfigLoader { } catch (IOException | ClassNotFoundException ex) { throw new ReportConfigException("Unable to read table report settings " + filePath, ex); } - + // read file report settings filePath = reportDirPath.toString() + File.separator + FILE_REPORT_CONFIG_FILE; try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(filePath))) { @@ -93,7 +96,7 @@ final class ReportingConfigLoader { } catch (IOException | ClassNotFoundException ex) { throw new ReportConfigException("Unable to read file report settings " + filePath, ex); } - + // read map of module configuration objects Map moduleConfigs = null; filePath = reportDirPath.toString() + File.separator + MODULE_CONFIG_FILE; @@ -102,11 +105,11 @@ final class ReportingConfigLoader { } catch (IOException | ClassNotFoundException ex) { throw new ReportConfigException("Unable to read module configurations map " + filePath, ex); } - + if (moduleConfigs == null || moduleConfigs.isEmpty()) { return config; } - + // read each ReportModuleSettings object individually for (Iterator> iterator = moduleConfigs.entrySet().iterator(); iterator.hasNext();) { ReportModuleConfig moduleConfig = iterator.next().getValue(); @@ -114,16 +117,19 @@ final class ReportingConfigLoader { try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(filePath))) { moduleConfig.setModuleSettings((ReportModuleSettings) in.readObject()); } catch (IOException | ClassNotFoundException ex) { - /* NOTE: we do not want to re-throw the exception because we do not - want a single error while reading in a (3rd party) report module - to prevent us from reading the entire reporting configuration.*/ + /* + * NOTE: we do not want to re-throw the exception because we do + * not want a single error while reading in a (3rd party) report + * module to prevent us from reading the entire reporting + * configuration. + */ logger.log(Level.SEVERE, "Unable to read module settings " + filePath, ex); iterator.remove(); } } - + config.setModuleConfigs(moduleConfigs); - + return config; } @@ -132,15 +138,16 @@ final class ReportingConfigLoader { * an atomic, thread safe way. * * @param reportConfig ReportingConfig object to serialize to disk + * * @throws ReportConfigException if an error occurred while saving the - * configuration + * configuration */ static synchronized void saveConfig(ReportingConfig reportConfig) throws ReportConfigException { if (reportConfig == null) { throw new ReportConfigException("Reporting configuration is NULL"); } - + // construct the configuration directory path Path pathToConfigDir = Paths.get(ReportingConfigLoader.REPORT_CONFIG_FOLDER_PATH, reportConfig.getName()); @@ -168,7 +175,7 @@ final class ReportingConfigLoader { } // save map of module configuration objects - filePath = pathToConfigDir.toString() + File.separator + MODULE_CONFIG_FILE; + filePath = pathToConfigDir.toString() + File.separator + MODULE_CONFIG_FILE; try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) { out.writeObject(reportConfig.getModuleConfigs()); } catch (IOException ex) { @@ -176,10 +183,13 @@ final class ReportingConfigLoader { } // save each ReportModuleSettings object individually - /* NOTE: This is done to protect us from errors in reading/writing 3rd - party report module settings. If we were to serialize the entire ReportingConfig - object, then a single error while reading in a 3rd party report module - would prevent us from reading the entire reporting configuration.*/ + /* + * NOTE: This is done to protect us from errors in reading/writing 3rd + * party report module settings. If we were to serialize the entire + * ReportingConfig object, then a single error while reading in a 3rd + * party report module would prevent us from reading the entire + * reporting configuration. + */ if (reportConfig.getModuleConfigs() == null) { return; } diff --git a/Core/src/org/sleuthkit/autopsy/report/infrastructure/TableReportGenerator.java b/Core/src/org/sleuthkit/autopsy/report/infrastructure/TableReportGenerator.java index 8432526e4e..4836b03d37 100644 --- a/Core/src/org/sleuthkit/autopsy/report/infrastructure/TableReportGenerator.java +++ b/Core/src/org/sleuthkit/autopsy/report/infrastructure/TableReportGenerator.java @@ -46,8 +46,8 @@ import org.sleuthkit.autopsy.casemodule.services.TagsManager; import org.sleuthkit.autopsy.coreutils.ImageUtils; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.datamodel.ContentUtils; -import org.sleuthkit.autopsy.report.ReportProgressPanel; import static org.sleuthkit.autopsy.casemodule.services.TagsManager.getNotableTagLabel; +import org.sleuthkit.autopsy.report.ReportProgressPanel; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.Account; import org.sleuthkit.datamodel.BlackboardArtifact; @@ -60,6 +60,7 @@ import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TagName; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskData; +import org.sleuthkit.autopsy.report.ReportProgressPanel; class TableReportGenerator { @@ -80,10 +81,10 @@ class TableReportGenerator { this.progressPanel = progressPanel; this.tableReport = tableReport; this.columnHeaderMap = new HashMap<>(); - errorList = new ArrayList<>(); + errorList = new ArrayList<>(); this.settings = settings; } - + private void getAllExistingTags() throws NoCurrentCaseException, TskCoreException { List tagNames = new ArrayList<>(); @@ -98,6 +99,7 @@ class TableReportGenerator { tagNamesFilter = new HashSet<>(tagNames); } + @SuppressWarnings("deprecation") private void getAllExistingArtiactTypes() throws NoCurrentCaseException, TskCoreException { // get all possible artifact types ArrayList doNotReport = new ArrayList<>(); @@ -116,7 +118,7 @@ class TableReportGenerator { progressPanel.start(); progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportGenerator.progress.readingTagsArtifacts.text")); - + if (settings.useStoredTagsAndArtifactsLists()) { // Get the artifact types selected by the user. artifactTypes = settings.getArtifactSelections(); @@ -130,7 +132,7 @@ class TableReportGenerator { if (settings.getSelectedReportOption() == TableReportSettings.TableReportOption.ALL_TAGGED_RESULTS) { getAllExistingTags(); } - + // get all possible artifact types getAllExistingArtiactTypes(); } catch (NoCurrentCaseException | TskCoreException ex) { @@ -139,11 +141,11 @@ class TableReportGenerator { return; } } - + // Start the progress indicators for each active TableReportModule. progressPanel.setIndeterminate(false); progressPanel.setMaximumProgress(this.artifactTypes.size() + 2); // +2 for content and blackboard artifact tags - + // report on the blackboard results if (progressPanel.getStatus() != ReportProgressPanel.ReportStatus.CANCELED) { makeBlackboardArtifactTables(); diff --git a/Core/src/org/sleuthkit/autopsy/report/modules/bodyfile/BodyFileReport.java b/Core/src/org/sleuthkit/autopsy/report/modules/bodyfile/BodyFileReport.java index a0d43bf4e5..1e802fa20d 100644 --- a/Core/src/org/sleuthkit/autopsy/report/modules/bodyfile/BodyFileReport.java +++ b/Core/src/org/sleuthkit/autopsy/report/modules/bodyfile/BodyFileReport.java @@ -35,9 +35,9 @@ import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.ingest.IngestManager; -import org.sleuthkit.autopsy.report.ReportProgressPanel; import org.sleuthkit.autopsy.report.ReportProgressPanel.ReportStatus; import org.sleuthkit.datamodel.*; +import org.sleuthkit.autopsy.report.ReportProgressPanel; /** * BodyFileReport generates a report in the body file format specified on The diff --git a/Core/src/org/sleuthkit/autopsy/report/modules/caseuco/CaseUcoFormatExporter.java b/Core/src/org/sleuthkit/autopsy/report/modules/caseuco/CaseUcoFormatExporter.java index 7df1494688..3003f03e7d 100755 --- a/Core/src/org/sleuthkit/autopsy/report/modules/caseuco/CaseUcoFormatExporter.java +++ b/Core/src/org/sleuthkit/autopsy/report/modules/caseuco/CaseUcoFormatExporter.java @@ -43,7 +43,6 @@ import org.sleuthkit.autopsy.casemodule.services.TagsManager; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.datamodel.ContentUtils; import org.sleuthkit.autopsy.ingest.IngestManager; -import org.sleuthkit.autopsy.report.ReportProgressPanel; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifactTag; @@ -55,6 +54,7 @@ import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskData; import org.sleuthkit.datamodel.TagName; +import org.sleuthkit.autopsy.report.ReportProgressPanel; /** * Generates CASE-UCO report file for a data source diff --git a/Core/src/org/sleuthkit/autopsy/report/modules/kml/KMLReport.java b/Core/src/org/sleuthkit/autopsy/report/modules/kml/KMLReport.java index c1a8ec4046..acf730a1d7 100644 --- a/Core/src/org/sleuthkit/autopsy/report/modules/kml/KMLReport.java +++ b/Core/src/org/sleuthkit/autopsy/report/modules/kml/KMLReport.java @@ -46,8 +46,8 @@ import org.jdom2.CDATA; import org.openide.filesystems.FileUtil; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.report.ReportBranding; -import org.sleuthkit.autopsy.report.ReportProgressPanel; import org.sleuthkit.datamodel.ReadContentInputStream.ReadContentInputStreamException; +import org.sleuthkit.autopsy.report.ReportProgressPanel; /** * Generates a KML file based on geospatial information from the BlackBoard. diff --git a/Core/src/org/sleuthkit/autopsy/report/modules/portablecase/PortableCaseReportModule.java b/Core/src/org/sleuthkit/autopsy/report/modules/portablecase/PortableCaseReportModule.java index de3350ad88..927cf9bf0c 100644 --- a/Core/src/org/sleuthkit/autopsy/report/modules/portablecase/PortableCaseReportModule.java +++ b/Core/src/org/sleuthkit/autopsy/report/modules/portablecase/PortableCaseReportModule.java @@ -43,7 +43,6 @@ import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.datamodel.ContentUtils; import org.sleuthkit.autopsy.coreutils.FileTypeUtils.FileTypeCategory; -import org.sleuthkit.autopsy.report.ReportProgressPanel; import org.sleuthkit.autopsy.report.modules.caseuco.CaseUcoFormatExporter; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact; @@ -63,6 +62,7 @@ import org.sleuthkit.datamodel.TskDataException; import org.sleuthkit.datamodel.TskData; import org.sleuthkit.datamodel.Volume; import org.sleuthkit.datamodel.VolumeSystem; +import org.sleuthkit.autopsy.report.ReportProgressPanel; /** * Creates a portable case from tagged files diff --git a/Core/src/org/sleuthkit/autopsy/report/modules/stix/STIXReportModule.java b/Core/src/org/sleuthkit/autopsy/report/modules/stix/STIXReportModule.java index 6421cc4a32..17ac2ab813 100644 --- a/Core/src/org/sleuthkit/autopsy/report/modules/stix/STIXReportModule.java +++ b/Core/src/org/sleuthkit/autopsy/report/modules/stix/STIXReportModule.java @@ -57,9 +57,9 @@ import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.report.GeneralReportModule; import org.sleuthkit.autopsy.report.NoReportModuleSettings; import org.sleuthkit.autopsy.report.ReportModuleSettings; -import org.sleuthkit.autopsy.report.ReportProgressPanel; import org.sleuthkit.autopsy.report.ReportProgressPanel.ReportStatus; import org.sleuthkit.datamodel.TskCoreException; +import org.sleuthkit.autopsy.report.ReportProgressPanel; /** * diff --git a/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/SaveTaggedHashesToHashDb.java b/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/SaveTaggedHashesToHashDb.java index 8fc57c0ae8..85e1d581ab 100644 --- a/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/SaveTaggedHashesToHashDb.java +++ b/Core/src/org/sleuthkit/autopsy/report/modules/taggedhashes/SaveTaggedHashesToHashDb.java @@ -32,12 +32,12 @@ import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb; import org.sleuthkit.autopsy.report.GeneralReportModule; import org.sleuthkit.autopsy.report.NoReportModuleSettings; import org.sleuthkit.autopsy.report.ReportModuleSettings; -import org.sleuthkit.autopsy.report.ReportProgressPanel; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.ContentTag; import org.sleuthkit.datamodel.TagName; import org.sleuthkit.datamodel.TskCoreException; +import org.sleuthkit.autopsy.report.ReportProgressPanel; /** * Instances of this class plug in to the reporting infrastructure to provide a