Merge pull request #5724 from rcordovano/6108-relocate-cr-upgrade

6108 relocate central repository schema updates
This commit is contained in:
Richard Cordovano 2020-03-23 13:17:27 -04:00 committed by GitHub
commit d5bbd76daa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 199 additions and 214 deletions

View File

@ -7,7 +7,14 @@ AbstractSqlEamDb.cannotUpgrage.message=Currently selected database platform "{0}
AbstractSqlEamDb.failedToReadMajorVersion.message=Failed to read schema version for Central Repository. AbstractSqlEamDb.failedToReadMajorVersion.message=Failed to read schema version for Central Repository.
AbstractSqlEamDb.failedToReadMinorVersion.message=Failed to read schema minor version for Central Repository. AbstractSqlEamDb.failedToReadMinorVersion.message=Failed to read schema minor version for Central Repository.
AbstractSqlEamDb.upgradeSchema.incompatible=The selected Central Repository is not compatible with the current version of the application, please upgrade the application if you wish to use this Central Repository. AbstractSqlEamDb.upgradeSchema.incompatible=The selected Central Repository is not compatible with the current version of the application, please upgrade the application if you wish to use this Central Repository.
CentralRepoDbChoice.Disabled.Text=Disabled
CentralRepoDbChoice.PostgreSQL.Text=Custom PostgreSQL
CentralRepoDbChoice.PostgreSQL_Multiuser.Text=PostgreSQL using multi-user settings
CentralRepoDbChoice.Sqlite.Text=SQLite
CentralRepoDbManager.connectionErrorMsg.text=Failed to connect to central repository database. CentralRepoDbManager.connectionErrorMsg.text=Failed to connect to central repository database.
CentralRepositoryService.progressMsg.updatingDataSourcesTable=Checking for v1.2 data updates...
CentralRepositoryService.progressMsg.updatingSchema=Updating schema...
CentralRepositoryService.serviceName=Central Repository Service
CorrelationAttributeInstance.invalidName.message=Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'. CorrelationAttributeInstance.invalidName.message=Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'.
CorrelationAttributeInstance.nullName.message=Database name is null. CorrelationAttributeInstance.nullName.message=Database name is null.
CorrelationAttributeUtil.emailaddresses.text=Email Addresses CorrelationAttributeUtil.emailaddresses.text=Email Addresses
@ -21,7 +28,6 @@ CorrelationType.MAC.displayName=MAC Addresses
CorrelationType.PHONE.displayName=Phone Numbers CorrelationType.PHONE.displayName=Phone Numbers
CorrelationType.SSID.displayName=Wireless Networks CorrelationType.SSID.displayName=Wireless Networks
CorrelationType.USBID.displayName=USB Devices CorrelationType.USBID.displayName=USB Devices
DataSourceUpdateService.serviceName.text=Update Central Repository Data Sources
EamArtifactInstances.knownStatus.bad=Bad EamArtifactInstances.knownStatus.bad=Bad
EamArtifactInstances.knownStatus.known=Known EamArtifactInstances.knownStatus.known=Known
EamArtifactInstances.knownStatus.unknown=Unknown EamArtifactInstances.knownStatus.unknown=Unknown

View File

