19 package org.sleuthkit.autopsy.discovery.ui;
22 import java.util.LinkedHashMap;
23 import javax.swing.SwingWorker;
24 import java.util.List;
26 import java.util.logging.Level;
43 final class SearchWorker
extends SwingWorker<Void, Void> {
45 private final static Logger logger = Logger.getLogger(SearchWorker.class.getName());
46 private static final String USER_NAME_PROPERTY =
"user.name";
47 private final List<AbstractFilter> filters;
48 private final DiscoveryAttributes.AttributeType groupingAttr;
49 private final ResultsSorter.SortingMethod fileSort;
50 private final Group.GroupSortingAlgorithm groupSortAlgorithm;
51 private final CentralRepository centralRepoDb;
52 private final SearchData.
Type searchType;
53 private final Map<GroupKey, Integer> results =
new LinkedHashMap<>();
65 SearchWorker(CentralRepository centralRepo, SearchData.Type type, List<AbstractFilter> searchfilters, DiscoveryAttributes.AttributeType groupingAttribute, Group.GroupSortingAlgorithm groupSort, ResultsSorter.SortingMethod fileSortMethod) {
66 centralRepoDb = centralRepo;
68 filters = searchfilters;
69 groupingAttr = groupingAttribute;
70 groupSortAlgorithm = groupSort;
71 fileSort = fileSortMethod;
75 protected Void doInBackground() throws Exception {
78 if (searchType == SearchData.Type.DOMAIN) {
79 DomainSearch domainSearch =
new DomainSearch();
80 results.putAll(domainSearch.getGroupSizes(System.getProperty(USER_NAME_PROPERTY), filters,
84 Case.getCurrentCase().getSleuthkitCase(), centralRepoDb));
86 results.putAll(FileSearch.getGroupSizes(System.getProperty(USER_NAME_PROPERTY), filters,
90 Case.getCurrentCase().getSleuthkitCase(), centralRepoDb));
92 }
catch (DiscoveryException ex) {
93 logger.log(Level.SEVERE,
"Error running file search test", ex);
100 protected void done() {
102 DiscoveryEventUtils.getDiscoveryEventBus().post(
new DiscoveryEventUtils.SearchCancelledEvent());
104 DiscoveryEventUtils.getDiscoveryEventBus().post(
new DiscoveryEventUtils.SearchCompleteEvent(results, filters, groupingAttr, groupSortAlgorithm, fileSort));