19 package org.sleuthkit.autopsy.centralrepository.contentviewer;
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.HashMap;
24 import java.util.HashSet;
27 import java.util.logging.Level;
28 import javax.swing.SwingWorker;
29 import org.openide.nodes.Node;
48 class OtherOccurrencesNodeWorker
extends SwingWorker<OtherOccurrencesData, Void> {
50 private static final Logger logger = Logger.getLogger(OtherOccurrencesNodeWorker.class.getName());
52 private final Node node;
59 OtherOccurrencesNodeWorker(Node node) {
64 protected OtherOccurrencesData doInBackground() throws Exception {
65 OsAccount osAccount = node.getLookup().lookup(OsAccount.class);
66 AbstractFile file = OtherOccurrences.getAbstractFileFromNode(node);
67 if (osAccount != null) {
68 file = node.getLookup().lookup(AbstractFile.class);
71 String dataSourceName =
"";
72 Map<String, CorrelationCase> caseNames =
new HashMap<>();
73 Case currentCase = Case.getCurrentCaseThrows();
74 OtherOccurrencesData data = null;
77 Content dataSource = file.getDataSource();
78 deviceId = currentCase.getSleuthkitCase().getDataSource(dataSource.getId()).getDeviceId();
79 dataSourceName = dataSource.getName();
81 }
catch (TskException ex) {
86 Collection<CorrelationAttributeInstance> correlationAttributes =
new ArrayList<>();
87 if (osAccount != null) {
88 correlationAttributes = OtherOccurrences.getCorrelationAttributeFromOsAccount(node, osAccount);
90 correlationAttributes = OtherOccurrences.getCorrelationAttributesFromNode(node, file);
93 Set<String> dataSources =
new HashSet<>();
94 for (CorrelationAttributeInstance corAttr : correlationAttributes) {
95 for (NodeData nodeData : OtherOccurrences.getCorrelatedInstances(file, deviceId, dataSourceName, corAttr).values()) {
96 if (nodeData.isCentralRepoNode()) {
98 dataSources.add(OtherOccurrences.makeDataSourceString(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(), nodeData.getDeviceID(), nodeData.getDataSourceName()));
99 caseNames.put(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(), nodeData.getCorrelationAttributeInstance().getCorrelationCase());
100 }
catch (CentralRepoException ex) {
101 logger.log(Level.WARNING,
"Unable to get correlation case for displaying other occurrence for case: " + nodeData.getCaseName(), ex);
105 dataSources.add(OtherOccurrences.makeDataSourceString(Case.getCurrentCaseThrows().getName(), nodeData.getDeviceID(), nodeData.getDataSourceName()));
106 caseNames.put(Case.getCurrentCaseThrows().getName(),
new CorrelationCase(Case.getCurrentCaseThrows().getName(), Case.getCurrentCaseThrows().getDisplayName()));
107 }
catch (NoCurrentCaseException ex) {
108 logger.log(Level.WARNING,
"No current case open for other occurrences", ex);
119 if (!isCancelled()) {
120 data =
new OtherOccurrencesData(correlationAttributes, file, dataSourceName, deviceId, caseNames, totalCount, dataSources.size(), OtherOccurrences.getEarliestCaseDate());
130 static class OtherOccurrencesData {
132 private final String deviceId;
133 private final AbstractFile file;
134 private final String dataSourceName;
135 private final Map<String, CorrelationCase> caseMap;
136 private final int instanceDataCount;
137 private final int dataSourceCount;
138 private final String earliestCaseDate;
139 private final Collection<CorrelationAttributeInstance> correlationAttributes;
141 private OtherOccurrencesData(Collection<CorrelationAttributeInstance> correlationAttributes, AbstractFile file, String dataSourceName, String deviceId, Map<String, CorrelationCase> caseMap,
int instanceCount,
int dataSourceCount, String earliestCaseDate) {
143 this.deviceId = deviceId;
144 this.dataSourceName = dataSourceName;
145 this.caseMap = caseMap;
146 this.instanceDataCount = instanceCount;
147 this.dataSourceCount = dataSourceCount;
148 this.earliestCaseDate = earliestCaseDate;
149 this.correlationAttributes = correlationAttributes;
152 public String getDeviceId() {
156 public AbstractFile getFile() {
160 public String getDataSourceName() {
161 return dataSourceName;
164 public Map<String, CorrelationCase> getCaseMap() {
168 public int getInstanceDataCount() {
169 return instanceDataCount;
172 public int getDataSourceCount() {
173 return dataSourceCount;
181 public String getEarliestCaseDate() {
182 return earliestCaseDate;
185 public Collection<CorrelationAttributeInstance> getCorrelationAttributes() {
186 return correlationAttributes;