diff --git a/Core/src/org/sleuthkit/autopsy/report/Bundle.properties b/Core/src/org/sleuthkit/autopsy/report/Bundle.properties index 8d6e81e3ef..20f16e4ac6 100644 --- a/Core/src/org/sleuthkit/autopsy/report/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/report/Bundle.properties @@ -37,7 +37,7 @@ FileReportDataTypes.knownStatus.text=Known Status FileReportDataTypes.perms.text=Permissions FileReportDataTypes.path.text=Full Path FileReportText.getName.text=Files - Text -FileReportText.getDesc.text=A tab delimited text file containing information about individual files in the case. +FileReportText.getDesc.text=A delimited text file containing information about individual files in the case. ReportBodyFile.progress.querying=Querying files... ReportBodyFile.ingestWarning.text=Warning, this report was run before ingest services completed\! ReportBodyFile.progress.loading=Loading files... @@ -258,3 +258,5 @@ CreatePortableCasePanel.outputFolderTextField.text=jTextField1 CreatePortableCasePanel.chooseOutputFolderButton.text=Choose folder CreatePortableCasePanel.jLabel1.text=Export files tagged as: CreatePortableCasePanel.jLabel2.text=Select output folder: +ReportFileTextConfigurationPanel.tabDelimitedButton.text=Tab delimited +ReportFileTextConfigurationPanel.commaDelimitedButton.text=Comma delimited diff --git a/Core/src/org/sleuthkit/autopsy/report/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/report/Bundle.properties-MERGED index 3111ffbe6d..1187fe8e81 100755 --- a/Core/src/org/sleuthkit/autopsy/report/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/report/Bundle.properties-MERGED @@ -85,7 +85,7 @@ FileReportDataTypes.knownStatus.text=Known Status FileReportDataTypes.perms.text=Permissions FileReportDataTypes.path.text=Full Path FileReportText.getName.text=Files - Text -FileReportText.getDesc.text=A tab delimited text file containing information about individual files in the case. +FileReportText.getDesc.text=A delimited text file containing information about individual files in the case. ReportBodyFile.progress.querying=Querying files... ReportBodyFile.ingestWarning.text=Warning, this report was run before ingest services completed\! ReportBodyFile.progress.loading=Loading files... @@ -306,4 +306,6 @@ CreatePortableCasePanel.outputFolderTextField.text=jTextField1 CreatePortableCasePanel.chooseOutputFolderButton.text=Choose folder CreatePortableCasePanel.jLabel1.text=Export files tagged as: CreatePortableCasePanel.jLabel2.text=Select output folder: +ReportFileTextConfigurationPanel.tabDelimitedButton.text=Tab delimited +ReportFileTextConfigurationPanel.commaDelimitedButton.text=Comma delimited TableReportGenerator.StatusColumn.Header=Review Status diff --git a/Core/src/org/sleuthkit/autopsy/report/FileReportText.java b/Core/src/org/sleuthkit/autopsy/report/FileReportText.java index f96bad446b..9d3de2c945 100644 --- a/Core/src/org/sleuthkit/autopsy/report/FileReportText.java +++ b/Core/src/org/sleuthkit/autopsy/report/FileReportText.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2013 - 2018 Basis Technology Corp. + * Copyright 2013 - 2019 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,6 +19,7 @@ package org.sleuthkit.autopsy.report; import java.io.BufferedWriter; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; @@ -27,6 +28,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.logging.Level; +import javax.swing.JPanel; import org.sleuthkit.autopsy.coreutils.Logger; import org.openide.util.NbBundle; @@ -36,18 +38,18 @@ import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.TskCoreException; /** - * A Tab-delimited text report of the files in the case. + * A delimited text report of the files in the case. * * @author jwallace */ class FileReportText implements FileReportModule { private static final Logger logger = Logger.getLogger(FileReportText.class.getName()); + private static final String FILE_NAME = "file-report.txt"; //NON-NLS + private static FileReportText instance; private String reportPath; private Writer out; - private static final String FILE_NAME = "file-report.txt"; //NON-NLS - - private static FileReportText instance; + private ReportFileTextConfigurationPanel configPanel; // Get the default implementation of this report public static synchronized FileReportText getDefault() { @@ -62,7 +64,7 @@ class FileReportText implements FileReportModule { this.reportPath = baseReportDir + FILE_NAME; try { out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(this.reportPath))); - } catch (IOException ex) { + } catch (FileNotFoundException ex) { logger.log(Level.WARNING, "Failed to create report text file", ex); //NON-NLS } } @@ -85,11 +87,12 @@ class FileReportText implements FileReportModule { } } - private String getTabDelimitedList(List list) { - StringBuilder output = new StringBuilder(); + private String getDelimitedList(List list, String delimiter) { + StringBuilder output; + output = new StringBuilder(); Iterator it = list.iterator(); while (it.hasNext()) { - output.append(it.next()).append((it.hasNext() ? "\t" : System.lineSeparator())); + output.append('"').append(it.next()).append('"').append((it.hasNext() ? delimiter : System.lineSeparator())); } return output.toString(); } @@ -101,7 +104,7 @@ class FileReportText implements FileReportModule { titles.add(col.getName()); } try { - out.write(getTabDelimitedList(titles)); + out.write(getDelimitedList(titles, configPanel.getDelimiter())); } catch (IOException ex) { logger.log(Level.WARNING, "Error when writing headers to report file: {0}", ex); //NON-NLS } @@ -114,7 +117,7 @@ class FileReportText implements FileReportModule { cells.add(type.getValue(toAdd)); } try { - out.write(getTabDelimitedList(cells)); + out.write(getDelimitedList(cells, configPanel.getDelimiter())); } catch (IOException ex) { logger.log(Level.WARNING, "Error when writing row to report file: {0}", ex); //NON-NLS } @@ -143,4 +146,12 @@ class FileReportText implements FileReportModule { public String getRelativeFilePath() { return FILE_NAME; } + + @Override + public JPanel getConfigurationPanel() { + if (configPanel == null) { + configPanel = new ReportFileTextConfigurationPanel(); + } + return configPanel; + } } diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportFileTextConfigurationPanel.form b/Core/src/org/sleuthkit/autopsy/report/ReportFileTextConfigurationPanel.form new file mode 100644 index 0000000000..d0c59f7bdd --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/report/ReportFileTextConfigurationPanel.form @@ -0,0 +1,68 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportFileTextConfigurationPanel.java b/Core/src/org/sleuthkit/autopsy/report/ReportFileTextConfigurationPanel.java new file mode 100644 index 0000000000..e1b9de2df2 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/report/ReportFileTextConfigurationPanel.java @@ -0,0 +1,99 @@ +/* + * 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; + +/** + * Panel for configuring settings for the file text report + */ +class ReportFileTextConfigurationPanel extends javax.swing.JPanel { + + private static final long serialVersionUID = 1L; + private static final String TAB_DELIMITER = "\t"; //NON-NLS + private static final String COMMA_DELIMITER = ","; //NON-NLS + + /** + * Creates new form ReportFileTextConfigurationPanel + */ + ReportFileTextConfigurationPanel() { + initComponents(); + } + + /** + * Get the delimiter that was selected on this panel + * + * @return the selected delimiter + */ + String getDelimiter() { + if (commaDelimitedButton.isSelected()) { + return COMMA_DELIMITER; + } else { + //if the comma button is not selected default to tab since it was previously the only option + return TAB_DELIMITER; + } + } + + /** + * 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() { + + delimiterGroup = new javax.swing.ButtonGroup(); + tabDelimitedButton = new javax.swing.JRadioButton(); + commaDelimitedButton = new javax.swing.JRadioButton(); + + delimiterGroup.add(tabDelimitedButton); + tabDelimitedButton.setSelected(true); + org.openide.awt.Mnemonics.setLocalizedText(tabDelimitedButton, org.openide.util.NbBundle.getMessage(ReportFileTextConfigurationPanel.class, "ReportFileTextConfigurationPanel.tabDelimitedButton.text")); // NOI18N + + delimiterGroup.add(commaDelimitedButton); + org.openide.awt.Mnemonics.setLocalizedText(commaDelimitedButton, org.openide.util.NbBundle.getMessage(ReportFileTextConfigurationPanel.class, "ReportFileTextConfigurationPanel.commaDelimitedButton.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() + .addComponent(tabDelimitedButton, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(commaDelimitedButton, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(166, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(tabDelimitedButton) + .addComponent(commaDelimitedButton)) + .addContainerGap(78, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JRadioButton commaDelimitedButton; + private javax.swing.ButtonGroup delimiterGroup; + private javax.swing.JRadioButton tabDelimitedButton; + // End of variables declaration//GEN-END:variables +}