@ -0,0 +1,115 @@
/*
* Central Repository
*
* Copyright 2018-2020 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.centralrepository.datamodel;
import org.openide.util.NbBundle;
import org.openide.util.lookup.ServiceProvider;
import org.sleuthkit.autopsy.appservices.AutopsyService;
import org.sleuthkit.autopsy.progress.ProgressIndicator;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.DataSource;
import org.sleuthkit.datamodel.TskCoreException;
/**
* The Autopsy application service for the central repository.
*/
@ServiceProvider(service = AutopsyService.class)
public class CentralRepositoryService implements AutopsyService {
@Override
@NbBundle.Messages({
"CentralRepositoryService.serviceName=Central Repository Service"
})
public String getServiceName() {
return Bundle.CentralRepositoryService_serviceName();
}
@NbBundle.Messages({
"CentralRepositoryService.progressMsg.updatingSchema=Updating schema...",
"CentralRepositoryService.progressMsg.updatingDataSourcesTable=Checking for v1.2 data updates...",})
@Override
public void openCaseResources(CaseContext context) throws AutopsyServiceException {
if (!CentralRepository.isEnabled()) {
return;
}
ProgressIndicator progress = context.getProgressIndicator();
progress.progress(Bundle.CentralRepositoryService_progressMsg_updatingSchema());
updateSchema();
if (context.cancelRequested()) {
return;
}
progress.progress(Bundle.CentralRepositoryService_progressMsg_updatingDataSourcesTable());
dataUpgradeForVersion1dot2(context.getCase());
}
/**
* Updates the central repository schema to the latest version.
*
* @throws AutopsyServiceException
*/
private void updateSchema() throws AutopsyServiceException {
try {
CentralRepoDbManager.upgradeDatabase();
} catch (CentralRepoException ex) {
throw new AutopsyServiceException("Failed to update the Central Repository schema", ex);
}
}
/**
* Adds missing data source object IDs from data sources in this case to the
* corresponding records in the central repository. This is a data update to
* go with the v1.2 schema update.
*
* @throws AutopsyServiceException
*/
private void dataUpgradeForVersion1dot2(Case currentCase) throws AutopsyServiceException {
try {
/*
* If the case is in the central repository, there may be missing
* data source object IDs in the data_sources.datasource_obj_id
* column that was added in the version 1.2 schema update.
*/
CentralRepository centralRepository = CentralRepository.getInstance();
CorrelationCase correlationCase = centralRepository.getCase(currentCase);
if (correlationCase != null) {
for (CorrelationDataSource correlationDataSource : centralRepository.getDataSources()) {
/*
* ResultSet.getLong returns zero when the value in the
* result set is NULL.
*/
if (correlationDataSource.getCaseID() == correlationCase.getID() && correlationDataSource.getDataSourceObjectID() == 0) {
for (Content dataSource : currentCase.getDataSources()) {
if (((DataSource) dataSource).getDeviceId().equals(correlationDataSource.getDeviceID()) && dataSource.getName().equals(correlationDataSource.getName())) {
centralRepository.addDataSourceObjectId(correlationDataSource.getID(), dataSource.getId());
break;
}
}
}
}
}
} catch (CentralRepoException | TskCoreException ex) {
throw new AutopsyServiceException("Failed to update data sources in the Central Repository for schema v1.2", ex);
}
}
}

View File

@ -1,68 +0,0 @@
/*
* Central Repository
*
* Copyright 2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.centralrepository.datamodel;
import org.openide.util.NbBundle;
import org.openide.util.lookup.ServiceProvider;
import org.sleuthkit.autopsy.appservices.AutopsyService;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.DataSource;
import org.sleuthkit.datamodel.TskCoreException;
/**
* Class which updates the data sources in the central repository to include the
* object id which ties them to the current case.
*
*/
@ServiceProvider(service = AutopsyService.class)
public class DataSourceUpdateService implements AutopsyService {
@Override
@NbBundle.Messages({"DataSourceUpdateService.serviceName.text=Update Central Repository Data Sources"})
public String getServiceName() {
return Bundle.DataSourceUpdateService_serviceName_text();
}
@Override
public void openCaseResources(CaseContext context) throws AutopsyServiceException {
if (CentralRepository.isEnabled()) {
try {
CentralRepository centralRepository = CentralRepository.getInstance();
CorrelationCase correlationCase = centralRepository.getCase(context.getCase());
//if the case isn't in the central repository yet there won't be data sources in it to update
if (correlationCase != null) {
for (CorrelationDataSource correlationDataSource : centralRepository.getDataSources()) {
//ResultSet.getLong has a value of 0 when the value is null
if (correlationDataSource.getCaseID() == correlationCase.getID() && correlationDataSource.getDataSourceObjectID() == 0) {
for (Content dataSource : context.getCase().getDataSources()) {
if (((DataSource) dataSource).getDeviceId().equals(correlationDataSource.getDeviceID()) && dataSource.getName().equals(correlationDataSource.getName())) {
centralRepository.addDataSourceObjectId(correlationDataSource.getID(), dataSource.getId());
break;
}
}
}
}
}
} catch (CentralRepoException | TskCoreException ex) {
throw new AutopsyServiceException("Unabe to update datasources in central repository", ex);
}
}
}
}

