19 package org.sleuthkit.autopsy.modules.hashdatabase;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.util.Collection;
24 import java.util.HashSet;
25 import java.util.List;
26 import java.util.logging.Level;
27 import javax.swing.AbstractAction;
28 import javax.swing.JMenu;
29 import javax.swing.JMenuItem;
30 import javax.swing.JOptionPane;
31 import org.apache.commons.lang3.StringUtils;
32 import org.openide.util.NbBundle;
33 import org.openide.util.Utilities;
34 import org.openide.util.actions.Presenter;
35 import org.openide.windows.WindowManager;
51 "AddContentToHashDbAction.singleSelectionName");
53 "AddContentToHashDbAction.multipleSelectionName");
57 "AddContentToHashDbAction.singleSelectionNameDuringIngest");
59 "AddContentToHashDbAction.multipleSelectionNameDuringIngest");
63 "AddContentToHashDbAction.singleSelectionNameEmpty");
65 "AddContentToHashDbAction.multipleSelectionNameEmpty");
67 "AddContentToHashDbAction.singleSelectionNameNoMD5");
69 "AddContentToHashDbAction.multipleSelectionNameNoMD5");
82 if (null == instance) {
117 private static final long serialVersionUID = 1L;
124 super(SINGLE_SELECTION_NAME);
125 int numberOfFilesSelected = selectedFiles.size();
131 SINGLE_SELECTION_NAME_DURING_INGEST,
132 MULTI_SELECTION_NAME_DURING_INGEST);
134 }
else if (numberOfFilesSelected == 0) {
139 SINGLE_SELECTION_NAME,
140 MULTI_SELECTION_NAME);
144 for (AbstractFile file : selectedFiles) {
145 if (file.getSize() == 0) {
148 SINGLE_SELECTION_NAME_EMPTY_FILE,
149 MULTI_SELECTION_NAME_EMPTY_FILE);
151 }
else if (null == file.getMd5Hash() || StringUtils.isBlank(file.getMd5Hash())) {
154 SINGLE_SELECTION_NAME_NO_MD5,
155 MULTI_SELECTION_NAME_NO_MD5);
164 JMenuItem newHashSetItem =
new JMenuItem(NbBundle.getMessage(
this.getClass(),
165 "AddContentToHashDbAction.ContentMenu.createDbItem"));
166 newHashSetItem.addActionListener(
new ActionListener() {
169 HashDb hashDb =
new HashDbCreateDatabaseDialog().getHashDatabase();
170 if (null != hashDb) {
183 if (!hashDatabases.isEmpty()) {
184 for (
final HashDb database : hashDatabases) {
185 JMenuItem databaseItem = add(database.getHashSetName());
186 databaseItem.addActionListener(
new ActionListener() {
194 JMenuItem empty =
new JMenuItem(
195 NbBundle.getMessage(
this.getClass(),
196 "AddContentToHashDbAction.ContentMenu.noHashDbsConfigd"));
197 empty.setEnabled(
false);
208 this(
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class)));
221 String singleSelection, String multiSelection) {
222 if (numberOfFilesSelected > 1) {
223 setText(multiSelection);
225 setText(singleSelection);
230 for (AbstractFile file : files) {
231 String md5Hash = file.getMd5Hash();
232 if (null != md5Hash) {
234 if (HashUtility.isNoDataMd5(md5Hash)) {
236 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
237 NbBundle.getMessage(this.getClass(),
238 "AddContentToHashDbAction.addFilesToHashSet.unableToAddFileEmptyMsg",
240 NbBundle.getMessage(
this.getClass(),
241 "AddContentToHashDbAction.addFilesToHashSet.addToHashDbErr1.text"),
242 JOptionPane.ERROR_MESSAGE);
247 }
catch (TskCoreException ex) {
249 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
250 NbBundle.getMessage(this.getClass(),
251 "AddContentToHashDbAction.addFilesToHashSet.unableToAddFileMsg",
253 NbBundle.getMessage(
this.getClass(),
254 "AddContentToHashDbAction.addFilesToHashSet.addToHashDbErr2.text"),
255 JOptionPane.ERROR_MESSAGE);
258 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
259 NbBundle.getMessage(this.getClass(),
260 "AddContentToHashDbAction.addFilesToHashSet.unableToAddFileSzMsg",
261 files.size() > 1 ? NbBundle
262 .getMessage(this.getClass(),
263 "AddContentToHashDbAction.addFilesToHashSet.files") : NbBundle
264 .getMessage(this.getClass(),
265 "AddContentToHashDbAction.addFilesToHashSet.file")),
266 NbBundle.getMessage(
this.getClass(),
267 "AddContentToHashDbAction.addFilesToHashSet.addToHashDbErr3.text"),
268 JOptionPane.ERROR_MESSAGE);
static synchronized IngestManager getInstance()
static final String SINGLE_SELECTION_NAME
AddContentToHashDbAction()
boolean isIngestRunning()
static final String MULTI_SELECTION_NAME
JMenuItem getPopupPresenter()
static final String SINGLE_SELECTION_NAME_EMPTY_FILE
static final String SINGLE_SELECTION_NAME_NO_MD5
static final String MULTI_SELECTION_NAME_DURING_INGEST
static final long serialVersionUID
static final String SINGLE_SELECTION_NAME_DURING_INGEST
static synchronized HashDbManager getInstance()
void actionPerformed(ActionEvent event)
synchronized List< HashDb > getUpdateableHashSets()
JMenuItem getMenuForFiles(Collection< AbstractFile > selectedFiles)
synchronized static Logger getLogger(String name)
static AddContentToHashDbAction instance
static synchronized AddContentToHashDbAction getInstance()
static final String MULTI_SELECTION_NAME_EMPTY_FILE
static final String MULTI_SELECTION_NAME_NO_MD5
abstract void addHashes(Content content)