Autopsy  4.17.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ArtifactsWorker.java
Go to the documentation of this file.
1 /*
2  * Autopsy
3  *
4  * Copyright 2020 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.discovery.ui;
20 
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;
34 import org.sleuthkit.datamodel.BlackboardArtifact;
35 
39 class ArtifactsWorker extends SwingWorker<List<BlackboardArtifact>, Void> {
40 
41  private final BlackboardArtifact.ARTIFACT_TYPE artifactType;
42  private final static Logger logger = Logger.getLogger(ArtifactsWorker.class.getName());
43  private final String domain;
44 
51  ArtifactsWorker(BlackboardArtifact.ARTIFACT_TYPE artifactType, String domain) {
52  this.artifactType = artifactType;
53  this.domain = domain;
54  }
55 
56  @Override
57  protected List<BlackboardArtifact> doInBackground() throws Exception {
58  if (artifactType != null && !StringUtils.isBlank(domain)) {
59  DomainSearch domainSearch = new DomainSearch();
60  try {
61  return domainSearch.getArtifacts(new DomainSearchArtifactsRequest(Case.getCurrentCase().getSleuthkitCase(), domain, artifactType));
62  } catch (DiscoveryException ex) {
63  if (ex.getCause() instanceof InterruptedException) {
64  this.cancel(true);
65  //ignore the exception as it was cancelled while the cache was performing its get and we support cancellation
66  } else {
67  throw ex;
68  }
69  }
70  }
71  return new ArrayList<>();
72  }
73 
74  @Override
75  protected void done() {
76  List<BlackboardArtifact> listOfArtifacts = new ArrayList<>();
77  if (!isCancelled()) {
78  try {
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) {
85  //Worker was cancelled after previously finishing its background work, exception ignored to cut down on non-helpful logging
86  }
87  }
88 
89  }
90 }

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