View File

@ -39,16 +39,6 @@ import org.sleuthkit.autopsy.coreutils.Version;
* central repository, sets up a default, single-user SQLite central repository * central repository, sets up a default, single-user SQLite central repository
* if no central repository is configured, and updates the central repository * if no central repository is configured, and updates the central repository
* schema as required. * schema as required.
*
* TODO (Jira-6108): At first glance, this package seems to have become a rather
* strange package for the "package installer" for the CR to reside in. The
* org.sleuthkit.autopsy.centralrepository package would seem to be more
* appropriate with so much going on. However, having a central repository
* schema update occur in a "package installer" with no user feedback is not
* optimal. Furthermore, for a multi-user (collaborative) installation, a schema
* update should be done in a more controlled way by acquiring an exclusive
* coordination service lock and requiring shared locks to be acquired by nodes
* with open cases.
*/ */
public class Installer extends ModuleInstall { public class Installer extends ModuleInstall {
@ -84,9 +74,8 @@ public class Installer extends ModuleInstall {
/* /*
* Adds/removes application event listeners responsible for adding data to * Adds/removes application event listeners responsible for adding data to
* the central repository, sets up a default, single-user SQLite central * the central repository and sets up a default, single-user SQLite central
* repository if no central repository is configured, and updates the * repository if no central repository is configured.
* central repository schema as required.
* *
* Called by the registered Installer for the Autopsy-Core module located in * Called by the registered Installer for the Autopsy-Core module located in
* the org.sleuthkit.autopsy.core package when the already installed * the org.sleuthkit.autopsy.core package when the already installed
@ -105,8 +94,6 @@ public class Installer extends ModuleInstall {
if (Version.getBuildType() == Version.Type.RELEASE) { if (Version.getBuildType() == Version.Type.RELEASE) {
setupDefaultCentralRepository(); setupDefaultCentralRepository();
} }
updateCentralRepoSchema();
} }
/** /**
@ -198,20 +185,6 @@ public class Installer extends ModuleInstall {
manager.setupDefaultSqliteDb(); manager.setupDefaultSqliteDb();
} }
/**
* Update the central repository schema.
*/
private void updateCentralRepoSchema() {
try {
CentralRepoDbManager.upgradeDatabase();
} catch (CentralRepoException ex) {
logger.log(Level.SEVERE, "An error occurred updating the central repository schema", ex);
if (RuntimeProperties.runningWithGUI()) {
doMessageBoxIfRunningInGUI(ex);
}
}
}
/** /**
* Display a central repository exception in a message box if running with a * Display a central repository exception in a message box if running with a
* GUI. * GUI.

View File

@ -39,7 +39,6 @@ GlobalSettingsPanel.onMultiUserChange.disabledMu.title=Central Repository Change
GlobalSettingsPanel.onMultiUserChange.enable.description=Do you want to update the Central Repository to use this PostgreSQL database? GlobalSettingsPanel.onMultiUserChange.enable.description=Do you want to update the Central Repository to use this PostgreSQL database?
GlobalSettingsPanel.onMultiUserChange.enable.description2=The Central Repository stores hash values and accounts from past cases. GlobalSettingsPanel.onMultiUserChange.enable.description2=The Central Repository stores hash values and accounts from past cases.
GlobalSettingsPanel.onMultiUserChange.enable.title=Use with Central Repository? GlobalSettingsPanel.onMultiUserChange.enable.title=Use with Central Repository?
GlobalSettingsPanel.updateFailed.title=Central repository disabled
GlobalSettingsPanel.validationErrMsg.ingestRunning=You cannot change settings while ingest is running. GlobalSettingsPanel.validationErrMsg.ingestRunning=You cannot change settings while ingest is running.
GlobalSettingsPanel.validationerrMsg.mustConfigure=Configure the database to enable this module. GlobalSettingsPanel.validationerrMsg.mustConfigure=Configure the database to enable this module.
ManageCasesDialog.title.text=Manage Cases ManageCasesDialog.title.text=Manage Cases

View File

@ -56,8 +56,6 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
private static final Set<IngestManager.IngestJobEvent> INGEST_JOB_EVENTS_OF_INTEREST = EnumSet.of(IngestManager.IngestJobEvent.STARTED, IngestManager.IngestJobEvent.CANCELLED, IngestManager.IngestJobEvent.COMPLETED); private static final Set<IngestManager.IngestJobEvent> INGEST_JOB_EVENTS_OF_INTEREST = EnumSet.of(IngestManager.IngestJobEvent.STARTED, IngestManager.IngestJobEvent.CANCELLED, IngestManager.IngestJobEvent.COMPLETED);
private final IngestJobEventPropertyChangeListener ingestJobEventListener; private final IngestJobEventPropertyChangeListener ingestJobEventListener;
/** /**
* Creates new form EamOptionsPanel * Creates new form EamOptionsPanel
*/ */
@ -75,7 +73,6 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
}); });
} }
private void customizeComponents() { private void customizeComponents() {
setName(NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.pnCorrelationProperties.border.title")); setName(NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.pnCorrelationProperties.border.title"));
} }
@ -85,39 +82,36 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
ingestStateUpdated(Case.isCaseOpen()); ingestStateUpdated(Case.isCaseOpen());
} }
private void updateDatabase() {
updateDatabase(this);
}
/** /**
* This method invokes central repository database choice selection as well as input for necessary configuration. * This method invokes central repository database choice selection as well
* as input for necessary configuration.
*
* @param parent The parent component for displaying dialogs. * @param parent The parent component for displaying dialogs.
* @param initialSelection If non-null, the menu item will be set to this choice; if null, * @param initialSelection If non-null, the menu item will be set to this
* the currently selected db choice will be selected. * choice; if null, the currently selected db choice
* will be selected.
*
* @return True if there was a change. * @return True if there was a change.
*/ */
private static boolean invokeCrChoice(Component parent, CentralRepoDbChoice initialSelection) { private static boolean invokeCrChoice(Component parent, CentralRepoDbChoice initialSelection) {
EamDbSettingsDialog dialog = (initialSelection != null) ? EamDbSettingsDialog dialog = (initialSelection != null)
new EamDbSettingsDialog(initialSelection) : ? new EamDbSettingsDialog(initialSelection)
new EamDbSettingsDialog(); : new EamDbSettingsDialog();
return dialog.wasConfigurationChanged();
if (dialog.wasConfigurationChanged()) {
updateDatabase(parent);
return true;
} }
return false;
}
/** /**
* When multi user settings are updated, this function triggers pertinent updates for central repository. * When multi user settings are updated, this function triggers pertinent
* NOTE: If multi user settings were previously enabled and multi user settings are currently selected, this function assumes * updates for central repository. NOTE: If multi user settings were
* there is a change in the postgres connectivity. * previously enabled and multi user settings are currently selected, this
* function assumes there is a change in the postgres connectivity.
* *
* @param parent The swing component that serves as a parent for dialogs that may arise. * @param parent The swing component that serves as a parent
* @param muPreviouslySelected If multi user settings were previously enabled. * for dialogs that may arise.
* @param muCurrentlySelected If multi user settings are currently enabled as of most recent change. * @param muPreviouslySelected If multi user settings were previously
* enabled.
* @param muCurrentlySelected If multi user settings are currently enabled
* as of most recent change.
*/ */
@NbBundle.Messages({ @NbBundle.Messages({
"GlobalSettingsPanel.onMultiUserChange.enable.title=Use with Central Repository?", "GlobalSettingsPanel.onMultiUserChange.enable.title=Use with Central Repository?",
@ -132,12 +126,12 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
if (!muPreviouslySelected && muCurrentlySelected) { if (!muPreviouslySelected && muCurrentlySelected) {
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(parent, if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(parent,
"<html><body>" + "<html><body>"
"<div style='width: 400px;'>" + + "<div style='width: 400px;'>"
"<p>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.enable.description") + "</p>" + + "<p>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.enable.description") + "</p>"
"<p style='margin-top: 10px'>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.enable.description2") + "</p>" + + "<p style='margin-top: 10px'>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.enable.description2") + "</p>"
"</div>" + + "</div>"
"</body></html>", + "</body></html>",
NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.enable.title"), NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.enable.title"),
JOptionPane.YES_NO_OPTION)) { JOptionPane.YES_NO_OPTION)) {
@ -147,14 +141,12 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
handleDbChange(parent); handleDbChange(parent);
} }
}); });
} } // moving from selected to not selected && 'PostgreSQL using multi-user settings' is selected
// moving from selected to not selected && 'PostgreSQL using multi-user settings' is selected
else if (muPreviouslySelected && !muCurrentlySelected && crEnabled && crMultiUser) { else if (muPreviouslySelected && !muCurrentlySelected && crEnabled && crMultiUser) {
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
askForCentralRepoDbChoice(parent); askForCentralRepoDbChoice(parent);
}); });
} } // changing multi-user settings connection && 'PostgreSQL using multi-user settings' is selected &&
// changing multi-user settings connection && 'PostgreSQL using multi-user settings' is selected &&
// central repo either enabled or was disabled due to error // central repo either enabled or was disabled due to error
else if (muPreviouslySelected && muCurrentlySelected && crMultiUser && (crEnabled || crDisabledDueToFailure)) { else if (muPreviouslySelected && muCurrentlySelected && crMultiUser && (crEnabled || crDisabledDueToFailure)) {
// test databse for CR change // test databse for CR change
@ -163,10 +155,12 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
} }
} }
/** /**
* This method is called when a user must select a new database other than using database from multi user settings. * This method is called when a user must select a new database other than
* @param parent The parent component to use for displaying dialogs in reference. * using database from multi user settings.
*
* @param parent The parent component to use for displaying dialogs in
* reference.
*/ */
@NbBundle.Messages({ @NbBundle.Messages({
"GlobalSettingsPanel.onMultiUserChange.disabledMu.title=Central Repository Change Necessary", "GlobalSettingsPanel.onMultiUserChange.disabledMu.title=Central Repository Change Necessary",
@ -186,12 +180,12 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
int result = JOptionPane.showOptionDialog( int result = JOptionPane.showOptionDialog(
parent, parent,
"<html><body>" + "<html><body>"
"<div style='width: 400px;'>" + + "<div style='width: 400px;'>"
"<p>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.disabledMu.description") + "</p>" + + "<p>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.disabledMu.description") + "</p>"
"<p style='margin-top: 10px'>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.disabledMu.description2") + "</p>" + + "<p style='margin-top: 10px'>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.disabledMu.description2") + "</p>"
"</div>" + + "</div>"
"</body></html>", + "</body></html>",
NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.disabledMu.title"), NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.disabledMu.title"),
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE, JOptionPane.PLAIN_MESSAGE,
@ -202,49 +196,19 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
if (JOptionPane.YES_OPTION == result) { if (JOptionPane.YES_OPTION == result) {
invokeCrChoice(parent, CentralRepoDbChoice.SQLITE); invokeCrChoice(parent, CentralRepoDbChoice.SQLITE);
} } else if (JOptionPane.NO_OPTION == result) {
else if (JOptionPane.NO_OPTION == result) {
invokeCrChoice(parent, CentralRepoDbChoice.POSTGRESQL_CUSTOM); invokeCrChoice(parent, CentralRepoDbChoice.POSTGRESQL_CUSTOM);
} }
} }
private static void handleDbChange(Component parent) { private static void handleDbChange(Component parent) {
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
boolean successful = EamDbSettingsDialog.testStatusAndCreate(parent, new CentralRepoDbManager()); if (!EamDbSettingsDialog.testStatusAndCreate(parent, new CentralRepoDbManager())) {
if (successful) {
updateDatabase(parent);
}
else {
// disable central repository due to error
CentralRepoDbManager.disableDueToFailure(); CentralRepoDbManager.disableDueToFailure();
} }
}); });
} }
@Messages({"GlobalSettingsPanel.updateFailed.title=Central repository disabled"})
private static void updateDatabase(Component parent) {
if (CentralRepoDbChoice.DISABLED.equals(CentralRepoDbManager.getSavedDbChoice())) {
return;
}
parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
CentralRepoDbManager.upgradeDatabase();
parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
} catch (CentralRepoException ex) {
parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
JOptionPane.showMessageDialog(parent,
ex.getUserMessage(),
NbBundle.getMessage(GlobalSettingsPanel.class,
"GlobalSettingsPanel.updateFailed.title"),
JOptionPane.WARNING_MESSAGE);
} finally {
parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
/** /**
* This method is called from within the constructor to initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always * WARNING: Do NOT modify this code. The content of this method is always
@ -591,15 +555,13 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
store(); store();
// if moving to using CR, multi-user mode is disabled and selection is multiuser settings, set to disabled // if moving to using CR, multi-user mode is disabled and selection is multiuser settings, set to disabled
if (cbUseCentralRepo.isSelected() && if (cbUseCentralRepo.isSelected()
!CentralRepoDbManager.isPostgresMultiuserAllowed() && && !CentralRepoDbManager.isPostgresMultiuserAllowed()
CentralRepoDbManager.getSavedDbChoice() == CentralRepoDbChoice.POSTGRESQL_MULTIUSER) { && CentralRepoDbManager.getSavedDbChoice() == CentralRepoDbChoice.POSTGRESQL_MULTIUSER) {
CentralRepoDbManager.saveDbChoice(CentralRepoDbChoice.DISABLED); CentralRepoDbManager.saveDbChoice(CentralRepoDbChoice.DISABLED);
} }
updateDatabase();
load(); load();
this.ingestStateUpdated(Case.isCaseOpen()); this.ingestStateUpdated(Case.isCaseOpen());
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null); firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
@ -620,20 +582,17 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
lbDbNameValue.setText(""); lbDbNameValue.setText("");
lbDbLocationValue.setText(""); lbDbLocationValue.setText("");
tbOops.setText(Bundle.GlobalSettingsPanel_validationerrMsg_mustConfigure()); tbOops.setText(Bundle.GlobalSettingsPanel_validationerrMsg_mustConfigure());
} } else {
else {
enableButtonSubComponents(cbUseCentralRepo.isSelected()); enableButtonSubComponents(cbUseCentralRepo.isSelected());
if (selectedDb == CentralRepoPlatforms.POSTGRESQL) { if (selectedDb == CentralRepoPlatforms.POSTGRESQL) {
try { try {
PostgresCentralRepoSettings dbSettingsPg = new PostgresCentralRepoSettings(); PostgresCentralRepoSettings dbSettingsPg = new PostgresCentralRepoSettings();
lbDbNameValue.setText(dbSettingsPg.getDbName()); lbDbNameValue.setText(dbSettingsPg.getDbName());
lbDbLocationValue.setText(dbSettingsPg.getHost()); lbDbLocationValue.setText(dbSettingsPg.getHost());
} } catch (CentralRepoException e) {
catch (CentralRepoException e) {
logger.log(Level.WARNING, "Unable to load settings into global panel for postgres settings", e); logger.log(Level.WARNING, "Unable to load settings into global panel for postgres settings", e);
} }
} } else if (selectedDb == CentralRepoPlatforms.SQLITE) {
else if (selectedDb == CentralRepoPlatforms.SQLITE) {
SqliteCentralRepoSettings dbSettingsSqlite = new SqliteCentralRepoSettings(); SqliteCentralRepoSettings dbSettingsSqlite = new SqliteCentralRepoSettings();
lbDbNameValue.setText(dbSettingsSqlite.getDbName()); lbDbNameValue.setText(dbSettingsSqlite.getDbName());
lbDbLocationValue.setText(dbSettingsSqlite.getDbDirectory()); lbDbLocationValue.setText(dbSettingsSqlite.getDbDirectory());
@ -647,7 +606,8 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
} }
/** /**
* This method validates that the dialog/panel is filled out correctly for our usage. * This method validates that the dialog/panel is filled out correctly for
* our usage.
* *
* @return True if it is okay, false otherwise. * @return True if it is okay, false otherwise.
*/ */