Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
Installer.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2015 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.util.logging.Level;
22 import org.openide.modules.ModuleInstall;
23 import org.openide.util.NbBundle;
24 import org.openide.windows.WindowManager;
30 
38 class Installer extends ModuleInstall {
39 
40  private static final Logger logger = Logger.getLogger(Installer.class.getName());
41  private static final long serialVersionUID = 1L;
42 
43  @Override
44  public void restored() {
45  //Setup the default KeywordSearch configuration files
46  KeywordSearchSettings.setDefaults();
47 
48  Case.addEventSubscriber(Case.Events.CURRENT_CASE.toString(), new KeywordSearch.CaseChangeListener());
49 
50  final Server server = KeywordSearch.getServer();
51  try {
52  server.start();
53  } catch (SolrServerNoPortException ex) {
54  logger.log(Level.SEVERE, "Failed to start Keyword Search server: ", ex); //NON-NLS
55  if (ex.getPortNumber() == server.getCurrentSolrServerPort()) {
56  reportPortError(ex.getPortNumber());
57  } else {
58  reportStopPortError(ex.getPortNumber());
59  }
60  } catch (KeywordSearchModuleException ex) {
61  logger.log(Level.SEVERE, "Failed to start Keyword Search server: ", ex); //NON-NLS
62  reportInitError(ex.getMessage());
63  }
64  }
65 
66  @Override
67  public boolean closing() {
68  //platform about to close
69 
70  KeywordSearch.getServer().stop();
71 
72  return true;
73  }
74 
75  @Override
76  public void uninstalled() {
77  //module is being unloaded
78  KeywordSearch.getServer().stop();
79 
80  }
81 
82  private void reportPortError(final int curFailPort) {
83  WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
84  @Override
85  public void run() {
86  final String msg = NbBundle.getMessage(this.getClass(), "Installer.reportPortError", curFailPort, Version.getName(), Server.PROPERTIES_CURRENT_SERVER_PORT, Server.PROPERTIES_FILE);
87  MessageNotifyUtil.Notify.error(NbBundle.getMessage(this.getClass(), "Installer.errorInitKsmMsg"), msg);
88  }
89  });
90  }
91 
92  private void reportStopPortError(final int curFailPort) {
93  WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
94  @Override
95  public void run() {
96  final String msg = NbBundle.getMessage(this.getClass(), "Installer.reportStopPortError", curFailPort, Server.PROPERTIES_CURRENT_STOP_PORT, Server.PROPERTIES_FILE);
97  MessageNotifyUtil.Notify.error(NbBundle.getMessage(this.getClass(), "Installer.errorInitKsmMsg"), msg);
98  }
99  });
100  }
101 
102  private void reportInitError(final String msg) {
103  WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
104  @Override
105  public void run() {
106  MessageNotifyUtil.Notify.error(NbBundle.getMessage(this.getClass(), "Installer.errorInitKsmMsg"), msg);
107  }
108  });
109  }
110 }

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