19 package org.sleuthkit.autopsy.communications.relationships;
21 import java.util.HashMap;
22 import java.util.List;
25 import java.util.logging.Level;
26 import javax.swing.Action;
27 import org.openide.nodes.AbstractNode;
28 import org.openide.nodes.ChildFactory;
29 import org.openide.nodes.Children;
30 import org.openide.nodes.Node;
31 import org.openide.nodes.Sheet;
47 final class ThreadChildNodeFactory
extends ChildFactory<BlackboardArtifact> {
49 private static final Logger logger = Logger.getLogger(ThreadChildNodeFactory.class.getName());
51 private SelectionInfo selectionInfo;
53 private final Action preferredAction;
62 ThreadChildNodeFactory(Action preferredAction) {
63 this.preferredAction = preferredAction;
71 public void refresh(SelectionInfo selectionInfo) {
72 this.selectionInfo = selectionInfo;
85 protected boolean createKeys(List<BlackboardArtifact> list) {
86 CommunicationsManager communicationManager;
88 communicationManager = Case.getCurrentCaseThrows().getSleuthkitCase().getCommunicationsManager();
89 }
catch (NoCurrentCaseException | TskCoreException ex) {
90 logger.log(Level.SEVERE,
"Failed to get communications manager from case.", ex);
94 if(selectionInfo == null) {
98 final Set<Content> relationshipSources;
101 relationshipSources = communicationManager.getRelationshipSources(selectionInfo.getAccountDevicesInstances(), selectionInfo.getCommunicationsFilter());
103 createRootMessageKeys(list, relationshipSources) ;
104 }
catch (TskCoreException ex) {
105 logger.log(Level.SEVERE,
"Failed to get relationship sources.", ex);
122 private boolean createRootMessageKeys(List<BlackboardArtifact> list, Set<Content> relationshipSources)
throws TskCoreException{
123 Map<String, BlackboardArtifact> rootMessageMap =
new HashMap<>();
124 for(Content content: relationshipSources) {
125 if(!(content instanceof BlackboardArtifact)) {
129 BlackboardArtifact bba = (BlackboardArtifact) content;
130 BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(bba.getArtifactTypeID());
132 if (fromID == BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG
133 || fromID == BlackboardArtifact.ARTIFACT_TYPE.TSK_CALLLOG
134 || fromID == BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE) {
139 String threadID = MessageNode.UNTHREADED_ID;
140 BlackboardAttribute attribute = bba.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_THREAD_ID));
142 if(attribute != null) {
143 threadID = attribute.getValueString();
146 BlackboardArtifact tableArtifact = rootMessageMap.get(threadID);
147 if(tableArtifact == null) {
148 rootMessageMap.put(threadID, bba);
151 BlackboardAttribute tableAttribute = tableArtifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_SENT));
152 attribute = bba.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_SENT));
155 if(tableAttribute != null
157 && tableAttribute.getValueLong() > attribute.getValueLong()) {
158 rootMessageMap.put(threadID, bba);
164 for(BlackboardArtifact bba: rootMessageMap.values()) {
172 protected Node createNodeForKey(BlackboardArtifact bba) {
173 BlackboardAttribute attribute = null;
175 attribute = bba.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_THREAD_ID));
176 }
catch (TskCoreException ex) {
177 logger.log(Level.WARNING, String.format(
"Unable to get threadID for artifact: %s", bba.getName()), ex);
180 if (attribute != null) {
181 return new ThreadNode(bba, attribute.getValueString(), preferredAction);
184 return new UnthreadedNode();
191 final class UnthreadedNode
extends AbstractNode {
196 super(Children.LEAF);
197 setDisplayName(
"Unthreaded");
198 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/communications/images/unthreaded.png" );
202 protected Sheet createSheet() {
203 Sheet sheet = super.createSheet();
204 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
205 if (sheetSet == null) {
206 sheetSet = Sheet.createPropertiesSet();
211 sheetSet.put(
new NodeProperty<>(
"ThreadID",
"ThreadID",
"",MessageNode.UNTHREADED_ID));