19 package org.sleuthkit.autopsy.commandlineingest;
 
   21 import java.awt.BorderLayout;
 
   22 import java.awt.Cursor;
 
   23 import java.util.List;
 
   25 import javax.swing.DefaultComboBoxModel;
 
   26 import javax.swing.JOptionPane;
 
   27 import org.openide.util.NbBundle.Messages;
 
   30 import org.openide.windows.WindowManager;
 
   38 @SuppressWarnings(
"PMD.SingularField") 
 
   41     private static final long serialVersionUID = 1L;
 
   44     private static final String REPORTING_CONFIGURATION_NAME = 
"CommandLineIngest";
 
   45     private static final boolean DISPLAY_CASE_SPECIFIC_DATA = 
false; 
 
   46     private static final boolean RUN_REPORTS = 
false; 
 
   62         return REPORTING_CONFIGURATION_NAME;
 
   66         this.getParent().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
   69         showWarnings(ingestJobSettings);
 
   72         add(ingestJobSettingsPanel, BorderLayout.PAGE_START);
 
   74         if (JOptionPane.showConfirmDialog(
this, ingestJobSettingsPanel, 
"Ingest Module Configuration", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) == JOptionPane.OK_OPTION) {
 
   76             ingestJobSettings = ingestJobSettingsPanel.
getSettings();
 
   77             ingestJobSettings.
save();
 
   78             showWarnings(ingestJobSettings);
 
   81         this.getParent().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
 
   85         List<String> warnings = ingestJobSettings.
getWarnings();
 
   86         if (warnings.isEmpty() == 
false) {
 
   87             StringBuilder warningMessage = 
new StringBuilder();
 
   88             for (String warning : warnings) {
 
   89                 warningMessage.append(warning).append(
"\n");
 
   91             JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), warningMessage.toString());
 
   96         "CommandListIngestSettingsPanel_Default_Report_DisplayName=Default",
 
   97         "CommandListIngestSettingsPanel_Make_Config=Make new profile..." 
  104         configNames.remove(REPORTING_CONFIGURATION_NAME);
 
  106         DefaultComboBoxModel<String> model = 
new DefaultComboBoxModel<>();
 
  107         model.addElement(Bundle.CommandListIngestSettingsPanel_Default_Report_DisplayName());
 
  108         for (String name : configNames) {
 
  109             model.addElement(name);
 
  112         model.addElement(Bundle.CommandListIngestSettingsPanel_Make_Config());
 
  114         reportProfileCB.setModel(model);
 
  115         reportProfileCB.setSelectedIndex(0);
 
  127         return configNames.contains(name);
 
  138         String reportName = (String) reportProfileCB.getSelectedItem();
 
  140         if (reportName.equals(Bundle.CommandListIngestSettingsPanel_Default_Report_DisplayName())) {
 
  141             reportName = REPORTING_CONFIGURATION_NAME;
 
  152     @SuppressWarnings(
"unchecked")
 
  154     private 
void initComponents() {
 
  155         java.awt.GridBagConstraints gridBagConstraints;
 
  157         nodePanel = 
new javax.swing.JPanel();
 
  158         bnEditIngestSettings = 
new javax.swing.JButton();
 
  159         bnEditReportSettings = 
new javax.swing.JButton();
 
  160         javax.swing.JTextPane ingestDescriptionTextPane = 
new javax.swing.JTextPane();
 
  161         javax.swing.JLabel ingestProfileLabel = 
new javax.swing.JLabel();
 
  162         ingestProfileCB = 
new javax.swing.JComboBox<>();
 
  163         javax.swing.JTextPane reportDescriptionTextPane = 
new javax.swing.JTextPane();
 
  164         javax.swing.JLabel reportProfileLabel = 
new javax.swing.JLabel();
 
  165         reportProfileCB = 
new javax.swing.JComboBox<>();
 
  166         javax.swing.Box.Filler bottomFiller = 
new javax.swing.Box.Filler(
new java.awt.Dimension(0, 0), 
new java.awt.Dimension(0, 0), 
new java.awt.Dimension(0, 0));
 
  167         jTextPane1 = 
new javax.swing.JTextPane();
 
  169         setPreferredSize(
new java.awt.Dimension(810, 422));
 
  170         setLayout(
new java.awt.BorderLayout());
 
  172         nodePanel.setMinimumSize(
new java.awt.Dimension(100, 100));
 
  173         nodePanel.setPreferredSize(
new java.awt.Dimension(801, 551));
 
  174         nodePanel.setLayout(
new java.awt.GridBagLayout());
 
  176         org.openide.awt.Mnemonics.setLocalizedText(bnEditIngestSettings, 
org.openide.util.NbBundle.getMessage(
CommandLineIngestSettingsPanel.class, 
"CommandLineIngestSettingsPanel.bnEditIngestSettings.text")); 
 
  177         bnEditIngestSettings.setToolTipText(
org.openide.util.NbBundle.getMessage(
CommandLineIngestSettingsPanel.class, 
"CommandLineIngestSettingsPanel.bnEditIngestSettings.toolTipText")); 
 
  178         bnEditIngestSettings.setActionCommand(
org.openide.util.NbBundle.getMessage(
CommandLineIngestSettingsPanel.class, 
"CommandLineIngestSettingsPanel.bnEditIngestSettings.text")); 
 
  179         bnEditIngestSettings.addActionListener(
new java.awt.event.ActionListener() {
 
  180             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  181                 bnEditIngestSettingsActionPerformed(evt);
 
  184         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  185         gridBagConstraints.gridx = 2;
 
  186         gridBagConstraints.gridy = 2;
 
  187         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
 
  188         gridBagConstraints.insets = 
new java.awt.Insets(0, 9, 0, 0);
 
  189         nodePanel.add(bnEditIngestSettings, gridBagConstraints);
 
  191         org.openide.awt.Mnemonics.setLocalizedText(bnEditReportSettings, 
org.openide.util.NbBundle.getMessage(
CommandLineIngestSettingsPanel.class, 
"CommandLineIngestSettingsPanel.bnEditReportSettings.text")); 
 
  192         bnEditReportSettings.setToolTipText(
org.openide.util.NbBundle.getMessage(
CommandLineIngestSettingsPanel.class, 
"CommandLineIngestSettingsPanel.bnEditReportSettings.toolTipText")); 
 
  193         bnEditReportSettings.setActionCommand(
org.openide.util.NbBundle.getMessage(
CommandLineIngestSettingsPanel.class, 
"CommandLineIngestSettingsPanel.bnEditReportSettings.actionCommand")); 
 
  194         bnEditReportSettings.addActionListener(
new java.awt.event.ActionListener() {
 
  195             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  196                 bnEditReportSettingsActionPerformed(evt);
 
  199         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  200         gridBagConstraints.gridx = 2;
 
  201         gridBagConstraints.gridy = 4;
 
  202         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
 
  203         gridBagConstraints.insets = 
new java.awt.Insets(0, 9, 0, 0);
 
  204         nodePanel.add(bnEditReportSettings, gridBagConstraints);
 
  205         bnEditReportSettings.getAccessibleContext().setAccessibleName(
org.openide.util.NbBundle.getMessage(
CommandLineIngestSettingsPanel.class, 
"CommandLineIngestSettingsPanel.bnEditReportSettings.AccessibleContext.accessibleName")); 
 
  207         ingestDescriptionTextPane.setEditable(
false);
 
  208         ingestDescriptionTextPane.setBackground(javax.swing.UIManager.getDefaults().getColor(
"Label.background"));
 
  209         ingestDescriptionTextPane.setText(
org.openide.util.NbBundle.getMessage(
CommandLineIngestSettingsPanel.class, 
"CommandLineIngestSettingsPanel.ingestDescriptionTextPane.text")); 
 
  210         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  211         gridBagConstraints.gridx = 0;
 
  212         gridBagConstraints.gridy = 0;
 
  213         gridBagConstraints.gridwidth = 3;
 
  214         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
 
  215         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
 
  216         gridBagConstraints.weightx = 1.0;
 
  217         gridBagConstraints.insets = 
new java.awt.Insets(5, 5, 10, 5);
 
  218         nodePanel.add(ingestDescriptionTextPane, gridBagConstraints);
 
  220         org.openide.awt.Mnemonics.setLocalizedText(ingestProfileLabel, 
org.openide.util.NbBundle.getMessage(
CommandLineIngestSettingsPanel.class, 
"CommandLineIngestSettingsPanel.ingestProfileLabel.text")); 
 
  221         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  222         gridBagConstraints.gridx = 0;
 
  223         gridBagConstraints.gridy = 2;
 
  224         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
 
  225         gridBagConstraints.insets = 
new java.awt.Insets(0, 25, 0, 0);
 
  226         nodePanel.add(ingestProfileLabel, gridBagConstraints);
 
  228         ingestProfileCB.setModel(
new javax.swing.DefaultComboBoxModel<>(
new String[] { 
"Default" }));
 
  229         ingestProfileCB.setEnabled(
false);
 
  230         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  231         gridBagConstraints.gridx = 1;
 
  232         gridBagConstraints.gridy = 2;
 
  233         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
 
  234         gridBagConstraints.insets = 
new java.awt.Insets(0, 5, 0, 0);
 
  235         nodePanel.add(ingestProfileCB, gridBagConstraints);
 
  237         reportDescriptionTextPane.setEditable(
false);
 
  238         reportDescriptionTextPane.setBackground(javax.swing.UIManager.getDefaults().getColor(
"Label.background"));
 
  239         reportDescriptionTextPane.setText(
org.openide.util.NbBundle.getMessage(
CommandLineIngestSettingsPanel.class, 
"CommandLineIngestSettingsPanel.reportDescriptionTextPane.text")); 
 
  240         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  241         gridBagConstraints.gridx = 0;
 
  242         gridBagConstraints.gridy = 3;
 
  243         gridBagConstraints.gridwidth = 3;
 
  244         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
 
  245         gridBagConstraints.insets = 
new java.awt.Insets(15, 5, 5, 5);
 
  246         nodePanel.add(reportDescriptionTextPane, gridBagConstraints);
 
  248         org.openide.awt.Mnemonics.setLocalizedText(reportProfileLabel, 
org.openide.util.NbBundle.getMessage(
CommandLineIngestSettingsPanel.class, 
"CommandLineIngestSettingsPanel.reportProfileLabel.text")); 
 
  249         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  250         gridBagConstraints.gridx = 0;
 
  251         gridBagConstraints.gridy = 4;
 
  252         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
 
  253         gridBagConstraints.insets = 
new java.awt.Insets(0, 25, 0, 0);
 
  254         nodePanel.add(reportProfileLabel, gridBagConstraints);
 
  256         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  257         gridBagConstraints.gridx = 1;
 
  258         gridBagConstraints.gridy = 4;
 
  259         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
 
  260         gridBagConstraints.insets = 
new java.awt.Insets(0, 5, 0, 0);
 
  261         nodePanel.add(reportProfileCB, gridBagConstraints);
 
  262         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  263         gridBagConstraints.gridx = 0;
 
  264         gridBagConstraints.gridy = 5;
 
  265         gridBagConstraints.weighty = 1.0;
 
  266         nodePanel.add(bottomFiller, gridBagConstraints);
 
  268         jTextPane1.setEditable(
false);
 
  269         jTextPane1.setBackground(javax.swing.UIManager.getDefaults().getColor(
"Label.background"));
 
  271         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  272         gridBagConstraints.gridx = 0;
 
  273         gridBagConstraints.gridy = 1;
 
  274         gridBagConstraints.gridwidth = 3;
 
  275         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
 
  276         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
 
  277         gridBagConstraints.insets = 
new java.awt.Insets(10, 5, 5, 5);
 
  278         nodePanel.add(jTextPane1, gridBagConstraints);
 
  280         add(nodePanel, java.awt.BorderLayout.CENTER);
 
  283         "CommandListIngestSettingsPanel_Report_Name_Msg=Please supply a report profile name (letters, digits, and underscore characters only):",
 
  284         "CommandLineIngestSettingPanel_empty_report_name_mgs=Report profile name was empty, no profile created.",
 
  285         "CommandLineIngestSettingPanel_existing_report_name_mgs=Report profile name was already exists, no profile created.",
 
  286         "CommandLineIngestSettingPanel_invalid_report_name_mgs=Report profile name contained illegal characters, no profile created." 
  289         String reportName = getReportName();
 
  290         if (reportName.equals(Bundle.CommandListIngestSettingsPanel_Make_Config())) {
 
  291             reportName = JOptionPane.showInputDialog(
this, Bundle.CommandListIngestSettingsPanel_Report_Name_Msg());
 
  294             if (reportName == null) {
 
  296             } 
else if (reportName.isEmpty()) {
 
  297                 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), Bundle.CommandLineIngestSettingPanel_empty_report_name_mgs());
 
  299             } 
else if (doesReportProfileNameExist(reportName)) {
 
  300                 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), Bundle.CommandLineIngestSettingPanel_existing_report_name_mgs());
 
  304                 String originalReportName = reportName;
 
  305                 reportName = reportName.replaceAll(
"[^A-Za-z0-9_]", 
"");
 
  306                 if (reportName.isEmpty() || (!(originalReportName.equals(reportName)))) {
 
  308                     JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), Bundle.CommandLineIngestSettingPanel_invalid_report_name_mgs());
 
  314         this.getParent().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
  315         doReportWizard(reportName, DISPLAY_CASE_SPECIFIC_DATA, RUN_REPORTS);
 
  319         if (((DefaultComboBoxModel) reportProfileCB.getModel()).getIndexOf(reportName) >= 0) {
 
  320             reportProfileCB.setSelectedItem(reportName);
 
  323         this.getParent().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
 
  327         displayIngestJobSettingsPanel();
 
void displayIngestJobSettingsPanel()
 
static void showWarnings(IngestJobSettings ingestJobSettings)
 
javax.swing.JTextPane jTextPane1
 
javax.swing.JButton bnEditReportSettings
 
void bnEditReportSettingsActionPerformed(java.awt.event.ActionEvent evt)
 
javax.swing.JPanel nodePanel
 
static void doReportWizard(String configName, boolean displayCaseSpecificData, boolean runReports)
 
static Set< String > getReportConfigNames()
 
IngestJobSettings getSettings()
 
javax.swing.JComboBox< String > reportProfileCB
 
void bnEditIngestSettingsActionPerformed(java.awt.event.ActionEvent evt)
 
javax.swing.JButton bnEditIngestSettings
 
List< String > getWarnings()
 
javax.swing.JComboBox< String > ingestProfileCB
 
synchronized static Logger getLogger(String name)
 
static String getCommandLineModeIngestModuleContextString()
 
static String getDefaultReportingConfigName()
 
CommandLineIngestSettingsPanel(CommandLineIngestSettingsPanelController theController)
 
boolean doesReportProfileNameExist(String name)