19package org.sleuthkit.autopsy.datamodel;
21import java.util.ArrayList;
22import java.util.Arrays;
23import java.util.Collection;
24import java.util.HashSet;
26import java.util.logging.Level;
27import javax.swing.Action;
28import org.apache.commons.lang3.StringUtils;
29import org.openide.nodes.Children;
30import org.openide.nodes.Sheet;
31import org.openide.util.Lookup;
32import org.openide.util.NbBundle;
33import org.openide.util.Utilities;
34import org.openide.util.lookup.Lookups;
35import org.sleuthkit.autopsy.actions.AddContentTagAction;
36import org.sleuthkit.autopsy.actions.DeleteFileContentTagAction;
37import org.sleuthkit.autopsy.casemodule.Case;
38import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
39import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint;
40import org.sleuthkit.autopsy.coreutils.Logger;
41import static org.sleuthkit.autopsy.datamodel.FileNode.getIconForFileType;
42import org.sleuthkit.autopsy.directorytree.ExportCSVAction;
43import org.sleuthkit.autopsy.directorytree.ExternalViewerAction;
44import org.sleuthkit.autopsy.directorytree.ExternalViewerShortcutAction;
45import org.sleuthkit.autopsy.directorytree.ExtractAction;
46import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
47import org.sleuthkit.autopsy.directorytree.ViewContextAction;
48import org.sleuthkit.autopsy.timeline.actions.ViewFileInTimelineAction;
49import org.sleuthkit.datamodel.AbstractFile;
50import org.sleuthkit.datamodel.TskException;
51import org.sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments.Attachment;
52import org.sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments.FileAttachment;
53import org.sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments.URLAttachment;
71 super.setDisplayName(
attachment.getLocation());
75 AbstractFile attchmentAbstractFile =
null;
77 if (attachmentObjId !=
null && attachmentObjId > 0) {
81 LOGGER.log(Level.WARNING,
"Error loading attachment file with object id " + attachmentObjId, ex);
92 "AttachmentNode.getActions.viewFileInDir.text=View File in Directory",
93 "AttachmentNode.getActions.viewInNewWin.text=View in New Window",
94 "AttachmentNode.getActions.openInExtViewer.text=Open in External Viewer Ctrl+E",
95 "AttachmentNode.getActions.searchFilesSameMD5.text=Search for files with the same MD5 hash"})
98 List<Action> actionsList =
new ArrayList<>();
101 if (this.attachmentFile !=
null) {
102 actionsList.add(
new ViewContextAction(Bundle.AttachmentNode_getActions_viewFileInDir_text(),
this.attachmentFile));
104 actionsList.add(
null);
106 actionsList.add(
new NewWindowViewAction(Bundle.AttachmentNode_getActions_viewInNewWin_text(),
this));
107 final Collection<AbstractFile> selectedFilesList
108 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
109 if (selectedFilesList.size() == 1) {
111 Bundle.AttachmentNode_getActions_openInExtViewer_text(),
this));
115 actionsList.add(
null);
119 actionsList.add(
null);
122 if (1 == selectedFilesList.size()) {
127 actionsList.add(
null);
129 actionsList.addAll(Arrays.asList(super.getActions(
true)));
130 return actionsList.toArray(
new Action[0]);
137 Sheet sheet =
new Sheet();
138 Sheet.Set sheetSet = Sheet.createPropertiesSet();
141 sheetSet.put(
new NodeProperty<>(
"Location",
"Location",
"", this.attachment.getLocation()));
150 if (StringUtils.isNotEmpty(mimeType)) {
151 sheetSet.put(
new NodeProperty<>(
"Mime type",
"Mime type",
"", mimeType));
161 return visitor.
visit(
this);
171 return getClass().getName();
176 if (attachmentObjId !=
null && attachmentObjId > 0) {
197 this.setIconBaseWithExtension(getIconForFileType(
attachmentFile));
198 }
else if (
attachment instanceof FileAttachment) {
199 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/document-question-16.png");
200 }
else if (
attachment instanceof URLAttachment) {
201 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/url-16.png");
203 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/file-icon-deleted.png");
static synchronized AddContentTagAction getInstance()
static synchronized DeleteFileContentTagAction getInstance()
SleuthkitCase getSleuthkitCase()
static Case getCurrentCaseThrows()
synchronized static Logger getLogger(String name)
static final Logger LOGGER
AttachmentNode(Attachment attachment)
final AbstractFile attachmentFile
Action[] getActions(boolean context)
static Lookup createLookup(Attachment attachment)
final Attachment attachment
DisplayableItemNode(Children children)
static synchronized ExportCSVAction getInstance()
static synchronized ExternalViewerShortcutAction getInstance()
static ViewFileInTimelineAction createViewFileAction(AbstractFile file)
T visit(DataSourceFilesNode in)