Autopsy  4.19.3
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 2022 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  "ExtractAllTermsReport.search.noFilesInIdxMsg=No files are in index yet. If Solr keyword search indexing and Solr indexing were enabled, wait for ingest to complete.",
55  "ExtractAllTermsReport.search.noFilesInIdxMsg2=No files are in index yet. Re-ingest the image with the Keyword Search Module and Solr indexing enabled.",
56  "ExtractAllTermsReport.search.searchIngestInProgressTitle=Keyword Search Ingest in Progress",
57  "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>",
58  "ExtractAllTermsReport.startExport=Starting Unique Word Extraction",
59  "ExtractAllTermsReport.export.error=Error During Unique Word Extraction",
60  "ExtractAllTermsReport.exportComplete=Unique Word Extraction Complete"
61  })
62  @Override
63  public void generateReport(GeneralReportSettings settings, ReportProgressPanel progressPanel) {
64 
65  if (!Case.isCaseOpen()) {
66  logger.log(Level.SEVERE, "No open case when attempting to run {0} report", Bundle.ExtractAllTermsReport_getName_text()); //NON-NLS
67  progressPanel.complete(ReportProgressPanel.ReportStatus.ERROR, Bundle.ExtractAllTermsReport_error_noOpenCase());
68  return;
69  }
70 
71  progressPanel.setIndeterminate(true);
72  progressPanel.start();
73  progressPanel.updateStatusLabel("Extracting unique words...");
74 
75  boolean isIngestRunning = IngestManager.getInstance().isIngestRunning();
76 
77  int filesIndexed = 0;
78  try { // see if there are any indexed files
79  filesIndexed = KeywordSearch.getServer().queryNumIndexedFiles();
81  }
82 
83  if (filesIndexed == 0) {
84  if (isIngestRunning) {
85  progressPanel.complete(ReportProgressPanel.ReportStatus.ERROR, Bundle.ExtractAllTermsReport_search_noFilesInIdxMsg());
86  } else {
87  progressPanel.complete(ReportProgressPanel.ReportStatus.ERROR, Bundle.ExtractAllTermsReport_search_noFilesInIdxMsg2());
88  }
89  progressPanel.setIndeterminate(false);
90  return;
91  }
92 
93  // check if keyword search module ingest is running (indexing, etc)
94  if (isIngestRunning) {
95  if (KeywordSearchUtil.displayConfirmDialog(Bundle.ExtractAllTermsReport_search_searchIngestInProgressTitle(),
96  Bundle.ExtractAllTermsReport_search_ingestInProgressBody(), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN) == false) {
97  progressPanel.cancel();
98  return;
99  }
100  }
101 
102  final Server server = KeywordSearch.getServer();
103  try {
104  progressPanel.updateStatusLabel(Bundle.ExtractAllTermsReport_startExport());
105  Path outputFile = Paths.get(settings.getReportDirectoryPath(), getRelativeFilePath());
106  server.extractAllTermsForDataSource(outputFile, progressPanel);
108  logger.log(Level.SEVERE, "Exception while extracting unique terms", ex); //NON-NLS
109  progressPanel.setIndeterminate(false);
110  progressPanel.complete(ReportProgressPanel.ReportStatus.ERROR, Bundle.ExtractAllTermsReport_export_error());
111  return;
112  }
113 
114  progressPanel.setIndeterminate(false);
115  progressPanel.complete(ReportProgressPanel.ReportStatus.COMPLETE, Bundle.ExtractAllTermsReport_exportComplete());
116  }
117 
118  @Override
119  public boolean supportsDataSourceSelection() {
120  return false;
121  }
122 
123  @NbBundle.Messages({
124  "ExtractAllTermsReport.description.text=Extracts all unique words out of the current case. NOTE: The extracted words are lower-cased."})
125  @Override
126  public String getDescription() {
127  return Bundle.ExtractAllTermsReport_description_text();
128  }
129  @Override
130  public JPanel getConfigurationPanel() {
131  return new NoReportConfigurationPanel();
132  }
133 
134  @Override
135  public String getRelativeFilePath() {
136  return OUTPUT_FILE_NAME;
137  }
138 
139 }
static synchronized IngestManager getInstance()
void generateReport(GeneralReportSettings settings, ReportProgressPanel progressPanel)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2022 Basis Technology. Generated on: Tue Jun 27 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.