Autopsy  4.13.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ContactsChildNodeFactory.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2019 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.communications.relationships;
20 
21 import java.util.List;
22 import java.util.Set;
23 import java.util.logging.Level;
24 import org.openide.nodes.ChildFactory;
25 import org.openide.nodes.Node;
29 import org.sleuthkit.datamodel.BlackboardArtifact;
30 import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT;
31 import org.sleuthkit.datamodel.CommunicationsManager;
32 import org.sleuthkit.datamodel.Content;
33 import org.sleuthkit.datamodel.TskCoreException;
34 
38 final class ContactsChildNodeFactory extends ChildFactory<BlackboardArtifact>{
39  private static final Logger logger = Logger.getLogger(ContactsChildNodeFactory.class.getName());
40 
41  private SelectionInfo selectionInfo;
42 
49  ContactsChildNodeFactory(SelectionInfo selectionInfo) {
50  this.selectionInfo = selectionInfo;
51  }
52 
58  public void refresh(SelectionInfo selectionInfo) {
59  this.selectionInfo = selectionInfo;
60  refresh(true);
61  }
62 
69  @Override
70  protected boolean createKeys(List<BlackboardArtifact> list) {
71 
72  if(selectionInfo == null) {
73  return true;
74  }
75 
76  final Set<Content> relationshipSources;
77  try {
78  relationshipSources = selectionInfo.getRelationshipSources();
79  } catch (TskCoreException ex) {
80  logger.log(Level.SEVERE, "Failed to load relationship sources.", ex); //NON-NLS
81  return false;
82  }
83 
84  relationshipSources.stream().filter((content) -> (content instanceof BlackboardArtifact)).forEachOrdered((content) -> {
85 
86  BlackboardArtifact bba = (BlackboardArtifact) content;
87  BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(bba.getArtifactTypeID());
88 
89  if (fromID == TSK_CONTACT) {
90  list.add(bba);
91  }
92  });
93 
94  return true;
95  }
96 
97  @Override
98  protected Node createNodeForKey(BlackboardArtifact key) {
99  return new ContactNode(key);
100  }
101 }

Copyright © 2012-2019 Basis Technology. Generated on: Tue Jan 7 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.