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
@ -18,16 +18,11 @@ import org.sleuthkit.autopsy.coordinationservice.CoordinationService;
|
|||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
|
|
||||||
|
|
||||||
public class CentralRepoDbManager {
|
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());
|
private static final Logger logger = Logger.getLogger(CentralRepoDbManager.class.getName());
|
||||||
|
|
||||||
|
private static final String CENTRAL_REPO_DB_NAME = "central_repository";
|
||||||
|
|
||||||
public static String getDefaultSqliteDbName() {
|
|
||||||
return CENTRAL_REPO_DB_NAME + CENTRAL_REPO_SQLITE_EXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upgrade the current Central Reposity schema to the newest version. If the
|
* Upgrade the current Central Reposity schema to the newest version. If the
|
||||||
* upgrade fails, the Central Repository will be disabled and the current
|
* upgrade fails, the Central Repository will be disabled and the current
|
||||||
@ -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."})
|
@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 {
|
public static void upgradeDatabase() throws CentralRepoException {
|
||||||
if (!CentralRepository.isEnabled()) {
|
if (!CentralRepository.isEnabled()) {
|
||||||
// TODO
|
return;
|
||||||
// EamDbSettingsDialog dialog = new EamDbSettingsDialog();
|
|
||||||
// dialog.promptUserForSetup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CentralRepository db = null;
|
CentralRepository db = null;
|
||||||
CoordinationService.Lock lock = null;
|
CoordinationService.Lock lock = null;
|
||||||
//get connection
|
//get connection
|
||||||
@ -129,6 +123,11 @@ public class CentralRepoDbManager {
|
|||||||
return dbSettingsSqlite;
|
return dbSettingsSqlite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setupDefaultSqliteSettings() {
|
||||||
|
selectedPlatform = CentralRepoPlatforms.SQLITE;
|
||||||
|
dbSettingsSqlite.setupDefaultSettings();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if changes to the central repository configuration were
|
* Returns if changes to the central repository configuration were
|
||||||
* successfully applied
|
* successfully applied
|
||||||
@ -313,7 +312,7 @@ public class CentralRepoDbManager {
|
|||||||
break;
|
break;
|
||||||
case SQLITE:
|
case SQLITE:
|
||||||
File databasePath = new File(tfDatabasePath);
|
File databasePath = new File(tfDatabasePath);
|
||||||
dbSettingsSqlite.setDbName(getDefaultSqliteDbName());
|
dbSettingsSqlite.setDbName(SqliteCentralRepoSettings.DEFAULT_DBNAME);
|
||||||
dbSettingsSqlite.setDbDirectory(databasePath.getPath());
|
dbSettingsSqlite.setDbDirectory(databasePath.getPath());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -42,8 +42,8 @@ import static org.sleuthkit.autopsy.centralrepository.datamodel.RdbmsCentralRepo
|
|||||||
*/
|
*/
|
||||||
public final class SqliteCentralRepoSettings {
|
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 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 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_DRIVER = "org.sqlite.JDBC"; // NON-NLS
|
||||||
private final static String JDBC_BASE_URI = "jdbc:sqlite:"; // NON-NLS
|
private final static String JDBC_BASE_URI = "jdbc:sqlite:"; // NON-NLS
|
||||||
@ -89,6 +89,14 @@ public final class SqliteCentralRepoSettings {
|
|||||||
this.bulkThreshold = RdbmsCentralRepo.DEFAULT_BULK_THRESHHOLD;
|
this.bulkThreshold = RdbmsCentralRepo.DEFAULT_BULK_THRESHHOLD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets database directory and name to defaults
|
||||||
|
*/
|
||||||
|
public void setupDefaultSettings() {
|
||||||
|
dbName = DEFAULT_DBNAME;
|
||||||
|
dbDirectory = DEFAULT_DBDIRECTORY;
|
||||||
|
}
|
||||||
|
|
||||||
public void saveSettings() {
|
public void saveSettings() {
|
||||||
createDbDirectory();
|
createDbDirectory();
|
||||||
|
@ -28,6 +28,7 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException;
|
|||||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbUtil;
|
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbUtil;
|
||||||
import org.sleuthkit.autopsy.core.RuntimeProperties;
|
import org.sleuthkit.autopsy.core.RuntimeProperties;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
|
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install event listeners during module initialization
|
* Install event listeners during module initialization
|
||||||
@ -52,7 +53,14 @@ public class Installer extends ModuleInstall {
|
|||||||
super();
|
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
|
@Override
|
||||||
public void restored() {
|
public void restored() {
|
||||||
Case.addPropertyChangeListener(pcl);
|
Case.addPropertyChangeListener(pcl);
|
||||||
@ -60,7 +68,29 @@ public class Installer extends ModuleInstall {
|
|||||||
|
|
||||||
// Perform the database upgrade and inform the user if it fails
|
// Perform the database upgrade and inform the user if it fails
|
||||||
try {
|
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) {
|
} catch (CentralRepoException ex) {
|
||||||
if (RuntimeProperties.runningWithGUI()) {
|
if (RuntimeProperties.runningWithGUI()) {
|
||||||
WindowManager.getDefault().invokeWhenUIReady(() -> {
|
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.CentralRepoException;
|
||||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoPlatforms;
|
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoPlatforms;
|
||||||
import org.sleuthkit.autopsy.centralrepository.datamodel.DatabaseTestResult;
|
import org.sleuthkit.autopsy.centralrepository.datamodel.DatabaseTestResult;
|
||||||
|
import org.sleuthkit.autopsy.centralrepository.datamodel.SqliteCentralRepoSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration dialog for Central Repository database settings.
|
* Configuration dialog for Central Repository database settings.
|
||||||
@ -84,7 +85,7 @@ public class EamDbSettingsDialog extends JDialog {
|
|||||||
if (pathname.isDirectory()) {
|
if (pathname.isDirectory()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return pathname.getName().equalsIgnoreCase(CentralRepoDbManager.getDefaultSqliteDbName());
|
return pathname.getName().equalsIgnoreCase(SqliteCentralRepoSettings.DEFAULT_DBNAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -500,7 +501,7 @@ public class EamDbSettingsDialog extends JDialog {
|
|||||||
}//GEN-LAST:event_cbDatabaseTypeActionPerformed
|
}//GEN-LAST:event_cbDatabaseTypeActionPerformed
|
||||||
|
|
||||||
private void updateFullDbPath() {
|
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());
|
dataBaseFileTextArea.setCaretPosition(dataBaseFileTextArea.getText().length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user