Autopsy  4.4
Graphical digital forensics platform for The Sleuth Kit and other tools.
KeywordSearchPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2013 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.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.List;
25 import org.openide.util.NbBundle;
26 
33 abstract class KeywordSearchPanel extends javax.swing.JPanel {
34 
35  private final String keywordSearchErrorDialogHeader = org.openide.util.NbBundle.getMessage(this.getClass(), "AbstractKeywordSearchPerformer.search.dialogErrorHeader");
36  protected int filesIndexed;
37 
38  KeywordSearchPanel() {
39  initListeners();
40  }
41 
42  private void initListeners() {
43  KeywordSearch.addNumIndexedFilesChangeListener(
44  new PropertyChangeListener() {
45  @Override
46  public void propertyChange(PropertyChangeEvent evt) {
47  String changed = evt.getPropertyName();
48  Object newValue = evt.getNewValue();
49 
50  if (changed.equals(KeywordSearch.NUM_FILES_CHANGE_EVT)) {
51  int newFilesIndexed = ((Integer) newValue).intValue();
52  filesIndexed = newFilesIndexed;
53  postFilesIndexedChange();
54  }
55  }
56  });
57  }
58 
62  protected abstract void postFilesIndexedChange();
63 
69  abstract List<KeywordList> getKeywordLists();
70 
76  public void setFilesIndexed(int filesIndexed) {
77  this.filesIndexed = filesIndexed;
78  }
79 
84  public void search() {
85  boolean isIngestRunning = IngestManager.getInstance().isIngestRunning();
86 
87  if (filesIndexed == 0) {
88  try { // see if another node added any indexed files
89  filesIndexed = KeywordSearch.getServer().queryNumIndexedFiles();
90  } catch (KeywordSearchModuleException | NoOpenCoreException ignored) {
91  }
92  }
93  if (filesIndexed == 0) {
94  if (isIngestRunning) {
95  KeywordSearchUtil.displayDialog(keywordSearchErrorDialogHeader, NbBundle.getMessage(this.getClass(),
96  "AbstractKeywordSearchPerformer.search.noFilesInIdxMsg",
97  KeywordSearchSettings.getUpdateFrequency().getTime()), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
98  } else {
99  KeywordSearchUtil.displayDialog(keywordSearchErrorDialogHeader, NbBundle.getMessage(this.getClass(),
100  "AbstractKeywordSearchPerformer.search.noFilesIdxdMsg"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
101  }
102  return;
103  }
104 
105  //check if keyword search module ingest is running (indexing, etc)
106  if (isIngestRunning) {
107  if (KeywordSearchUtil.displayConfirmDialog(org.openide.util.NbBundle.getMessage(this.getClass(), "AbstractKeywordSearchPerformer.search.searchIngestInProgressTitle"),
108  NbBundle.getMessage(this.getClass(), "AbstractKeywordSearchPerformer.search.ingestInProgressBody"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN) == false) {
109  return;
110  }
111  }
112 
113  KeywordSearchQueryDelegator man = null;
114 
115  final List<KeywordList> keywordLists = getKeywordLists();
116  if (keywordLists.isEmpty()) {
117  KeywordSearchUtil.displayDialog(keywordSearchErrorDialogHeader, NbBundle.getMessage(this.getClass(),
118  "AbstractKeywordSearchPerformer.search.emptyKeywordErrorBody"),
119  KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
120  return;
121  }
122  man = new KeywordSearchQueryDelegator(keywordLists);
123 
124  if (man.validate()) {
125  man.execute();
126  } else {
127  KeywordSearchUtil.displayDialog(keywordSearchErrorDialogHeader, NbBundle.getMessage(this.getClass(),
128  "AbstractKeywordSearchPerformer.search.invalidSyntaxHeader"), KeywordSearchUtil.DIALOG_MESSAGE_TYPE.ERROR);
129  }
130  }
131 }

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