19 package org.sleuthkit.autopsy.discovery.ui;
21 import java.util.ArrayList;
22 import java.util.List;
23 import java.util.concurrent.CancellationException;
24 import java.util.concurrent.ExecutionException;
25 import java.util.logging.Level;
26 import javax.swing.SwingWorker;
27 import org.apache.commons.lang3.StringUtils;
39 class ArtifactsWorker
extends SwingWorker<List<BlackboardArtifact>, Void> {
41 private final BlackboardArtifact.ARTIFACT_TYPE artifactType;
42 private final static Logger logger = Logger.getLogger(ArtifactsWorker.class.getName());
43 private final String domain;
51 ArtifactsWorker(BlackboardArtifact.ARTIFACT_TYPE artifactType, String domain) {
52 this.artifactType = artifactType;
57 protected List<BlackboardArtifact> doInBackground() throws Exception {
58 if (artifactType != null && !StringUtils.isBlank(domain)) {
59 DomainSearch domainSearch =
new DomainSearch();
61 return domainSearch.getArtifacts(
new DomainSearchArtifactsRequest(Case.getCurrentCase().getSleuthkitCase(), domain, artifactType));
62 }
catch (DiscoveryException ex) {
63 if (ex.getCause() instanceof InterruptedException) {
71 return new ArrayList<>();
75 protected void done() {
76 List<BlackboardArtifact> listOfArtifacts =
new ArrayList<>();
79 listOfArtifacts.addAll(
get());
80 DiscoveryEventUtils.getDiscoveryEventBus().post(
new DiscoveryEventUtils.ArtifactSearchResultEvent(artifactType, listOfArtifacts));
81 }
catch (InterruptedException | ExecutionException ex) {
82 logger.log(Level.SEVERE,
"Exception while trying to get list of artifacts for Domain details for artifact type: "
83 + artifactType.getDisplayName() +
" and domain: " + domain, ex);
84 }
catch (CancellationException ignored) {