Autopsy  4.17.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.apache.solr.client.solrj.SolrServerException;
23 import org.openide.modules.ModuleInstall;
24 import org.openide.util.NbBundle;
25 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  final Server server = KeywordSearch.getServer();
49  try {
50  server.start();
51  } catch (SolrServerNoPortException ex) {
52  logger.log(Level.SEVERE, "Failed to start Keyword Search server: ", ex); //NON-NLS
53  if (ex.getPortNumber() == server.getLocalSolrServerPort()) {
54  reportPortError(ex.getPortNumber());
55  } else {
56  reportStopPortError(ex.getPortNumber());
57  }
58  } catch (KeywordSearchModuleException | SolrServerException ex) {
59  logger.log(Level.SEVERE, "Failed to start Keyword Search server: ", ex); //NON-NLS
60  reportInitError(ex.getMessage());
61  }
62  }
63 
64  @Override
65  public boolean closing() {
66  //platform about to close
67 
68  KeywordSearch.getServer().stop();
69 
70  return true;
71  }
72 
73  @Override
74  public void uninstalled() {
75  //module is being unloaded
76  KeywordSearch.getServer().stop();
77 
78  }
79 
80  private void reportPortError(final int curFailPort) {
81  WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
82  @Override
83  public void run() {
84  final String msg = NbBundle.getMessage(this.getClass(), "Installer.reportPortError", curFailPort, Version.getName(), Server.PROPERTIES_CURRENT_SERVER_PORT, Server.PROPERTIES_FILE);
85  MessageNotifyUtil.Notify.error(NbBundle.getMessage(this.getClass(), "Installer.errorInitKsmMsg"), msg);
86  }
87  });
88  }
89 
90  private void reportStopPortError(final int curFailPort) {
91  WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
92  @Override
93  public void run() {
94  final String msg = NbBundle.getMessage(this.getClass(), "Installer.reportStopPortError", curFailPort, Server.PROPERTIES_CURRENT_STOP_PORT, Server.PROPERTIES_FILE);
95  MessageNotifyUtil.Notify.error(NbBundle.getMessage(this.getClass(), "Installer.errorInitKsmMsg"), msg);
96  }
97  });
98  }
99 
100  private void reportInitError(final String msg) {
101  WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
102  @Override
103  public void run() {
104  MessageNotifyUtil.Notify.error(NbBundle.getMessage(this.getClass(), "Installer.errorInitKsmMsg"), msg);
105  }
106  });
107  }
108 }

Copyright © 2012-2021 Basis Technology. Generated on: Tue Jan 19 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.