Autopsy  4.15.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;
20 
21 import java.util.LinkedHashMap;
22 import javax.swing.SwingWorker;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.logging.Level;
30 
34 final class SearchWorker extends SwingWorker<Void, Void> {
35 
36  private final static Logger logger = Logger.getLogger(SearchWorker.class.getName());
37  private static final String USER_NAME_PROPERTY = "user.name"; //NON-NLS
38  private final List<FileSearchFiltering.FileFilter> filters;
39  private final FileSearch.AttributeType groupingAttr;
40  private final FileSorter.SortingMethod fileSort;
41  private final FileGroup.GroupSortingAlgorithm groupSortAlgorithm;
42  private final CentralRepository centralRepoDb;
43  private final Map<GroupKey, Integer> results = new LinkedHashMap<>();
44 
55  SearchWorker(CentralRepository centralRepo, List<FileSearchFiltering.FileFilter> searchfilters, FileSearch.AttributeType groupingAttribute, FileGroup.GroupSortingAlgorithm groupSort, FileSorter.SortingMethod fileSortMethod) {
56  centralRepoDb = centralRepo;
57  filters = searchfilters;
58  groupingAttr = groupingAttribute;
59  groupSortAlgorithm = groupSort;
60  fileSort = fileSortMethod;
61  }
62 
63  @Override
64  protected Void doInBackground() throws Exception {
65  try {
66  // Run the search
67  results.putAll(FileSearch.getGroupSizes(System.getProperty(USER_NAME_PROPERTY), filters,
68  groupingAttr,
69  groupSortAlgorithm,
70  fileSort,
71  Case.getCurrentCase().getSleuthkitCase(), centralRepoDb));
72  } catch (FileSearchException ex) {
73  logger.log(Level.SEVERE, "Error running file search test", ex);
74  cancel(true);
75  }
76  return null;
77  }
78 
79  @Override
80  protected void done() {
81  if (isCancelled()) {
82  DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.SearchCancelledEvent());
83  } else {
84  DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.SearchCompleteEvent(results, filters, groupingAttr, groupSortAlgorithm, fileSort));
85  }
86  }
87 }

Copyright © 2012-2020 Basis Technology. Generated on: Mon Jul 6 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.