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 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;
29 import org.sleuthkit.datamodel.SleuthkitJNI;
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
53  * IllegalStateException if it can't be initalized, but NetBeans doesn't
54  * handle that behaviour well (it just disables the module, and all
55  * dependant modules, on the current and all subsequent application
56  * launches). Hence, we deal with it manually.
57  *
58  */
59 
60  // Check that the the Sleuth Kit JNI is working by getting the Sleuth Kit version number
61  Logger logger = Logger.getLogger(Installer.class.getName());
62  try {
63  String skVersion = SleuthkitJNI.getVersion();
64 
65  if (skVersion == null) {
66  throw new Exception(NbBundle.getMessage(this.getClass(), "Installer.exception.tskVerStringNull.msg"));
67  } else if (skVersion.length() == 0) {
68  throw new Exception(NbBundle.getMessage(this.getClass(), "Installer.exception.taskVerStringBang.msg"));
69  } else {
70  logger.log(Level.CONFIG, "Sleuth Kit Version: {0}", skVersion); //NON-NLS
71  }
72 
73  } catch (Exception e) {
74  logger.log(Level.SEVERE, "Error calling Sleuth Kit library (test call failed)", e); //NON-NLS
75 
76  // Normal error box log handler won't be loaded yet, so show error here.
77  final Component parentComponent = null; // Use default window frame.
78  final String message = NbBundle.getMessage(this.getClass(), "Installer.tskLibErr.msg", e.toString());
79  final String title = NbBundle.getMessage(this.getClass(), "Installer.tskLibErr.err");
80  final int messageType = JOptionPane.ERROR_MESSAGE;
81 
82  JOptionPane.showMessageDialog(
83  parentComponent,
84  message,
85  title,
86  messageType);
87 
88  // exit after user exits the error dialog box
89  LifecycleManager.getDefault().exit();
90  }
91 
92  }
93 }
static synchronized Installer getDefault()
Definition: Installer.java:38
synchronized static Logger getLogger(String name)
Definition: Logger.java:161

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