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;
 
   45 final class SearchWorker 
extends SwingWorker<Void, Void> {
 
   47     private final static Logger logger = Logger.getLogger(SearchWorker.class.getName());
 
   48     private static final String USER_NAME_PROPERTY = 
"user.name"; 
 
   49     private final List<AbstractFilter> filters;
 
   50     private final DiscoveryAttributes.AttributeType groupingAttr;
 
   51     private final ResultsSorter.SortingMethod fileSort;
 
   52     private final Group.GroupSortingAlgorithm groupSortAlgorithm;
 
   53     private final CentralRepository centralRepoDb;
 
   54     private final SearchData.
Type searchType;
 
   55     private final Map<GroupKey, Integer> results = 
new LinkedHashMap<>();
 
   67     SearchWorker(CentralRepository centralRepo, SearchData.Type type, List<AbstractFilter> searchfilters, DiscoveryAttributes.AttributeType groupingAttribute, Group.GroupSortingAlgorithm groupSort, ResultsSorter.SortingMethod fileSortMethod) {
 
   68         centralRepoDb = centralRepo;
 
   70         filters = searchfilters;
 
   71         groupingAttr = groupingAttribute;
 
   72         groupSortAlgorithm = groupSort;
 
   73         fileSort = fileSortMethod;
 
   77     protected Void doInBackground() throws Exception {
 
   80             SearchContext context = 
new SwingWorkerSearchContext(
this);
 
   81             if (searchType == SearchData.Type.DOMAIN) {
 
   82                 DomainSearch domainSearch = 
new DomainSearch();
 
   83                 results.putAll(domainSearch.getGroupSizes(System.getProperty(USER_NAME_PROPERTY), filters,
 
   87                         Case.getCurrentCase().getSleuthkitCase(), centralRepoDb, context));
 
   89                 results.putAll(FileSearch.getGroupSizes(System.getProperty(USER_NAME_PROPERTY), filters,
 
   93                         Case.getCurrentCase().getSleuthkitCase(), centralRepoDb, context));
 
   95         } 
catch (DiscoveryException ex) {
 
   96             logger.log(Level.SEVERE, 
"Error running file search test.", ex);
 
   98         } 
catch (SearchCancellationException ex) {
 
  101             logger.log(Level.INFO, 
"Discovery search was cancelled.", ex);
 
  107     protected void done() {
 
  109             DiscoveryEventUtils.getDiscoveryEventBus().post(
new DiscoveryEventUtils.SearchCancelledEvent());
 
  111             DiscoveryEventUtils.getDiscoveryEventBus().post(
new DiscoveryEventUtils.SearchCompleteEvent(results, filters, groupingAttr, groupSortAlgorithm, fileSort));