19 package org.sleuthkit.autopsy.discovery.ui;
22 import java.util.List;
23 import java.util.ArrayList;
24 import java.util.logging.Level;
25 import javax.swing.SwingWorker;
45 final class PageWorker
extends SwingWorker<Void, Void> {
47 private final static Logger logger = Logger.getLogger(PageWorker.class.getName());
48 private static final String USER_NAME_PROPERTY =
"user.name";
49 private final List<AbstractFilter> searchfilters;
50 private final DiscoveryAttributes.AttributeType groupingAttribute;
51 private final Group.GroupSortingAlgorithm groupSort;
52 private final ResultsSorter.SortingMethod fileSortMethod;
53 private final GroupKey groupKey;
54 private final int startingEntry;
55 private final int pageSize;
56 private final SearchData.Type resultType;
57 private final CentralRepository centralRepo;
58 private final List<Result> results =
new ArrayList<>();
76 PageWorker(List<AbstractFilter> searchfilters, DiscoveryAttributes.AttributeType groupingAttribute,
77 Group.GroupSortingAlgorithm groupSort, ResultsSorter.SortingMethod fileSortMethod, GroupKey groupKey,
78 int startingEntry,
int pageSize, SearchData.Type resultType, CentralRepository centralRepo) {
79 this.searchfilters = searchfilters;
80 this.groupingAttribute = groupingAttribute;
81 this.groupSort = groupSort;
82 this.fileSortMethod = fileSortMethod;
83 this.groupKey = groupKey;
84 this.startingEntry = startingEntry;
85 this.pageSize = pageSize;
86 this.resultType = resultType;
87 this.centralRepo = centralRepo;
91 protected Void doInBackground() throws Exception {
92 SearchContext context =
new SwingWorkerSearchContext(
this);
95 if (resultType == SearchData.Type.DOMAIN) {
96 DomainSearch domainSearch =
new DomainSearch();
97 results.addAll(domainSearch.getDomainsInGroup(System.getProperty(USER_NAME_PROPERTY), searchfilters,
100 fileSortMethod, groupKey, startingEntry, pageSize,
101 Case.getCurrentCase().getSleuthkitCase(), centralRepo, context));
103 results.addAll(FileSearch.getFilesInGroup(System.getProperty(USER_NAME_PROPERTY), searchfilters,
106 fileSortMethod, groupKey, startingEntry, pageSize,
107 Case.getCurrentCase().getSleuthkitCase(), centralRepo, context));
109 }
catch (DiscoveryException ex) {
110 logger.log(Level.SEVERE,
"Error running file search test", ex);
112 }
catch (SearchCancellationException ex) {
116 logger.log(Level.WARNING,
"Search was cancelled while retrieving data for results page with starting entry: " + startingEntry, ex);
122 protected void done() {
123 if (!isCancelled()) {
124 int currentPage = startingEntry / pageSize;
125 DiscoveryEventUtils.getDiscoveryEventBus().post(
new DiscoveryEventUtils.PageRetrievedEvent(resultType, currentPage, results));