mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 08:26:15 +00:00
Merge pull request #5724 from rcordovano/6108-relocate-cr-upgrade
6108 relocate central repository schema updates
This commit is contained in:
commit
d5bbd76daa
@ -7,7 +7,14 @@ AbstractSqlEamDb.cannotUpgrage.message=Currently selected database platform "{0}
|
||||
AbstractSqlEamDb.failedToReadMajorVersion.message=Failed to read schema 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.
|
||||
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.
|
||||
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.nullName.message=Database name is null.
|
||||
CorrelationAttributeUtil.emailaddresses.text=Email Addresses
|
||||
@ -21,7 +28,6 @@ CorrelationType.MAC.displayName=MAC Addresses
|
||||
CorrelationType.PHONE.displayName=Phone Numbers
|
||||
CorrelationType.SSID.displayName=Wireless Networks
|
||||
CorrelationType.USBID.displayName=USB Devices
|
||||
DataSourceUpdateService.serviceName.text=Update Central Repository Data Sources
|
||||
EamArtifactInstances.knownStatus.bad=Bad
|
||||
EamArtifactInstances.knownStatus.known=Known
|
||||
EamArtifactInstances.knownStatus.unknown=Unknown
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -39,16 +39,6 @@ import org.sleuthkit.autopsy.coreutils.Version;
|
||||
* central repository, sets up a default, single-user SQLite central repository
|
||||
* if no central repository is configured, and updates the central repository
|
||||
* 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 {
|
||||
|
||||
@ -84,9 +74,8 @@ public class Installer extends ModuleInstall {
|
||||
|
||||
/*
|
||||
* Adds/removes application event listeners responsible for adding data to
|
||||
* the central repository, sets up a default, single-user SQLite central
|
||||
* repository if no central repository is configured, and updates the
|
||||
* central repository schema as required.
|
||||
* the central repository and sets up a default, single-user SQLite central
|
||||
* repository if no central repository is configured.
|
||||
*
|
||||
* Called by the registered Installer for the Autopsy-Core module located in
|
||||
* 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) {
|
||||
setupDefaultCentralRepository();
|
||||
}
|
||||
|
||||
updateCentralRepoSchema();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,20 +185,6 @@ public class Installer extends ModuleInstall {
|
||||
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
|
||||
* GUI.
|
||||
|
@ -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.description2=The Central Repository stores hash values and accounts from past cases.
|
||||
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.mustConfigure=Configure the database to enable this module.
|
||||
ManageCasesDialog.title.text=Manage Cases
|
||||
|
@ -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 final IngestJobEventPropertyChangeListener ingestJobEventListener;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates new form EamOptionsPanel
|
||||
*/
|
||||
@ -75,7 +73,6 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void customizeComponents() {
|
||||
setName(NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.pnCorrelationProperties.border.title"));
|
||||
}
|
||||
@ -85,39 +82,36 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
ingestStateUpdated(Case.isCaseOpen());
|
||||
}
|
||||
|
||||
private void updateDatabase() {
|
||||
updateDatabase(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method invokes central repository database choice selection as well as input for necessary configuration.
|
||||
* @param parent The parent component for displaying dialogs.
|
||||
* @param initialSelection If non-null, the menu item will be set to this choice; if null,
|
||||
* the currently selected db choice will be selected.
|
||||
* @return True if there was a change.
|
||||
* This method invokes central repository database choice selection as well
|
||||
* as input for necessary configuration.
|
||||
*
|
||||
* @param parent The parent component for displaying dialogs.
|
||||
* @param initialSelection If non-null, the menu item will be set to this
|
||||
* choice; if null, the currently selected db choice
|
||||
* will be selected.
|
||||
*
|
||||
* @return True if there was a change.
|
||||
*/
|
||||
private static boolean invokeCrChoice(Component parent, CentralRepoDbChoice initialSelection) {
|
||||
EamDbSettingsDialog dialog = (initialSelection != null) ?
|
||||
new EamDbSettingsDialog(initialSelection) :
|
||||
new EamDbSettingsDialog();
|
||||
|
||||
if (dialog.wasConfigurationChanged()) {
|
||||
updateDatabase(parent);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
EamDbSettingsDialog dialog = (initialSelection != null)
|
||||
? new EamDbSettingsDialog(initialSelection)
|
||||
: new EamDbSettingsDialog();
|
||||
return dialog.wasConfigurationChanged();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* When multi user settings are updated, this function triggers pertinent updates for central repository.
|
||||
* NOTE: If multi user settings were previously enabled and multi user settings are currently selected, this function assumes
|
||||
* there is a change in the postgres connectivity.
|
||||
* When multi user settings are updated, this function triggers pertinent
|
||||
* updates for central repository. NOTE: If multi user settings were
|
||||
* 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 muPreviouslySelected If multi user settings were previously enabled.
|
||||
* @param muCurrentlySelected If multi user settings are currently enabled as of most recent change.
|
||||
* @param parent The swing component that serves as a parent
|
||||
* for dialogs that may arise.
|
||||
* @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({
|
||||
"GlobalSettingsPanel.onMultiUserChange.enable.title=Use with Central Repository?",
|
||||
@ -131,30 +125,28 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
|
||||
if (!muPreviouslySelected && muCurrentlySelected) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(parent,
|
||||
"<html><body>" +
|
||||
"<div style='width: 400px;'>" +
|
||||
"<p>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.enable.description") + "</p>" +
|
||||
"<p style='margin-top: 10px'>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.enable.description2") + "</p>" +
|
||||
"</div>" +
|
||||
"</body></html>",
|
||||
NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.enable.title"),
|
||||
JOptionPane.YES_NO_OPTION)) {
|
||||
if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(parent,
|
||||
"<html><body>"
|
||||
+ "<div style='width: 400px;'>"
|
||||
+ "<p>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.enable.description") + "</p>"
|
||||
+ "<p style='margin-top: 10px'>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.enable.description2") + "</p>"
|
||||
+ "</div>"
|
||||
+ "</body></html>",
|
||||
NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.enable.title"),
|
||||
JOptionPane.YES_NO_OPTION)) {
|
||||
|
||||
// setup database for CR
|
||||
CentralRepoDbUtil.setUseCentralRepo(true);
|
||||
CentralRepoDbManager.saveDbChoice(CentralRepoDbChoice.POSTGRESQL_MULTIUSER);
|
||||
handleDbChange(parent);
|
||||
}
|
||||
// setup database for CR
|
||||
CentralRepoDbUtil.setUseCentralRepo(true);
|
||||
CentralRepoDbManager.saveDbChoice(CentralRepoDbChoice.POSTGRESQL_MULTIUSER);
|
||||
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) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
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
|
||||
else if (muPreviouslySelected && muCurrentlySelected && crMultiUser && (crEnabled || crDisabledDueToFailure)) {
|
||||
// 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.
|
||||
* @param parent The parent component to use for displaying dialogs in reference.
|
||||
* This method is called when a user must select a new database other than
|
||||
* using database from multi user settings.
|
||||
*
|
||||
* @param parent The parent component to use for displaying dialogs in
|
||||
* reference.
|
||||
*/
|
||||
@NbBundle.Messages({
|
||||
"GlobalSettingsPanel.onMultiUserChange.disabledMu.title=Central Repository Change Necessary",
|
||||
@ -186,12 +180,12 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
|
||||
int result = JOptionPane.showOptionDialog(
|
||||
parent,
|
||||
"<html><body>" +
|
||||
"<div style='width: 400px;'>" +
|
||||
"<p>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.disabledMu.description") + "</p>" +
|
||||
"<p style='margin-top: 10px'>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.disabledMu.description2") + "</p>" +
|
||||
"</div>" +
|
||||
"</body></html>",
|
||||
"<html><body>"
|
||||
+ "<div style='width: 400px;'>"
|
||||
+ "<p>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.disabledMu.description") + "</p>"
|
||||
+ "<p style='margin-top: 10px'>" + NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.disabledMu.description2") + "</p>"
|
||||
+ "</div>"
|
||||
+ "</body></html>",
|
||||
NbBundle.getMessage(GlobalSettingsPanel.class, "GlobalSettingsPanel.onMultiUserChange.disabledMu.title"),
|
||||
JOptionPane.YES_NO_CANCEL_OPTION,
|
||||
JOptionPane.PLAIN_MESSAGE,
|
||||
@ -202,49 +196,19 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
|
||||
if (JOptionPane.YES_OPTION == result) {
|
||||
invokeCrChoice(parent, CentralRepoDbChoice.SQLITE);
|
||||
}
|
||||
else if (JOptionPane.NO_OPTION == result) {
|
||||
} else if (JOptionPane.NO_OPTION == result) {
|
||||
invokeCrChoice(parent, CentralRepoDbChoice.POSTGRESQL_CUSTOM);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void handleDbChange(Component parent) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
boolean successful = EamDbSettingsDialog.testStatusAndCreate(parent, new CentralRepoDbManager());
|
||||
if (successful) {
|
||||
updateDatabase(parent);
|
||||
}
|
||||
else {
|
||||
// disable central repository due to error
|
||||
if (!EamDbSettingsDialog.testStatusAndCreate(parent, new CentralRepoDbManager())) {
|
||||
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.
|
||||
* 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();
|
||||
|
||||
// if moving to using CR, multi-user mode is disabled and selection is multiuser settings, set to disabled
|
||||
if (cbUseCentralRepo.isSelected() &&
|
||||
!CentralRepoDbManager.isPostgresMultiuserAllowed() &&
|
||||
CentralRepoDbManager.getSavedDbChoice() == CentralRepoDbChoice.POSTGRESQL_MULTIUSER) {
|
||||
if (cbUseCentralRepo.isSelected()
|
||||
&& !CentralRepoDbManager.isPostgresMultiuserAllowed()
|
||||
&& CentralRepoDbManager.getSavedDbChoice() == CentralRepoDbChoice.POSTGRESQL_MULTIUSER) {
|
||||
|
||||
CentralRepoDbManager.saveDbChoice(CentralRepoDbChoice.DISABLED);
|
||||
}
|
||||
|
||||
|
||||
updateDatabase();
|
||||
load();
|
||||
this.ingestStateUpdated(Case.isCaseOpen());
|
||||
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
||||
@ -620,20 +582,17 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
||||
lbDbNameValue.setText("");
|
||||
lbDbLocationValue.setText("");
|
||||
tbOops.setText(Bundle.GlobalSettingsPanel_validationerrMsg_mustConfigure());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
enableButtonSubComponents(cbUseCentralRepo.isSelected());
|
||||
if (selectedDb == CentralRepoPlatforms.POSTGRESQL) {
|
||||
try {
|
||||
PostgresCentralRepoSettings dbSettingsPg = new PostgresCentralRepoSettings();
|
||||
lbDbNameValue.setText(dbSettingsPg.getDbName());
|
||||
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);
|
||||
}
|
||||
}
|
||||
else if (selectedDb == CentralRepoPlatforms.SQLITE) {
|
||||
} else if (selectedDb == CentralRepoPlatforms.SQLITE) {
|
||||
SqliteCentralRepoSettings dbSettingsSqlite = new SqliteCentralRepoSettings();
|
||||
lbDbNameValue.setText(dbSettingsSqlite.getDbName());
|
||||
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.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user