mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
created central repo on first load
This commit is contained in:
parent
851a3308ad
commit
1b18e39dcf
@ -255,6 +255,9 @@ public class CentralRepoDbManager {
|
|||||||
break;
|
break;
|
||||||
case SQLITE:
|
case SQLITE:
|
||||||
// save the new SQLite settings
|
// save the new SQLite settings
|
||||||
|
logger.info(String.format("Attempting to set up sqlite database at path: %s with filename: %s",
|
||||||
|
dbSettingsSqlite.getDbDirectory(), dbSettingsSqlite.getDbName()));
|
||||||
|
|
||||||
dbSettingsSqlite.saveSettings();
|
dbSettingsSqlite.saveSettings();
|
||||||
// Load those newly saved settings into the sqlite db manager instance
|
// Load those newly saved settings into the sqlite db manager instance
|
||||||
// in case we are still using the same instance.
|
// in case we are still using the same instance.
|
||||||
|
@ -18,8 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.centralrepository.eventlisteners;
|
package org.sleuthkit.autopsy.centralrepository.eventlisteners;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.logging.Level;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
import org.openide.modules.ModuleInstall;
|
import org.openide.modules.ModuleInstall;
|
||||||
|
import org.openide.util.Exceptions;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.openide.windows.WindowManager;
|
import org.openide.windows.WindowManager;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
@ -55,55 +59,95 @@ public class Installer extends ModuleInstall {
|
|||||||
|
|
||||||
@NbBundle.Messages({
|
@NbBundle.Messages({
|
||||||
"Installer.centralRepoUpgradeFailed.title=Central repository disabled",
|
"Installer.centralRepoUpgradeFailed.title=Central repository disabled",
|
||||||
"Installer.initialCreateSqlite.title=Create Sqlite Central Repository?",
|
"Installer.initialCreateSqlite.title=Enable Central Repository?",
|
||||||
"Installer.initialCreateSqlite.message=The central repository allows a user to find matching artifacts both across cases " +
|
"Installer.initialCreateSqlite.message=The Central Repository is not enabled. Would you like to enable it? " +
|
||||||
"and across data sources in the same case. Having data in the central repository is useful for file discovery. Would you " +
|
"It will store information about all hashes and identifiers that you process. You can use this to ignore previously " +
|
||||||
"like to create the default Central Repository now? If you choose not to at this time, this setting can be changed in the " +
|
"seen files and make connections between cases."
|
||||||
"options panel."
|
|
||||||
})
|
})
|
||||||
@Override
|
@Override
|
||||||
public void restored() {
|
public void restored() {
|
||||||
Case.addPropertyChangeListener(pcl);
|
Case.addPropertyChangeListener(pcl);
|
||||||
ieListener.installListeners();
|
ieListener.installListeners();
|
||||||
|
|
||||||
// Perform the database upgrade and inform the user if it fails
|
String initialized = ModuleSettings.getConfigSetting("CentralRepository", "initialized");
|
||||||
try {
|
|
||||||
String initialized = ModuleSettings.getConfigSetting("CentralRepository", "initialized");
|
// if central repository hasn't been previously initialized, initialize it
|
||||||
if (!Boolean.parseBoolean(initialized)) {
|
if (!Boolean.parseBoolean(initialized)) {
|
||||||
String dialogText = "<html><body><p style='max-width: 400px;'>" +
|
// if running with a GUI, prompt the user
|
||||||
NbBundle.getMessage(this.getClass(), "Installer.initialCreateSqlite.message") +
|
|
||||||
"</p></body></html>";
|
|
||||||
|
|
||||||
boolean setupSqlite = !RuntimeProperties.runningWithGUI() ||
|
|
||||||
JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(WindowManager.getDefault().getMainWindow(),
|
|
||||||
dialogText,
|
|
||||||
NbBundle.getMessage(this.getClass(), "Installer.initialCreateSqlite.title"),
|
|
||||||
JOptionPane.YES_NO_OPTION);
|
|
||||||
|
|
||||||
if (setupSqlite) {
|
|
||||||
CentralRepoDbManager manager = new CentralRepoDbManager();
|
|
||||||
manager.setupDefaultSqliteSettings();
|
|
||||||
manager.saveNewCentralRepo();
|
|
||||||
}
|
|
||||||
|
|
||||||
ModuleSettings.setConfigSetting("CentralRepository", "initialized", "true");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
CentralRepoDbManager.upgradeDatabase();
|
|
||||||
}
|
|
||||||
} catch (CentralRepoException ex) {
|
|
||||||
if (RuntimeProperties.runningWithGUI()) {
|
if (RuntimeProperties.runningWithGUI()) {
|
||||||
WindowManager.getDefault().invokeWhenUIReady(() -> {
|
try {
|
||||||
JOptionPane.showMessageDialog(null,
|
SwingUtilities.invokeAndWait(() -> {
|
||||||
ex.getUserMessage(),
|
try {
|
||||||
NbBundle.getMessage(this.getClass(),
|
String dialogText = "<html><body><p style='width: 400px;'>"
|
||||||
"Installer.centralRepoUpgradeFailed.title"),
|
+ NbBundle.getMessage(this.getClass(), "Installer.initialCreateSqlite.message")
|
||||||
JOptionPane.ERROR_MESSAGE);
|
+ "</p></body></html>";
|
||||||
});
|
|
||||||
|
if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(WindowManager.getDefault().getMainWindow(),
|
||||||
|
dialogText,
|
||||||
|
NbBundle.getMessage(this.getClass(), "Installer.initialCreateSqlite.title"),
|
||||||
|
JOptionPane.YES_NO_OPTION)) {
|
||||||
|
|
||||||
|
setupDefaultSqlite();
|
||||||
|
}
|
||||||
|
} catch (CentralRepoException ex) {
|
||||||
|
LOGGER.log(Level.SEVERE, "There was an error while initializing the central repository database", ex);
|
||||||
|
|
||||||
|
reportUpgradeError(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOGGER.log(Level.SEVERE, "There was an error while running the swing utility invoke later while creating the central repository database", ex);
|
||||||
|
}
|
||||||
|
} // if no GUI, just initialize
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
setupDefaultSqlite();
|
||||||
|
} catch (CentralRepoException ex) {
|
||||||
|
LOGGER.log(Level.SEVERE, "There was an error while initializing the central repository database", ex);
|
||||||
|
|
||||||
|
reportUpgradeError(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ModuleSettings.setConfigSetting("CentralRepository", "initialized", "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
// now run regular module startup code
|
||||||
|
try {
|
||||||
|
CentralRepoDbManager.upgradeDatabase();
|
||||||
|
} catch (CentralRepoException ex) {
|
||||||
|
LOGGER.log(Level.SEVERE, "There was an error while upgrading the central repository database", ex);
|
||||||
|
if (RuntimeProperties.runningWithGUI()) {
|
||||||
|
reportUpgradeError(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupDefaultSqlite() throws CentralRepoException {
|
||||||
|
CentralRepoDbUtil.setUseCentralRepo(true);
|
||||||
|
CentralRepoDbManager manager = new CentralRepoDbManager();
|
||||||
|
manager.setupDefaultSqliteSettings();
|
||||||
|
manager.createDb();
|
||||||
|
manager.saveNewCentralRepo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reportUpgradeError(CentralRepoException ex) {
|
||||||
|
try {
|
||||||
|
SwingUtilities.invokeAndWait(() -> {
|
||||||
|
JOptionPane.showMessageDialog(null,
|
||||||
|
ex.getUserMessage(),
|
||||||
|
NbBundle.getMessage(this.getClass(),
|
||||||
|
"Installer.centralRepoUpgradeFailed.title"),
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.warning("There was an error while running the swing utility invoke later while displaying an error " +
|
||||||
|
"for creating the central repository database: "
|
||||||
|
+ e.getMessage() + System.lineSeparator() + e.getStackTrace());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean closing() {
|
public boolean closing() {
|
||||||
//platform about to close
|
//platform about to close
|
||||||
|
Loading…
x
Reference in New Issue
Block a user