19 package org.sleuthkit.autopsy.communications.relationships;
21 import com.google.gson.Gson;
22 import java.util.Arrays;
23 import java.util.Collection;
24 import java.util.HashSet;
26 import java.util.TreeSet;
27 import java.util.function.Consumer;
28 import java.util.logging.Level;
29 import org.openide.nodes.Children;
30 import org.openide.nodes.Node;
31 import org.openide.nodes.Sheet;
32 import org.openide.util.NbBundle;
41 import org.
sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments.FileAttachment;
42 import org.
sleuthkit.datamodel.blackboardutils.attributes.MessageAttachments;
47 final class AttachmentThumbnailsChildren
extends Children.Keys<AbstractFile> {
49 private static final Logger LOGGER = Logger.getLogger(AttachmentThumbnailsChildren.class.getName());
51 private final Set<BlackboardArtifact> artifacts;
60 AttachmentThumbnailsChildren(Set<BlackboardArtifact> artifacts) {
63 this.artifacts = artifacts;
68 protected Node[] createNodes(AbstractFile t) {
69 return new Node[]{
new AttachementThumbnailNode(t)};
73 protected void addNotify() {
76 Set<AbstractFile> thumbnails =
new TreeSet<>((AbstractFile file1, AbstractFile file2) -> {
77 int result = Long.compare(file1.getSize(), file2.getSize());
79 result = file1.getName().compareTo(file2.getName());
85 artifacts.forEach(
new Consumer<BlackboardArtifact>() {
87 public void accept(BlackboardArtifact bba) {
90 BlackboardAttribute attachmentsAttr = bba.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ATTACHMENTS));
91 if (attachmentsAttr != null) {
93 String jsonVal = attachmentsAttr.getValueString();
94 MessageAttachments msgAttachments =
new Gson().fromJson(jsonVal, MessageAttachments.class);
96 Collection<FileAttachment> fileAttachments = msgAttachments.getFileAttachments();
97 for (FileAttachment fileAttachment : fileAttachments) {
98 long attachedFileObjId = fileAttachment.getObjectId();
99 if (attachedFileObjId >= 0) {
100 AbstractFile attachedFile = bba.getSleuthkitCase().getAbstractFileById(attachedFileObjId);
101 thumbnails.add(attachedFile);
105 for (Content childContent : bba.getChildren()) {
106 if (childContent instanceof AbstractFile) {
107 thumbnails.add((AbstractFile) childContent);
112 }
catch (TskCoreException ex) {
113 LOGGER.log(Level.WARNING,
"Unable to get children from artifact.", ex);
124 static class AttachementThumbnailNode
extends FileNode {
126 AttachementThumbnailNode(AbstractFile file) {
131 protected Sheet createSheet() {
132 Sheet sheet = super.createSheet();
133 Set<String> keepProps =
new HashSet<>(Arrays.asList(
134 NbBundle.getMessage(AbstractAbstractFileNode.class,
"AbstractAbstractFileNode.nameColLbl"),
135 NbBundle.getMessage(AbstractAbstractFileNode.class,
"AbstractAbstractFileNode.createSheet.score.name"),
136 NbBundle.getMessage(AbstractAbstractFileNode.class,
"AbstractAbstractFileNode.createSheet.comment.name"),
137 NbBundle.getMessage(AbstractAbstractFileNode.class,
"AbstractAbstractFileNode.createSheet.count.name"),
138 NbBundle.getMessage(AbstractAbstractFileNode.class,
"AbstractAbstractFileNode.sizeColLbl"),
139 NbBundle.getMessage(AbstractAbstractFileNode.class,
"AbstractAbstractFileNode.mimeType"),
140 NbBundle.getMessage(AbstractAbstractFileNode.class,
"AbstractAbstractFileNode.knownColLbl")));
143 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
144 for (Node.Property<?> p : sheetSet.getProperties()) {
145 if (!keepProps.contains(p.getName())) {
146 sheetSet.remove(p.getName());