Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
OpenFileDiscoveryAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy
3  *
4  * Copyright 2019 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.filequery;
20 
21 import java.awt.Component;
22 import java.util.HashMap;
23 import java.util.Map;
24 import java.util.logging.Level;
25 import javax.swing.ImageIcon;
26 import javax.swing.JButton;
27 import javax.swing.JOptionPane;
28 import org.openide.awt.ActionID;
29 import org.openide.awt.ActionReference;
30 import org.openide.awt.ActionReferences;
31 import org.openide.awt.ActionRegistration;
32 import org.openide.util.HelpCtx;
33 import org.openide.util.NbBundle;
34 import org.openide.util.actions.CallableSystemAction;
35 import org.openide.util.actions.Presenter;
39 import org.sleuthkit.datamodel.DataSource;
40 import org.sleuthkit.datamodel.IngestJobInfo;
41 import org.sleuthkit.datamodel.SleuthkitCase;
42 import org.sleuthkit.datamodel.TskCoreException;
43 
48 @ActionID(category = "Tools", id = "org.sleuthkit.autopsy.newpackage.OpenFileDiscoveryAction")
49 @ActionReferences(value = {
50  @ActionReference(path = "Menu/Tools", position = 103)
51  ,
52  @ActionReference(path = "Toolbars/Case", position = 105)})
53 @ActionRegistration(displayName = "#CTL_OpenFileDiscoveryAction", lazy = false)
54 @NbBundle.Messages({"CTL_OpenFileDiscoveryAction=File Discovery"})
55 public final class OpenFileDiscoveryAction extends CallableSystemAction implements Presenter.Toolbar {
56 
57  private static final Logger logger = Logger.getLogger(OpenFileDiscoveryAction.class.getName());
58 
59  private static final String DISPLAY_NAME = Bundle.CTL_OpenFileDiscoveryAction();
60  private static final long serialVersionUID = 1L;
61  private final JButton toolbarButton = new JButton();
62 
64  toolbarButton.addActionListener(OpenFileDiscoveryAction.this::actionPerformed);
65  this.setEnabled(false);
66  }
67 
68  @Override
69  public boolean isEnabled() {
70  return Case.isCaseOpen();
71  }
72 
73  @NbBundle.Messages({"OpenFileDiscoveryAction.resultsIncomplete.text=Results may be incomplete"})
74 
75  @Override
76  @SuppressWarnings("fallthrough")
77  public void performAction() {
79  if (tc != null) {
80  if (tc.isOpened() == false) {
81  tc.open();
82  tc.updateSearchSettings();
83  displayErrorMessage(tc);
84  }
85  tc.toFront();
86  tc.requestActive();
87 
88  }
89  }
90 
98  //check if modules run and assemble message
99  try {
100  SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase();
101  Map<Long, DataSourceModulesWrapper> dataSourceIngestModules = new HashMap<>();
102  for (DataSource dataSource : skCase.getDataSources()) {
103  dataSourceIngestModules.put(dataSource.getId(), new DataSourceModulesWrapper(dataSource.getName()));
104  }
105 
106  for (IngestJobInfo jobInfo : skCase.getIngestJobs()) {
107  dataSourceIngestModules.get(jobInfo.getObjectId()).updateModulesRun(jobInfo);
108  }
109  String message = "";
110  for (DataSourceModulesWrapper dsmodulesWrapper : dataSourceIngestModules.values()) {
111  message += dsmodulesWrapper.getMessage();
112  }
113  if (!message.isEmpty()) {
114  JOptionPane.showMessageDialog(tc, message, Bundle.OpenFileDiscoveryAction_resultsIncomplete_text(), JOptionPane.INFORMATION_MESSAGE);
115  }
116  } catch (NoCurrentCaseException | TskCoreException ex) {
117  logger.log(Level.WARNING, "Exception while determining which modules have been run for File Discovery", ex);
118  }
119  }
120 
126  @Override
127  public Component getToolbarPresenter() {
128  ImageIcon icon = new ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/discovery-icon-24.png")); //NON-NLS
129  toolbarButton.setIcon(icon);
130  toolbarButton.setText(this.getName());
131  return toolbarButton;
132  }
133 
139  @Override
140  public void setEnabled(boolean value) {
141  super.setEnabled(value);
142  toolbarButton.setEnabled(value);
143  }
144 
145  @Override
146  public String getName() {
147  return DISPLAY_NAME;
148  }
149 
150  @Override
151  public HelpCtx getHelpCtx() {
152  return HelpCtx.DEFAULT_HELP;
153  }
154 
155  @Override
156  public boolean asynchronous() {
157  return false; // run on edt
158  }
159 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.