mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
working through initial central repository enable
This commit is contained in:
parent
49bf930794
commit
851a3308ad
@ -19,14 +19,9 @@ import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
|
||||
|
||||
public class CentralRepoDbManager {
|
||||
private static final String CENTRAL_REPO_DB_NAME = "central_repository";
|
||||
private static final String CENTRAL_REPO_SQLITE_EXT = ".db";
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CentralRepoDbManager.class.getName());
|
||||
|
||||
public static String getDefaultSqliteDbName() {
|
||||
return CENTRAL_REPO_DB_NAME + CENTRAL_REPO_SQLITE_EXT;
|
||||
}
|
||||
private static final String CENTRAL_REPO_DB_NAME = "central_repository";
|
||||
|
||||
/**
|
||||
* Upgrade the current Central Reposity schema to the newest version. If the
|
||||
@ -36,10 +31,9 @@ public class CentralRepoDbManager {
|
||||
@NbBundle.Messages(value = {"EamDbUtil.centralRepoDisabled.message= The Central Repository has been disabled.", "EamDbUtil.centralRepoUpgradeFailed.message=Failed to upgrade Central Repository.", "EamDbUtil.centralRepoConnectionFailed.message=Unable to connect to Central Repository.", "EamDbUtil.exclusiveLockAquisitionFailure.message=Unable to acquire exclusive lock for Central Repository."})
|
||||
public static void upgradeDatabase() throws CentralRepoException {
|
||||
if (!CentralRepository.isEnabled()) {
|
||||
// TODO
|
||||
// EamDbSettingsDialog dialog = new EamDbSettingsDialog();
|
||||
// dialog.promptUserForSetup();
|
||||
return;
|
||||
}
|
||||
|
||||
CentralRepository db = null;
|
||||
CoordinationService.Lock lock = null;
|
||||
//get connection
|
||||
@ -129,6 +123,11 @@ public class CentralRepoDbManager {
|
||||
return dbSettingsSqlite;
|
||||
}
|
||||
|
||||
public void setupDefaultSqliteSettings() {
|
||||
selectedPlatform = CentralRepoPlatforms.SQLITE;
|
||||
dbSettingsSqlite.setupDefaultSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if changes to the central repository configuration were
|
||||
* successfully applied
|
||||
@ -313,7 +312,7 @@ public class CentralRepoDbManager {
|
||||
break;
|
||||
case SQLITE:
|
||||
File databasePath = new File(tfDatabasePath);
|
||||
dbSettingsSqlite.setDbName(getDefaultSqliteDbName());
|
||||
dbSettingsSqlite.setDbName(SqliteCentralRepoSettings.DEFAULT_DBNAME);
|
||||
dbSettingsSqlite.setDbDirectory(databasePath.getPath());
|
||||
break;
|
||||
default:
|
||||
|
@ -42,8 +42,8 @@ import static org.sleuthkit.autopsy.centralrepository.datamodel.RdbmsCentralRepo
|
||||
*/
|
||||
public final class SqliteCentralRepoSettings {
|
||||
|
||||
public final static String DEFAULT_DBNAME = "central_repository.db"; // NON-NLS
|
||||
private final static Logger LOGGER = Logger.getLogger(SqliteCentralRepoSettings.class.getName());
|
||||
private final static String DEFAULT_DBNAME = "central_repository.db"; // NON-NLS
|
||||
private final static String DEFAULT_DBDIRECTORY = PlatformUtil.getUserDirectory() + File.separator + "central_repository"; // NON-NLS
|
||||
private final static String JDBC_DRIVER = "org.sqlite.JDBC"; // NON-NLS
|
||||
private final static String JDBC_BASE_URI = "jdbc:sqlite:"; // NON-NLS
|
||||
@ -90,6 +90,14 @@ public final class SqliteCentralRepoSettings {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sets database directory and name to defaults
|
||||
*/
|
||||
public void setupDefaultSettings() {
|
||||
dbName = DEFAULT_DBNAME;
|
||||
dbDirectory = DEFAULT_DBDIRECTORY;
|
||||
}
|
||||
|
||||
public void saveSettings() {
|
||||
createDbDirectory();
|
||||
|
||||
|
@ -28,6 +28,7 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbUtil;
|
||||
import org.sleuthkit.autopsy.core.RuntimeProperties;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
|
||||
/**
|
||||
* Install event listeners during module initialization
|
||||
@ -52,7 +53,14 @@ public class Installer extends ModuleInstall {
|
||||
super();
|
||||
}
|
||||
|
||||
@NbBundle.Messages({"Installer.centralRepoUpgradeFailed.title=Central repository disabled"})
|
||||
@NbBundle.Messages({
|
||||
"Installer.centralRepoUpgradeFailed.title=Central repository disabled",
|
||||
"Installer.initialCreateSqlite.title=Create Sqlite Central Repository?",
|
||||
"Installer.initialCreateSqlite.message=The central repository allows a user to find matching artifacts both across cases " +
|
||||
"and across data sources in the same case. Having data in the central repository is useful for file discovery. Would you " +
|
||||
"like to create the default Central Repository now? If you choose not to at this time, this setting can be changed in the " +
|
||||
"options panel."
|
||||
})
|
||||
@Override
|
||||
public void restored() {
|
||||
Case.addPropertyChangeListener(pcl);
|
||||
@ -60,7 +68,29 @@ public class Installer extends ModuleInstall {
|
||||
|
||||
// Perform the database upgrade and inform the user if it fails
|
||||
try {
|
||||
CentralRepoDbManager.upgradeDatabase();
|
||||
String initialized = ModuleSettings.getConfigSetting("CentralRepository", "initialized");
|
||||
if (!Boolean.parseBoolean(initialized)) {
|
||||
String dialogText = "<html><body><p style='max-width: 400px;'>" +
|
||||
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()) {
|
||||
WindowManager.getDefault().invokeWhenUIReady(() -> {
|
||||
|
@ -44,6 +44,7 @@ import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoPlatforms;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.DatabaseTestResult;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.SqliteCentralRepoSettings;
|
||||
|
||||
/**
|
||||
* Configuration dialog for Central Repository database settings.
|
||||
@ -84,7 +85,7 @@ public class EamDbSettingsDialog extends JDialog {
|
||||
if (pathname.isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
return pathname.getName().equalsIgnoreCase(CentralRepoDbManager.getDefaultSqliteDbName());
|
||||
return pathname.getName().equalsIgnoreCase(SqliteCentralRepoSettings.DEFAULT_DBNAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -500,7 +501,7 @@ public class EamDbSettingsDialog extends JDialog {
|
||||
}//GEN-LAST:event_cbDatabaseTypeActionPerformed
|
||||
|
||||
private void updateFullDbPath() {
|
||||
dataBaseFileTextArea.setText(tfDatabasePath.getText() + File.separator + manager.getDefaultSqliteDbName());
|
||||
dataBaseFileTextArea.setText(tfDatabasePath.getText() + File.separator + SqliteCentralRepoSettings.DEFAULT_DBNAME);
|
||||
dataBaseFileTextArea.setCaretPosition(dataBaseFileTextArea.getText().length());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user