19 package org.sleuthkit.autopsy.datamodel;
21 import java.util.ArrayList;
22 import java.util.Arrays;
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.Action;
28 import org.apache.commons.lang3.StringUtils;
29 import org.openide.nodes.Children;
30 import org.openide.nodes.Sheet;
31 import org.openide.util.Lookup;
32 import org.openide.util.NbBundle;
33 import org.openide.util.Utilities;
34 import org.openide.util.lookup.Lookups;
51 import org.
sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments.Attachment;
52 import org.
sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments.FileAttachment;
53 import org.
sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments.URLAttachment;
70 super.setName(attachment.getLocation());
71 super.setDisplayName(attachment.getLocation());
74 Long attachmentObjId = attachment.getObjId();
75 AbstractFile attchmentAbstractFile = null;
77 if (attachmentObjId != null && attachmentObjId > 0) {
81 LOGGER.log(Level.WARNING,
"Error loading attachment file with object id " + attachmentObjId, ex);
84 attachmentFile = attchmentAbstractFile;
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<>();
99 actionsList.addAll(Arrays.asList(super.getActions(
true)));
102 if (this.attachmentFile != null) {
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));
116 actionsList.add(null);
120 actionsList.add(null);
123 if (1 == selectedFilesList.size()) {
129 return actionsList.toArray(
new Action[0]);
136 Sheet sheet =
new Sheet();
137 Sheet.Set sheetSet = Sheet.createPropertiesSet();
140 sheetSet.put(
new NodeProperty<>(
"Location",
"Location",
"", this.attachment.getLocation()));
142 if (attachmentFile != null) {
143 long size = attachmentFile.getSize();
144 String mimeType = attachmentFile.getMIMEType();
149 if (StringUtils.isNotEmpty(mimeType)) {
150 sheetSet.put(
new NodeProperty<>(
"Mime type",
"Mime type",
"", mimeType));
152 sheetSet.put(
new NodeProperty<>(
"Known",
"Known",
"", attachmentFile.getKnown().getName()));
160 return visitor.
visit(
this);
170 return getClass().getName();
174 Long attachmentObjId = attachment.getObjId();
175 if (attachmentObjId != null && attachmentObjId > 0) {
176 AbstractFile attachmentFile = null;
179 if (attachmentFile != null) {
180 return Lookups.fixed(attachment, attachmentFile);
182 return Lookups.fixed(attachment);
185 return Lookups.fixed(attachment);
188 return Lookups.fixed(attachment);
195 if (attachmentFile != null) {
196 this.setIconBaseWithExtension(getIconForFileType(attachmentFile));
197 }
else if (attachment instanceof FileAttachment) {
198 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/document-question-16.png");
199 }
else if (attachment instanceof URLAttachment) {
200 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/url-16.png");
202 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/file-icon-deleted.png");
static final Logger LOGGER
final AbstractFile attachmentFile
static Lookup createLookup(Attachment attachment)
static synchronized ExportCSVAction getInstance()
static synchronized DeleteFileContentTagAction getInstance()
AttachmentNode(Attachment attachment)
SleuthkitCase getSleuthkitCase()
T visit(DataSourceFilesNode in)
Action[] getActions(boolean context)
static synchronized ExternalViewerShortcutAction getInstance()
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
final Attachment attachment
static ViewFileInTimelineAction createViewFileAction(AbstractFile file)
static synchronized AddContentTagAction getInstance()