Autopsy  4.17.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
SearchWorker.java
Go to the documentation of this file.
1 /*
2  * Autopsy
3  *
4  * Copyright 2019 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.LinkedHashMap;
23 import javax.swing.SwingWorker;
24 import java.util.List;
25 import java.util.Map;
26 import java.util.logging.Level;
39 
43 final class SearchWorker extends SwingWorker<Void, Void> {
44 
45  private final static Logger logger = Logger.getLogger(SearchWorker.class.getName());
46  private static final String USER_NAME_PROPERTY = "user.name"; //NON-NLS
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<>();
54 
65  SearchWorker(CentralRepository centralRepo, SearchData.Type type, List<AbstractFilter> searchfilters, DiscoveryAttributes.AttributeType groupingAttribute, Group.GroupSortingAlgorithm groupSort, ResultsSorter.SortingMethod fileSortMethod) {
66  centralRepoDb = centralRepo;
67  searchType = type;
68  filters = searchfilters;
69  groupingAttr = groupingAttribute;
70  groupSortAlgorithm = groupSort;
71  fileSort = fileSortMethod;
72  }
73 
74  @Override
75  protected Void doInBackground() throws Exception {
76  try {
77  // Run the search
78  if (searchType == SearchData.Type.DOMAIN) {
79  DomainSearch domainSearch = new DomainSearch();
80  results.putAll(domainSearch.getGroupSizes(System.getProperty(USER_NAME_PROPERTY), filters,
81  groupingAttr,
82  groupSortAlgorithm,
83  fileSort,
84  Case.getCurrentCase().getSleuthkitCase(), centralRepoDb));
85  } else {
86  results.putAll(FileSearch.getGroupSizes(System.getProperty(USER_NAME_PROPERTY), filters,
87  groupingAttr,
88  groupSortAlgorithm,
89  fileSort,
90  Case.getCurrentCase().getSleuthkitCase(), centralRepoDb));
91  }
92  } catch (DiscoveryException ex) {
93  logger.log(Level.SEVERE, "Error running file search test", ex);
94  cancel(true);
95  }
96  return null;
97  }
98 
99  @Override
100  protected void done() {
101  if (isCancelled()) {
102  DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.SearchCancelledEvent());
103  } else {
104  DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.SearchCompleteEvent(results, filters, groupingAttr, groupSortAlgorithm, fileSort));
105  }
106  }
107 }

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.