Autopsy  4.19.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
ExtractAllTermsReport.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2021 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.keywordsearch;
20 
21 import java.nio.file.Path;
22 import java.nio.file.Paths;
23 import java.util.logging.Level;
24 import javax.swing.JPanel;
25 import org.openide.util.NbBundle;
26 import org.openide.util.lookup.ServiceProvider;
34 
39 @ServiceProvider(service = GeneralReportModule.class)
40 public class ExtractAllTermsReport implements GeneralReportModule {
41 
42  private static final Logger logger = Logger.getLogger(ExtractAllTermsReport.class.getName());
43  private static final String OUTPUT_FILE_NAME = "Unique Words.txt";
44 
45  @NbBundle.Messages({
46  "ExtractAllTermsReport.getName.text=Extract Unique Words"})
47  @Override
48  public String getName() {
49  return Bundle.ExtractAllTermsReport_getName_text();
50  }
51 
52  @NbBundle.Messages({
53  "ExtractAllTermsReport.error.noOpenCase=No currently open case.",
54  "# {0} - Keyword search commit frequency",
55  "ExtractAllTermsReport.search.noFilesInIdxMsg=No files are in index yet. Try again later. Index is updated every {0} minutes.",
56  "ExtractAllTermsReport.search.noFilesInIdxMsg2=No files are in index yet. Try again later",
57  "ExtractAllTermsReport.search.searchIngestInProgressTitle=Keyword Search Ingest in Progress",
58  "ExtractAllTermsReport.search.ingestInProgressBody=<html>Keyword Search Ingest is currently running.<br />Not all files have been indexed and unique word extraction might yield incomplete results.<br />Do you want to proceed with unique word extraction anyway?</html>",
59  "ExtractAllTermsReport.startExport=Starting Unique Word Extraction",
60  "ExtractAllTermsReport.export.error=Error During Unique Word Extraction",
61  "ExtractAllTermsReport.exportComplete=Unique Word Extraction Complete"
62  })
63  @Override
64  public void generateReport(GeneralReportSettings settings, ReportProgressPanel progressPanel) {
65 
66  if (!Case.isCaseOpen()) {
67  logger.log(Level.SEVERE, "No open case when attempting to run {0} report", Bundle.ExtractAllTermsReport_getName_text()); //NON-NLS
68  progressPanel.complete(ReportProgressPanel.ReportStatus.ERROR, Bundle.ExtractAllTermsReport_error_noOpenCase());
69  return;
70  }
71 
72  progressPanel.setIndeterminate(true);
73  progressPanel.start();
74  progressPanel.updateStatusLabel("Extracting unique words...");
75 
76  boolean isIngestRunning = IngestManager.getInstance().isIngestRunning();
77 
78  int filesIndexed = 0;
79  try { // see if there are any indexed files
80  filesIndexed = KeywordSearch.getServer().queryNumIndexedFiles();
82  }
83 
84  if (filesIndexed == 0) {
85  if (isIngestRunning) {
86  progressPanel.complete(ReportProgressPanel.ReportStatus.ERROR, Bundle.ExtractAllTermsReport_search_noFilesInIdxMsg(KeywordSearchSettings.getUpdateFrequency().getTime()));
87  } else {
88  progressPanel.complete(ReportProgressPanel.ReportStatus.ERROR, Bundle.ExtractAllTermsReport_search_noFilesInIdxMsg2());
89  }
90  progressPanel.setIndeterminate(false);
91  return;
92  }
93 
94  // check if keyword search module ingest is running (indexing, etc)
95  if (isIngestRunning) {
96  if (KeywordSearchUtil.displayConfirmDialog(Bundle.ExtractAllTermsReport_search_searchIngestInProgressTitle(),
97  Bundle.ExtractAllTermsReport_search_ingestInProgressBody(), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN) == false) {
98  progressPanel.cancel();
99  return;
100  }
101  }
102 
103  final Server server = KeywordSearch.getServer();
104  try {
105  progressPanel.updateStatusLabel(Bundle.ExtractAllTermsReport_startExport());
106  Path outputFile = Paths.get(settings.getReportDirectoryPath(), getRelativeFilePath());
107  server.extractAllTermsForDataSource(outputFile, progressPanel);
109  logger.log(Level.SEVERE, "Exception while extracting unique terms", ex); //NON-NLS
110  progressPanel.setIndeterminate(false);
111  progressPanel.complete(ReportProgressPanel.ReportStatus.ERROR, Bundle.ExtractAllTermsReport_export_error());
112  return;
113  }
114 
115  progressPanel.setIndeterminate(false);
116  progressPanel.complete(ReportProgressPanel.ReportStatus.COMPLETE, Bundle.ExtractAllTermsReport_exportComplete());
117  }
118 
119  @Override
120  public boolean supportsDataSourceSelection() {
121  return false;
122  }
123 
124  @NbBundle.Messages({
125  "ExtractAllTermsReport.description.text=Extracts all unique words out of the current case. NOTE: The extracted words are lower-cased."})
126  @Override
127  public String getDescription() {
128  return Bundle.ExtractAllTermsReport_description_text();
129  }
130  @Override
131  public JPanel getConfigurationPanel() {
132  return new NoReportConfigurationPanel();
133  }
134 
135  @Override
136  public String getRelativeFilePath() {
137  return OUTPUT_FILE_NAME;
138  }
139 
140 }
static synchronized IngestManager getInstance()
void generateReport(GeneralReportSettings settings, ReportProgressPanel progressPanel)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

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