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.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
|
||||||
|
@ -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
|
* 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.
|
||||||
|
@ -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
|
||||||
|
@ -50,20 +50,18 @@ import java.util.logging.Level;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
|
@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
|
||||||
public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel implements OptionsPanel {
|
public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel implements OptionsPanel {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final Logger logger = Logger.getLogger(GlobalSettingsPanel.class.getName());
|
private static final Logger logger = Logger.getLogger(GlobalSettingsPanel.class.getName());
|
||||||
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
|
||||||
*/
|
*/
|
||||||
public GlobalSettingsPanel() {
|
public GlobalSettingsPanel() {
|
||||||
ingestJobEventListener = new IngestJobEventPropertyChangeListener();
|
ingestJobEventListener = new IngestJobEventPropertyChangeListener();
|
||||||
|
|
||||||
// listen for change events in currently saved choice
|
// listen for change events in currently saved choice
|
||||||
CentralRepoDbManager.addPropertyChangeListener((PropertyChangeEvent evt) -> ingestStateUpdated(Case.isCaseOpen()));
|
CentralRepoDbManager.addPropertyChangeListener((PropertyChangeEvent evt) -> ingestStateUpdated(Case.isCaseOpen()));
|
||||||
initComponents();
|
initComponents();
|
||||||
@ -74,8 +72,7 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
ingestStateUpdated(evt.getNewValue() != null);
|
ingestStateUpdated(evt.getNewValue() != null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
* @param parent The parent component for displaying dialogs.
|
* as input for necessary configuration.
|
||||||
* @param initialSelection If non-null, the menu item will be set to this choice; if null,
|
*
|
||||||
* the currently selected db choice will be selected.
|
* @param parent The parent component for displaying dialogs.
|
||||||
* @return True if there was a change.
|
* @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) {
|
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 muPreviouslySelected If multi user settings were previously enabled.
|
* @param parent The swing component that serves as a parent
|
||||||
* @param muCurrentlySelected If multi user settings are currently enabled as of most recent change.
|
* 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({
|
@NbBundle.Messages({
|
||||||
"GlobalSettingsPanel.onMultiUserChange.enable.title=Use with Central Repository?",
|
"GlobalSettingsPanel.onMultiUserChange.enable.title=Use with Central Repository?",
|
||||||
@ -128,33 +122,31 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
boolean crEnabled = CentralRepoDbUtil.allowUseOfCentralRepository();
|
boolean crEnabled = CentralRepoDbUtil.allowUseOfCentralRepository();
|
||||||
boolean crMultiUser = CentralRepoDbManager.getSavedDbChoice() == CentralRepoDbChoice.POSTGRESQL_MULTIUSER;
|
boolean crMultiUser = CentralRepoDbManager.getSavedDbChoice() == CentralRepoDbChoice.POSTGRESQL_MULTIUSER;
|
||||||
boolean crDisabledDueToFailure = CentralRepoDbManager.isDisabledDueToFailure();
|
boolean crDisabledDueToFailure = CentralRepoDbManager.isDisabledDueToFailure();
|
||||||
|
|
||||||
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)) {
|
||||||
|
|
||||||
// setup database for CR
|
// setup database for CR
|
||||||
CentralRepoDbUtil.setUseCentralRepo(true);
|
CentralRepoDbUtil.setUseCentralRepo(true);
|
||||||
CentralRepoDbManager.saveDbChoice(CentralRepoDbChoice.POSTGRESQL_MULTIUSER);
|
CentralRepoDbManager.saveDbChoice(CentralRepoDbChoice.POSTGRESQL_MULTIUSER);
|
||||||
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",
|
||||||
@ -177,21 +171,21 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
// disable central repository until user makes choice
|
// disable central repository until user makes choice
|
||||||
CentralRepoDbUtil.setUseCentralRepo(false);
|
CentralRepoDbUtil.setUseCentralRepo(false);
|
||||||
CentralRepoDbManager.saveDbChoice(CentralRepoDbChoice.DISABLED, false);
|
CentralRepoDbManager.saveDbChoice(CentralRepoDbChoice.DISABLED, false);
|
||||||
|
|
||||||
Object[] options = {
|
Object[] options = {
|
||||||
"Use SQLite",
|
"Use SQLite",
|
||||||
"Configure PostgreSQL",
|
"Configure PostgreSQL",
|
||||||
"Disable Central Repository"
|
"Disable Central Repository"
|
||||||
};
|
};
|
||||||
|
|
||||||
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,
|
||||||
@ -199,51 +193,21 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
options,
|
options,
|
||||||
options[0]
|
options[0]
|
||||||
);
|
);
|
||||||
|
|
||||||
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.
|
||||||
@ -589,17 +553,15 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i
|
|||||||
private void cbUseCentralRepoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbUseCentralRepoActionPerformed
|
private void cbUseCentralRepoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbUseCentralRepoActionPerformed
|
||||||
//if saved setting is disabled checkbox should be disabled already
|
//if saved setting is disabled checkbox should be disabled already
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user