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;
 
   44     private final boolean grabFocus;
 
   55     ArtifactsWorker(BlackboardArtifact.ARTIFACT_TYPE artifactType, String domain, 
boolean shouldGrabFocus) {
 
   56         this.artifactType = artifactType;
 
   58         this.grabFocus = shouldGrabFocus;
 
   62     protected List<BlackboardArtifact> doInBackground() throws Exception {
 
   63         if (artifactType != null && !StringUtils.isBlank(domain)) {
 
   64             DomainSearch domainSearch = 
new DomainSearch();
 
   66                 return domainSearch.getArtifacts(
new DomainSearchArtifactsRequest(Case.getCurrentCase().getSleuthkitCase(), domain, artifactType));
 
   67             } 
catch (DiscoveryException ex) {
 
   68                 if (ex.getCause() instanceof InterruptedException) {
 
   76         return new ArrayList<>();
 
   80     protected void done() {
 
   81         List<BlackboardArtifact> listOfArtifacts = 
new ArrayList<>();
 
   84                 listOfArtifacts.addAll(
get());
 
   85                 DiscoveryEventUtils.getDiscoveryEventBus().post(
new DiscoveryEventUtils.ArtifactSearchResultEvent(artifactType, listOfArtifacts, grabFocus));
 
   86             } 
catch (InterruptedException | ExecutionException ex) {
 
   87                 logger.log(Level.SEVERE, 
"Exception while trying to get list of artifacts for Domain details for artifact type: " 
   88                         + artifactType.getDisplayName() + 
" and domain: " + domain, ex);
 
   89             } 
catch (CancellationException ignored) {