Autopsy  4.21.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
MiniTimelineWorker.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 
22 import java.util.ArrayList;
23 import java.util.List;
24 import java.util.concurrent.CancellationException;
25 import java.util.concurrent.ExecutionException;
26 import java.util.logging.Level;
27 import javax.swing.SwingWorker;
28 import org.apache.commons.lang3.StringUtils;
34 
39 class MiniTimelineWorker extends SwingWorker<Void, Void> {
40 
41  private final static Logger logger = Logger.getLogger(MiniTimelineWorker.class.getName());
42  private final String domain;
43  private final boolean grabFocus;
44 
53  MiniTimelineWorker(String domain, boolean shouldGrabFocus) {
54  this.domain = domain;
55  this.grabFocus = shouldGrabFocus;
56  }
57 
58  @Override
59  protected Void doInBackground() throws Exception {
60  List<MiniTimelineResult> results = new ArrayList<>();
61  if (!StringUtils.isBlank(domain)) {
62  DomainSearch domainSearch = new DomainSearch();
63  try {
64  results.addAll(domainSearch.getAllArtifactsForDomain(Case.getCurrentCase().getSleuthkitCase(), domain));
65  DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.MiniTimelineResultEvent(results, domain, grabFocus));
66  } catch (DiscoveryException ex) {
67  if (ex.getCause() instanceof InterruptedException) {
68  this.cancel(true);
69  //ignore the exception as it was cancelled while the cache was performing its get and we support cancellation
70  } else {
71  throw ex;
72  }
73  }
74  }
75  return null;
76  }
77 
78  @Override
79  protected void done() {
80  if (!isCancelled()) {
81  try {
82  get();
83  } catch (InterruptedException | ExecutionException ex) {
84  logger.log(Level.SEVERE, "Exception while trying to get list of artifacts for Domain details for mini timeline view for domain: " + domain, ex);
85  } catch (CancellationException ignored) {
86  //Worker was cancelled after previously finishing its background work, exception ignored to cut down on non-helpful logging
87  }
88  }
89  }
90 }

Copyright © 2012-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.