Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
KeywordSearch.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2018 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.PropertyChangeListener;
22 import java.beans.PropertyChangeSupport;
23 import java.io.IOException;
24 import java.util.logging.FileHandler;
25 import java.util.logging.Level;
26 import java.util.logging.SimpleFormatter;
27 import org.openide.util.NbBundle;
32 
37 public class KeywordSearch {
38 
39  private static Server server;
40  //we want a custom java.util.logging.Logger here for a reason
41  //a separate logger from framework logs
42  private static final java.util.logging.Logger tikaLogger = java.util.logging.Logger.getLogger("Tika"); //NON-NLS
43  private static final Logger logger = Logger.getLogger(Case.class.getName());
44 
45  // @@@ We should move this into TskData (or somewhere) because we are using
46  // this value in the results tree to display substring differently from regexp (KeywordHit.java)
47  public enum QueryType {
48  LITERAL, SUBSTRING, REGEX
49  };
50  public static final String NUM_FILES_CHANGE_EVT = "NUM_FILES_CHANGE_EVT"; //NON-NLS
51  private static PropertyChangeSupport changeSupport = new PropertyChangeSupport(KeywordSearch.class);
52 
59  public static synchronized Server getServer() {
60  if (server == null) {
61  server = new Server();
62  }
63  return server;
64  }
65 
66  static {
67  try {
68  final int MAX_TIKA_LOG_FILES = 3;
69  FileHandler tikaLogHandler = new FileHandler(PlatformUtil.getUserDirectory().getAbsolutePath() + "/var/log/tika.log", //NON-NLS
70  0, MAX_TIKA_LOG_FILES);
71  tikaLogHandler.setFormatter(new SimpleFormatter());
72  tikaLogHandler.setEncoding(PlatformUtil.getLogFileEncoding());
73  tikaLogger.addHandler(tikaLogHandler);
74  //do not forward to the parent autopsy logger
75  tikaLogger.setUseParentHandlers(false);
76  } catch (IOException | SecurityException ex) {
77  logger.log(Level.SEVERE, "Error setting up tika logging", ex); //NON-NLS
78  }
79  }
80 
81  // don't instantiate
82  private KeywordSearch() {
83  throw new AssertionError();
84  }
85 
86  static java.util.logging.Logger getTikaLogger() {
87  return tikaLogger;
88  }
89 
90  public static void addNumIndexedFilesChangeListener(PropertyChangeListener l) {
91  changeSupport.addPropertyChangeListener(NUM_FILES_CHANGE_EVT, l);
92  }
93 
94  public static void removeNumIndexedFilesChangeListener(PropertyChangeListener l) {
95  changeSupport.removePropertyChangeListener(l);
96  }
97 
98  public static void fireNumIndexedFilesChange(Integer oldNum, Integer newNum) {
99 
100  try {
101  changeSupport.firePropertyChange(NUM_FILES_CHANGE_EVT, oldNum, newNum);
102  } catch (Exception e) {
103  logger.log(Level.SEVERE, "KeywordSearch listener threw exception", e); //NON-NLS
104  MessageNotifyUtil.Notify.show(NbBundle.getMessage(KeywordSearch.class, "KeywordSearch.moduleErr"),
105  NbBundle.getMessage(KeywordSearch.class,
106  "KeywordSearch.fireNumIdxFileChg.moduleErr.msg"),
108  }
109  }
110 }
static void fireNumIndexedFilesChange(Integer oldNum, Integer newNum)
static void addNumIndexedFilesChangeListener(PropertyChangeListener l)
Logger(String name, String resourceBundleName)
Definition: Logger.java:160
static final java.util.logging.Logger tikaLogger
static void removeNumIndexedFilesChangeListener(PropertyChangeListener l)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static void show(String title, String message, MessageType type, ActionListener actionListener)

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