19 package org.sleuthkit.autopsy.modules.fileextmismatch;
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.HashMap;
24 import java.util.List;
26 import java.util.logging.Level;
27 import javax.swing.Action;
28 import javax.swing.JOptionPane;
29 import org.openide.util.NbBundle;
30 import org.openide.util.Utilities;
31 import org.openide.util.lookup.ServiceProvider;
42 @ServiceProvider(service = ContextMenuActionsProvider.class)
48 ArrayList<Action> actions =
new ArrayList<>();
53 final Collection<? extends BlackboardArtifact> selectedArts = Utilities.actionsGlobalContext().lookupAll(
BlackboardArtifact.class);
56 if (selectedArts.size() == 1) {
61 if (nodeArt.getArtifactTypeName().equals(
"TSK_EXT_MISMATCH_DETECTED")) {
62 String mimeTypeStr =
"";
68 int i = af.
getName().lastIndexOf(
".");
69 if ((i > -1) && ((i + 1) < af.
getName().length())) {
70 extStr = af.
getName().substring(i + 1).toLowerCase();
73 if (mimeTypeStr == null) {
77 if (!extStr.isEmpty() && !mimeTypeStr.isEmpty()) {
79 if (extStr.length() > 10) {
80 extStr = extStr.substring(0, 9);
82 if (mimeTypeStr.length() > 40) {
83 mimeTypeStr = mimeTypeStr.substring(0, 39);
85 String menuItemStr = NbBundle.getMessage(this.getClass(),
86 "FileExtMismatchContextMenuActionsProvider.menuItemStr",
90 HashMap<String, Set<String>> editableMap;
92 FileExtMismatchSettings settings = FileExtMismatchSettings.readSettings();
93 editableMap = settings.getMimeTypeToExtsMap();
94 actions.add(
new AddFileExtensionAction(menuItemStr, extStr, mimeTypeStr, settings));
95 Set<String> editedExtensions = editableMap.get(mimeTypeStr);
96 if (editedExtensions.contains(extStr)) {
98 actions.get(0).setEnabled(
false);
100 }
catch (FileExtMismatchSettings.FileExtMismatchSettingsException ex) {
101 JOptionPane.showMessageDialog(null,
102 NbBundle.getMessage(
this.getClass(),
"AddFileExtensionAction.msgDlg.msg2"),
103 NbBundle.getMessage(
this.getClass(),
"AddFileExtensionAction.msgDlg.title"),
104 JOptionPane.ERROR_MESSAGE);
105 logger.log(Level.WARNING,
"File extension mismatch settings could not be read, extensions update not available.", ex);
static synchronized IngestManager getInstance()
boolean isIngestRunning()
synchronized static Logger getLogger(String name)