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<>();
101 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));
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()));
143 if (attachmentFile != null) {
144 long size = attachmentFile.getSize();
145 String mimeType = attachmentFile.getMIMEType();
150 if (StringUtils.isNotEmpty(mimeType)) {
151 sheetSet.put(
new NodeProperty<>(
"Mime type",
"Mime type",
"", mimeType));
153 sheetSet.put(
new NodeProperty<>(
"Known",
"Known",
"", attachmentFile.getKnown().getName()));
161 return visitor.
visit(
this);
171 return getClass().getName();
175 Long attachmentObjId = attachment.getObjId();
176 if (attachmentObjId != null && attachmentObjId > 0) {
177 AbstractFile attachmentFile = null;
180 if (attachmentFile != null) {
181 return Lookups.fixed(attachment, attachmentFile);
183 return Lookups.fixed(attachment);
186 return Lookups.fixed(attachment);
189 return Lookups.fixed(attachment);
196 if (attachmentFile != null) {
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 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()