mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
updates from debugging
This commit is contained in:
parent
13719c3e70
commit
00a94d649b
@ -194,14 +194,21 @@ public class CentralRepoDbManager {
|
||||
private CentralRepoDbChoice selectedDbChoice;
|
||||
|
||||
private final PostgresCentralRepoSettings dbSettingsPostgres;
|
||||
private final PostgresCentralRepoSettings dbSettingsMultiUser;
|
||||
private final SqliteCentralRepoSettings dbSettingsSqlite;
|
||||
|
||||
private boolean configurationChanged = false;
|
||||
|
||||
public CentralRepoDbManager() {
|
||||
dbSettingsPostgres = new PostgresCentralRepoSettings();
|
||||
dbSettingsSqlite = new SqliteCentralRepoSettings();
|
||||
selectedDbChoice = getSavedDbChoice();
|
||||
dbSettingsPostgres = new PostgresCentralRepoSettings(PostgresSettingsLoader.CUSTOM_LOADER);
|
||||
dbSettingsMultiUser = new PostgresCentralRepoSettings(PostgresSettingsLoader.MULTIUSER_LOADER);
|
||||
dbSettingsSqlite = new SqliteCentralRepoSettings();
|
||||
}
|
||||
|
||||
|
||||
public PostgresCentralRepoSettings getDbSettingsMultiUser() {
|
||||
return dbSettingsMultiUser;
|
||||
}
|
||||
|
||||
public PostgresCentralRepoSettings getDbSettingsPostgres() {
|
||||
@ -250,6 +257,8 @@ public class CentralRepoDbManager {
|
||||
}
|
||||
|
||||
private CentralRepoDbConnectivityManager getSelectedSettings() throws CentralRepoException {
|
||||
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER)
|
||||
return dbSettingsMultiUser;
|
||||
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_CUSTOM)
|
||||
return dbSettingsPostgres;
|
||||
if (selectedDbChoice == CentralRepoDbChoice.SQLITE)
|
||||
@ -261,6 +270,8 @@ public class CentralRepoDbManager {
|
||||
}
|
||||
|
||||
private RdbmsCentralRepoFactory getDbFactory() throws CentralRepoException {
|
||||
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_MULTIUSER)
|
||||
return new RdbmsCentralRepoFactory(CentralRepoPlatforms.POSTGRESQL, dbSettingsMultiUser);
|
||||
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_CUSTOM)
|
||||
return new RdbmsCentralRepoFactory(CentralRepoPlatforms.POSTGRESQL, dbSettingsPostgres);
|
||||
if (selectedDbChoice == CentralRepoDbChoice.SQLITE)
|
||||
@ -271,11 +282,18 @@ public class CentralRepoDbManager {
|
||||
throw new CentralRepoException("Unknown database type: " + selectedDbChoice);
|
||||
}
|
||||
|
||||
/**
|
||||
* create central repo database if it does not already exist
|
||||
* @return true if successful; false if unsuccessful
|
||||
* @throws CentralRepoException if
|
||||
*/
|
||||
public boolean createDb() throws CentralRepoException {
|
||||
boolean result = false;
|
||||
boolean dbCreated = true;
|
||||
|
||||
CentralRepoDbConnectivityManager selectedDbSettings = getSelectedSettings();
|
||||
if (selectedDbSettings == null)
|
||||
throw new CentralRepoException("Unable to derive connectivity manager from settings: " + selectedDbChoice);
|
||||
|
||||
if (!selectedDbSettings.verifyDatabaseExists()) {
|
||||
dbCreated = selectedDbSettings.createDatabase();
|
||||
@ -294,7 +312,6 @@ public class CentralRepoDbManager {
|
||||
if (!result) {
|
||||
// Remove the incomplete database
|
||||
if (dbCreated) {
|
||||
// RAMAN TBD: migrate deleteDatabase() to RdbmsCentralRepoFactory
|
||||
selectedDbSettings.deleteDatabase();
|
||||
}
|
||||
|
||||
@ -344,7 +361,7 @@ public class CentralRepoDbManager {
|
||||
// in case we are still using the same instance.
|
||||
if (selectedDbChoice != null && selectedDbSettings != CentralRepoDbChoice.DISABLED) {
|
||||
try {
|
||||
logger.info("Creating central repo db with settings: " + selectedDbSettings);
|
||||
logger.info("Saving central repo settings for db: " + selectedDbSettings);
|
||||
CentralRepository.getInstance().updateSettings();
|
||||
configurationChanged = true;
|
||||
} catch (CentralRepoException ex) {
|
||||
@ -399,7 +416,7 @@ public class CentralRepoDbManager {
|
||||
}
|
||||
|
||||
public DatabaseTestResult testStatus() {
|
||||
if (selectedDbChoice == CentralRepoDbChoice.POSTGRESQL_CUSTOM) {
|
||||
if (selectedDbChoice.getDbPlatform() == CentralRepoPlatforms.POSTGRESQL) {
|
||||
if (dbSettingsPostgres.verifyConnection()) {
|
||||
if (dbSettingsPostgres.verifyDatabaseExists()) {
|
||||
if (dbSettingsPostgres.verifyDatabaseSchema()) {
|
||||
@ -413,7 +430,7 @@ public class CentralRepoDbManager {
|
||||
} else {
|
||||
testingStatus = DatabaseTestResult.CONNECTION_FAILED;
|
||||
}
|
||||
} else if (selectedDbChoice == CentralRepoDbChoice.SQLITE) {
|
||||
} else if (selectedDbChoice.getDbPlatform() == CentralRepoPlatforms.SQLITE) {
|
||||
if (dbSettingsSqlite.dbFileExists()) {
|
||||
if (dbSettingsSqlite.verifyConnection()) {
|
||||
if (dbSettingsSqlite.verifyDatabaseSchema()) {
|
||||
|
@ -145,9 +145,9 @@
|
||||
<Component id="bnDatabasePathFileOpen" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="cbDatabaseType" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cbDatabaseType" min="-2" pref="210" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="lbSingleUserSqLite" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lbSingleUserSqLite" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jpDbPassword" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="tbDbUsername" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
|
@ -377,9 +377,9 @@ public class EamDbSettingsDialog extends JDialog {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(bnDatabasePathFileOpen))
|
||||
.addGroup(pnSQLiteSettingsLayout.createSequentialGroup()
|
||||
.addComponent(cbDatabaseType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(cbDatabaseType, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(lbSingleUserSqLite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(lbSingleUserSqLite, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE))
|
||||
.addComponent(jpDbPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(tbDbUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(tbDbPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user