Autopsy  4.14.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.filequery;
20 
21 import java.util.List;
22 import java.util.ArrayList;
23 import java.util.logging.Level;
24 import javax.swing.SwingWorker;
29 
33 final class PageWorker extends SwingWorker<Void, Void> {
34 
35  private final static Logger logger = Logger.getLogger(PageWorker.class.getName());
36  private static final String USER_NAME_PROPERTY = "user.name"; //NON-NLS
37  private final List<FileSearchFiltering.FileFilter> searchfilters;
38  private final FileSearch.AttributeType groupingAttribute;
39  private final FileGroup.GroupSortingAlgorithm groupSort;
40  private final FileSorter.SortingMethod fileSortMethod;
41  private final GroupKey groupKey;
42  private final int startingEntry;
43  private final int pageSize;
44  private final FileSearchData.FileType resultType;
45  private final CentralRepository centralRepo;
46  private final List<ResultFile> results = new ArrayList<>();
47 
64  PageWorker(List<FileSearchFiltering.FileFilter> searchfilters, FileSearch.AttributeType groupingAttribute,
65  FileGroup.GroupSortingAlgorithm groupSort, FileSorter.SortingMethod fileSortMethod, GroupKey groupKey,
66  int startingEntry, int pageSize, FileSearchData.FileType resultType, CentralRepository centralRepo) {
67  this.searchfilters = searchfilters;
68  this.groupingAttribute = groupingAttribute;
69  this.groupSort = groupSort;
70  this.fileSortMethod = fileSortMethod;
71  this.groupKey = groupKey;
72  this.startingEntry = startingEntry;
73  this.pageSize = pageSize;
74  this.resultType = resultType;
75  this.centralRepo = centralRepo;
76  }
77 
78  @Override
79  protected Void doInBackground() throws Exception {
80 
81  try {
82  // Run the search
83  results.addAll(FileSearch.getFilesInGroup(System.getProperty(USER_NAME_PROPERTY), searchfilters,
84  groupingAttribute,
85  groupSort,
86  fileSortMethod, groupKey, startingEntry, pageSize,
87  Case.getCurrentCase().getSleuthkitCase(), centralRepo));
88  } catch (FileSearchException ex) {
89  logger.log(Level.SEVERE, "Error running file search test", ex);
90  cancel(true);
91  }
92  return null;
93  }
94 
95  @Override
96  protected void done() {
97  if (!isCancelled()) {
98  int currentPage = startingEntry / pageSize; //integer division should round down to get page number correctly
99  DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.PageRetrievedEvent(resultType, currentPage, results));
100  }
101  }
102 
103 }

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