Autopsy  4.1
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;
29 
37 class Installer extends ModuleInstall {
38 
39  private static final Logger logger = Logger.getLogger(Installer.class.getName());
40  private static final long serialVersionUID = 1L;
41 
42  @Override
43  public void restored() {
44  //Setup the default KeywordSearch configuration files
45  KeywordSearchSettings.setDefaults();
46 
47  final Server server = KeywordSearch.getServer();
48  try {
49  server.start();
50  } catch (SolrServerNoPortException ex) {
51  logger.log(Level.SEVERE, "Failed to start Keyword Search server: ", ex); //NON-NLS
52  if (ex.getPortNumber() == server.getCurrentSolrServerPort()) {
53  reportPortError(ex.getPortNumber());
54  } else {
55  reportStopPortError(ex.getPortNumber());
56  }
57  } catch (KeywordSearchModuleException ex) {
58  logger.log(Level.SEVERE, "Failed to start Keyword Search server: ", ex); //NON-NLS
59  reportInitError(ex.getMessage());
60  }
61  }
62 
63  @Override
64  public boolean closing() {
65  //platform about to close
66 
67  KeywordSearch.getServer().stop();
68 
69  return true;
70  }
71 
72  @Override
73  public void uninstalled() {
74  //module is being unloaded
75  KeywordSearch.getServer().stop();
76 
77  }
78 
79  private void reportPortError(final int curFailPort) {
80  WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
81  @Override
82  public void run() {
83  final String msg = NbBundle.getMessage(this.getClass(), "Installer.reportPortError", curFailPort, Version.getName(), Server.PROPERTIES_CURRENT_SERVER_PORT, Server.PROPERTIES_FILE);
84  MessageNotifyUtil.Notify.error(NbBundle.getMessage(this.getClass(), "Installer.errorInitKsmMsg"), msg);
85  }
86  });
87  }
88 
89  private void reportStopPortError(final int curFailPort) {
90  WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
91  @Override
92  public void run() {
93  final String msg = NbBundle.getMessage(this.getClass(), "Installer.reportStopPortError", curFailPort, Server.PROPERTIES_CURRENT_STOP_PORT, Server.PROPERTIES_FILE);
94  MessageNotifyUtil.Notify.error(NbBundle.getMessage(this.getClass(), "Installer.errorInitKsmMsg"), msg);
95  }
96  });
97  }
98 
99  private void reportInitError(final String msg) {
100  WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
101  @Override
102  public void run() {
103  MessageNotifyUtil.Notify.error(NbBundle.getMessage(this.getClass(), "Installer.errorInitKsmMsg"), msg);
104  }
105  });
106  }
107 }

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