mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Added reason for files not candidates to be added to hashsets
This commit is contained in:
parent
0f9b42b9c2
commit
59ccaa50eb
@ -1,15 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2013-2018 Basis Technology Corp.
|
* Copyright 2013-2018 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@ -27,6 +27,7 @@ import javax.swing.AbstractAction;
|
|||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.openide.util.Utilities;
|
import org.openide.util.Utilities;
|
||||||
import org.openide.util.actions.Presenter;
|
import org.openide.util.actions.Presenter;
|
||||||
@ -42,17 +43,30 @@ import org.sleuthkit.datamodel.TskCoreException;
|
|||||||
* Instances of this Action allow users to content to a hash database.
|
* Instances of this Action allow users to content to a hash database.
|
||||||
*/
|
*/
|
||||||
final class AddContentToHashDbAction extends AbstractAction implements Presenter.Popup {
|
final class AddContentToHashDbAction extends AbstractAction implements Presenter.Popup {
|
||||||
|
|
||||||
private static AddContentToHashDbAction instance;
|
private static AddContentToHashDbAction instance;
|
||||||
|
|
||||||
private final static String SINGLE_SELECTION_NAME = NbBundle.getMessage(AddContentToHashDbAction.class,
|
private final static String SINGLE_SELECTION_NAME = NbBundle.getMessage(AddContentToHashDbAction.class,
|
||||||
"AddContentToHashDbAction.singleSelectionName");
|
"AddContentToHashDbAction.singleSelectionName");
|
||||||
private final static String MULTIPLE_SELECTION_NAME = NbBundle.getMessage(AddContentToHashDbAction.class,
|
private final static String MULTI_SELECTION_NAME = NbBundle.getMessage(AddContentToHashDbAction.class,
|
||||||
"AddContentToHashDbAction.multipleSelectionName");
|
"AddContentToHashDbAction.multipleSelectionName");
|
||||||
|
|
||||||
|
//During ingest display strings. This text will be greyed out and unclickable
|
||||||
private final static String SINGLE_SELECTION_NAME_DURING_INGEST = NbBundle.getMessage(AddContentToHashDbAction.class,
|
private final static String SINGLE_SELECTION_NAME_DURING_INGEST = NbBundle.getMessage(AddContentToHashDbAction.class,
|
||||||
"AddContentToHashDbAction.singleSelectionNameDuringIngest");
|
"AddContentToHashDbAction.singleSelectionNameDuringIngest");
|
||||||
private final static String MULTIPLE_SELECTION_NAME_DURING_INGEST = NbBundle.getMessage(AddContentToHashDbAction.class,
|
private final static String MULTI_SELECTION_NAME_DURING_INGEST = NbBundle.getMessage(AddContentToHashDbAction.class,
|
||||||
"AddContentToHashDbAction.multipleSelectionNameDuringIngest");
|
"AddContentToHashDbAction.multipleSelectionNameDuringIngest");
|
||||||
|
|
||||||
|
//No MD5 Hash and Empty File display strings. This text will be greyed out and unclickable
|
||||||
|
private final static String SINGLE_SELECTION_NAME_EMPTY_FILE = NbBundle.getMessage(AddContentToHashDbAction.class,
|
||||||
|
"AddContentToHashDbAction.singleSelectionNameEmpty");
|
||||||
|
private final static String MULTI_SELECTION_NAME_EMPTY_FILE = NbBundle.getMessage(AddContentToHashDbAction.class,
|
||||||
|
"AddContentToHashDbAction.multipleSelectionNameEmpty");
|
||||||
|
private final static String SINGLE_SELECTION_NAME_NO_MD5 = NbBundle.getMessage(AddContentToHashDbAction.class,
|
||||||
|
"AddContentToHashDbAction.singleSelectionNameNoMD5");
|
||||||
|
private final static String MULTI_SELECTION_NAME_NO_MD5 = NbBundle.getMessage(AddContentToHashDbAction.class,
|
||||||
|
"AddContentToHashDbAction.multipleSelectionNameNoMD5");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AddContentToHashDbAction is a singleton to support multi-selection of
|
* AddContentToHashDbAction is a singleton to support multi-selection of
|
||||||
* nodes, since org.openide.nodes.NodeOp.findActions(Node[] nodes) will only
|
* nodes, since org.openide.nodes.NodeOp.findActions(Node[] nodes) will only
|
||||||
@ -86,30 +100,40 @@ final class AddContentToHashDbAction extends AbstractAction implements Presenter
|
|||||||
super(SINGLE_SELECTION_NAME);
|
super(SINGLE_SELECTION_NAME);
|
||||||
// Get any AbstractFile objects from the lookup of the currently focused top component.
|
// Get any AbstractFile objects from the lookup of the currently focused top component.
|
||||||
final Collection<? extends AbstractFile> selectedFiles = Utilities.actionsGlobalContext().lookupAll(AbstractFile.class);
|
final Collection<? extends AbstractFile> selectedFiles = Utilities.actionsGlobalContext().lookupAll(AbstractFile.class);
|
||||||
|
int numberOfFilesSelected = selectedFiles.size();
|
||||||
|
|
||||||
// Disable the menu if file ingest is in progress.
|
// Disable the menu if file ingest is in progress.
|
||||||
if (IngestManager.getInstance().isIngestRunning()) {
|
if (IngestManager.getInstance().isIngestRunning()) {
|
||||||
if(selectedFiles.size() > 1) {
|
setEnabled(false);
|
||||||
//Displays: 'Add Files to Hash Set (Ingest is running)'
|
setTextBasedOnNumberOfSelections(numberOfFilesSelected,
|
||||||
setText(MULTIPLE_SELECTION_NAME_DURING_INGEST);
|
SINGLE_SELECTION_NAME_DURING_INGEST,
|
||||||
} else {
|
MULTI_SELECTION_NAME_DURING_INGEST);
|
||||||
setText(SINGLE_SELECTION_NAME_DURING_INGEST);
|
|
||||||
}
|
|
||||||
setEnabled(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedFiles.isEmpty()) {
|
if (selectedFiles.isEmpty()) {
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
return;
|
return;
|
||||||
} else if (selectedFiles.size() > 1) {
|
} else {
|
||||||
setText(MULTIPLE_SELECTION_NAME);
|
setTextBasedOnNumberOfSelections(numberOfFilesSelected,
|
||||||
|
SINGLE_SELECTION_NAME,
|
||||||
|
MULTI_SELECTION_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable the menu if hashes have not been calculated.
|
// Disable the menu if md5 have not been computed or if the file size
|
||||||
|
// is empty. Display the appropriate reason to the user.
|
||||||
for (AbstractFile file : selectedFiles) {
|
for (AbstractFile file : selectedFiles) {
|
||||||
if (null == file.getMd5Hash()) {
|
if (file.getSize() == 0) {
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
|
setTextBasedOnNumberOfSelections(numberOfFilesSelected,
|
||||||
|
SINGLE_SELECTION_NAME_EMPTY_FILE,
|
||||||
|
MULTI_SELECTION_NAME_EMPTY_FILE);
|
||||||
|
return;
|
||||||
|
} else if (null == file.getMd5Hash() || StringUtils.isBlank(file.getMd5Hash())) {
|
||||||
|
setEnabled(false);
|
||||||
|
setTextBasedOnNumberOfSelections(numberOfFilesSelected,
|
||||||
|
SINGLE_SELECTION_NAME_NO_MD5,
|
||||||
|
MULTI_SELECTION_NAME_NO_MD5);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,6 +178,23 @@ final class AddContentToHashDbAction extends AbstractAction implements Presenter
|
|||||||
add(newHashSetItem);
|
add(newHashSetItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines which (2) display text should be set given the number of
|
||||||
|
* files selected.
|
||||||
|
*
|
||||||
|
* @param numberOfFilesSelected Number of currently selected files
|
||||||
|
* @param multiSelection Text to display with multiple selections
|
||||||
|
* @param singleSelection Text to display with single selection
|
||||||
|
*/
|
||||||
|
private void setTextBasedOnNumberOfSelections(int numberOfFilesSelected,
|
||||||
|
String singleSelection, String multiSelection) {
|
||||||
|
if (numberOfFilesSelected > 1) {
|
||||||
|
setText(multiSelection);
|
||||||
|
} else {
|
||||||
|
setText(singleSelection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void addFilesToHashSet(final Collection<? extends AbstractFile> files, HashDb hashSet) {
|
private void addFilesToHashSet(final Collection<? extends AbstractFile> files, HashDb hashSet) {
|
||||||
for (AbstractFile file : files) {
|
for (AbstractFile file : files) {
|
||||||
String md5Hash = file.getMd5Hash();
|
String md5Hash = file.getMd5Hash();
|
||||||
@ -187,8 +228,8 @@ final class AddContentToHashDbAction extends AbstractAction implements Presenter
|
|||||||
NbBundle.getMessage(this.getClass(),
|
NbBundle.getMessage(this.getClass(),
|
||||||
"AddContentToHashDbAction.addFilesToHashSet.unableToAddFileSzMsg",
|
"AddContentToHashDbAction.addFilesToHashSet.unableToAddFileSzMsg",
|
||||||
files.size() > 1 ? NbBundle
|
files.size() > 1 ? NbBundle
|
||||||
.getMessage(this.getClass(),
|
.getMessage(this.getClass(),
|
||||||
"AddContentToHashDbAction.addFilesToHashSet.files") : NbBundle
|
"AddContentToHashDbAction.addFilesToHashSet.files") : NbBundle
|
||||||
.getMessage(this.getClass(),
|
.getMessage(this.getClass(),
|
||||||
"AddContentToHashDbAction.addFilesToHashSet.file")),
|
"AddContentToHashDbAction.addFilesToHashSet.file")),
|
||||||
NbBundle.getMessage(this.getClass(),
|
NbBundle.getMessage(this.getClass(),
|
||||||
|
@ -155,6 +155,10 @@ AddContentToHashDbAction.singleSelectionName=Add File to Hash Set
|
|||||||
AddContentToHashDbAction.multipleSelectionName=Add Files to Hash Set
|
AddContentToHashDbAction.multipleSelectionName=Add Files to Hash Set
|
||||||
AddContentToHashDbAction.singleSelectionNameDuringIngest=Add File to Hash Set (Ingest is running)
|
AddContentToHashDbAction.singleSelectionNameDuringIngest=Add File to Hash Set (Ingest is running)
|
||||||
AddContentToHashDbAction.multipleSelectionNameDuringIngest=Add Files to Hash Set (Ingest is running)
|
AddContentToHashDbAction.multipleSelectionNameDuringIngest=Add Files to Hash Set (Ingest is running)
|
||||||
|
AddContentToHashDbAction.singleSelectionNameNoMD5=Add File to Hash Set (No MD5 Hash)
|
||||||
|
AddContentToHashDbAction.multipleSelectionNameNoMD5=Add Files to Hash Set (No MD5 Hash)
|
||||||
|
AddContentToHashDbAction.singleSelectionNameEmpty=Add File to Hash Set (Empty File)
|
||||||
|
AddContentToHashDbAction.multipleSelectionNameEmpty=Add Files to Hash Set (Empty File)
|
||||||
HashDbManager.ingestRunningExceptionMsg=Ingest is ongoing; this service will be unavailable until it finishes.
|
HashDbManager.ingestRunningExceptionMsg=Ingest is ongoing; this service will be unavailable until it finishes.
|
||||||
HashDbManager.saveErrorExceptionMsg=Error saving hash configuration
|
HashDbManager.saveErrorExceptionMsg=Error saving hash configuration
|
||||||
HashLookupSettingsPanel.jButton3.text=Import Hash Set
|
HashLookupSettingsPanel.jButton3.text=Import Hash Set
|
||||||
|
Loading…
x
Reference in New Issue
Block a user