Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
RunIngestModulesAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2017 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.ingest.runIngestModuleWizard;
20 
21 import java.awt.Cursor;
22 import java.awt.event.ActionEvent;
23 import java.text.MessageFormat;
24 import java.util.ArrayList;
25 import java.util.List;
26 import javax.swing.Action;
27 import javax.swing.JOptionPane;
28 import org.openide.DialogDisplayer;
29 import org.openide.WizardDescriptor;
30 import org.openide.util.HelpCtx;
31 import org.openide.util.NbBundle.Messages;
32 import org.openide.util.actions.CallableSystemAction;
33 import org.openide.windows.WindowManager;
38 
44 public final class RunIngestModulesAction extends CallableSystemAction {
45 
46  @Messages("RunIngestModulesAction.name=Run Ingest Modules")
47  private static final long serialVersionUID = 1L;
48 
49  /*
50  * Note that the execution context is the name of the dialog that used to be
51  * used instead of this wizard and is retained for backwards compatibility.
52  */
53  private static final String EXECUTION_CONTEXT = "org.sleuthkit.autopsy.ingest.RunIngestModulesDialog";
54  private final List<Content> dataSources = new ArrayList<>();
55  private final IngestJobSettings.IngestType ingestType;
56 
64  this.putValue(Action.NAME, Bundle.RunIngestModulesAction_name());
65  this.dataSources.addAll(dataSources);
66  this.ingestType = IngestJobSettings.IngestType.ALL_MODULES;
67  }
68 
76  this.putValue(Action.NAME, Bundle.RunIngestModulesAction_name());
77  this.dataSources.add(dir);
79  }
80 
86  @Override
87  public void actionPerformed(ActionEvent e) {
93  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
94  RunIngestModulesWizardIterator wizard = new RunIngestModulesWizardIterator(EXECUTION_CONTEXT, this.ingestType, this.dataSources);
95  WizardDescriptor wiz = new WizardDescriptor(wizard);
96  wiz.setTitleFormat(new MessageFormat("{0}"));
97  wiz.setTitle(Bundle.RunIngestModulesAction_name());
98  WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
99  if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
100  IngestJobSettings ingestJobSettings = wizard.getIngestJobSettings();
101  showWarnings(ingestJobSettings);
102  IngestManager.getInstance().queueIngestJob(this.dataSources, ingestJobSettings);
103  }
104  }
105 
111  private static void showWarnings(IngestJobSettings ingestJobSettings) {
112  List<String> warnings = ingestJobSettings.getWarnings();
113  if (warnings.isEmpty() == false) {
114  StringBuilder warningMessage = new StringBuilder(1024);
115  for (String warning : warnings) {
116  warningMessage.append(warning).append("\n");
117  }
118  JOptionPane.showMessageDialog(null, warningMessage.toString());
119  }
120  }
121 
122  @Override
123  public void performAction() {
124  actionPerformed(null);
125  }
126 
127  @Override
128  public String getName() {
129  return Bundle.RunIngestModulesAction_name();
130  }
131 
132  @Override
133  public HelpCtx getHelpCtx() {
134  return HelpCtx.DEFAULT_HELP;
135  }
136 
137 }
static synchronized IngestManager getInstance()
void queueIngestJob(Collection< Content > dataSources, IngestJobSettings settings)

Copyright © 2012-2016 Basis Technology. Generated on: Mon Apr 24 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.