Autopsy  3.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 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.datamodel;
20 
21 import java.awt.Component;
22 import java.util.logging.Level;
23 
24 import org.openide.util.NbBundle;
26 import javax.swing.JOptionPane;
27 import org.openide.LifecycleManager;
28 import org.openide.modules.ModuleInstall;
30 
34 public class Installer extends ModuleInstall {
35 
36  private static Installer instance;
37 
38  public synchronized static Installer getDefault() {
39  if (instance == null) {
40  instance = new Installer();
41  }
42  return instance;
43  }
44 
45  private Installer() {
46  super();
47  }
48 
49  @Override
50  public void validate() throws IllegalStateException {
51  /*
52  * The NetBeans API specifies that a module should throw an IllegalStateException
53  * if it can't be initalized, but NetBeans doesn't handle that behaviour
54  * well (it just disables the module, and all dependant modules, on the
55  * current and all subsequent application launches). Hence, we deal with
56  * it manually.
57  *
58  */
59 
60 
61  // Check that the the Sleuth Kit JNI is working by getting the Sleuth Kit version number
62  Logger logger = Logger.getLogger(Installer.class.getName());
63  try {
64  String skVersion = SleuthkitJNI.getVersion();
65 
66  if (skVersion == null) {
67  throw new Exception(NbBundle.getMessage(this.getClass(), "Installer.exception.tskVerStringNull.msg"));
68  } else if (skVersion.length() == 0) {
69  throw new Exception(NbBundle.getMessage(this.getClass(), "Installer.exception.taskVerStringBang.msg"));
70  } else {
71  logger.log(Level.CONFIG, "Sleuth Kit Version: {0}", skVersion); //NON-NLS
72  }
73 
74  } catch (Exception e) {
75  logger.log(Level.SEVERE, "Error calling Sleuth Kit library (test call failed)", e); //NON-NLS
76 
77 
78  // Normal error box log handler won't be loaded yet, so show error here.
79  final Component parentComponent = null; // Use default window frame.
80  final String message = NbBundle.getMessage(this.getClass(), "Installer.tskLibErr.msg", e.toString());
81  final String title = NbBundle.getMessage(this.getClass(), "Installer.tskLibErr.err");
82  final int messageType = JOptionPane.ERROR_MESSAGE;
83 
84  JOptionPane.showMessageDialog(
85  parentComponent,
86  message,
87  title,
88  messageType);
89 
90 
91  // exit after user exits the error dialog box
92  LifecycleManager.getDefault().exit();
93  }
94 
95  }
96 }
static synchronized Installer getDefault()
Definition: Installer.java:38
static Logger getLogger(String name)
Definition: Logger.java:131

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