19 package org.sleuthkit.autopsy.communications;
21 import com.google.common.cache.CacheBuilder;
22 import com.google.common.cache.CacheLoader;
23 import com.google.common.cache.LoadingCache;
24 import java.beans.PropertyChangeEvent;
25 import java.beans.PropertyChangeListener;
26 import java.sql.SQLException;
27 import java.util.ArrayList;
28 import java.util.EnumSet;
29 import java.util.HashMap;
30 import java.util.List;
32 import java.util.concurrent.ExecutionException;
33 import java.util.concurrent.TimeUnit;
34 import java.util.logging.Level;
57 private final LoadingCache<String, Map<String, List<BlackboardArtifact>>>
accountMap;
69 static public synchronized List<BlackboardArtifact>
getContacts(Account account)
throws ExecutionException {
76 static synchronized void invalidateCache() {
85 accountMap = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).build(
86 new CacheLoader<String, Map<String, List<BlackboardArtifact>>>() {
88 public Map<String, List<BlackboardArtifact>> load(String key) {
91 }
catch (SQLException | TskCoreException ex) {
92 logger.log(Level.WARNING,
"Failed to build account to contact map", ex);
94 return new HashMap<>();
98 PropertyChangeListener ingestListener = pce -> {
99 String eventType = pce.getPropertyName();
100 if (eventType.equals(DATA_ADDED.toString())) {
109 if (event.getNewValue() == null) {
123 if (instance == null) {
138 private Map<String, List<BlackboardArtifact>>
buildMap() throws TskCoreException, SQLException {
139 Map<String, List<BlackboardArtifact>> acctMap =
new HashMap<>();
142 for (BlackboardArtifact contactArtifact : contactList) {
143 List<BlackboardAttribute> contactAttributes = contactArtifact.getAttributes();
144 for (BlackboardAttribute attribute : contactAttributes) {
145 String typeName = attribute.getAttributeType().getTypeName();
147 if (typeName.startsWith(
"TSK_EMAIL")
148 || typeName.startsWith(
"TSK_PHONE")
149 || typeName.startsWith(
"TSK_NAME")
150 || typeName.startsWith(
"TSK_ID")) {
151 String accountID = attribute.getValueString();
152 List<BlackboardArtifact> artifactList = acctMap.getOrDefault(accountID,
new ArrayList<>());
154 acctMap.put(accountID, artifactList);
156 if (!artifactList.contains(contactArtifact)) {
157 artifactList.add(contactArtifact);
BlackboardArtifact.Type getBlackboardArtifactType()
static synchronized IngestManager getInstance()
SleuthkitCase getSleuthkitCase()
void addIngestModuleEventListener(final PropertyChangeListener listener)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)