Autopsy  4.19.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
PageWorker.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.List;
23 import java.util.ArrayList;
24 import java.util.logging.Level;
25 import javax.swing.SwingWorker;
39 
43 final class PageWorker extends SwingWorker<Void, Void> {
44 
45  private final static Logger logger = Logger.getLogger(PageWorker.class.getName());
46  private static final String USER_NAME_PROPERTY = "user.name"; //NON-NLS
47  private final List<AbstractFilter> searchfilters;
48  private final DiscoveryAttributes.AttributeType groupingAttribute;
49  private final Group.GroupSortingAlgorithm groupSort;
50  private final ResultsSorter.SortingMethod fileSortMethod;
51  private final GroupKey groupKey;
52  private final int startingEntry;
53  private final int pageSize;
54  private final SearchData.Type resultType;
55  private final CentralRepository centralRepo;
56  private final List<Result> results = new ArrayList<>();
57 
74  PageWorker(List<AbstractFilter> searchfilters, DiscoveryAttributes.AttributeType groupingAttribute,
75  Group.GroupSortingAlgorithm groupSort, ResultsSorter.SortingMethod fileSortMethod, GroupKey groupKey,
76  int startingEntry, int pageSize, SearchData.Type resultType, CentralRepository centralRepo) {
77  this.searchfilters = searchfilters;
78  this.groupingAttribute = groupingAttribute;
79  this.groupSort = groupSort;
80  this.fileSortMethod = fileSortMethod;
81  this.groupKey = groupKey;
82  this.startingEntry = startingEntry;
83  this.pageSize = pageSize;
84  this.resultType = resultType;
85  this.centralRepo = centralRepo;
86  }
87 
88  @Override
89  protected Void doInBackground() throws Exception {
90 
91  try {
92  // Run the search
93  if (resultType == SearchData.Type.DOMAIN) {
94  DomainSearch domainSearch = new DomainSearch();
95  results.addAll(domainSearch.getDomainsInGroup(System.getProperty(USER_NAME_PROPERTY), searchfilters,
96  groupingAttribute,
97  groupSort,
98  fileSortMethod, groupKey, startingEntry, pageSize,
99  Case.getCurrentCase().getSleuthkitCase(), centralRepo));
100  } else {
101  results.addAll(FileSearch.getFilesInGroup(System.getProperty(USER_NAME_PROPERTY), searchfilters,
102  groupingAttribute,
103  groupSort,
104  fileSortMethod, groupKey, startingEntry, pageSize,
105  Case.getCurrentCase().getSleuthkitCase(), centralRepo));
106  }
107  } catch (DiscoveryException ex) {
108  logger.log(Level.SEVERE, "Error running file search test", ex);
109  cancel(true);
110  }
111  return null;
112  }
113 
114  @Override
115  protected void done() {
116  if (!isCancelled()) {
117  int currentPage = startingEntry / pageSize; //integer division should round down to get page number correctly
118  DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.PageRetrievedEvent(resultType, currentPage, results));
119  }
120  }
121 
122 }

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