From dd3a9a744d0ad591572b6a26210a2d6659102e6e Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Wed, 29 Jan 2020 17:29:23 -0500 Subject: [PATCH 1/2] Rename central repository data model classes --- .../allcasessearch/AllCasesSearchAction.java | 4 +- .../allcasessearch/AllCasesSearchDialog.java | 12 +- .../autopsy/casemodule/CaseDetailsPanel.java | 14 +- .../casemodule/NewCaseWizardAction.java | 10 +- .../casemodule/NewCaseWizardPanel2.java | 4 +- .../OptionalCasePropertiesPanel.java | 38 +- .../AddEditCentralRepoCommentAction.java | 16 +- ...CentralRepoContextMenuActionsProvider.java | 6 +- .../DataContentViewerOtherCases.java | 66 +- .../contentviewer/OccurrencePanel.java | 10 +- .../OtherOccurrenceNodeInstanceData.java | 18 +- ...OtherOccurrencesDataSourcesTableModel.java | 4 +- .../OtherOccurrencesFilesTableModel.java | 4 +- ...SqlEamDb.java => AbstractCentralRepo.java} | 972 ++++++++--------- ...{EamDbUtil.java => CentralRepoDbUtil.java} | 70 +- ...ception.java => CentralRepoException.java} | 12 +- ...ance.java => CentralRepoFileInstance.java} | 16 +- ...GlobalSet.java => CentralRepoFileSet.java} | 10 +- ...tion.java => CentralRepoOrganization.java} | 10 +- ...ormEnum.java => CentralRepoPlatforms.java} | 22 +- .../{EamDb.java => CentralRepository.java} | 242 ++--- .../CorrelationAttributeInstance.java | 24 +- .../CorrelationAttributeNormalizer.java | 2 +- ...til.java => CorrelationAttributeUtil.java} | 44 +- .../datamodel/CorrelationCase.java | 8 +- .../datamodel/CorrelationDataSource.java | 31 +- .../datamodel/DataSourceUpdateService.java | 6 +- ...resEamDb.java => PostgresCentralRepo.java} | 56 +- ....java => PostgresCentralRepoSettings.java} | 80 +- ...qliteEamDb.java => SqliteCentralRepo.java} | 226 ++-- ...gs.java => SqliteCentralRepoSettings.java} | 58 +- .../eventlisteners/CaseEventListener.java | 68 +- .../eventlisteners/IngestEventsListener.java | 38 +- .../eventlisteners/Installer.java | 8 +- .../ingestmodule/CentralRepoIngestModule.java | 52 +- .../AddNewOrganizationDialog.java | 20 +- .../optionspanel/CaseDataSourcesWrapper.java | 4 +- .../optionspanel/EamDbSettingsDialog.form | 6 +- .../optionspanel/EamDbSettingsDialog.java | 68 +- .../optionspanel/GlobalSettingsPanel.java | 36 +- .../optionspanel/ManageCasesDialog.java | 8 +- .../ManageCorrelationPropertiesDialog.java | 16 +- .../ManageOrganizationsDialog.form | 4 +- .../ManageOrganizationsDialog.java | 52 +- .../AbstractCommonAttributeSearcher.java | 10 +- .../AllInterCaseCommonAttributeSearcher.java | 10 +- .../CommonAttributeCaseSearchResults.java | 24 +- .../CommonAttributeCountSearchResults.java | 14 +- .../CommonAttributePanel.java | 40 +- .../CommonAttributeSearchAction.java | 10 +- .../InterCaseCommonAttributeSearcher.java | 14 +- .../InterCasePanel.java | 4 +- .../InterCaseSearchResultsProcessor.java | 46 +- .../IntraCaseCommonAttributeSearcher.java | 6 +- ...ingleInterCaseCommonAttributeSearcher.java | 14 +- .../CorrelationCaseChildNodeFactory.java | 18 +- .../relationships/SummaryViewer.java | 4 +- .../AnnotationsContentViewer.java | 18 +- .../corecomponents/ViewPreferencesPanel.java | 2 +- .../datamodel/AbstractAbstractFileNode.java | 16 +- .../datamodel/BlackboardArtifactNode.java | 16 +- .../autopsy/datamodel/GetSCOTask.java | 16 +- .../autopsy/filequery/FileSearch.java | 38 +- .../filequery/FileSearchFiltering.java | 16 +- .../autopsy/filequery/FileSearchPanel.java | 22 +- .../autopsy/filequery/PageWorker.java | 6 +- .../autopsy/filequery/ResultsPanel.java | 12 +- .../autopsy/filequery/SearchWorker.java | 6 +- .../HashDbCreateDatabaseDialog.java | 34 +- .../HashDbImportDatabaseDialog.java | 26 +- .../modules/hashdatabase/HashDbManager.java | 60 +- .../hashdatabase/HashLookupSettingsPanel.java | 10 +- .../ImportCentralRepoDbProgressDialog.java | 22 +- .../datamodel/CentralRepoDatamodelTest.java | 982 +++++++++--------- .../CommonAttributeSearchInterCaseTest.java | 2 +- ...estedWithHashAndFileTypeInterCaseTest.java | 2 +- ...estedWithHashAndFileTypeIntraCaseTest.java | 20 +- .../InterCaseTestUtils.java | 34 +- ...tchesInAtLeastTwoSourcesIntraCaseTest.java | 4 +- 79 files changed, 2026 insertions(+), 2027 deletions(-) rename Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/{AbstractSqlEamDb.java => AbstractCentralRepo.java} (77%) rename Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/{EamDbUtil.java => CentralRepoDbUtil.java} (81%) rename Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/{EamDbException.java => CentralRepoException.java} (83%) rename Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/{EamGlobalFileInstance.java => CentralRepoFileInstance.java} (87%) rename Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/{EamGlobalSet.java => CentralRepoFileSet.java} (96%) rename Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/{EamOrganization.java => CentralRepoOrganization.java} (94%) rename Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/{EamDbPlatformEnum.java => CentralRepoPlatforms.java} (80%) rename Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/{EamDb.java => CentralRepository.java} (74%) rename Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/{EamArtifactUtil.java => CorrelationAttributeUtil.java} (89%) rename Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/{PostgresEamDb.java => PostgresCentralRepo.java} (80%) rename Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/{PostgresEamDbSettings.java => PostgresCentralRepoSettings.java} (89%) rename Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/{SqliteEamDb.java => SqliteCentralRepo.java} (81%) rename Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/{SqliteEamDbSettings.java => SqliteCentralRepoSettings.java} (91%) diff --git a/Core/src/org/sleuthkit/autopsy/allcasessearch/AllCasesSearchAction.java b/Core/src/org/sleuthkit/autopsy/allcasessearch/AllCasesSearchAction.java index f04eebabdc..676a565de2 100755 --- a/Core/src/org/sleuthkit/autopsy/allcasessearch/AllCasesSearchAction.java +++ b/Core/src/org/sleuthkit/autopsy/allcasessearch/AllCasesSearchAction.java @@ -26,7 +26,7 @@ import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.actions.CallableSystemAction; import org.sleuthkit.autopsy.casemodule.Case; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Action for accessing the Search Other Cases dialog. @@ -39,7 +39,7 @@ public class AllCasesSearchAction extends CallableSystemAction { @Override public boolean isEnabled() { - return EamDb.isEnabled() && Case.isCaseOpen(); + return CentralRepository.isEnabled() && Case.isCaseOpen(); } @Override diff --git a/Core/src/org/sleuthkit/autopsy/allcasessearch/AllCasesSearchDialog.java b/Core/src/org/sleuthkit/autopsy/allcasessearch/AllCasesSearchDialog.java index 814b696ce3..d8c82dc40b 100755 --- a/Core/src/org/sleuthkit/autopsy/allcasessearch/AllCasesSearchDialog.java +++ b/Core/src/org/sleuthkit/autopsy/allcasessearch/AllCasesSearchDialog.java @@ -37,8 +37,7 @@ import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizer; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer; import org.sleuthkit.autopsy.corecomponents.DataResultTopComponent; import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; @@ -46,6 +45,7 @@ import org.sleuthkit.autopsy.corecomponents.TableFilterNode; import org.sleuthkit.autopsy.corecomponents.TextPrompt; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.datamodel.EmptyNode; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; @Messages({ "AllCasesSearchDialog.dialogTitle.text=Search All Cases", @@ -103,8 +103,8 @@ final class AllCasesSearchDialog extends javax.swing.JDialog { List correlationInstances = new ArrayList<>(); try { - correlationInstances = EamDb.getInstance().getArtifactInstancesByTypeValue(type, value); - } catch (EamDbException ex) { + correlationInstances = CentralRepository.getInstance().getArtifactInstancesByTypeValue(type, value); + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Unable to connect to the Central Repository database.", ex); } catch (CorrelationAttributeNormalizationException ex) { logger.log(Level.SEVERE, "Unable to retrieve data from the Central Repository.", ex); @@ -336,12 +336,12 @@ final class AllCasesSearchDialog extends javax.swing.JDialog { * Add correlation types to the combo-box. */ try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); correlationTypes.clear(); correlationTypes.addAll(dbManager.getDefinedCorrelationTypes()); int numberOfCases = dbManager.getCases().size(); casesLabel.setText(Bundle.AllCasesSearchDialog_caseLabel_text(numberOfCases)); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Unable to connect to the Central Repository database.", ex); } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/CaseDetailsPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/CaseDetailsPanel.java index d5b8dbdfa7..c5ca31f65e 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/CaseDetailsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/CaseDetailsPanel.java @@ -22,10 +22,10 @@ import java.nio.file.Paths; import java.util.logging.Level; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamOrganization; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoOrganization; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * A panel that allows the user to view various details of a case and change @@ -69,7 +69,7 @@ final class CaseDetailsPanel extends javax.swing.JPanel { } else { dbNameField.setText(theCase.getMetadata().getCaseDatabaseName()); } - boolean cREnabled = EamDb.isEnabled(); + boolean cREnabled = CentralRepository.isEnabled(); lbOrganizationNameLabel.setEnabled(cREnabled); lbOrganizationNameText.setEnabled(cREnabled); lbPointOfContactEmailLabel.setEnabled(cREnabled); @@ -79,15 +79,15 @@ final class CaseDetailsPanel extends javax.swing.JPanel { lbPointOfContactPhoneLabel.setEnabled(cREnabled); lbPointOfContactPhoneText.setEnabled(cREnabled); pnOrganization.setEnabled(cREnabled); - EamOrganization currentOrg = null; + CentralRepoOrganization currentOrg = null; if (cREnabled) { try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); if (dbManager != null) { CorrelationCase correlationCase = dbManager.getCase(theCase); currentOrg = correlationCase.getOrg(); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Unable to access Correlation Case when Central Repo is enabled", ex); } } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java index c5e6ece78d..92f83ba26c 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java @@ -38,10 +38,10 @@ import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.actions.IngestRunningCheck; import org.sleuthkit.autopsy.casemodule.Case.CaseType; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamOrganization; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoOrganization; import org.sleuthkit.autopsy.coreutils.FileUtil; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * The action associated with the Case/New Case menu item, t toolbar button, and @@ -89,15 +89,15 @@ final class NewCaseWizardAction extends CallableSystemAction { String createdDirectory = (String) wizardDescriptor.getProperty("createdDirectory"); //NON-NLS CaseType caseType = CaseType.values()[(int) wizardDescriptor.getProperty("caseType")]; //NON-NLS Case.createAsCurrentCase(caseType, createdDirectory, new CaseDetails(caseName, caseNumber, examinerName, examinerPhone, examinerEmail, caseNotes)); - if (EamDb.isEnabled()) { //if the eam is enabled we need to save the case organization information now - EamDb dbManager = EamDb.getInstance(); + if (CentralRepository.isEnabled()) { //if the eam is enabled we need to save the case organization information now + CentralRepository dbManager = CentralRepository.getInstance(); if (dbManager != null) { CorrelationCase cRCase = dbManager.getCase(Case.getCurrentCaseThrows()); if (cRCase == null) { cRCase = dbManager.newCase(Case.getCurrentCaseThrows()); } if (!organizationName.isEmpty()) { - for (EamOrganization org : dbManager.getOrganizations()) { + for (CentralRepoOrganization org : dbManager.getOrganizations()) { if (org.getName().equals(organizationName)) { cRCase.setOrg(org); dbManager.updateCase(cRCase); diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel2.java b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel2.java index aa9b6643d8..b5119dc389 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel2.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardPanel2.java @@ -29,9 +29,9 @@ import org.openide.util.HelpCtx; import org.openide.windows.WindowManager; import java.awt.Cursor; import java.util.logging.Level; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ModuleSettings; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * The second panel of the New Case wizard. @@ -145,7 +145,7 @@ class NewCaseWizardPanel2 implements WizardDescriptor.ValidatingPanel orgs = null; + private CentralRepoOrganization selectedOrg = null; + private java.util.List orgs = null; /** * Creates new form OptionalCasePropertiesPanel @@ -92,14 +92,14 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel { } private void setUpOrganizationData() { - if (EamDb.isEnabled()) { + if (CentralRepository.isEnabled()) { try { Case currentCase = Case.getCurrentCaseThrows(); if (currentCase != null) { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); selectedOrg = dbManager.getCase(currentCase).getOrg(); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Unable to get Organization associated with the case from Central Repo", ex); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); @@ -109,13 +109,13 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel { setCurrentlySelectedOrganization(selectedOrg.getName()); } else { - setCurrentlySelectedOrganization(EamDbUtil.getDefaultOrgName()); + setCurrentlySelectedOrganization(CentralRepoDbUtil.getDefaultOrgName()); } } } void setUpCaseDetailsFields() { - boolean cREnabled = EamDb.isEnabled(); + boolean cREnabled = CentralRepository.isEnabled(); comboBoxOrgName.setEnabled(cREnabled); bnNewOrganization.setEnabled(cREnabled); lbPointOfContactNameText.setEnabled(cREnabled); @@ -138,13 +138,13 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel { Object selectedBeforeLoad = comboBoxOrgName.getSelectedItem(); comboBoxOrgName.removeAllItems(); try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); orgs = dbManager.getOrganizations(); orgs.forEach((org) -> { comboBoxOrgName.addItem(org.getName()); }); comboBoxOrgName.setSelectedItem(selectedBeforeLoad); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.WARNING, "Unable to populate list of Organizations from Central Repo", ex); } } @@ -180,7 +180,7 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel { if (selectedOrg != null) { return selectedOrg.getName(); } else { - return EamDbUtil.getDefaultOrgName(); + return CentralRepoDbUtil.getDefaultOrgName(); } } @@ -514,7 +514,7 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel { clearOrganization(); return; } - for (EamOrganization org : orgs) { + for (CentralRepoOrganization org : orgs) { if (org.getName().equals(orgName)) { selectedOrg = org; lbPointOfContactNameText.setText(selectedOrg.getPocName()); @@ -538,7 +538,7 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel { }//GEN-LAST:event_bnNewOrganizationActionPerformed void setCurrentlySelectedOrganization(String orgName) { - comboBoxOrgName.setSelectedItem(orgName == null ? EamDbUtil.getDefaultOrgName() : orgName); + comboBoxOrgName.setSelectedItem(orgName == null ? CentralRepoDbUtil.getDefaultOrgName() : orgName); } @Messages({ @@ -583,9 +583,9 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel { */ private void updateCorrelationCase() { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - if (EamDb.isEnabled()) { + if (CentralRepository.isEnabled()) { try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); CorrelationCase correlationCase = dbManager.getCase(Case.getCurrentCaseThrows()); if (caseDisplayNameTextField.isVisible()) { correlationCase.setDisplayName(caseDisplayNameTextField.getText()); @@ -597,7 +597,7 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel { correlationCase.setExaminerPhone(tfExaminerPhoneText.getText()); correlationCase.setNotes(taNotesText.getText()); dbManager.updateCase(correlationCase); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Error connecting to central repository database", ex); // NON-NLS } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); // NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/AddEditCentralRepoCommentAction.java b/Core/src/org/sleuthkit/autopsy/centralrepository/AddEditCentralRepoCommentAction.java index e9e9c4270a..dae8bbe312 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/AddEditCentralRepoCommentAction.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/AddEditCentralRepoCommentAction.java @@ -29,11 +29,11 @@ import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.AbstractFile; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * An AbstractAction to manage adding and modifying a Central Repository file @@ -61,10 +61,10 @@ public final class AddEditCentralRepoCommentAction extends AbstractAction { */ public AddEditCentralRepoCommentAction(AbstractFile file) { fileId = file.getId(); - correlationAttributeInstance = EamArtifactUtil.getInstanceFromContent(file); + correlationAttributeInstance = CorrelationAttributeUtil.getInstanceFromContent(file); if (correlationAttributeInstance == null) { addToDatabase = true; - correlationAttributeInstance = EamArtifactUtil.makeInstanceFromContent(file); + correlationAttributeInstance = CorrelationAttributeUtil.makeInstanceFromContent(file); } if (file.getSize() == 0) { putValue(Action.NAME, Bundle.AddEditCentralRepoCommentAction_menuItemText_addEditCentralRepoCommentEmptyFile()); @@ -94,10 +94,10 @@ public final class AddEditCentralRepoCommentAction extends AbstractAction { comment = null; if (centralRepoCommentDialog.isCommentUpdated()) { - EamDb dbManager; + CentralRepository dbManager; try { - dbManager = EamDb.getInstance(); + dbManager = CentralRepository.getInstance(); if (addToDatabase) { dbManager.addArtifactInstance(correlationAttributeInstance); @@ -111,7 +111,7 @@ public final class AddEditCentralRepoCommentAction extends AbstractAction { } catch (NoCurrentCaseException ex) { logger.log(Level.WARNING, "Case not open after changing central repository comment", ex); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Error adding comment", ex); NotifyDescriptor notifyDescriptor = new NotifyDescriptor.Message( "An error occurred while trying to save the comment to the central repository.", diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/CentralRepoContextMenuActionsProvider.java b/Core/src/org/sleuthkit/autopsy/centralrepository/CentralRepoContextMenuActionsProvider.java index bfeae53ca6..0540fb2a81 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/CentralRepoContextMenuActionsProvider.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/CentralRepoContextMenuActionsProvider.java @@ -24,10 +24,10 @@ import java.util.List; import javax.swing.Action; import org.openide.util.Utilities; import org.openide.util.lookup.ServiceProvider; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; +import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil; import org.sleuthkit.autopsy.corecomponentinterfaces.ContextMenuActionsProvider; import org.sleuthkit.datamodel.AbstractFile; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * This creates a single context menu item for adding or editing a Central @@ -46,7 +46,7 @@ public class CentralRepoContextMenuActionsProvider implements ContextMenuActions } for (AbstractFile file : selectedFiles) { - if (EamDb.isEnabled() && EamArtifactUtil.isSupportedAbstractFileType(file) && file.isFile()) { + if (CentralRepository.isEnabled() && CorrelationAttributeUtil.isSupportedAbstractFileType(file) && file.isFile()) { AddEditCentralRepoCommentAction action = new AddEditCentralRepoCommentAction(file); if (action.getCorrelationAttribute() == null) { action.setEnabled(false); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/DataContentViewerOtherCases.java b/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/DataContentViewerOtherCases.java index 9713a5b47a..a28a013220 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/DataContentViewerOtherCases.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/DataContentViewerOtherCases.java @@ -62,10 +62,10 @@ import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationDataSource; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifactTag; @@ -73,9 +73,9 @@ import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.ContentTag; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TskData; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * View correlation results from other cases @@ -206,7 +206,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi StringBuilder msg = new StringBuilder(correlationAttributes.size()); int percentage; try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); for (CorrelationAttributeInstance eamArtifact : correlationAttributes) { try { percentage = dbManager.getFrequencyPercentage(eamArtifact); @@ -221,7 +221,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi msg.toString(), Bundle.DataContentViewerOtherCases_correlatedArtifacts_title(), DEFAULT_OPTION, PLAIN_MESSAGE); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error getting commonality details.", ex); JOptionPane.showConfirmDialog(showCommonalityMenuItem, Bundle.DataContentViewerOtherCases_correlatedArtifacts_failed(), @@ -241,7 +241,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi String details = Bundle.DataContentViewerOtherCases_caseDetailsDialog_noDetails(); try { if (-1 != selectedRowViewIdx) { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); int selectedRowModelIdx = filesTable.convertRowIndexToModel(selectedRowViewIdx); List rowList = filesTableModel.getListOfNodesForFile(selectedRowModelIdx); if (!rowList.isEmpty()) { @@ -262,7 +262,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi details = Bundle.DataContentViewerOtherCases_caseDetailsDialog_noDetailsReference(); } } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error loading case details", ex); } finally { JOptionPane.showConfirmDialog(showCaseDetailsMenuItem, @@ -463,20 +463,20 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi // correlate on blackboard artifact attributes if they exist and supported BlackboardArtifact bbArtifact = getBlackboardArtifactFromNode(node); - if (bbArtifact != null && EamDb.isEnabled()) { - ret.addAll(EamArtifactUtil.makeInstancesFromBlackboardArtifact(bbArtifact, false)); + if (bbArtifact != null && CentralRepository.isEnabled()) { + ret.addAll(CorrelationAttributeUtil.makeInstancesFromBlackboardArtifact(bbArtifact, false)); } // we can correlate based on the MD5 if it is enabled - if (this.file != null && EamDb.isEnabled() && this.file.getSize() > 0) { + if (this.file != null && CentralRepository.isEnabled() && this.file.getSize() > 0) { try { - List artifactTypes = EamDb.getInstance().getDefinedCorrelationTypes(); + List artifactTypes = CentralRepository.getInstance().getDefinedCorrelationTypes(); String md5 = this.file.getMd5Hash(); if (md5 != null && !md5.isEmpty() && null != artifactTypes && !artifactTypes.isEmpty()) { for (CorrelationAttributeInstance.Type aType : artifactTypes) { if (aType.getId() == CorrelationAttributeInstance.FILES_TYPE_ID) { - CorrelationCase corCase = EamDb.getInstance().getCase(Case.getCurrentCase()); + CorrelationCase corCase = CentralRepository.getInstance().getCase(Case.getCurrentCase()); try { ret.add(new CorrelationAttributeInstance( aType, @@ -494,7 +494,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi } } } - } catch (EamDbException | TskCoreException ex) { + } catch (CentralRepoException | TskCoreException ex) { LOGGER.log(Level.SEVERE, "Error connecting to DB", ex); // NON-NLS } // If EamDb not enabled, get the Files default correlation type to allow Other Occurances to be enabled. @@ -510,7 +510,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi .get(); //The Central Repository is not enabled ret.add(new CorrelationAttributeInstance(fileAttributeType, md5, null, null, "", "", TskData.FileKnown.UNKNOWN, this.file.getId())); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error connecting to DB", ex); // NON-NLS } catch (CorrelationAttributeNormalizationException ex) { LOGGER.log(Level.INFO, String.format("Unable to create CorrelationAttributeInstance for value %s", md5), ex); // NON-NLS @@ -529,11 +529,11 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi private void setEarliestCaseDate() { String dateStringDisplay = Bundle.DataContentViewerOtherCases_earliestCaseNotAvailable(); - if (EamDb.isEnabled()) { + if (CentralRepository.isEnabled()) { LocalDateTime earliestDate = LocalDateTime.now(DateTimeZone.UTC); DateFormat datetimeFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.US); try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); List cases = dbManager.getCases(); for (CorrelationCase aCase : cases) { LocalDateTime caseDate = LocalDateTime.fromDateFields(datetimeFormat.parse(aCase.getCreationDate())); @@ -545,7 +545,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error getting list of cases from database.", ex); // NON-NLS } catch (ParseException ex) { LOGGER.log(Level.SEVERE, "Error parsing date of cases from database.", ex); // NON-NLS @@ -574,8 +574,8 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi String caseUUID = openCase.getName(); HashMap nodeDataMap = new HashMap<>(); - if (EamDb.isEnabled()) { - List instances = EamDb.getInstance().getArtifactInstancesByTypeValue(corAttr.getCorrelationType(), corAttr.getCorrelationValue()); + if (CentralRepository.isEnabled()) { + List instances = CentralRepository.getInstance().getArtifactInstancesByTypeValue(corAttr.getCorrelationType(), corAttr.getCorrelationValue()); for (CorrelationAttributeInstance artifactInstance : instances) { @@ -604,7 +604,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi } } return nodeDataMap; - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error getting artifact instances from database.", ex); // NON-NLS } catch (CorrelationAttributeNormalizationException ex) { LOGGER.log(Level.INFO, "Error getting artifact instances from database.", ex); // NON-NLS @@ -630,9 +630,9 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi * * @throws NoCurrentCaseException * @throws TskCoreException - * @throws EamDbException + * @throws CentralRepoException */ - private List getCaseDbMatches(CorrelationAttributeInstance corAttr, Case openCase) throws NoCurrentCaseException, TskCoreException, EamDbException { + private List getCaseDbMatches(CorrelationAttributeInstance corAttr, Case openCase) throws NoCurrentCaseException, TskCoreException, CentralRepoException { String md5 = corAttr.getCorrelationValue(); SleuthkitCase tsk = openCase.getSleuthkitCase(); List matches = tsk.findAllFilesWhere(String.format("md5 = '%s'", new Object[]{md5})); @@ -656,9 +656,9 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi * @param newFile * * @throws TskCoreException - * @throws EamDbException + * @throws CentralRepoException */ - private void addOrUpdateNodeData(final Case autopsyCase, Map nodeDataMap, AbstractFile newFile) throws TskCoreException, EamDbException { + private void addOrUpdateNodeData(final Case autopsyCase, Map nodeDataMap, AbstractFile newFile) throws TskCoreException, CentralRepoException { OtherOccurrenceNodeInstanceData newNode = new OtherOccurrenceNodeInstanceData(newFile, autopsyCase); @@ -699,7 +699,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi // (either through the MD5 hash of the associated file or through a BlackboardArtifact) // - The central repo is disabled and the backing file has a valid MD5 hash this.file = this.getAbstractFileFromNode(node); - if (EamDb.isEnabled()) { + if (CentralRepository.isEnabled()) { return !getCorrelationAttributesFromNode(node).isEmpty(); } else { return this.file != null @@ -758,7 +758,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi try { dataSources.add(makeDataSourceString(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(), nodeData.getDeviceID(), nodeData.getDataSourceName())); caseNames.put(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(), nodeData.getCorrelationAttributeInstance().getCorrelationCase()); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.WARNING, "Unable to get correlation case for displaying other occurrence for case: " + nodeData.getCaseName(), ex); } } else { @@ -833,7 +833,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi } else if (currentCaseName != null && (casesTableModel.getCorrelationCase(casesTable.convertRowIndexToModel(selectedRow)).getCaseUUID().equals(currentCaseName))) { dataSourcesTableModel.addNodeData(nodeData); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.WARNING, "Unable to get correlation attribute instance from OtherOccurrenceNodeInstanceData for case " + nodeData.getCaseName(), ex); } } @@ -870,7 +870,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi filesTableModel.addNodeData(nodeData); } } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.WARNING, "Unable to get correlation attribute instance from OtherOccurrenceNodeInstanceData for case " + nodeData.getCaseName(), ex); } } @@ -934,17 +934,17 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi */ private String getCaseCreatedDate(int caseTableRowIdx) { try { - if (EamDb.isEnabled()) { + if (CentralRepository.isEnabled()) { CorrelationCase partialCase; partialCase = casesTableModel.getCorrelationCase(casesTable.convertRowIndexToModel(caseTableRowIdx)); if (partialCase == null) { return ""; } - return EamDb.getInstance().getCaseByUUID(partialCase.getCaseUUID()).getCreationDate(); + return CentralRepository.getInstance().getCaseByUUID(partialCase.getCaseUUID()).getCreationDate(); } else { return Case.getCurrentCase().getCreatedDate(); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.WARNING, "Error getting case created date for row: " + caseTableRowIdx, ex); } return ""; @@ -1102,7 +1102,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi private void rightClickPopupMenuPopupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_rightClickPopupMenuPopupMenuWillBecomeVisible boolean enableCentralRepoActions = false; - if (EamDb.isEnabled() && filesTable.getSelectedRowCount() == 1) { + if (CentralRepository.isEnabled() && filesTable.getSelectedRowCount() == 1) { int rowIndex = filesTable.getSelectedRow(); List selectedFile = filesTableModel.getListOfNodesForFile(rowIndex); if (!selectedFile.isEmpty() && selectedFile.get(0) instanceof OtherOccurrenceNodeInstanceData) { @@ -1159,7 +1159,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi String tempCaseUUID; try { tempCaseUUID = nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(); - } catch (EamDbException ignored) { + } catch (CentralRepoException ignored) { //non central repo nodeData won't have a correlation case try { tempCaseUUID = Case.getCurrentCaseThrows().getName(); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OccurrencePanel.java b/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OccurrencePanel.java index 36877a124d..c66d4ce085 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OccurrencePanel.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OccurrencePanel.java @@ -30,10 +30,10 @@ import java.util.logging.Level; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.TskData; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Panel for displaying other occurrence details. @@ -203,14 +203,14 @@ final class OccurrencePanel extends javax.swing.JPanel { try { OtherOccurrenceNodeInstanceData nodeData = ((OtherOccurrenceNodeInstanceData) occurrence); if (nodeData.isCentralRepoNode()) { - if (EamDb.isEnabled()) { + if (CentralRepository.isEnabled()) { CorrelationCase partialCase = nodeData.getCorrelationAttributeInstance().getCorrelationCase(); - caseDate = EamDb.getInstance().getCaseByUUID(partialCase.getCaseUUID()).getCreationDate(); + caseDate = CentralRepository.getInstance().getCaseByUUID(partialCase.getCaseUUID()).getCreationDate(); } } else { caseDate = Case.getCurrentCase().getCreatedDate(); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.WARNING, "Error getting case created date for other occurrence content viewer", ex); } //Collect the data that is necessary for the other sections diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrenceNodeInstanceData.java b/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrenceNodeInstanceData.java index 7703e19e62..92ebc821f8 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrenceNodeInstanceData.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrenceNodeInstanceData.java @@ -20,7 +20,7 @@ package org.sleuthkit.autopsy.centralrepository.contentviewer; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.DataSource; import org.sleuthkit.datamodel.TskCoreException; @@ -75,16 +75,16 @@ class OtherOccurrenceNodeInstanceData implements OtherOccurrenceNodeData { * @param newFile The abstract file * @param autopsyCase The current case * - * @throws EamDbException + * @throws CentralRepoException */ - OtherOccurrenceNodeInstanceData(AbstractFile newFile, Case autopsyCase) throws EamDbException { + OtherOccurrenceNodeInstanceData(AbstractFile newFile, Case autopsyCase) throws CentralRepoException { caseName = autopsyCase.getDisplayName(); try { DataSource dataSource = autopsyCase.getSleuthkitCase().getDataSource(newFile.getDataSource().getId()); deviceID = dataSource.getDeviceId(); dataSourceName = dataSource.getName(); } catch (TskDataException | TskCoreException ex) { - throw new EamDbException("Error loading data source for abstract file ID " + newFile.getId(), ex); + throw new CentralRepoException("Error loading data source for abstract file ID " + newFile.getId(), ex); } filePath = newFile.getParentPath() + newFile.getName(); @@ -211,9 +211,9 @@ class OtherOccurrenceNodeInstanceData implements OtherOccurrenceNodeData { * * @return the original abstract file */ - AbstractFile getAbstractFile() throws EamDbException { + AbstractFile getAbstractFile() throws CentralRepoException { if (originalAbstractFile == null) { - throw new EamDbException("AbstractFile is null"); + throw new CentralRepoException("AbstractFile is null"); } return originalAbstractFile; } @@ -224,11 +224,11 @@ class OtherOccurrenceNodeInstanceData implements OtherOccurrenceNodeData { * * @return the original CorrelationAttributeInstance * - * @throws EamDbException + * @throws CentralRepoException */ - CorrelationAttributeInstance getCorrelationAttributeInstance() throws EamDbException { + CorrelationAttributeInstance getCorrelationAttributeInstance() throws CentralRepoException { if (originalCorrelationInstance == null) { - throw new EamDbException("CorrelationAttributeInstance is null"); + throw new CentralRepoException("CorrelationAttributeInstance is null"); } return originalCorrelationInstance; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrencesDataSourcesTableModel.java b/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrencesDataSourcesTableModel.java index 76871d074d..89d2a599ec 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrencesDataSourcesTableModel.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrencesDataSourcesTableModel.java @@ -26,7 +26,7 @@ import javax.swing.table.AbstractTableModel; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.coreutils.Logger; /** @@ -144,7 +144,7 @@ final class OtherOccurrencesDataSourcesTableModel extends AbstractTableModel { String caseUUID; try { caseUUID = nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(); - } catch (EamDbException ignored) { + } catch (CentralRepoException ignored) { //non central repo nodeData won't have a correlation case try { caseUUID = Case.getCurrentCaseThrows().getName(); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrencesFilesTableModel.java b/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrencesFilesTableModel.java index 3344951857..8f78d66ee8 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrencesFilesTableModel.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrencesFilesTableModel.java @@ -28,7 +28,7 @@ import org.openide.util.NbBundle.Messages; import org.apache.commons.io.FilenameUtils; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.coreutils.Logger; /** @@ -123,7 +123,7 @@ public class OtherOccurrencesFilesTableModel extends AbstractTableModel { String caseUUID; try { caseUUID = nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(); - } catch (EamDbException ignored) { + } catch (CentralRepoException ignored) { //non central repo nodeData won't have a correlation case try { caseUUID = Case.getCurrentCaseThrows().getName(); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractCentralRepo.java similarity index 77% rename from Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java rename to Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractCentralRepo.java index fee297880c..257465f5f0 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractCentralRepo.java @@ -1,7 +1,7 @@ /* * Central Repository * - * Copyright 2015-2019 Basis Technology Corp. + * Copyright 2015-2020 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -43,7 +43,7 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.casemodule.Case; -import static org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil.updateSchemaVersion; +import static org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbUtil.updateSchemaVersion; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.healthmonitor.HealthMonitor; import org.sleuthkit.autopsy.healthmonitor.TimingMetric; @@ -55,9 +55,9 @@ import org.sleuthkit.datamodel.TskData; * Generic JDBC methods * */ -abstract class AbstractSqlEamDb implements EamDb { +abstract class AbstractCentralRepo implements CentralRepository { - private final static Logger logger = Logger.getLogger(AbstractSqlEamDb.class.getName()); + private final static Logger logger = Logger.getLogger(AbstractCentralRepo.class.getName()); static final String SCHEMA_MAJOR_VERSION_KEY = "SCHEMA_VERSION"; static final String SCHEMA_MINOR_VERSION_KEY = "SCHEMA_MINOR_VERSION"; static final String CREATION_SCHEMA_MAJOR_VERSION_KEY = "CREATION_SCHEMA_MAJOR_VERSION"; @@ -96,25 +96,25 @@ abstract class AbstractSqlEamDb implements EamDb { * * @throws UnknownHostException, EamDbException */ - protected AbstractSqlEamDb() throws EamDbException { + protected AbstractCentralRepo() throws CentralRepoException { bulkArtifactsCount = 0; bulkArtifacts = new HashMap<>(); defaultCorrelationTypes = CorrelationAttributeInstance.getDefaultCorrelationTypes(); defaultCorrelationTypes.forEach((type) -> { - bulkArtifacts.put(EamDbUtil.correlationTypeToInstanceTableName(type), new ArrayList<>()); + bulkArtifacts.put(CentralRepoDbUtil.correlationTypeToInstanceTableName(type), new ArrayList<>()); }); } /** * Setup and create a connection to the selected database implementation */ - protected abstract Connection connect(boolean foreignKeys) throws EamDbException; + protected abstract Connection connect(boolean foreignKeys) throws CentralRepoException; /** * Setup and create a connection to the selected database implementation */ - protected abstract Connection connect() throws EamDbException; + protected abstract Connection connect() throws CentralRepoException; /** * Add a new name/value pair in the db_info table. @@ -122,10 +122,10 @@ abstract class AbstractSqlEamDb implements EamDb { * @param name Key to set * @param value Value to set * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void newDbInfo(String name, String value) throws EamDbException { + public void newDbInfo(String name, String value) throws CentralRepoException { Connection conn = connect(); PreparedStatement preparedStatement = null; @@ -137,16 +137,16 @@ abstract class AbstractSqlEamDb implements EamDb { preparedStatement.setString(2, value); preparedStatement.executeUpdate(); } catch (SQLException ex) { - throw new EamDbException("Error adding new name/value pair to db_info.", ex); + throw new CentralRepoException("Error adding new name/value pair to db_info.", ex); } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeConnection(conn); } } @Override - public void addDataSourceObjectId(int rowId, long dataSourceObjectId) throws EamDbException { + public void addDataSourceObjectId(int rowId, long dataSourceObjectId) throws CentralRepoException { Connection conn = connect(); PreparedStatement preparedStatement = null; String sql = "UPDATE data_sources SET datasource_obj_id=? WHERE id=?"; @@ -156,10 +156,10 @@ abstract class AbstractSqlEamDb implements EamDb { preparedStatement.setInt(2, rowId); preparedStatement.executeUpdate(); } catch (SQLException ex) { - throw new EamDbException("Error updating data source object id for data_sources row " + rowId, ex); + throw new CentralRepoException("Error updating data source object id for data_sources row " + rowId, ex); } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeConnection(conn); } } @@ -170,10 +170,10 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return value associated with name. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public String getDbInfo(String name) throws EamDbException { + public String getDbInfo(String name) throws CentralRepoException { Connection conn = connect(); PreparedStatement preparedStatement = null; @@ -188,11 +188,11 @@ abstract class AbstractSqlEamDb implements EamDb { value = resultSet.getString("value"); } } catch (SQLException ex) { - throw new EamDbException("Error getting value for name.", ex); + throw new CentralRepoException("Error getting value for name.", ex); } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return value; @@ -215,10 +215,10 @@ abstract class AbstractSqlEamDb implements EamDb { * @param name Name to find * @param value Value to assign to name. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void updateDbInfo(String name, String value) throws EamDbException { + public void updateDbInfo(String name, String value) throws CentralRepoException { Connection conn = connect(); PreparedStatement preparedStatement = null; @@ -229,10 +229,10 @@ abstract class AbstractSqlEamDb implements EamDb { preparedStatement.setString(2, name); preparedStatement.executeUpdate(); } catch (SQLException ex) { - throw new EamDbException("Error updating value for name.", ex); + throw new CentralRepoException("Error updating value for name.", ex); } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeConnection(conn); } } @@ -246,10 +246,10 @@ abstract class AbstractSqlEamDb implements EamDb { * @returns New Case class with populated database ID */ @Override - public synchronized CorrelationCase newCase(CorrelationCase eamCase) throws EamDbException { + public synchronized CorrelationCase newCase(CorrelationCase eamCase) throws CentralRepoException { if (eamCase.getCaseUUID() == null) { - throw new EamDbException("Case UUID is null"); + throw new CentralRepoException("Case UUID is null"); } // check if there is already an existing CorrelationCase for this Case @@ -307,7 +307,7 @@ abstract class AbstractSqlEamDb implements EamDb { //update the case in the caches resultSet = preparedStatement.getGeneratedKeys(); if (!resultSet.next()) { - throw new EamDbException(String.format("Failed to INSERT case %s in central repo", eamCase.getCaseUUID())); + throw new CentralRepoException(String.format("Failed to INSERT case %s in central repo", eamCase.getCaseUUID())); } int caseID = resultSet.getInt(1); //last_insert_rowid() CorrelationCase correlationCase = new CorrelationCase(caseID, eamCase.getCaseUUID(), eamCase.getOrg(), @@ -316,11 +316,11 @@ abstract class AbstractSqlEamDb implements EamDb { caseCacheByUUID.put(eamCase.getCaseUUID(), correlationCase); caseCacheById.put(caseID, correlationCase); } catch (SQLException ex) { - throw new EamDbException("Error inserting new case.", ex); // NON-NLS + throw new CentralRepoException("Error inserting new case.", ex); // NON-NLS } finally { - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeConnection(conn); } // get a new version with the updated ID @@ -333,15 +333,15 @@ abstract class AbstractSqlEamDb implements EamDb { * @param autopsyCase The case to add */ @Override - public CorrelationCase newCase(Case autopsyCase) throws EamDbException { + public CorrelationCase newCase(Case autopsyCase) throws CentralRepoException { if (autopsyCase == null) { - throw new EamDbException("Case is null"); + throw new CentralRepoException("Case is null"); } CorrelationCase curCeCase = new CorrelationCase( -1, autopsyCase.getName(), // unique case ID - EamOrganization.getDefault(), + CentralRepoOrganization.getDefault(), autopsyCase.getDisplayName(), autopsyCase.getCreatedDate(), autopsyCase.getNumber(), @@ -353,7 +353,7 @@ abstract class AbstractSqlEamDb implements EamDb { } @Override - public CorrelationCase getCase(Case autopsyCase) throws EamDbException { + public CorrelationCase getCase(Case autopsyCase) throws CentralRepoException { return getCaseByUUID(autopsyCase.getName()); } @@ -363,9 +363,9 @@ abstract class AbstractSqlEamDb implements EamDb { * @param eamCase The case to update */ @Override - public void updateCase(CorrelationCase eamCase) throws EamDbException { + public void updateCase(CorrelationCase eamCase) throws CentralRepoException { if (eamCase == null) { - throw new EamDbException("Correlation case is null"); + throw new CentralRepoException("Correlation case is null"); } Connection conn = connect(); @@ -419,10 +419,10 @@ abstract class AbstractSqlEamDb implements EamDb { caseCacheById.put(eamCase.getID(), eamCase); caseCacheByUUID.put(eamCase.getCaseUUID(), eamCase); } catch (SQLException ex) { - throw new EamDbException("Error updating case.", ex); // NON-NLS + throw new CentralRepoException("Error updating case.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeConnection(conn); } } @@ -434,14 +434,14 @@ abstract class AbstractSqlEamDb implements EamDb { * @return The retrieved case */ @Override - public CorrelationCase getCaseByUUID(String caseUUID) throws EamDbException { + public CorrelationCase getCaseByUUID(String caseUUID) throws CentralRepoException { try { return caseCacheByUUID.get(caseUUID, () -> getCaseByUUIDFromCr(caseUUID)); } catch (CacheLoader.InvalidCacheLoadException ignored) { //lambda valueloader returned a null value and cache can not store null values this is normal if the case does not exist in the central repo yet return null; } catch (ExecutionException ex) { - throw new EamDbException("Error getting autopsy case from Central repo", ex); + throw new CentralRepoException("Error getting autopsy case from Central repo", ex); } } @@ -452,7 +452,7 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return The retrieved case */ - private CorrelationCase getCaseByUUIDFromCr(String caseUUID) throws EamDbException { + private CorrelationCase getCaseByUUIDFromCr(String caseUUID) throws CentralRepoException { Connection conn = connect(); CorrelationCase eamCaseResult = null; @@ -477,11 +477,11 @@ abstract class AbstractSqlEamDb implements EamDb { caseCacheById.put(eamCaseResult.getID(), eamCaseResult); } } catch (SQLException ex) { - throw new EamDbException("Error getting case details.", ex); // NON-NLS + throw new CentralRepoException("Error getting case details.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return eamCaseResult; @@ -495,14 +495,14 @@ abstract class AbstractSqlEamDb implements EamDb { * @return The retrieved case */ @Override - public CorrelationCase getCaseById(int caseId) throws EamDbException { + public CorrelationCase getCaseById(int caseId) throws CentralRepoException { try { return caseCacheById.get(caseId, () -> getCaseByIdFromCr(caseId)); } catch (CacheLoader.InvalidCacheLoadException ignored) { //lambda valueloader returned a null value and cache can not store null values this is normal if the case does not exist in the central repo yet return null; } catch (ExecutionException ex) { - throw new EamDbException("Error getting autopsy case from Central repo", ex); + throw new CentralRepoException("Error getting autopsy case from Central repo", ex); } } @@ -513,7 +513,7 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return The retrieved case */ - private CorrelationCase getCaseByIdFromCr(int caseId) throws EamDbException { + private CorrelationCase getCaseByIdFromCr(int caseId) throws CentralRepoException { Connection conn = connect(); CorrelationCase eamCaseResult = null; @@ -537,11 +537,11 @@ abstract class AbstractSqlEamDb implements EamDb { caseCacheByUUID.put(eamCaseResult.getCaseUUID(), eamCaseResult); } } catch (SQLException ex) { - throw new EamDbException("Error getting case details.", ex); // NON-NLS + throw new CentralRepoException("Error getting case details.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return eamCaseResult; @@ -553,7 +553,7 @@ abstract class AbstractSqlEamDb implements EamDb { * @return List of cases */ @Override - public List getCases() throws EamDbException { + public List getCases() throws CentralRepoException { Connection conn = connect(); List cases = new ArrayList<>(); @@ -574,11 +574,11 @@ abstract class AbstractSqlEamDb implements EamDb { cases.add(eamCaseResult); } } catch (SQLException ex) { - throw new EamDbException("Error getting all cases.", ex); // NON-NLS + throw new CentralRepoException("Error getting all cases.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return cases; @@ -617,15 +617,15 @@ abstract class AbstractSqlEamDb implements EamDb { * @param eamDataSource the data source to add */ @Override - public CorrelationDataSource newDataSource(CorrelationDataSource eamDataSource) throws EamDbException { + public CorrelationDataSource newDataSource(CorrelationDataSource eamDataSource) throws CentralRepoException { if (eamDataSource.getCaseID() == -1) { - throw new EamDbException("Case ID is -1"); + throw new CentralRepoException("Case ID is -1"); } if (eamDataSource.getDeviceID() == null) { - throw new EamDbException("Device ID is null"); + throw new CentralRepoException("Device ID is null"); } if (eamDataSource.getName() == null) { - throw new EamDbException("Name is null"); + throw new CentralRepoException("Name is null"); } if (eamDataSource.getID() != -1) { // This data source is already in the central repo @@ -665,7 +665,7 @@ abstract class AbstractSqlEamDb implements EamDb { eamDataSource.getCaseID(), eamDataSource.getDataSourceObjectID()), () -> getDataSourceFromCr(eamDataSource.getCaseID(), eamDataSource.getDataSourceObjectID())); } catch (CacheLoader.InvalidCacheLoadException | ExecutionException getException) { - throw new EamDbException(String.format("Unable to to INSERT or get data source %s in central repo:", eamDataSource.getName()), getException); + throw new CentralRepoException(String.format("Unable to to INSERT or get data source %s in central repo:", eamDataSource.getName()), getException); } } else { //if a new data source was added to the central repository update the caches to include it and return it @@ -690,12 +690,12 @@ abstract class AbstractSqlEamDb implements EamDb { eamDataSource.getCaseID(), eamDataSource.getDataSourceObjectID()), () -> getDataSourceFromCr(eamDataSource.getCaseID(), eamDataSource.getDataSourceObjectID())); } catch (CacheLoader.InvalidCacheLoadException | ExecutionException getException) { - throw new EamDbException(String.format("Unable to to INSERT or get data source %s in central repo, insert failed due to Exception: %s", eamDataSource.getName(), insertException.getMessage()), getException); + throw new CentralRepoException(String.format("Unable to to INSERT or get data source %s in central repo, insert failed due to Exception: %s", eamDataSource.getName(), insertException.getMessage()), getException); } } finally { - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeConnection(conn); } } @@ -708,13 +708,13 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return The data source * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public CorrelationDataSource getDataSource(CorrelationCase correlationCase, Long dataSourceObjectId) throws EamDbException { + public CorrelationDataSource getDataSource(CorrelationCase correlationCase, Long dataSourceObjectId) throws CentralRepoException { if (correlationCase == null) { - throw new EamDbException("Correlation case is null"); + throw new CentralRepoException("Correlation case is null"); } try { return dataSourceCacheByDsObjectId.get(getDataSourceByDSObjectIdCacheKey(correlationCase.getID(), dataSourceObjectId), () -> getDataSourceFromCr(correlationCase.getID(), dataSourceObjectId)); @@ -722,7 +722,7 @@ abstract class AbstractSqlEamDb implements EamDb { //lambda valueloader returned a null value and cache can not store null values this is normal if the dataSource does not exist in the central repo yet return null; } catch (ExecutionException ex) { - throw new EamDbException("Error getting data source from central repository", ex); + throw new CentralRepoException("Error getting data source from central repository", ex); } } @@ -736,9 +736,9 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return The data source * - * @throws EamDbException + * @throws CentralRepoException */ - private CorrelationDataSource getDataSourceFromCr(int correlationCaseId, Long dataSourceObjectId) throws EamDbException { + private CorrelationDataSource getDataSourceFromCr(int correlationCaseId, Long dataSourceObjectId) throws CentralRepoException { Connection conn = connect(); CorrelationDataSource eamDataSourceResult = null; @@ -759,11 +759,11 @@ abstract class AbstractSqlEamDb implements EamDb { dataSourceCacheById.put(getDataSourceByIdCacheKey(correlationCaseId, eamDataSourceResult.getID()), eamDataSourceResult); } } catch (SQLException ex) { - throw new EamDbException("Error getting data source.", ex); // NON-NLS + throw new CentralRepoException("Error getting data source.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return eamDataSourceResult; @@ -779,9 +779,9 @@ abstract class AbstractSqlEamDb implements EamDb { * @return The data source */ @Override - public CorrelationDataSource getDataSourceById(CorrelationCase correlationCase, int dataSourceId) throws EamDbException { + public CorrelationDataSource getDataSourceById(CorrelationCase correlationCase, int dataSourceId) throws CentralRepoException { if (correlationCase == null) { - throw new EamDbException("Correlation case is null"); + throw new CentralRepoException("Correlation case is null"); } try { return dataSourceCacheById.get(getDataSourceByIdCacheKey(correlationCase.getID(), dataSourceId), () -> getDataSourceByIdFromCr(correlationCase, dataSourceId)); @@ -789,7 +789,7 @@ abstract class AbstractSqlEamDb implements EamDb { //lambda valueloader returned a null value and cache can not store null values this is normal if the dataSource does not exist in the central repo yet return null; } catch (ExecutionException ex) { - throw new EamDbException("Error getting data source from central repository", ex); + throw new CentralRepoException("Error getting data source from central repository", ex); } } @@ -802,7 +802,7 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return The data source */ - private CorrelationDataSource getDataSourceByIdFromCr(CorrelationCase correlationCase, int dataSourceId) throws EamDbException { + private CorrelationDataSource getDataSourceByIdFromCr(CorrelationCase correlationCase, int dataSourceId) throws CentralRepoException { Connection conn = connect(); CorrelationDataSource eamDataSourceResult = null; @@ -823,11 +823,11 @@ abstract class AbstractSqlEamDb implements EamDb { dataSourceCacheByDsObjectId.put(getDataSourceByDSObjectIdCacheKey(correlationCase.getID(), eamDataSourceResult.getDataSourceObjectID()), eamDataSourceResult); } } catch (SQLException ex) { - throw new EamDbException("Error getting data source.", ex); // NON-NLS + throw new CentralRepoException("Error getting data source.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return eamDataSourceResult; @@ -839,7 +839,7 @@ abstract class AbstractSqlEamDb implements EamDb { * @return list of data sources in the DB */ @Override - public List getDataSources() throws EamDbException { + public List getDataSources() throws CentralRepoException { Connection conn = connect(); List dataSources = new ArrayList<>(); @@ -857,11 +857,11 @@ abstract class AbstractSqlEamDb implements EamDb { dataSources.add(eamDataSourceResult); } } catch (SQLException ex) { - throw new EamDbException("Error getting all data sources.", ex); // NON-NLS + throw new CentralRepoException("Error getting all data sources.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return dataSources; @@ -873,7 +873,7 @@ abstract class AbstractSqlEamDb implements EamDb { * @param eamDataSource The data source to update */ @Override - public void updateDataSourceMd5Hash(CorrelationDataSource eamDataSource) throws EamDbException { + public void updateDataSourceMd5Hash(CorrelationDataSource eamDataSource) throws CentralRepoException { updateDataSourceStringValue(eamDataSource, "md5", eamDataSource.getMd5()); } @@ -883,7 +883,7 @@ abstract class AbstractSqlEamDb implements EamDb { * @param eamDataSource The data source to update */ @Override - public void updateDataSourceSha1Hash(CorrelationDataSource eamDataSource) throws EamDbException { + public void updateDataSourceSha1Hash(CorrelationDataSource eamDataSource) throws CentralRepoException { updateDataSourceStringValue(eamDataSource, "sha1", eamDataSource.getSha1()); } @@ -894,7 +894,7 @@ abstract class AbstractSqlEamDb implements EamDb { * @param eamDataSource The data source to update */ @Override - public void updateDataSourceSha256Hash(CorrelationDataSource eamDataSource) throws EamDbException { + public void updateDataSourceSha256Hash(CorrelationDataSource eamDataSource) throws CentralRepoException { updateDataSourceStringValue(eamDataSource, "sha256", eamDataSource.getSha256()); } @@ -905,9 +905,9 @@ abstract class AbstractSqlEamDb implements EamDb { * @param column The name of the column to be updated * @param value The value to assign to the specified column */ - private void updateDataSourceStringValue(CorrelationDataSource eamDataSource, String column, String value) throws EamDbException { + private void updateDataSourceStringValue(CorrelationDataSource eamDataSource, String column, String value) throws CentralRepoException { if (eamDataSource == null) { - throw new EamDbException("Correlation data source is null"); + throw new CentralRepoException("Correlation data source is null"); } Connection conn = connect(); @@ -928,10 +928,10 @@ abstract class AbstractSqlEamDb implements EamDb { dataSourceCacheByDsObjectId.put(getDataSourceByDSObjectIdCacheKey(eamDataSource.getCaseID(), eamDataSource.getDataSourceObjectID()), eamDataSource); dataSourceCacheById.put(getDataSourceByIdCacheKey(eamDataSource.getCaseID(), eamDataSource.getID()), eamDataSource); } catch (SQLException ex) { - throw new EamDbException(String.format("Error updating data source (obj_id=%d).", eamDataSource.getDataSourceObjectID()), ex); // NON-NLS + throw new CentralRepoException(String.format("Error updating data source (obj_id=%d).", eamDataSource.getDataSourceObjectID()), ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeConnection(conn); } } @@ -941,10 +941,10 @@ abstract class AbstractSqlEamDb implements EamDb { * @param eamDataSource The data source * @param newName The new name * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void updateDataSourceName(CorrelationDataSource eamDataSource, String newName) throws EamDbException { + public void updateDataSourceName(CorrelationDataSource eamDataSource, String newName) throws CentralRepoException { Connection conn = connect(); @@ -971,11 +971,11 @@ abstract class AbstractSqlEamDb implements EamDb { dataSourceCacheByDsObjectId.put(getDataSourceByDSObjectIdCacheKey(updatedDataSource.getCaseID(), updatedDataSource.getDataSourceObjectID()), updatedDataSource); dataSourceCacheById.put(getDataSourceByIdCacheKey(updatedDataSource.getCaseID(), updatedDataSource.getID()), updatedDataSource); } catch (SQLException ex) { - throw new EamDbException("Error updating name of data source with ID " + eamDataSource.getDataSourceObjectID() + throw new CentralRepoException("Error updating name of data source with ID " + eamDataSource.getDataSourceObjectID() + " to " + newName, ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeConnection(conn); } } @@ -986,7 +986,7 @@ abstract class AbstractSqlEamDb implements EamDb { * @param eamArtifact The artifact to add */ @Override - public void addArtifactInstance(CorrelationAttributeInstance eamArtifact) throws EamDbException { + public void addArtifactInstance(CorrelationAttributeInstance eamArtifact) throws CentralRepoException { checkAddArtifactInstanceNulls(eamArtifact); Connection conn = connect(); @@ -994,7 +994,7 @@ abstract class AbstractSqlEamDb implements EamDb { PreparedStatement preparedStatement = null; // @@@ We should cache the case and data source IDs in memory - String tableName = EamDbUtil.correlationTypeToInstanceTableName(eamArtifact.getCorrelationType()); + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(eamArtifact.getCorrelationType()); String sql = "INSERT INTO " + tableName @@ -1023,43 +1023,43 @@ abstract class AbstractSqlEamDb implements EamDb { } } catch (SQLException ex) { - throw new EamDbException("Error inserting new artifact into artifacts table.", ex); // NON-NLS + throw new CentralRepoException("Error inserting new artifact into artifacts table.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeConnection(conn); } } - private void checkAddArtifactInstanceNulls(CorrelationAttributeInstance eamArtifact) throws EamDbException { + private void checkAddArtifactInstanceNulls(CorrelationAttributeInstance eamArtifact) throws CentralRepoException { if (eamArtifact == null) { - throw new EamDbException("CorrelationAttribute is null"); + throw new CentralRepoException("CorrelationAttribute is null"); } if (eamArtifact.getCorrelationType() == null) { - throw new EamDbException("Correlation type is null"); + throw new CentralRepoException("Correlation type is null"); } if (eamArtifact.getCorrelationValue() == null) { - throw new EamDbException("Correlation value is null"); + throw new CentralRepoException("Correlation value is null"); } if (eamArtifact.getCorrelationValue().length() >= MAX_VALUE_LENGTH) { - throw new EamDbException("Artifact value too long for central repository." + throw new CentralRepoException("Artifact value too long for central repository." + "\nCorrelationArtifact ID: " + eamArtifact.getID() + "\nCorrelationArtifact Type: " + eamArtifact.getCorrelationType().getDisplayName() + "\nCorrelationArtifact Value: " + eamArtifact.getCorrelationValue()); } if (eamArtifact.getCorrelationCase() == null) { - throw new EamDbException("CorrelationAttributeInstance case is null"); + throw new CentralRepoException("CorrelationAttributeInstance case is null"); } if (eamArtifact.getCorrelationDataSource() == null) { - throw new EamDbException("CorrelationAttributeInstance data source is null"); + throw new CentralRepoException("CorrelationAttributeInstance data source is null"); } if (eamArtifact.getKnownStatus() == null) { - throw new EamDbException("CorrelationAttributeInstance known status is null"); + throw new CentralRepoException("CorrelationAttributeInstance known status is null"); } } @Override - public List getArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException { + public List getArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException { if (value == null) { throw new CorrelationAttributeNormalizationException("Cannot get artifact instances for null value"); } @@ -1067,7 +1067,7 @@ abstract class AbstractSqlEamDb implements EamDb { } @Override - public List getArtifactInstancesByTypeValues(CorrelationAttributeInstance.Type aType, List values) throws EamDbException, CorrelationAttributeNormalizationException { + public List getArtifactInstancesByTypeValues(CorrelationAttributeInstance.Type aType, List values) throws CentralRepoException, CorrelationAttributeNormalizationException { if (aType == null) { throw new CorrelationAttributeNormalizationException("Cannot get artifact instances for null type"); } @@ -1078,7 +1078,7 @@ abstract class AbstractSqlEamDb implements EamDb { } @Override - public List getArtifactInstancesByTypeValuesAndCases(CorrelationAttributeInstance.Type aType, List values, List caseIds) throws EamDbException, CorrelationAttributeNormalizationException { + public List getArtifactInstancesByTypeValuesAndCases(CorrelationAttributeInstance.Type aType, List values, List caseIds) throws CentralRepoException, CorrelationAttributeNormalizationException { if (aType == null) { throw new CorrelationAttributeNormalizationException("Cannot get artifact instances for null type"); } @@ -1088,7 +1088,7 @@ abstract class AbstractSqlEamDb implements EamDb { if (caseIds == null || caseIds.isEmpty()) { throw new CorrelationAttributeNormalizationException("Cannot get artifact instances without specified cases"); } - String tableName = EamDbUtil.correlationTypeToInstanceTableName(aType); + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(aType); String sql = " and " + tableName @@ -1113,7 +1113,7 @@ abstract class AbstractSqlEamDb implements EamDb { * @throws CorrelationAttributeNormalizationException */ private String prepareGetInstancesSql(CorrelationAttributeInstance.Type aType, List values) throws CorrelationAttributeNormalizationException { - String tableName = EamDbUtil.correlationTypeToInstanceTableName(aType); + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(aType); String sql = "SELECT " + tableName @@ -1157,9 +1157,9 @@ abstract class AbstractSqlEamDb implements EamDb { * values * * @throws CorrelationAttributeNormalizationException - * @throws EamDbException + * @throws CentralRepoException */ - private List getArtifactInstances(String sql, CorrelationAttributeInstance.Type aType) throws CorrelationAttributeNormalizationException, EamDbException { + private List getArtifactInstances(String sql, CorrelationAttributeInstance.Type aType) throws CorrelationAttributeNormalizationException, CentralRepoException { Connection conn = connect(); List artifactInstances = new ArrayList<>(); CorrelationAttributeInstance artifactInstance; @@ -1173,11 +1173,11 @@ abstract class AbstractSqlEamDb implements EamDb { artifactInstances.add(artifactInstance); } } catch (SQLException ex) { - throw new EamDbException("Error getting artifact instances by artifactType and artifactValue.", ex); // NON-NLS + throw new CentralRepoException("Error getting artifact instances by artifactType and artifactValue.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return artifactInstances; } @@ -1193,7 +1193,7 @@ abstract class AbstractSqlEamDb implements EamDb { * ArtifactValue. */ @Override - public Long getCountArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException { + public Long getCountArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException { String normalizedValue = CorrelationAttributeNormalizer.normalize(aType, value); Connection conn = connect(); @@ -1202,7 +1202,7 @@ abstract class AbstractSqlEamDb implements EamDb { PreparedStatement preparedStatement = null; ResultSet resultSet = null; - String tableName = EamDbUtil.correlationTypeToInstanceTableName(aType); + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(aType); String sql = "SELECT count(*) FROM " + tableName @@ -1215,20 +1215,20 @@ abstract class AbstractSqlEamDb implements EamDb { resultSet.next(); instanceCount = resultSet.getLong(1); } catch (SQLException ex) { - throw new EamDbException("Error getting count of artifact instances by artifactType and artifactValue.", ex); // NON-NLS + throw new CentralRepoException("Error getting count of artifact instances by artifactType and artifactValue.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return instanceCount; } @Override - public int getFrequencyPercentage(CorrelationAttributeInstance corAttr) throws EamDbException, CorrelationAttributeNormalizationException { + public int getFrequencyPercentage(CorrelationAttributeInstance corAttr) throws CentralRepoException, CorrelationAttributeNormalizationException { if (corAttr == null) { - throw new EamDbException("CorrelationAttribute is null"); + throw new CentralRepoException("CorrelationAttribute is null"); } Double uniqueTypeValueTuples = getCountUniqueCaseDataSourceTuplesHavingTypeValue(corAttr.getCorrelationType(), corAttr.getCorrelationValue()).doubleValue(); Double uniqueCaseDataSourceTuples = getCountUniqueDataSources().doubleValue(); @@ -1247,7 +1247,7 @@ abstract class AbstractSqlEamDb implements EamDb { * @return Number of unique tuples */ @Override - public Long getCountUniqueCaseDataSourceTuplesHavingTypeValue(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException { + public Long getCountUniqueCaseDataSourceTuplesHavingTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException { String normalizedValue = CorrelationAttributeNormalizer.normalize(aType, value); Connection conn = connect(); @@ -1256,7 +1256,7 @@ abstract class AbstractSqlEamDb implements EamDb { PreparedStatement preparedStatement = null; ResultSet resultSet = null; - String tableName = EamDbUtil.correlationTypeToInstanceTableName(aType); + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(aType); String sql = "SELECT count(*) FROM (SELECT DISTINCT case_id, data_source_id FROM " + tableName @@ -1271,18 +1271,18 @@ abstract class AbstractSqlEamDb implements EamDb { resultSet.next(); instanceCount = resultSet.getLong(1); } catch (SQLException ex) { - throw new EamDbException("Error counting unique caseDisplayName/dataSource tuples having artifactType and artifactValue.", ex); // NON-NLS + throw new CentralRepoException("Error counting unique caseDisplayName/dataSource tuples having artifactType and artifactValue.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return instanceCount; } @Override - public Long getCountUniqueDataSources() throws EamDbException { + public Long getCountUniqueDataSources() throws CentralRepoException { Connection conn = connect(); Long instanceCount = 0L; @@ -1297,11 +1297,11 @@ abstract class AbstractSqlEamDb implements EamDb { resultSet.next(); instanceCount = resultSet.getLong(1); } catch (SQLException ex) { - throw new EamDbException("Error counting data sources.", ex); // NON-NLS + throw new CentralRepoException("Error counting data sources.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return instanceCount; @@ -1319,7 +1319,7 @@ abstract class AbstractSqlEamDb implements EamDb { * dataSource */ @Override - public Long getCountArtifactInstancesByCaseDataSource(CorrelationDataSource correlationDataSource) throws EamDbException { + public Long getCountArtifactInstancesByCaseDataSource(CorrelationDataSource correlationDataSource) throws CentralRepoException { Connection conn = connect(); Long instanceCount = 0L; @@ -1331,7 +1331,7 @@ abstract class AbstractSqlEamDb implements EamDb { String sql = "SELECT 0 "; for (CorrelationAttributeInstance.Type type : artifactTypes) { - String table_name = EamDbUtil.correlationTypeToInstanceTableName(type); + String table_name = CentralRepoDbUtil.correlationTypeToInstanceTableName(type); sql += "+ (SELECT count(*) FROM " + table_name @@ -1344,11 +1344,11 @@ abstract class AbstractSqlEamDb implements EamDb { resultSet.next(); instanceCount = resultSet.getLong(1); } catch (SQLException ex) { - throw new EamDbException("Error counting artifact instances by caseName/dataSource.", ex); // NON-NLS + throw new CentralRepoException("Error counting artifact instances by caseName/dataSource.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return instanceCount; @@ -1362,14 +1362,14 @@ abstract class AbstractSqlEamDb implements EamDb { * @param eamArtifact The artifact to add */ @Override - public void addAttributeInstanceBulk(CorrelationAttributeInstance eamArtifact) throws EamDbException { + public void addAttributeInstanceBulk(CorrelationAttributeInstance eamArtifact) throws CentralRepoException { if (eamArtifact.getCorrelationType() == null) { - throw new EamDbException("Correlation type is null"); + throw new CentralRepoException("Correlation type is null"); } synchronized (bulkArtifacts) { - bulkArtifacts.get(EamDbUtil.correlationTypeToInstanceTableName(eamArtifact.getCorrelationType())).add(eamArtifact); + bulkArtifacts.get(CentralRepoDbUtil.correlationTypeToInstanceTableName(eamArtifact.getCorrelationType())).add(eamArtifact); bulkArtifactsCount++; if (bulkArtifactsCount >= bulkArtifactsThreshold) { @@ -1390,7 +1390,7 @@ abstract class AbstractSqlEamDb implements EamDb { * addAttributeInstanceBulk() method */ @Override - public void commitAttributeInstancesBulk() throws EamDbException { + public void commitAttributeInstancesBulk() throws CentralRepoException { List artifactTypes = getDefinedCorrelationTypes(); Connection conn = connect(); @@ -1420,19 +1420,19 @@ abstract class AbstractSqlEamDb implements EamDb { if (!eamArtifact.getCorrelationValue().isEmpty()) { if (eamArtifact.getCorrelationCase() == null) { - throw new EamDbException("CorrelationAttributeInstance case is null for: " + throw new CentralRepoException("CorrelationAttributeInstance case is null for: " + "\n\tCorrelationArtifact ID: " + eamArtifact.getID() + "\n\tCorrelationArtifact Type: " + eamArtifact.getCorrelationType().getDisplayName() + "\n\tCorrelationArtifact Value: " + eamArtifact.getCorrelationValue()); } if (eamArtifact.getCorrelationDataSource() == null) { - throw new EamDbException("CorrelationAttributeInstance data source is null for: " + throw new CentralRepoException("CorrelationAttributeInstance data source is null for: " + "\n\tCorrelationArtifact ID: " + eamArtifact.getID() + "\n\tCorrelationArtifact Type: " + eamArtifact.getCorrelationType().getDisplayName() + "\n\tCorrelationArtifact Value: " + eamArtifact.getCorrelationValue()); } if (eamArtifact.getKnownStatus() == null) { - throw new EamDbException("CorrelationAttributeInstance known status is null for: " + throw new CentralRepoException("CorrelationAttributeInstance known status is null for: " + "\n\tCorrelationArtifact ID: " + eamArtifact.getID() + "\n\tCorrelationArtifact Type: " + eamArtifact.getCorrelationType().getDisplayName() + "\n\tCorrelationArtifact Value: " + eamArtifact.getCorrelationValue() @@ -1480,10 +1480,10 @@ abstract class AbstractSqlEamDb implements EamDb { bulkArtifactsCount = 0; } } catch (SQLException ex) { - throw new EamDbException("Error inserting bulk artifacts.", ex); // NON-NLS + throw new CentralRepoException("Error inserting bulk artifacts.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(bulkPs); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(bulkPs); + CentralRepoDbUtil.closeConnection(conn); } } @@ -1491,9 +1491,9 @@ abstract class AbstractSqlEamDb implements EamDb { * Executes a bulk insert of the cases */ @Override - public void bulkInsertCases(List cases) throws EamDbException { + public void bulkInsertCases(List cases) throws CentralRepoException { if (cases == null) { - throw new EamDbException("cases argument is null"); + throw new CentralRepoException("cases argument is null"); } if (cases.isEmpty()) { @@ -1560,10 +1560,10 @@ abstract class AbstractSqlEamDb implements EamDb { // send the remaining batch records bulkPs.executeBatch(); } catch (SQLException ex) { - throw new EamDbException("Error inserting bulk cases.", ex); // NON-NLS + throw new CentralRepoException("Error inserting bulk cases.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(bulkPs); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(bulkPs); + CentralRepoDbUtil.closeConnection(conn); } } @@ -1574,23 +1574,23 @@ abstract class AbstractSqlEamDb implements EamDb { * @param eamArtifact The correlation attribute whose database instance will * be updated. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void updateAttributeInstanceComment(CorrelationAttributeInstance eamArtifact) throws EamDbException { + public void updateAttributeInstanceComment(CorrelationAttributeInstance eamArtifact) throws CentralRepoException { if (eamArtifact == null) { - throw new EamDbException("CorrelationAttributeInstance is null"); + throw new CentralRepoException("CorrelationAttributeInstance is null"); } if (eamArtifact.getCorrelationCase() == null) { - throw new EamDbException("Correlation case is null"); + throw new CentralRepoException("Correlation case is null"); } if (eamArtifact.getCorrelationDataSource() == null) { - throw new EamDbException("Correlation data source is null"); + throw new CentralRepoException("Correlation data source is null"); } Connection conn = connect(); PreparedStatement preparedQuery = null; - String tableName = EamDbUtil.correlationTypeToInstanceTableName(eamArtifact.getCorrelationType()); + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(eamArtifact.getCorrelationType()); String sqlUpdate = "UPDATE " + tableName @@ -1609,10 +1609,10 @@ abstract class AbstractSqlEamDb implements EamDb { preparedQuery.setString(5, eamArtifact.getFilePath().toLowerCase()); preparedQuery.executeUpdate(); } catch (SQLException ex) { - throw new EamDbException("Error getting/setting artifact instance comment=" + eamArtifact.getComment(), ex); // NON-NLS + throw new CentralRepoException("Error getting/setting artifact instance comment=" + eamArtifact.getComment(), ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedQuery); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedQuery); + CentralRepoDbUtil.closeConnection(conn); } } @@ -1628,14 +1628,14 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return The correlation attribute if it exists; otherwise null. * - * @throws EamDbException + * @throws CentralRepoException */ @Override public CorrelationAttributeInstance getCorrelationAttributeInstance(CorrelationAttributeInstance.Type type, CorrelationCase correlationCase, - CorrelationDataSource correlationDataSource, long objectID) throws EamDbException, CorrelationAttributeNormalizationException { + CorrelationDataSource correlationDataSource, long objectID) throws CentralRepoException, CorrelationAttributeNormalizationException { if (correlationCase == null) { - throw new EamDbException("Correlation case is null"); + throw new CentralRepoException("Correlation case is null"); } Connection conn = connect(); @@ -1646,7 +1646,7 @@ abstract class AbstractSqlEamDb implements EamDb { try { - String tableName = EamDbUtil.correlationTypeToInstanceTableName(type); + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(type); String sql = "SELECT id, value, file_path, known_status, comment FROM " + tableName @@ -1668,11 +1668,11 @@ abstract class AbstractSqlEamDb implements EamDb { instanceId, correlationCase, correlationDataSource, filePath, comment, TskData.FileKnown.valueOf((byte) knownStatus), objectID); } } catch (SQLException ex) { - throw new EamDbException("Error getting notable artifact instances.", ex); // NON-NLS + throw new CentralRepoException("Error getting notable artifact instances.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return correlationAttributeInstance; @@ -1690,20 +1690,20 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return The correlation attribute if it exists; otherwise null. * - * @throws EamDbException + * @throws CentralRepoException */ @Override public CorrelationAttributeInstance getCorrelationAttributeInstance(CorrelationAttributeInstance.Type type, CorrelationCase correlationCase, - CorrelationDataSource correlationDataSource, String value, String filePath) throws EamDbException, CorrelationAttributeNormalizationException { + CorrelationDataSource correlationDataSource, String value, String filePath) throws CentralRepoException, CorrelationAttributeNormalizationException { if (correlationCase == null) { - throw new EamDbException("Correlation case is null"); + throw new CentralRepoException("Correlation case is null"); } if (correlationDataSource == null) { - throw new EamDbException("Correlation data source is null"); + throw new CentralRepoException("Correlation data source is null"); } if (filePath == null) { - throw new EamDbException("Correlation file path is null"); + throw new CentralRepoException("Correlation file path is null"); } Connection conn = connect(); @@ -1715,7 +1715,7 @@ abstract class AbstractSqlEamDb implements EamDb { try { String normalizedValue = CorrelationAttributeNormalizer.normalize(type, value); - String tableName = EamDbUtil.correlationTypeToInstanceTableName(type); + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(type); String sql = "SELECT id, known_status, comment FROM " + tableName @@ -1739,11 +1739,11 @@ abstract class AbstractSqlEamDb implements EamDb { instanceId, correlationCase, correlationDataSource, filePath, comment, TskData.FileKnown.valueOf((byte) knownStatus), null); } } catch (SQLException ex) { - throw new EamDbException("Error getting notable artifact instances.", ex); // NON-NLS + throw new CentralRepoException("Error getting notable artifact instances.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return correlationAttributeInstance; @@ -1760,19 +1760,19 @@ abstract class AbstractSqlEamDb implements EamDb { * KNOWN */ @Override - public void setAttributeInstanceKnownStatus(CorrelationAttributeInstance eamArtifact, TskData.FileKnown knownStatus) throws EamDbException { + public void setAttributeInstanceKnownStatus(CorrelationAttributeInstance eamArtifact, TskData.FileKnown knownStatus) throws CentralRepoException { if (eamArtifact == null) { - throw new EamDbException("CorrelationAttribute is null"); + throw new CentralRepoException("CorrelationAttribute is null"); } if (knownStatus == null) { - throw new EamDbException("Known status is null"); + throw new CentralRepoException("Known status is null"); } if (eamArtifact.getCorrelationCase() == null) { - throw new EamDbException("Correlation case is null"); + throw new CentralRepoException("Correlation case is null"); } if (eamArtifact.getCorrelationDataSource() == null) { - throw new EamDbException("Correlation data source is null"); + throw new CentralRepoException("Correlation data source is null"); } Connection conn = connect(); @@ -1781,7 +1781,7 @@ abstract class AbstractSqlEamDb implements EamDb { PreparedStatement preparedQuery = null; ResultSet resultSet = null; - String tableName = EamDbUtil.correlationTypeToInstanceTableName(eamArtifact.getCorrelationType()); + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(eamArtifact.getCorrelationType()); String sqlQuery = "SELECT id FROM " @@ -1835,12 +1835,12 @@ abstract class AbstractSqlEamDb implements EamDb { } } catch (SQLException ex) { - throw new EamDbException("Error getting/setting artifact instance knownStatus=" + knownStatus.getName(), ex); // NON-NLS + throw new CentralRepoException("Error getting/setting artifact instance knownStatus=" + knownStatus.getName(), ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedUpdate); - EamDbUtil.closeStatement(preparedQuery); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedUpdate); + CentralRepoDbUtil.closeStatement(preparedQuery); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } } @@ -1853,7 +1853,7 @@ abstract class AbstractSqlEamDb implements EamDb { * @return Number of matching eamArtifacts */ @Override - public Long getCountArtifactInstancesKnownBad(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException { + public Long getCountArtifactInstancesKnownBad(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException { String normalizedValue = CorrelationAttributeNormalizer.normalize(aType, value); @@ -1863,7 +1863,7 @@ abstract class AbstractSqlEamDb implements EamDb { PreparedStatement preparedStatement = null; ResultSet resultSet = null; - String tableName = EamDbUtil.correlationTypeToInstanceTableName(aType); + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(aType); String sql = "SELECT count(*) FROM " + tableName @@ -1877,11 +1877,11 @@ abstract class AbstractSqlEamDb implements EamDb { resultSet.next(); badInstances = resultSet.getLong(1); } catch (SQLException ex) { - throw new EamDbException("Error getting count of notable artifact instances.", ex); // NON-NLS + throw new CentralRepoException("Error getting count of notable artifact instances.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return badInstances; @@ -1897,10 +1897,10 @@ abstract class AbstractSqlEamDb implements EamDb { * @return List of cases containing this artifact with instances marked as * bad * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public List getListCasesHavingArtifactInstancesKnownBad(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException { + public List getListCasesHavingArtifactInstancesKnownBad(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException { String normalizedValue = CorrelationAttributeNormalizer.normalize(aType, value); @@ -1911,7 +1911,7 @@ abstract class AbstractSqlEamDb implements EamDb { PreparedStatement preparedStatement = null; ResultSet resultSet = null; - String tableName = EamDbUtil.correlationTypeToInstanceTableName(aType); + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(aType); String sql = "SELECT DISTINCT case_name FROM " + tableName @@ -1932,11 +1932,11 @@ abstract class AbstractSqlEamDb implements EamDb { caseNames.add(resultSet.getString("case_name")); } } catch (SQLException ex) { - throw new EamDbException("Error getting notable artifact instances.", ex); // NON-NLS + throw new CentralRepoException("Error getting notable artifact instances.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return caseNames.stream().collect(Collectors.toList()); @@ -1952,10 +1952,10 @@ abstract class AbstractSqlEamDb implements EamDb { * @return List of cases containing this artifact with instances marked as * bad * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public List getListCasesHavingArtifactInstances(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException { + public List getListCasesHavingArtifactInstances(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException { String normalizedValue = CorrelationAttributeNormalizer.normalize(aType, value); @@ -1966,7 +1966,7 @@ abstract class AbstractSqlEamDb implements EamDb { PreparedStatement preparedStatement = null; ResultSet resultSet = null; - String tableName = EamDbUtil.correlationTypeToInstanceTableName(aType); + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(aType); String sql = "SELECT DISTINCT case_name FROM " + tableName @@ -1984,11 +1984,11 @@ abstract class AbstractSqlEamDb implements EamDb { caseNames.add(resultSet.getString("case_name")); } } catch (SQLException ex) { - throw new EamDbException("Error getting notable artifact instances.", ex); // NON-NLS + throw new CentralRepoException("Error getting notable artifact instances.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return caseNames.stream().collect(Collectors.toList()); @@ -1999,10 +1999,10 @@ abstract class AbstractSqlEamDb implements EamDb { * * @param referenceSetID * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void deleteReferenceSet(int referenceSetID) throws EamDbException { + public void deleteReferenceSet(int referenceSetID) throws CentralRepoException { deleteReferenceSetEntries(referenceSetID); deleteReferenceSetEntry(referenceSetID); } @@ -2012,9 +2012,9 @@ abstract class AbstractSqlEamDb implements EamDb { * * @param referenceSetID * - * @throws EamDbException + * @throws CentralRepoException */ - private void deleteReferenceSetEntry(int referenceSetID) throws EamDbException { + private void deleteReferenceSetEntry(int referenceSetID) throws CentralRepoException { Connection conn = connect(); PreparedStatement preparedStatement = null; @@ -2025,10 +2025,10 @@ abstract class AbstractSqlEamDb implements EamDb { preparedStatement.setInt(1, referenceSetID); preparedStatement.executeUpdate(); } catch (SQLException ex) { - throw new EamDbException("Error deleting reference set " + referenceSetID, ex); // NON-NLS + throw new CentralRepoException("Error deleting reference set " + referenceSetID, ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeConnection(conn); } } @@ -2038,26 +2038,26 @@ abstract class AbstractSqlEamDb implements EamDb { * * @param referenceSetID * - * @throws EamDbException + * @throws CentralRepoException */ - private void deleteReferenceSetEntries(int referenceSetID) throws EamDbException { + private void deleteReferenceSetEntries(int referenceSetID) throws CentralRepoException { Connection conn = connect(); PreparedStatement preparedStatement = null; String sql = "DELETE FROM %s WHERE reference_set_id=?"; // When other reference types are added, this will need to loop over all the tables - String fileTableName = EamDbUtil.correlationTypeToReferenceTableName(getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID)); + String fileTableName = CentralRepoDbUtil.correlationTypeToReferenceTableName(getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID)); try { preparedStatement = conn.prepareStatement(String.format(sql, fileTableName)); preparedStatement.setInt(1, referenceSetID); preparedStatement.executeUpdate(); } catch (SQLException ex) { - throw new EamDbException("Error deleting files from reference set " + referenceSetID, ex); // NON-NLS + throw new CentralRepoException("Error deleting files from reference set " + referenceSetID, ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeConnection(conn); } } @@ -2072,11 +2072,11 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return true if a matching entry exists in the central repository * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public boolean referenceSetIsValid(int referenceSetID, String setName, String version) throws EamDbException { - EamGlobalSet refSet = this.getReferenceSetByID(referenceSetID); + public boolean referenceSetIsValid(int referenceSetID, String setName, String version) throws CentralRepoException { + CentralRepoFileSet refSet = this.getReferenceSetByID(referenceSetID); if (refSet == null) { return false; } @@ -2093,10 +2093,10 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return true if the hash is found in the reference set * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public boolean isFileHashInReferenceSet(String hash, int referenceSetID) throws EamDbException, CorrelationAttributeNormalizationException { + public boolean isFileHashInReferenceSet(String hash, int referenceSetID) throws CentralRepoException, CorrelationAttributeNormalizationException { return isValueInReferenceSet(hash, referenceSetID, CorrelationAttributeInstance.FILES_TYPE_ID); } @@ -2110,7 +2110,7 @@ abstract class AbstractSqlEamDb implements EamDb { * @return true if the value is found in the reference set */ @Override - public boolean isValueInReferenceSet(String value, int referenceSetID, int correlationTypeID) throws EamDbException, CorrelationAttributeNormalizationException { + public boolean isValueInReferenceSet(String value, int referenceSetID, int correlationTypeID) throws CentralRepoException, CorrelationAttributeNormalizationException { String normalizeValued = CorrelationAttributeNormalizer.normalize(this.getCorrelationTypeById(correlationTypeID), value); @@ -2121,7 +2121,7 @@ abstract class AbstractSqlEamDb implements EamDb { ResultSet resultSet = null; String sql = "SELECT count(*) FROM %s WHERE value=? AND reference_set_id=?"; - String fileTableName = EamDbUtil.correlationTypeToReferenceTableName(getCorrelationTypeById(correlationTypeID)); + String fileTableName = CentralRepoDbUtil.correlationTypeToReferenceTableName(getCorrelationTypeById(correlationTypeID)); try { preparedStatement = conn.prepareStatement(String.format(sql, fileTableName)); @@ -2131,11 +2131,11 @@ abstract class AbstractSqlEamDb implements EamDb { resultSet.next(); matchingInstances = resultSet.getLong(1); } catch (SQLException ex) { - throw new EamDbException("Error determining if value (" + normalizeValued + ") is in reference set " + referenceSetID, ex); // NON-NLS + throw new CentralRepoException("Error determining if value (" + normalizeValued + ") is in reference set " + referenceSetID, ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return 0 < matchingInstances; @@ -2150,7 +2150,7 @@ abstract class AbstractSqlEamDb implements EamDb { * @return Global known status of the artifact */ @Override - public boolean isArtifactKnownBadByReference(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException { + public boolean isArtifactKnownBadByReference(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException { //this should be done here so that we can be certain that aType and value are valid before we proceed String normalizeValued = CorrelationAttributeNormalizer.normalize(aType, value); @@ -2168,18 +2168,18 @@ abstract class AbstractSqlEamDb implements EamDb { String sql = "SELECT count(*) FROM %s WHERE value=? AND known_status=?"; try { - preparedStatement = conn.prepareStatement(String.format(sql, EamDbUtil.correlationTypeToReferenceTableName(aType))); + preparedStatement = conn.prepareStatement(String.format(sql, CentralRepoDbUtil.correlationTypeToReferenceTableName(aType))); preparedStatement.setString(1, normalizeValued); preparedStatement.setByte(2, TskData.FileKnown.BAD.getFileKnownValue()); resultSet = preparedStatement.executeQuery(); resultSet.next(); badInstances = resultSet.getLong(1); } catch (SQLException ex) { - throw new EamDbException("Error determining if artifact is notable by reference.", ex); // NON-NLS + throw new CentralRepoException("Error determining if artifact is notable by reference.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return 0 < badInstances; @@ -2191,22 +2191,22 @@ abstract class AbstractSqlEamDb implements EamDb { * @param type EamArtifact.Type to search for * @param instanceTableCallback callback to process the instance * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void processInstanceTable(CorrelationAttributeInstance.Type type, InstanceTableCallback instanceTableCallback) throws EamDbException { + public void processInstanceTable(CorrelationAttributeInstance.Type type, InstanceTableCallback instanceTableCallback) throws CentralRepoException { if (type == null) { - throw new EamDbException("Correlation type is null"); + throw new CentralRepoException("Correlation type is null"); } if (instanceTableCallback == null) { - throw new EamDbException("Callback interface is null"); + throw new CentralRepoException("Callback interface is null"); } Connection conn = connect(); PreparedStatement preparedStatement = null; ResultSet resultSet = null; - String tableName = EamDbUtil.correlationTypeToInstanceTableName(type); + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(type); StringBuilder sql = new StringBuilder(); sql.append("select * from "); sql.append(tableName); @@ -2216,11 +2216,11 @@ abstract class AbstractSqlEamDb implements EamDb { resultSet = preparedStatement.executeQuery(); instanceTableCallback.process(resultSet); } catch (SQLException ex) { - throw new EamDbException("Error getting all artifact instances from instances table", ex); + throw new CentralRepoException("Error getting all artifact instances from instances table", ex); } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } } @@ -2231,26 +2231,26 @@ abstract class AbstractSqlEamDb implements EamDb { * @param instanceTableCallback callback to process the instance * @param whereClause query string to execute * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void processInstanceTableWhere(CorrelationAttributeInstance.Type type, String whereClause, InstanceTableCallback instanceTableCallback) throws EamDbException { + public void processInstanceTableWhere(CorrelationAttributeInstance.Type type, String whereClause, InstanceTableCallback instanceTableCallback) throws CentralRepoException { if (type == null) { - throw new EamDbException("Correlation type is null"); + throw new CentralRepoException("Correlation type is null"); } if (instanceTableCallback == null) { - throw new EamDbException("Callback interface is null"); + throw new CentralRepoException("Callback interface is null"); } if (whereClause == null) { - throw new EamDbException("Where clause is null"); + throw new CentralRepoException("Where clause is null"); } Connection conn = connect(); PreparedStatement preparedStatement = null; ResultSet resultSet = null; - String tableName = EamDbUtil.correlationTypeToInstanceTableName(type); + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(type); StringBuilder sql = new StringBuilder(300); sql.append("select * from ") .append(tableName) @@ -2262,11 +2262,11 @@ abstract class AbstractSqlEamDb implements EamDb { resultSet = preparedStatement.executeQuery(); instanceTableCallback.process(resultSet); } catch (SQLException ex) { - throw new EamDbException("Error getting all artifact instances from instances table", ex); + throw new CentralRepoException("Error getting all artifact instances from instances table", ex); } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } } @@ -2276,17 +2276,17 @@ abstract class AbstractSqlEamDb implements EamDb { * @param selectClause query string to execute * @param instanceTableCallback callback to process the instance * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void processSelectClause(String selectClause, InstanceTableCallback instanceTableCallback) throws EamDbException { + public void processSelectClause(String selectClause, InstanceTableCallback instanceTableCallback) throws CentralRepoException { if (instanceTableCallback == null) { - throw new EamDbException("Callback interface is null"); + throw new CentralRepoException("Callback interface is null"); } if (selectClause == null) { - throw new EamDbException("Select clause is null"); + throw new CentralRepoException("Select clause is null"); } Connection conn = connect(); @@ -2301,20 +2301,20 @@ abstract class AbstractSqlEamDb implements EamDb { resultSet = preparedStatement.executeQuery(); instanceTableCallback.process(resultSet); } catch (SQLException ex) { - throw new EamDbException("Error running query", ex); + throw new CentralRepoException("Error running query", ex); } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } } @Override - public EamOrganization newOrganization(EamOrganization eamOrg) throws EamDbException { + public CentralRepoOrganization newOrganization(CentralRepoOrganization eamOrg) throws CentralRepoException { if (eamOrg == null) { - throw new EamDbException("EamOrganization is null"); + throw new CentralRepoException("EamOrganization is null"); } else if (eamOrg.getOrgID() != -1) { - throw new EamDbException("EamOrganization already has an ID"); + throw new CentralRepoException("EamOrganization already has an ID"); } Connection conn = connect(); @@ -2339,11 +2339,11 @@ abstract class AbstractSqlEamDb implements EamDb { throw new SQLException("Creating user failed, no ID obtained."); } } catch (SQLException ex) { - throw new EamDbException("Error inserting new organization.", ex); // NON-NLS + throw new CentralRepoException("Error inserting new organization.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(generatedKeys); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(generatedKeys); + CentralRepoDbUtil.closeConnection(conn); } } @@ -2352,13 +2352,13 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return A list of all organizations * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public List getOrganizations() throws EamDbException { + public List getOrganizations() throws CentralRepoException { Connection conn = connect(); - List orgs = new ArrayList<>(); + List orgs = new ArrayList<>(); PreparedStatement preparedStatement = null; ResultSet resultSet = null; String sql = "SELECT * FROM organizations"; @@ -2372,11 +2372,11 @@ abstract class AbstractSqlEamDb implements EamDb { return orgs; } catch (SQLException ex) { - throw new EamDbException("Error getting all organizations.", ex); // NON-NLS + throw new CentralRepoException("Error getting all organizations.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } } @@ -2387,10 +2387,10 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return The organization with the given ID * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public EamOrganization getOrganizationByID(int orgID) throws EamDbException { + public CentralRepoOrganization getOrganizationByID(int orgID) throws CentralRepoException { Connection conn = connect(); PreparedStatement preparedStatement = null; @@ -2405,11 +2405,11 @@ abstract class AbstractSqlEamDb implements EamDb { return getEamOrganizationFromResultSet(resultSet); } catch (SQLException ex) { - throw new EamDbException("Error getting organization by id.", ex); // NON-NLS + throw new CentralRepoException("Error getting organization by id.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } } @@ -2420,14 +2420,14 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return The organization object * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public EamOrganization getReferenceSetOrganization(int referenceSetID) throws EamDbException { + public CentralRepoOrganization getReferenceSetOrganization(int referenceSetID) throws CentralRepoException { - EamGlobalSet globalSet = getReferenceSetByID(referenceSetID); + CentralRepoFileSet globalSet = getReferenceSetByID(referenceSetID); if (globalSet == null) { - throw new EamDbException("Reference set with ID " + referenceSetID + " not found"); + throw new CentralRepoException("Reference set with ID " + referenceSetID + " not found"); } return (getOrganizationByID(globalSet.getOrgID())); } @@ -2437,13 +2437,13 @@ abstract class AbstractSqlEamDb implements EamDb { * * @param org * - * @throws EamDbException if invalid + * @throws CentralRepoException if invalid */ - private void testArgument(EamOrganization org) throws EamDbException { + private void testArgument(CentralRepoOrganization org) throws CentralRepoException { if (org == null) { - throw new EamDbException("EamOrganization is null"); + throw new CentralRepoException("EamOrganization is null"); } else if (org.getOrgID() == -1) { - throw new EamDbException("Organization has -1 row ID"); + throw new CentralRepoException("Organization has -1 row ID"); } } @@ -2453,10 +2453,10 @@ abstract class AbstractSqlEamDb implements EamDb { * @param updatedOrganization the values the Organization with the same ID * will be updated to in the database. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void updateOrganization(EamOrganization updatedOrganization) throws EamDbException { + public void updateOrganization(CentralRepoOrganization updatedOrganization) throws CentralRepoException { testArgument(updatedOrganization); Connection conn = connect(); @@ -2471,15 +2471,15 @@ abstract class AbstractSqlEamDb implements EamDb { preparedStatement.setInt(5, updatedOrganization.getOrgID()); preparedStatement.executeUpdate(); } catch (SQLException ex) { - throw new EamDbException("Error updating organization.", ex); // NON-NLS + throw new CentralRepoException("Error updating organization.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeConnection(conn); } } @Override - public void deleteOrganization(EamOrganization organizationToDelete) throws EamDbException { + public void deleteOrganization(CentralRepoOrganization organizationToDelete) throws CentralRepoException { testArgument(organizationToDelete); Connection conn = connect(); @@ -2495,18 +2495,18 @@ abstract class AbstractSqlEamDb implements EamDb { resultSet = checkIfUsedStatement.executeQuery(); resultSet.next(); if (resultSet.getLong(1) > 0) { - throw new EamDbException("Can not delete organization which is currently in use by a case or reference set in the central repository."); + throw new CentralRepoException("Can not delete organization which is currently in use by a case or reference set in the central repository."); } deleteOrgStatement = conn.prepareStatement(deleteOrgSql); deleteOrgStatement.setInt(1, organizationToDelete.getOrgID()); deleteOrgStatement.executeUpdate(); } catch (SQLException ex) { - throw new EamDbException("Error executing query when attempting to delete organization by id.", ex); // NON-NLS + throw new CentralRepoException("Error executing query when attempting to delete organization by id.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(checkIfUsedStatement); - EamDbUtil.closeStatement(deleteOrgStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(checkIfUsedStatement); + CentralRepoDbUtil.closeStatement(deleteOrgStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } } @@ -2517,20 +2517,20 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return The ID of the new global set * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public int newReferenceSet(EamGlobalSet eamGlobalSet) throws EamDbException { + public int newReferenceSet(CentralRepoFileSet eamGlobalSet) throws CentralRepoException { if (eamGlobalSet == null) { - throw new EamDbException("EamGlobalSet is null"); + throw new CentralRepoException("EamGlobalSet is null"); } if (eamGlobalSet.getFileKnownStatus() == null) { - throw new EamDbException("File known status on the EamGlobalSet is null"); + throw new CentralRepoException("File known status on the EamGlobalSet is null"); } if (eamGlobalSet.getType() == null) { - throw new EamDbException("Type on the EamGlobalSet is null"); + throw new CentralRepoException("Type on the EamGlobalSet is null"); } Connection conn = connect(); @@ -2565,12 +2565,12 @@ abstract class AbstractSqlEamDb implements EamDb { return resultSet.getInt("id"); } catch (SQLException ex) { - throw new EamDbException("Error inserting new global set.", ex); // NON-NLS + throw new CentralRepoException("Error inserting new global set.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement1); - EamDbUtil.closeStatement(preparedStatement2); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement1); + CentralRepoDbUtil.closeStatement(preparedStatement2); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } } @@ -2581,10 +2581,10 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return The global set associated with the ID * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public EamGlobalSet getReferenceSetByID(int referenceSetID) throws EamDbException { + public CentralRepoFileSet getReferenceSetByID(int referenceSetID) throws CentralRepoException { Connection conn = connect(); PreparedStatement preparedStatement1 = null; @@ -2602,11 +2602,11 @@ abstract class AbstractSqlEamDb implements EamDb { } } catch (SQLException ex) { - throw new EamDbException("Error getting reference set by id.", ex); // NON-NLS + throw new CentralRepoException("Error getting reference set by id.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement1); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement1); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } } @@ -2617,16 +2617,16 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return List of all reference sets in the central repository * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public List getAllReferenceSets(CorrelationAttributeInstance.Type correlationType) throws EamDbException { + public List getAllReferenceSets(CorrelationAttributeInstance.Type correlationType) throws CentralRepoException { if (correlationType == null) { - throw new EamDbException("Correlation type is null"); + throw new CentralRepoException("Correlation type is null"); } - List results = new ArrayList<>(); + List results = new ArrayList<>(); Connection conn = connect(); PreparedStatement preparedStatement1 = null; @@ -2641,11 +2641,11 @@ abstract class AbstractSqlEamDb implements EamDb { } } catch (SQLException ex) { - throw new EamDbException("Error getting reference sets.", ex); // NON-NLS + throw new CentralRepoException("Error getting reference sets.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement1); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement1); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return results; } @@ -2657,15 +2657,15 @@ abstract class AbstractSqlEamDb implements EamDb { * @param correlationType Correlation Type that this Reference * Instance is * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void addReferenceInstance(EamGlobalFileInstance eamGlobalFileInstance, CorrelationAttributeInstance.Type correlationType) throws EamDbException { + public void addReferenceInstance(CentralRepoFileInstance eamGlobalFileInstance, CorrelationAttributeInstance.Type correlationType) throws CentralRepoException { if (eamGlobalFileInstance.getKnownStatus() == null) { - throw new EamDbException("Known status of EamGlobalFileInstance is null"); + throw new CentralRepoException("Known status of EamGlobalFileInstance is null"); } if (correlationType == null) { - throw new EamDbException("Correlation type is null"); + throw new CentralRepoException("Correlation type is null"); } Connection conn = connect(); @@ -2676,17 +2676,17 @@ abstract class AbstractSqlEamDb implements EamDb { + getConflictClause(); try { - preparedStatement = conn.prepareStatement(String.format(sql, EamDbUtil.correlationTypeToReferenceTableName(correlationType))); + preparedStatement = conn.prepareStatement(String.format(sql, CentralRepoDbUtil.correlationTypeToReferenceTableName(correlationType))); preparedStatement.setInt(1, eamGlobalFileInstance.getGlobalSetID()); preparedStatement.setString(2, eamGlobalFileInstance.getMD5Hash()); preparedStatement.setByte(3, eamGlobalFileInstance.getKnownStatus().getFileKnownValue()); preparedStatement.setString(4, eamGlobalFileInstance.getComment()); preparedStatement.executeUpdate(); } catch (SQLException ex) { - throw new EamDbException("Error inserting new reference instance into reference_ table.", ex); // NON-NLS + throw new CentralRepoException("Error inserting new reference instance into reference_ table.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeConnection(conn); } } @@ -2700,10 +2700,10 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return true if a matching set is found * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public boolean referenceSetExists(String referenceSetName, String version) throws EamDbException { + public boolean referenceSetExists(String referenceSetName, String version) throws CentralRepoException { Connection conn = connect(); PreparedStatement preparedStatement1 = null; @@ -2718,27 +2718,27 @@ abstract class AbstractSqlEamDb implements EamDb { return (resultSet.next()); } catch (SQLException ex) { - throw new EamDbException("Error testing whether reference set exists (name: " + referenceSetName + throw new CentralRepoException("Error testing whether reference set exists (name: " + referenceSetName + " version: " + version, ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement1); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement1); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } } /** * Insert the bulk collection of Reference Type Instances * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void bulkInsertReferenceTypeEntries(Set globalInstances, CorrelationAttributeInstance.Type contentType) throws EamDbException { + public void bulkInsertReferenceTypeEntries(Set globalInstances, CorrelationAttributeInstance.Type contentType) throws CentralRepoException { if (contentType == null) { - throw new EamDbException("Correlation type is null"); + throw new CentralRepoException("Correlation type is null"); } if (globalInstances == null) { - throw new EamDbException("Null set of EamGlobalFileInstance"); + throw new CentralRepoException("Null set of EamGlobalFileInstance"); } Connection conn = connect(); @@ -2751,11 +2751,11 @@ abstract class AbstractSqlEamDb implements EamDb { String sql = "INSERT INTO %s(reference_set_id, value, known_status, comment) VALUES (?, ?, ?, ?) " + getConflictClause(); - bulkPs = conn.prepareStatement(String.format(sql, EamDbUtil.correlationTypeToReferenceTableName(contentType))); + bulkPs = conn.prepareStatement(String.format(sql, CentralRepoDbUtil.correlationTypeToReferenceTableName(contentType))); - for (EamGlobalFileInstance globalInstance : globalInstances) { + for (CentralRepoFileInstance globalInstance : globalInstances) { if (globalInstance.getKnownStatus() == null) { - throw new EamDbException("EamGlobalFileInstance with value " + globalInstance.getMD5Hash() + " has null known status"); + throw new CentralRepoException("EamGlobalFileInstance with value " + globalInstance.getMD5Hash() + " has null known status"); } bulkPs.setInt(1, globalInstance.getGlobalSetID()); @@ -2767,16 +2767,16 @@ abstract class AbstractSqlEamDb implements EamDb { bulkPs.executeBatch(); conn.commit(); - } catch (SQLException | EamDbException ex) { + } catch (SQLException | CentralRepoException ex) { try { conn.rollback(); } catch (SQLException ex2) { // We're alredy in an error state } - throw new EamDbException("Error inserting bulk artifacts.", ex); // NON-NLS + throw new CentralRepoException("Error inserting bulk artifacts.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(bulkPs); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(bulkPs); + CentralRepoDbUtil.closeConnection(conn); } } @@ -2788,21 +2788,21 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return List of all global file instances with a type and value * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public List getReferenceInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String aValue) throws EamDbException, CorrelationAttributeNormalizationException { + public List getReferenceInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String aValue) throws CentralRepoException, CorrelationAttributeNormalizationException { String normalizeValued = CorrelationAttributeNormalizer.normalize(aType, aValue); Connection conn = connect(); - List globalFileInstances = new ArrayList<>(); + List globalFileInstances = new ArrayList<>(); PreparedStatement preparedStatement1 = null; ResultSet resultSet = null; String sql1 = "SELECT * FROM %s WHERE value=?"; try { - preparedStatement1 = conn.prepareStatement(String.format(sql1, EamDbUtil.correlationTypeToReferenceTableName(aType))); + preparedStatement1 = conn.prepareStatement(String.format(sql1, CentralRepoDbUtil.correlationTypeToReferenceTableName(aType))); preparedStatement1.setString(1, normalizeValued); resultSet = preparedStatement1.executeQuery(); while (resultSet.next()) { @@ -2810,11 +2810,11 @@ abstract class AbstractSqlEamDb implements EamDb { } } catch (SQLException ex) { - throw new EamDbException("Error getting reference instances by type and value.", ex); // NON-NLS + throw new CentralRepoException("Error getting reference instances by type and value.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement1); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement1); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return globalFileInstances; @@ -2827,12 +2827,12 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return ID of this new Correlation Type * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public int newCorrelationType(CorrelationAttributeInstance.Type newType) throws EamDbException { + public int newCorrelationType(CorrelationAttributeInstance.Type newType) throws CentralRepoException { if (newType == null) { - throw new EamDbException("Correlation type is null"); + throw new CentralRepoException("Correlation type is null"); } int typeId; if (-1 == newType.getId()) { @@ -2852,9 +2852,9 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return ID of this new Correlation Type * - * @throws EamDbException + * @throws CentralRepoException */ - public int newCorrelationTypeNotKnownId(CorrelationAttributeInstance.Type newType) throws EamDbException { + public int newCorrelationTypeNotKnownId(CorrelationAttributeInstance.Type newType) throws CentralRepoException { Connection conn = connect(); PreparedStatement preparedStatement = null; @@ -2888,12 +2888,12 @@ abstract class AbstractSqlEamDb implements EamDb { typeId = correlationType.getId(); } } catch (SQLException ex) { - throw new EamDbException("Error inserting new correlation type.", ex); // NON-NLS + throw new CentralRepoException("Error inserting new correlation type.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeStatement(preparedStatementQuery); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeStatement(preparedStatementQuery); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return typeId; } @@ -2905,9 +2905,9 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return ID of this new Correlation Type * - * @throws EamDbException + * @throws CentralRepoException */ - private int newCorrelationTypeKnownId(CorrelationAttributeInstance.Type newType) throws EamDbException { + private int newCorrelationTypeKnownId(CorrelationAttributeInstance.Type newType) throws CentralRepoException { Connection conn = connect(); PreparedStatement preparedStatement = null; @@ -2942,18 +2942,18 @@ abstract class AbstractSqlEamDb implements EamDb { typeId = correlationType.getId(); } } catch (SQLException ex) { - throw new EamDbException("Error inserting new correlation type.", ex); // NON-NLS + throw new CentralRepoException("Error inserting new correlation type.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeStatement(preparedStatementQuery); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeStatement(preparedStatementQuery); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } return typeId; } @Override - public List getDefinedCorrelationTypes() throws EamDbException { + public List getDefinedCorrelationTypes() throws CentralRepoException { Connection conn = connect(); List aTypes = new ArrayList<>(); @@ -2970,11 +2970,11 @@ abstract class AbstractSqlEamDb implements EamDb { return aTypes; } catch (SQLException ex) { - throw new EamDbException("Error getting all correlation types.", ex); // NON-NLS + throw new CentralRepoException("Error getting all correlation types.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } } @@ -2985,10 +2985,10 @@ abstract class AbstractSqlEamDb implements EamDb { * @return List of enabled EamArtifact.Type's. If none are defined in the * database, the default list will be returned. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public List getEnabledCorrelationTypes() throws EamDbException { + public List getEnabledCorrelationTypes() throws CentralRepoException { Connection conn = connect(); List aTypes = new ArrayList<>(); @@ -3005,11 +3005,11 @@ abstract class AbstractSqlEamDb implements EamDb { return aTypes; } catch (SQLException ex) { - throw new EamDbException("Error getting enabled correlation types.", ex); // NON-NLS + throw new CentralRepoException("Error getting enabled correlation types.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } } @@ -3020,10 +3020,10 @@ abstract class AbstractSqlEamDb implements EamDb { * @return List of supported EamArtifact.Type's. If none are defined in the * database, the default list will be returned. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public List getSupportedCorrelationTypes() throws EamDbException { + public List getSupportedCorrelationTypes() throws CentralRepoException { Connection conn = connect(); List aTypes = new ArrayList<>(); @@ -3040,11 +3040,11 @@ abstract class AbstractSqlEamDb implements EamDb { return aTypes; } catch (SQLException ex) { - throw new EamDbException("Error getting supported correlation types.", ex); // NON-NLS + throw new CentralRepoException("Error getting supported correlation types.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } } @@ -3053,10 +3053,10 @@ abstract class AbstractSqlEamDb implements EamDb { * * @param aType EamArtifact.Type to update. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void updateCorrelationType(CorrelationAttributeInstance.Type aType) throws EamDbException { + public void updateCorrelationType(CorrelationAttributeInstance.Type aType) throws CentralRepoException { Connection conn = connect(); PreparedStatement preparedStatement = null; @@ -3072,10 +3072,10 @@ abstract class AbstractSqlEamDb implements EamDb { preparedStatement.executeUpdate(); typeCache.put(aType.getId(), aType); } catch (SQLException ex) { - throw new EamDbException("Error updating correlation type.", ex); // NON-NLS + throw new CentralRepoException("Error updating correlation type.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeConnection(conn); } } @@ -3087,17 +3087,17 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return EamArtifact.Type or null if it doesn't exist. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public CorrelationAttributeInstance.Type getCorrelationTypeById(int typeId) throws EamDbException { + public CorrelationAttributeInstance.Type getCorrelationTypeById(int typeId) throws CentralRepoException { try { return typeCache.get(typeId, () -> getCorrelationTypeByIdFromCr(typeId)); } catch (CacheLoader.InvalidCacheLoadException ignored) { //lambda valueloader returned a null value and cache can not store null values this is normal if the correlation type does not exist in the central repo yet return null; } catch (ExecutionException ex) { - throw new EamDbException("Error getting correlation type", ex); + throw new CentralRepoException("Error getting correlation type", ex); } } @@ -3108,9 +3108,9 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return EamArtifact.Type or null if it doesn't exist. * - * @throws EamDbException + * @throws CentralRepoException */ - private CorrelationAttributeInstance.Type getCorrelationTypeByIdFromCr(int typeId) throws EamDbException { + private CorrelationAttributeInstance.Type getCorrelationTypeByIdFromCr(int typeId) throws CentralRepoException { Connection conn = connect(); CorrelationAttributeInstance.Type aType; @@ -3126,15 +3126,15 @@ abstract class AbstractSqlEamDb implements EamDb { aType = getCorrelationTypeFromResultSet(resultSet); return aType; } else { - throw new EamDbException("Failed to find entry for correlation type ID = " + typeId); + throw new CentralRepoException("Failed to find entry for correlation type ID = " + typeId); } } catch (SQLException ex) { - throw new EamDbException("Error getting correlation type by id.", ex); // NON-NLS + throw new CentralRepoException("Error getting correlation type by id.", ex); // NON-NLS } finally { - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeConnection(conn); } } @@ -3153,12 +3153,12 @@ abstract class AbstractSqlEamDb implements EamDb { return null; } - EamOrganization eamOrg = null; + CentralRepoOrganization eamOrg = null; resultSet.getInt("org_id"); if (!resultSet.wasNull()) { - eamOrg = new EamOrganization(resultSet.getInt("org_id"), + eamOrg = new CentralRepoOrganization(resultSet.getInt("org_id"), resultSet.getString("org_name"), resultSet.getString("poc_name"), resultSet.getString("poc_email"), @@ -3191,7 +3191,7 @@ abstract class AbstractSqlEamDb implements EamDb { return eamDataSource; } - private CorrelationAttributeInstance.Type getCorrelationTypeFromResultSet(ResultSet resultSet) throws EamDbException, SQLException { + private CorrelationAttributeInstance.Type getCorrelationTypeFromResultSet(ResultSet resultSet) throws CentralRepoException, SQLException { if (null == resultSet) { return null; } @@ -3217,12 +3217,12 @@ abstract class AbstractSqlEamDb implements EamDb { * * @throws SQLException when an expected column name is not in the resultSet */ - private CorrelationAttributeInstance getEamArtifactInstanceFromResultSet(ResultSet resultSet, CorrelationAttributeInstance.Type aType) throws SQLException, EamDbException, CorrelationAttributeNormalizationException { + private CorrelationAttributeInstance getEamArtifactInstanceFromResultSet(ResultSet resultSet, CorrelationAttributeInstance.Type aType) throws SQLException, CentralRepoException, CorrelationAttributeNormalizationException { if (null == resultSet) { return null; } - EamOrganization eamOrg = new EamOrganization(resultSet.getInt("org_id"), + CentralRepoOrganization eamOrg = new CentralRepoOrganization(resultSet.getInt("org_id"), resultSet.getString("org_name"), resultSet.getString("poc_name"), resultSet.getString("poc_email"), @@ -3244,12 +3244,12 @@ abstract class AbstractSqlEamDb implements EamDb { resultSet.getLong("file_obj_id")); } - private EamOrganization getEamOrganizationFromResultSet(ResultSet resultSet) throws SQLException { + private CentralRepoOrganization getEamOrganizationFromResultSet(ResultSet resultSet) throws SQLException { if (null == resultSet) { return null; } - return new EamOrganization( + return new CentralRepoOrganization( resultSet.getInt("id"), resultSet.getString("org_name"), resultSet.getString("poc_name"), @@ -3258,29 +3258,29 @@ abstract class AbstractSqlEamDb implements EamDb { ); } - private EamGlobalSet getEamGlobalSetFromResultSet(ResultSet resultSet) throws SQLException, EamDbException { + private CentralRepoFileSet getEamGlobalSetFromResultSet(ResultSet resultSet) throws SQLException, CentralRepoException { if (null == resultSet) { return null; } - return new EamGlobalSet( + return new CentralRepoFileSet( resultSet.getInt("id"), resultSet.getInt("org_id"), resultSet.getString("set_name"), resultSet.getString("version"), TskData.FileKnown.valueOf(resultSet.getByte("known_status")), resultSet.getBoolean("read_only"), - EamDb.getInstance().getCorrelationTypeById(resultSet.getInt("type")), + CentralRepository.getInstance().getCorrelationTypeById(resultSet.getInt("type")), LocalDate.parse(resultSet.getString("import_date")) ); } - private EamGlobalFileInstance getEamGlobalFileInstanceFromResultSet(ResultSet resultSet) throws SQLException, EamDbException, CorrelationAttributeNormalizationException { + private CentralRepoFileInstance getEamGlobalFileInstanceFromResultSet(ResultSet resultSet) throws SQLException, CentralRepoException, CorrelationAttributeNormalizationException { if (null == resultSet) { return null; } - return new EamGlobalFileInstance( + return new CentralRepoFileInstance( resultSet.getInt("id"), resultSet.getInt("reference_set_id"), resultSet.getString("value"), @@ -3297,14 +3297,14 @@ abstract class AbstractSqlEamDb implements EamDb { * * @return true if the column exists, false if the column does not exist * - * @throws EamDbException + * @throws CentralRepoException */ abstract boolean doesColumnExist(Connection conn, String tableName, String columnName) throws SQLException; /** * Upgrade the schema of the database (if needed) * - * @throws EamDbException + * @throws CentralRepoException */ @Messages({"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.", "# {0} - minorVersion", @@ -3316,45 +3316,45 @@ abstract class AbstractSqlEamDb implements EamDb { "# {0} - platformName", "AbstractSqlEamDb.cannotUpgrage.message=Currently selected database platform \"{0}\" can not be upgraded."}) @Override - public void upgradeSchema() throws EamDbException, SQLException, IncompatibleCentralRepoException { + public void upgradeSchema() throws CentralRepoException, SQLException, IncompatibleCentralRepoException { ResultSet resultSet = null; Statement statement = null; PreparedStatement preparedStatement = null; Connection conn = null; - EamDbPlatformEnum selectedPlatform = null; + CentralRepoPlatforms selectedPlatform = null; try { conn = connect(false); conn.setAutoCommit(false); statement = conn.createStatement(); - selectedPlatform = EamDbPlatformEnum.getSelectedPlatform(); + selectedPlatform = CentralRepoPlatforms.getSelectedPlatform(); int minorVersion = 0; String minorVersionStr = null; - resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name='" + AbstractSqlEamDb.SCHEMA_MINOR_VERSION_KEY + "'"); + resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name='" + AbstractCentralRepo.SCHEMA_MINOR_VERSION_KEY + "'"); if (resultSet.next()) { minorVersionStr = resultSet.getString("value"); try { minorVersion = Integer.parseInt(minorVersionStr); } catch (NumberFormatException ex) { - throw new EamDbException("Bad value for schema minor version (" + minorVersionStr + ") - database is corrupt", Bundle.AbstractSqlEamDb_badMinorSchema_message(minorVersionStr), ex); + throw new CentralRepoException("Bad value for schema minor version (" + minorVersionStr + ") - database is corrupt", Bundle.AbstractSqlEamDb_badMinorSchema_message(minorVersionStr), ex); } } else { - throw new EamDbException("Failed to read schema minor version from db_info table", Bundle.AbstractSqlEamDb_failedToReadMinorVersion_message()); + throw new CentralRepoException("Failed to read schema minor version from db_info table", Bundle.AbstractSqlEamDb_failedToReadMinorVersion_message()); } int majorVersion = 0; String majorVersionStr = null; - resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name='" + AbstractSqlEamDb.SCHEMA_MAJOR_VERSION_KEY + "'"); + resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name='" + AbstractCentralRepo.SCHEMA_MAJOR_VERSION_KEY + "'"); if (resultSet.next()) { majorVersionStr = resultSet.getString("value"); try { majorVersion = Integer.parseInt(majorVersionStr); } catch (NumberFormatException ex) { - throw new EamDbException("Bad value for schema version (" + majorVersionStr + ") - database is corrupt", Bundle.AbstractSqlEamDb_badMajorSchema_message(majorVersionStr), ex); + throw new CentralRepoException("Bad value for schema version (" + majorVersionStr + ") - database is corrupt", Bundle.AbstractSqlEamDb_badMajorSchema_message(majorVersionStr), ex); } } else { - throw new EamDbException("Failed to read schema major version from db_info table", Bundle.AbstractSqlEamDb_failedToReadMajorVersion_message()); + throw new CentralRepoException("Failed to read schema major version from db_info table", Bundle.AbstractSqlEamDb_failedToReadMajorVersion_message()); } /* @@ -3393,7 +3393,7 @@ abstract class AbstractSqlEamDb implements EamDb { // There's an outide chance that the user has already made an organization with the default name, // and the default org being missing will not impact any database operations, so continue on // regardless of whether this succeeds. - EamDbUtil.insertDefaultOrganization(conn); + CentralRepoDbUtil.insertDefaultOrganization(conn); } /* @@ -3414,25 +3414,25 @@ abstract class AbstractSqlEamDb implements EamDb { case POSTGRESQL: addAttributeSql = "INSERT INTO correlation_types(id, display_name, db_table_name, supported, enabled) VALUES (?, ?, ?, ?, ?) " + getConflictClause(); //NON-NLS - addSsidTableTemplate = PostgresEamDbSettings.getCreateArtifactInstancesTableTemplate(); - addCaseIdIndexTemplate = PostgresEamDbSettings.getAddCaseIdIndexTemplate(); - addDataSourceIdIndexTemplate = PostgresEamDbSettings.getAddDataSourceIdIndexTemplate(); - addValueIndexTemplate = PostgresEamDbSettings.getAddValueIndexTemplate(); - addKnownStatusIndexTemplate = PostgresEamDbSettings.getAddKnownStatusIndexTemplate(); - addObjectIdIndexTemplate = PostgresEamDbSettings.getAddObjectIdIndexTemplate(); + addSsidTableTemplate = PostgresCentralRepoSettings.getCreateArtifactInstancesTableTemplate(); + addCaseIdIndexTemplate = PostgresCentralRepoSettings.getAddCaseIdIndexTemplate(); + addDataSourceIdIndexTemplate = PostgresCentralRepoSettings.getAddDataSourceIdIndexTemplate(); + addValueIndexTemplate = PostgresCentralRepoSettings.getAddValueIndexTemplate(); + addKnownStatusIndexTemplate = PostgresCentralRepoSettings.getAddKnownStatusIndexTemplate(); + addObjectIdIndexTemplate = PostgresCentralRepoSettings.getAddObjectIdIndexTemplate(); break; case SQLITE: addAttributeSql = "INSERT OR IGNORE INTO correlation_types(id, display_name, db_table_name, supported, enabled) VALUES (?, ?, ?, ?, ?)"; //NON-NLS - addSsidTableTemplate = SqliteEamDbSettings.getCreateArtifactInstancesTableTemplate(); - addCaseIdIndexTemplate = SqliteEamDbSettings.getAddCaseIdIndexTemplate(); - addDataSourceIdIndexTemplate = SqliteEamDbSettings.getAddDataSourceIdIndexTemplate(); - addValueIndexTemplate = SqliteEamDbSettings.getAddValueIndexTemplate(); - addKnownStatusIndexTemplate = SqliteEamDbSettings.getAddKnownStatusIndexTemplate(); - addObjectIdIndexTemplate = SqliteEamDbSettings.getAddObjectIdIndexTemplate(); + addSsidTableTemplate = SqliteCentralRepoSettings.getCreateArtifactInstancesTableTemplate(); + addCaseIdIndexTemplate = SqliteCentralRepoSettings.getAddCaseIdIndexTemplate(); + addDataSourceIdIndexTemplate = SqliteCentralRepoSettings.getAddDataSourceIdIndexTemplate(); + addValueIndexTemplate = SqliteCentralRepoSettings.getAddValueIndexTemplate(); + addKnownStatusIndexTemplate = SqliteCentralRepoSettings.getAddKnownStatusIndexTemplate(); + addObjectIdIndexTemplate = SqliteCentralRepoSettings.getAddObjectIdIndexTemplate(); break; default: - throw new EamDbException("Currently selected database platform \"" + selectedPlatform.name() + "\" can not be upgraded.", Bundle.AbstractSqlEamDb_cannotUpgrage_message(selectedPlatform.name())); + throw new CentralRepoException("Currently selected database platform \"" + selectedPlatform.name() + "\" can not be upgraded.", Bundle.AbstractSqlEamDb_cannotUpgrage_message(selectedPlatform.name())); } final String dataSourcesTableName = "data_sources"; final String dataSourceObjectIdColumnName = "datasource_obj_id"; @@ -3512,7 +3512,7 @@ abstract class AbstractSqlEamDb implements EamDb { String instance_type_dbname; final String objectIdColumnName = "file_obj_id"; for (CorrelationAttributeInstance.Type type : CorrelationAttributeInstance.getDefaultCorrelationTypes()) { - instance_type_dbname = EamDbUtil.correlationTypeToInstanceTableName(type); + instance_type_dbname = CentralRepoDbUtil.correlationTypeToInstanceTableName(type); if (!doesColumnExist(conn, instance_type_dbname, objectIdColumnName)) { statement.execute(String.format(addIntegerColumnTemplate, instance_type_dbname, objectIdColumnName)); //NON-NLS } @@ -3541,29 +3541,29 @@ abstract class AbstractSqlEamDb implements EamDb { * indicate that it is unknown. */ String creationMajorVer; - resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name = '" + AbstractSqlEamDb.CREATION_SCHEMA_MAJOR_VERSION_KEY + "'"); + resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name = '" + AbstractCentralRepo.CREATION_SCHEMA_MAJOR_VERSION_KEY + "'"); if (resultSet.next()) { creationMajorVer = resultSet.getString("value"); } else { creationMajorVer = "0"; } String creationMinorVer; - resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name = '" + AbstractSqlEamDb.CREATION_SCHEMA_MINOR_VERSION_KEY + "'"); + resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name = '" + AbstractCentralRepo.CREATION_SCHEMA_MINOR_VERSION_KEY + "'"); if (resultSet.next()) { creationMinorVer = resultSet.getString("value"); } else { creationMinorVer = "0"; } statement.execute("DROP TABLE db_info"); - if (selectedPlatform == EamDbPlatformEnum.POSTGRESQL) { + if (selectedPlatform == CentralRepoPlatforms.POSTGRESQL) { statement.execute("CREATE TABLE db_info (id SERIAL, name TEXT UNIQUE NOT NULL, value TEXT NOT NULL)"); } else { statement.execute("CREATE TABLE db_info (id INTEGER PRIMARY KEY, name TEXT UNIQUE NOT NULL, value TEXT NOT NULL)"); } - statement.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.SCHEMA_MAJOR_VERSION_KEY + "','" + majorVersionStr + "')"); - statement.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.SCHEMA_MINOR_VERSION_KEY + "','" + minorVersionStr + "')"); - statement.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.CREATION_SCHEMA_MAJOR_VERSION_KEY + "','" + creationMajorVer + "')"); - statement.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.CREATION_SCHEMA_MINOR_VERSION_KEY + "','" + creationMinorVer + "')"); + statement.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.SCHEMA_MAJOR_VERSION_KEY + "','" + majorVersionStr + "')"); + statement.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.SCHEMA_MINOR_VERSION_KEY + "','" + minorVersionStr + "')"); + statement.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.CREATION_SCHEMA_MAJOR_VERSION_KEY + "','" + creationMajorVer + "')"); + statement.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.CREATION_SCHEMA_MINOR_VERSION_KEY + "','" + creationMinorVer + "')"); } /* * Update to 1.3 @@ -3586,19 +3586,19 @@ abstract class AbstractSqlEamDb implements EamDb { + "md5 text DEFAULT NULL,sha1 text DEFAULT NULL,sha256 text DEFAULT NULL," + "foreign key (case_id) references cases(id) ON UPDATE SET NULL ON DELETE SET NULL," + "CONSTRAINT datasource_unique UNIQUE (case_id, device_id, name, datasource_obj_id))"); - statement.execute(SqliteEamDbSettings.getAddDataSourcesNameIndexStatement()); - statement.execute(SqliteEamDbSettings.getAddDataSourcesObjectIdIndexStatement()); + statement.execute(SqliteCentralRepoSettings.getAddDataSourcesNameIndexStatement()); + statement.execute(SqliteCentralRepoSettings.getAddDataSourcesObjectIdIndexStatement()); statement.execute("INSERT INTO data_sources SELECT * FROM old_data_sources"); statement.execute("DROP TABLE old_data_sources"); break; default: - throw new EamDbException("Currently selected database platform \"" + selectedPlatform.name() + "\" can not be upgraded.", Bundle.AbstractSqlEamDb_cannotUpgrage_message(selectedPlatform.name())); + throw new CentralRepoException("Currently selected database platform \"" + selectedPlatform.name() + "\" can not be upgraded.", Bundle.AbstractSqlEamDb_cannotUpgrage_message(selectedPlatform.name())); } } updateSchemaVersion(conn); conn.commit(); logger.log(Level.INFO, String.format("Central Repository schema updated to version %s", SOFTWARE_CR_DB_SCHEMA_VERSION)); - } catch (SQLException | EamDbException ex) { + } catch (SQLException | CentralRepoException ex) { try { if (conn != null) { conn.rollback(); @@ -3608,10 +3608,10 @@ abstract class AbstractSqlEamDb implements EamDb { } throw ex; } finally { - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeStatement(preparedStatement); - EamDbUtil.closeStatement(statement); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeStatement(statement); + CentralRepoDbUtil.closeConnection(conn); } } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbUtil.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbUtil.java similarity index 81% rename from Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbUtil.java rename to Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbUtil.java index c287990d79..50e0c0252c 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbUtil.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbUtil.java @@ -1,7 +1,7 @@ /* * Central Repository * - * Copyright 2015-2017 Basis Technology Corp. + * Copyright 2015-2020 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,14 +30,14 @@ import org.sleuthkit.autopsy.coordinationservice.CoordinationService; import org.sleuthkit.autopsy.coordinationservice.CoordinationService.CoordinationServiceException; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ModuleSettings; -import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractSqlEamDb.SOFTWARE_CR_DB_SCHEMA_VERSION; +import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractCentralRepo.SOFTWARE_CR_DB_SCHEMA_VERSION; /** * */ -public class EamDbUtil { +public class CentralRepoDbUtil { - private final static Logger LOGGER = Logger.getLogger(EamDbUtil.class.getName()); + private final static Logger LOGGER = Logger.getLogger(CentralRepoDbUtil.class.getName()); private static final String CENTRAL_REPO_NAME = "CentralRepository"; private static final String CENTRAL_REPO_USE_KEY = "db.useCentralRepo"; private static final String DEFAULT_ORG_NAME = "Not Specified"; @@ -47,7 +47,7 @@ public class EamDbUtil { * * @param statement The statement to be closed. * - * @throws EamDbException + * @throws CentralRepoException */ public static void closeStatement(Statement statement) { if (null != statement) { @@ -64,7 +64,7 @@ public class EamDbUtil { * * @param resultSet * - * @throws EamDbException + * @throws CentralRepoException */ public static void closeResultSet(ResultSet resultSet) { if (null != resultSet) { @@ -81,7 +81,7 @@ public class EamDbUtil { * * @param conn An open connection * - * @throws EamDbException + * @throws CentralRepoException */ public static void closeConnection(Connection conn) { if (null != conn) { @@ -117,11 +117,11 @@ public class EamDbUtil { preparedStatement.addBatch(); } preparedStatement.executeBatch(); - } catch (EamDbException | SQLException ex) { + } catch (CentralRepoException | SQLException ex) { LOGGER.log(Level.SEVERE, "Error inserting default correlation types.", ex); // NON-NLS return false; } finally { - EamDbUtil.closePreparedStatement(preparedStatement); + CentralRepoDbUtil.closePreparedStatement(preparedStatement); } return true; } @@ -135,8 +135,8 @@ public class EamDbUtil { */ static void updateSchemaVersion(Connection conn) throws SQLException { try (Statement statement = conn.createStatement()) { - statement.execute("UPDATE db_info SET value = '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "' WHERE name = '" + AbstractSqlEamDb.SCHEMA_MAJOR_VERSION_KEY + "'"); - statement.execute("UPDATE db_info SET value = '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "' WHERE name = '" + AbstractSqlEamDb.SCHEMA_MINOR_VERSION_KEY + "'"); + statement.execute("UPDATE db_info SET value = '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "' WHERE name = '" + AbstractCentralRepo.SCHEMA_MAJOR_VERSION_KEY + "'"); + statement.execute("UPDATE db_info SET value = '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "' WHERE name = '" + AbstractCentralRepo.SCHEMA_MINOR_VERSION_KEY + "'"); } } @@ -161,7 +161,7 @@ public class EamDbUtil { } catch (SQLException ex) { return false; } finally { - EamDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeResultSet(resultSet); } return true; } @@ -175,20 +175,20 @@ public class EamDbUtil { "EamDbUtil.centralRepoUpgradeFailed.message=Failed to upgrade Central Repository.", "EamDbUtil.centralRepoConnectionFailed.message=Unable to connect to Central Repository.", "EamDbUtil.exclusiveLockAquisitionFailure.message=Unable to acquire exclusive lock for Central Repository."}) - public static void upgradeDatabase() throws EamDbException { - if (!EamDb.isEnabled()) { + public static void upgradeDatabase() throws CentralRepoException { + if (!CentralRepository.isEnabled()) { return; } - EamDb db = null; + CentralRepository db = null; CoordinationService.Lock lock = null; //get connection try { try { - db = EamDb.getInstance(); - } catch (EamDbException ex) { + db = CentralRepository.getInstance(); + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error updating central repository, unable to make connection", ex); - throw new EamDbException("Error updating central repository, unable to make connection", Bundle.EamDbUtil_centralRepoConnectionFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message(), ex); + throw new CentralRepoException("Error updating central repository, unable to make connection", Bundle.EamDbUtil_centralRepoConnectionFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message(), ex); } //get lock necessary for upgrade if (db != null) { @@ -198,22 +198,22 @@ public class EamDbUtil { // (meaning the database is in use by another user) lock = db.getExclusiveMultiUserDbLock(); //perform upgrade - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error updating central repository, unable to acquire exclusive lock", ex); - throw new EamDbException("Error updating central repository, unable to acquire exclusive lock", Bundle.EamDbUtil_exclusiveLockAquisitionFailure_message() + Bundle.EamDbUtil_centralRepoDisabled_message(), ex); + throw new CentralRepoException("Error updating central repository, unable to acquire exclusive lock", Bundle.EamDbUtil_exclusiveLockAquisitionFailure_message() + Bundle.EamDbUtil_centralRepoDisabled_message(), ex); } try { db.upgradeSchema(); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error updating central repository", ex); - throw new EamDbException("Error updating central repository", ex.getUserMessage() + Bundle.EamDbUtil_centralRepoDisabled_message(), ex); + throw new CentralRepoException("Error updating central repository", ex.getUserMessage() + Bundle.EamDbUtil_centralRepoDisabled_message(), ex); } catch (SQLException ex) { LOGGER.log(Level.SEVERE, "Error updating central repository", ex); - throw new EamDbException("Error updating central repository", Bundle.EamDbUtil_centralRepoUpgradeFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message(), ex); + throw new CentralRepoException("Error updating central repository", Bundle.EamDbUtil_centralRepoUpgradeFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message(), ex); } catch (IncompatibleCentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error updating central repository", ex); - throw new EamDbException("Error updating central repository", ex.getMessage() + "\n\n" + Bundle.EamDbUtil_centralRepoUpgradeFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message(), ex); + throw new CentralRepoException("Error updating central repository", ex.getMessage() + "\n\n" + Bundle.EamDbUtil_centralRepoUpgradeFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message(), ex); } finally { if (lock != null) { try { @@ -224,19 +224,19 @@ public class EamDbUtil { } } } else { - throw new EamDbException("Unable to connect to database", Bundle.EamDbUtil_centralRepoConnectionFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message()); + throw new CentralRepoException("Unable to connect to database", Bundle.EamDbUtil_centralRepoConnectionFailed_message() + Bundle.EamDbUtil_centralRepoDisabled_message()); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // Disable the central repo and clear the current settings. try { - if (null != EamDb.getInstance()) { - EamDb.getInstance().shutdownConnections(); + if (null != CentralRepository.getInstance()) { + CentralRepository.getInstance().shutdownConnections(); } - } catch (EamDbException ex2) { + } catch (CentralRepoException ex2) { LOGGER.log(Level.SEVERE, "Error shutting down central repo connection pool", ex2); } - EamDbPlatformEnum.setSelectedPlatform(EamDbPlatformEnum.DISABLED.name()); - EamDbPlatformEnum.saveSelectedPlatform(); + CentralRepoPlatforms.setSelectedPlatform(CentralRepoPlatforms.DISABLED.name()); + CentralRepoPlatforms.saveSelectedPlatform(); throw ex; } } @@ -257,7 +257,7 @@ public class EamDbUtil { * * @return true if it is the default org, false otherwise */ - public static boolean isDefaultOrg(EamOrganization org) { + public static boolean isDefaultOrg(CentralRepoOrganization org) { return DEFAULT_ORG_NAME.equals(org.getName()); } @@ -286,7 +286,7 @@ public class EamDbUtil { LOGGER.log(Level.SEVERE, "Error adding default organization", ex); return false; } finally { - EamDbUtil.closePreparedStatement(preparedStatement); + CentralRepoDbUtil.closePreparedStatement(preparedStatement); } return true; @@ -338,7 +338,7 @@ public class EamDbUtil { } catch (SQLException ex) { return false; } finally { - EamDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeResultSet(resultSet); } return false; @@ -373,7 +373,7 @@ public class EamDbUtil { * * @deprecated Use closeStatement() instead. * - * @throws EamDbException + * @throws CentralRepoException */ @Deprecated public static void closePreparedStatement(PreparedStatement preparedStatement) { diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbException.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoException.java similarity index 83% rename from Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbException.java rename to Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoException.java index 262b550f5c..24ede0803d 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbException.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoException.java @@ -1,7 +1,7 @@ /* * Central Repository * - * Copyright 2015-2019 Basis Technology Corp. + * Copyright 2015-2020 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +23,7 @@ import org.sleuthkit.autopsy.exceptions.AutopsyException; /** * An exception to be thrown by an artifact manager. */ -public class EamDbException extends AutopsyException { +public class CentralRepoException extends AutopsyException { private static final long serialVersionUID = 1L; @@ -32,7 +32,7 @@ public class EamDbException extends AutopsyException { * * @param message The exception message. */ - public EamDbException(String message) { + public CentralRepoException(String message) { super(message); } @@ -42,7 +42,7 @@ public class EamDbException extends AutopsyException { * @param message Exception message. * @param userMessage the user friendly message to include in this exception */ - public EamDbException(String message, String userMessage) { + public CentralRepoException(String message, String userMessage) { super(message, userMessage); } @@ -54,7 +54,7 @@ public class EamDbException extends AutopsyException { * @param userMessage the user friendly message to include in this exception * @param cause Exception cause. */ - public EamDbException(String message, String userMessage, Throwable cause) { + public CentralRepoException(String message, String userMessage, Throwable cause) { super(message, userMessage, cause); } @@ -64,7 +64,7 @@ public class EamDbException extends AutopsyException { * @param message The exception message. * @param cause The exception cause. */ - public EamDbException(String message, Throwable cause) { + public CentralRepoException(String message, Throwable cause) { super(message, cause); } } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamGlobalFileInstance.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoFileInstance.java similarity index 87% rename from Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamGlobalFileInstance.java rename to Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoFileInstance.java index 9f51752251..bd243f812a 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamGlobalFileInstance.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoFileInstance.java @@ -1,7 +1,7 @@ /* * Central Repository * - * Copyright 2015-2017 Basis Technology Corp. + * Copyright 2015-2020 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,7 +24,7 @@ import org.sleuthkit.datamodel.TskData; /** * Global file hash instance */ -public class EamGlobalFileInstance { +public class CentralRepoFileInstance { private int instanceID; private int globalSetID; @@ -32,23 +32,23 @@ public class EamGlobalFileInstance { private TskData.FileKnown knownStatus; private String comment; - public EamGlobalFileInstance( + public CentralRepoFileInstance( int globalSetID, String MD5Hash, TskData.FileKnown knownStatus, - String comment) throws EamDbException, CorrelationAttributeNormalizationException { + String comment) throws CentralRepoException, CorrelationAttributeNormalizationException { this(-1, globalSetID, MD5Hash, knownStatus, comment); } - public EamGlobalFileInstance( + public CentralRepoFileInstance( int instanceID, int globalSetID, String MD5Hash, TskData.FileKnown knownStatus, - String comment) throws EamDbException, CorrelationAttributeNormalizationException { + String comment) throws CentralRepoException, CorrelationAttributeNormalizationException { if(knownStatus == null){ - throw new EamDbException("null known status"); + throw new CentralRepoException("null known status"); } this.instanceID = instanceID; this.globalSetID = globalSetID; @@ -61,7 +61,7 @@ public class EamGlobalFileInstance { public boolean equals(Object otherInstance) { if (this == otherInstance) { return true; - } else if (!(otherInstance instanceof EamGlobalFileInstance)) { + } else if (!(otherInstance instanceof CentralRepoFileInstance)) { return false; } else { return (this.hashCode() == otherInstance.hashCode()); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamGlobalSet.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoFileSet.java similarity index 96% rename from Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamGlobalSet.java rename to Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoFileSet.java index e9a230740c..1288efcd56 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamGlobalSet.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoFileSet.java @@ -1,7 +1,7 @@ /* * Central Repository * - * Copyright 2015-2017 Basis Technology Corp. + * Copyright 2015-2020 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,7 +24,7 @@ import org.sleuthkit.datamodel.TskData; /** * A global set in the Central Repository database */ -public class EamGlobalSet { +public class CentralRepoFileSet { private int globalSetID; private int orgID; @@ -35,7 +35,7 @@ public class EamGlobalSet { private CorrelationAttributeInstance.Type type; private LocalDate importDate; - public EamGlobalSet( + public CentralRepoFileSet( int globalSetID, int orgID, String setName, @@ -54,7 +54,7 @@ public class EamGlobalSet { this.importDate = importDate; } - public EamGlobalSet( + public CentralRepoFileSet( int orgID, String setName, String version, @@ -77,7 +77,7 @@ public class EamGlobalSet { * @param isReadOnly * @param type */ - public EamGlobalSet( + public CentralRepoFileSet( int orgID, String setName, String version, diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamOrganization.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoOrganization.java similarity index 94% rename from Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamOrganization.java rename to Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoOrganization.java index ba88798128..753c9e24d5 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamOrganization.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoOrganization.java @@ -21,7 +21,7 @@ package org.sleuthkit.autopsy.centralrepository.datamodel; /** * An organization in the Central Repository database */ -public class EamOrganization { +public class CentralRepoOrganization { private int orgID; private String name; @@ -29,7 +29,7 @@ public class EamOrganization { private String pocEmail; private String pocPhone; - EamOrganization( + CentralRepoOrganization( int orgID, String name, String pocName, @@ -42,7 +42,7 @@ public class EamOrganization { this.pocPhone = pocPhone; } - public EamOrganization( + public CentralRepoOrganization( String name, String pocName, String pocEmail, @@ -50,12 +50,12 @@ public class EamOrganization { this(-1, name, pocName, pocEmail, pocPhone); } - public EamOrganization( + public CentralRepoOrganization( String name) { this(-1, name, "", "", ""); } - public static EamOrganization getDefault() { + public static CentralRepoOrganization getDefault() { // TODO: when we allow the user to configure/specify the default organization // this will return it. return null; diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbPlatformEnum.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoPlatforms.java similarity index 80% rename from Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbPlatformEnum.java rename to Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoPlatforms.java index 6210d5d528..bcdf009ca3 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDbPlatformEnum.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoPlatforms.java @@ -1,7 +1,7 @@ /* * Central Repository * - * Copyright 2015-2017 Basis Technology Corp. + * Copyright 2015-2020 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +23,7 @@ import org.sleuthkit.autopsy.coreutils.ModuleSettings; /** * */ -public enum EamDbPlatformEnum { +public enum CentralRepoPlatforms { DISABLED("Disabled", true), SQLITE("SQLite", false), POSTGRESQL("PostgreSQL", false); @@ -31,7 +31,7 @@ public enum EamDbPlatformEnum { private final String platformName; private Boolean selected; - EamDbPlatformEnum(String name, Boolean selected) { + CentralRepoPlatforms(String name, Boolean selected) { this.platformName = name; this.selected = selected; loadSettings(); @@ -63,12 +63,12 @@ public enum EamDbPlatformEnum { return selected; } - public static EamDbPlatformEnum fromString(String pName) { + public static CentralRepoPlatforms fromString(String pName) { if (null == pName) { return DISABLED; } - for (EamDbPlatformEnum p : EamDbPlatformEnum.values()) { + for (CentralRepoPlatforms p : CentralRepoPlatforms.values()) { if (p.toString().equalsIgnoreCase(pName)) { return p; } @@ -80,8 +80,8 @@ public enum EamDbPlatformEnum { * Save the selected platform to the config file. */ public static void saveSelectedPlatform() { - EamDbPlatformEnum selectedPlatform = DISABLED; - for (EamDbPlatformEnum p : EamDbPlatformEnum.values()) { + CentralRepoPlatforms selectedPlatform = DISABLED; + for (CentralRepoPlatforms p : CentralRepoPlatforms.values()) { if (p.isSelected()) { selectedPlatform = p; } @@ -96,8 +96,8 @@ public enum EamDbPlatformEnum { * @param platformString The name of the selected platform. */ public static void setSelectedPlatform(String platformString) { - EamDbPlatformEnum pSelected = EamDbPlatformEnum.fromString(platformString); - for (EamDbPlatformEnum p : EamDbPlatformEnum.values()) { + CentralRepoPlatforms pSelected = CentralRepoPlatforms.fromString(platformString); + for (CentralRepoPlatforms p : CentralRepoPlatforms.values()) { p.setSelected(p == pSelected); } } @@ -108,8 +108,8 @@ public enum EamDbPlatformEnum { * @return The selected platform, or if not platform is selected, default to * DISABLED. */ - public static EamDbPlatformEnum getSelectedPlatform() { - for (EamDbPlatformEnum p : EamDbPlatformEnum.values()) { + public static CentralRepoPlatforms getSelectedPlatform() { + for (CentralRepoPlatforms p : CentralRepoPlatforms.values()) { if (p.isSelected()) { return p; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java similarity index 74% rename from Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java rename to Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java index c28c0537f7..3e7ac158a9 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java @@ -1,7 +1,7 @@ /* * Central Repository * - * Copyright 2015-2019 Basis Technology Corp. + * Copyright 2015-2020 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,27 +28,27 @@ import org.sleuthkit.autopsy.coordinationservice.CoordinationService; /** * Main interface for interacting with the database */ -public interface EamDb { +public interface CentralRepository { /** * Get the instance * * @return The EamDb instance or null if one is not configured. * - * @throws EamDbException + * @throws CentralRepoException */ - static EamDb getInstance() throws EamDbException { + static CentralRepository getInstance() throws CentralRepoException { - EamDbPlatformEnum selectedPlatform = EamDbPlatformEnum.DISABLED; - if (EamDbUtil.allowUseOfCentralRepository()) { - selectedPlatform = EamDbPlatformEnum.getSelectedPlatform(); + CentralRepoPlatforms selectedPlatform = CentralRepoPlatforms.DISABLED; + if (CentralRepoDbUtil.allowUseOfCentralRepository()) { + selectedPlatform = CentralRepoPlatforms.getSelectedPlatform(); } switch (selectedPlatform) { case POSTGRESQL: - return PostgresEamDb.getInstance(); + return PostgresCentralRepo.getInstance(); case SQLITE: - return SqliteEamDb.getInstance(); + return SqliteCentralRepo.getInstance(); default: return null; } @@ -61,9 +61,9 @@ public interface EamDb { * It will not close active/in-use connections. Thus, it is vital that there * are no in-use connections when you call this method. * - * @throws EamDbException if there is a problem closing the connection pool. + * @throws CentralRepoException if there is a problem closing the connection pool. */ - void shutdownConnections() throws EamDbException; + void shutdownConnections() throws CentralRepoException; /** * Update settings @@ -83,7 +83,7 @@ public interface EamDb { /** * Reset the database (testing method) */ - void reset() throws EamDbException; + void reset() throws CentralRepoException; /** * Is the database enabled? @@ -91,8 +91,8 @@ public interface EamDb { * @return Is the database enabled */ static boolean isEnabled() { - return EamDbUtil.allowUseOfCentralRepository() - && EamDbPlatformEnum.getSelectedPlatform() != EamDbPlatformEnum.DISABLED; + return CentralRepoDbUtil.allowUseOfCentralRepository() + && CentralRepoPlatforms.getSelectedPlatform() != CentralRepoPlatforms.DISABLED; } /** @@ -101,9 +101,9 @@ public interface EamDb { * @param name Key to set * @param value Value to set * - * @throws EamDbException + * @throws CentralRepoException */ - public void newDbInfo(String name, String value) throws EamDbException; + public void newDbInfo(String name, String value) throws CentralRepoException; /** * Set the data source object id for a specific entry in the data_sources @@ -113,7 +113,7 @@ public interface EamDb { * @param dataSourceObjectId - the object id for the data source from the * caseDb */ - void addDataSourceObjectId(int rowId, long dataSourceObjectId) throws EamDbException; + void addDataSourceObjectId(int rowId, long dataSourceObjectId) throws CentralRepoException; /** * Get the value for the given name from the name/value db_info table. @@ -122,9 +122,9 @@ public interface EamDb { * * @return value associated with name. * - * @throws EamDbException + * @throws CentralRepoException */ - public String getDbInfo(String name) throws EamDbException; + public String getDbInfo(String name) throws CentralRepoException; /** * Update the value for a name in the name/value db_info table. @@ -132,9 +132,9 @@ public interface EamDb { * @param name Name to find * @param value Value to assign to name. * - * @throws EamDbException + * @throws CentralRepoException */ - public void updateDbInfo(String name, String value) throws EamDbException; + public void updateDbInfo(String name, String value) throws CentralRepoException; /** * Creates new Case in the database @@ -143,21 +143,21 @@ public interface EamDb { * * @param eamCase The case to add */ - CorrelationCase newCase(CorrelationCase eamCase) throws EamDbException; + CorrelationCase newCase(CorrelationCase eamCase) throws CentralRepoException; /** * Creates new Case in the database from the given case * * @param autopsyCase The case to add */ - CorrelationCase newCase(Case autopsyCase) throws EamDbException; + CorrelationCase newCase(Case autopsyCase) throws CentralRepoException; /** * Updates an existing Case in the database * * @param eamCase The case to update */ - void updateCase(CorrelationCase eamCase) throws EamDbException; + void updateCase(CorrelationCase eamCase) throws CentralRepoException; /** * Retrieves Central Repo case based on an Autopsy Case @@ -166,9 +166,9 @@ public interface EamDb { * * @return CR Case * - * @throws EamDbException + * @throws CentralRepoException */ - CorrelationCase getCase(Case autopsyCase) throws EamDbException; + CorrelationCase getCase(Case autopsyCase) throws CentralRepoException; /** * Retrieves Case details based on Case UUID @@ -177,7 +177,7 @@ public interface EamDb { * * @return The retrieved case */ - CorrelationCase getCaseByUUID(String caseUUID) throws EamDbException; + CorrelationCase getCaseByUUID(String caseUUID) throws CentralRepoException; /** * Retrieves Case details based on Case ID @@ -186,14 +186,14 @@ public interface EamDb { * * @return The retrieved case */ - CorrelationCase getCaseById(int caseId) throws EamDbException; + CorrelationCase getCaseById(int caseId) throws CentralRepoException; /** * Retrieves cases that are in DB. * * @return List of cases */ - List getCases() throws EamDbException; + List getCases() throws CentralRepoException; /** * Creates new Data Source in the database @@ -203,21 +203,21 @@ public interface EamDb { * @return - A CorrelationDataSource object with data source's central * repository id */ - CorrelationDataSource newDataSource(CorrelationDataSource eamDataSource) throws EamDbException; + CorrelationDataSource newDataSource(CorrelationDataSource eamDataSource) throws CentralRepoException; /** * Updates the MD5 hash value in an existing data source in the database. * * @param eamDataSource The data source to update */ - void updateDataSourceMd5Hash(CorrelationDataSource eamDataSource) throws EamDbException; + void updateDataSourceMd5Hash(CorrelationDataSource eamDataSource) throws CentralRepoException; /** * Updates the SHA-1 hash value in an existing data source in the database. * * @param eamDataSource The data source to update */ - void updateDataSourceSha1Hash(CorrelationDataSource eamDataSource) throws EamDbException; + void updateDataSourceSha1Hash(CorrelationDataSource eamDataSource) throws CentralRepoException; /** * Updates the SHA-256 hash value in an existing data source in the @@ -225,7 +225,7 @@ public interface EamDb { * * @param eamDataSource The data source to update */ - void updateDataSourceSha256Hash(CorrelationDataSource eamDataSource) throws EamDbException; + void updateDataSourceSha256Hash(CorrelationDataSource eamDataSource) throws CentralRepoException; /** * Retrieves Data Source details based on data source device ID @@ -236,7 +236,7 @@ public interface EamDb { * * @return The data source */ - CorrelationDataSource getDataSource(CorrelationCase correlationCase, Long caseDbDataSourceId) throws EamDbException; + CorrelationDataSource getDataSource(CorrelationCase correlationCase, Long caseDbDataSourceId) throws CentralRepoException; /** * Retrieves Data Source details based on data source ID @@ -247,14 +247,14 @@ public interface EamDb { * * @return The data source */ - CorrelationDataSource getDataSourceById(CorrelationCase correlationCase, int dataSourceId) throws EamDbException; + CorrelationDataSource getDataSourceById(CorrelationCase correlationCase, int dataSourceId) throws CentralRepoException; /** * Retrieves data sources that are in DB * * @return List of data sources */ - List getDataSources() throws EamDbException; + List getDataSources() throws CentralRepoException; /** * Changes the name of a data source in the DB @@ -262,9 +262,9 @@ public interface EamDb { * @param eamDataSource The data source * @param newName The new name * - * @throws EamDbException + * @throws CentralRepoException */ - void updateDataSourceName(CorrelationDataSource eamDataSource, String newName) throws EamDbException; + void updateDataSourceName(CorrelationDataSource eamDataSource, String newName) throws CentralRepoException; /** * Inserts new Artifact(s) into the database. Should add associated Case and @@ -272,7 +272,7 @@ public interface EamDb { * * @param eamArtifact The artifact to add */ - void addArtifactInstance(CorrelationAttributeInstance eamArtifact) throws EamDbException; + void addArtifactInstance(CorrelationAttributeInstance eamArtifact) throws CentralRepoException; /** * Retrieves eamArtifact instances from the database that are associated @@ -286,9 +286,9 @@ public interface EamDb { * values * * @throws CorrelationAttributeNormalizationException - * @throws EamDbException + * @throws CentralRepoException */ - List getArtifactInstancesByTypeValues(CorrelationAttributeInstance.Type aType, List values) throws EamDbException, CorrelationAttributeNormalizationException; + List getArtifactInstancesByTypeValues(CorrelationAttributeInstance.Type aType, List values) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Retrieves eamArtifact instances from the database that are associated @@ -300,9 +300,9 @@ public interface EamDb { * @return List of artifact instances for a given type/value * * @throws CorrelationAttributeNormalizationException - * @throws EamDbException + * @throws CentralRepoException */ - List getArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException; + List getArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Retrieves eamArtifact instances from the database that are associated @@ -319,9 +319,9 @@ public interface EamDb { * values for the specified cases * * @throws CorrelationAttributeNormalizationException - * @throws EamDbException + * @throws CentralRepoException */ - List getArtifactInstancesByTypeValuesAndCases(CorrelationAttributeInstance.Type aType, List values, List caseIds) throws EamDbException, CorrelationAttributeNormalizationException; + List getArtifactInstancesByTypeValuesAndCases(CorrelationAttributeInstance.Type aType, List values, List caseIds) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Retrieves number of artifact instances in the database that are @@ -333,7 +333,7 @@ public interface EamDb { * @return Number of artifact instances having ArtifactType and * ArtifactValue. */ - Long getCountArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException; + Long getCountArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Calculate the percentage of data sources that have this attribute value. @@ -342,7 +342,7 @@ public interface EamDb { * * @return Int between 0 and 100 */ - int getFrequencyPercentage(CorrelationAttributeInstance corAttr) throws EamDbException, CorrelationAttributeNormalizationException; + int getFrequencyPercentage(CorrelationAttributeInstance corAttr) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Retrieves number of unique caseDisplayName / dataSource tuples in the @@ -354,14 +354,14 @@ public interface EamDb { * * @return Number of unique tuples */ - Long getCountUniqueCaseDataSourceTuplesHavingTypeValue(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException; + Long getCountUniqueCaseDataSourceTuplesHavingTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Retrieves number of data sources in the database. * * @return Number of unique data sources */ - Long getCountUniqueDataSources() throws EamDbException; + Long getCountUniqueDataSources() throws CentralRepoException; /** * Retrieves number of eamArtifact instances in the database that are @@ -372,7 +372,7 @@ public interface EamDb { * @return Number of artifact instances having caseDisplayName and * dataSource */ - Long getCountArtifactInstancesByCaseDataSource(CorrelationDataSource correlationDataSource) throws EamDbException; + Long getCountArtifactInstancesByCaseDataSource(CorrelationDataSource correlationDataSource) throws CentralRepoException; /** * Adds an eamArtifact to an internal list to be later added to DB. Artifact @@ -381,18 +381,18 @@ public interface EamDb { * * @param eamArtifact The artifact to add */ - void addAttributeInstanceBulk(CorrelationAttributeInstance eamArtifact) throws EamDbException; + void addAttributeInstanceBulk(CorrelationAttributeInstance eamArtifact) throws CentralRepoException; /** * Executes a bulk insert of the eamArtifacts added from the * addAttributeInstanceBulk() method */ - void commitAttributeInstancesBulk() throws EamDbException; + void commitAttributeInstancesBulk() throws CentralRepoException; /** * Executes a bulk insert of the cases */ - void bulkInsertCases(List cases) throws EamDbException; + void bulkInsertCases(List cases) throws CentralRepoException; /** * Update a correlation attribute instance comment in the database with that @@ -401,9 +401,9 @@ public interface EamDb { * @param eamArtifact The correlation attribute whose database instance will * be updated. * - * @throws EamDbException + * @throws CentralRepoException */ - void updateAttributeInstanceComment(CorrelationAttributeInstance eamArtifact) throws EamDbException; + void updateAttributeInstanceComment(CorrelationAttributeInstance eamArtifact) throws CentralRepoException; /** * Find a correlation attribute in the Central Repository database given the @@ -420,10 +420,10 @@ public interface EamDb { * * @return The correlation attribute if it exists; otherwise null. * - * @throws EamDbException + * @throws CentralRepoException */ CorrelationAttributeInstance getCorrelationAttributeInstance(CorrelationAttributeInstance.Type type, CorrelationCase correlationCase, - CorrelationDataSource correlationDataSource, String value, String filePath) throws EamDbException, CorrelationAttributeNormalizationException; + CorrelationDataSource correlationDataSource, String value, String filePath) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Find a correlation attribute in the Central Repository database given the @@ -437,10 +437,10 @@ public interface EamDb { * * @return The correlation attribute if it exists; otherwise null. * - * @throws EamDbException + * @throws CentralRepoException */ CorrelationAttributeInstance getCorrelationAttributeInstance(CorrelationAttributeInstance.Type type, CorrelationCase correlationCase, - CorrelationDataSource correlationDataSource, long objectID) throws EamDbException, CorrelationAttributeNormalizationException; + CorrelationDataSource correlationDataSource, long objectID) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Sets an eamArtifact instance to the given known status. If eamArtifact @@ -449,7 +449,7 @@ public interface EamDb { * @param eamArtifact Artifact containing exactly one (1) ArtifactInstance. * @param knownStatus The status to change the artifact to */ - void setAttributeInstanceKnownStatus(CorrelationAttributeInstance eamArtifact, TskData.FileKnown knownStatus) throws EamDbException; + void setAttributeInstanceKnownStatus(CorrelationAttributeInstance eamArtifact, TskData.FileKnown knownStatus) throws CentralRepoException; /** * Count matching eamArtifacts instances that have knownStatus = "Bad". @@ -459,7 +459,7 @@ public interface EamDb { * * @return Number of matching eamArtifacts */ - Long getCountArtifactInstancesKnownBad(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException; + Long getCountArtifactInstancesKnownBad(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Gets list of distinct case display names, where each case has 1+ Artifact @@ -471,9 +471,9 @@ public interface EamDb { * @return List of cases containing this artifact with instances marked as * bad * - * @throws EamDbException + * @throws CentralRepoException */ - List getListCasesHavingArtifactInstancesKnownBad(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException; + List getListCasesHavingArtifactInstancesKnownBad(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Gets list of distinct case display names, where each case has 1+ Artifact @@ -485,18 +485,18 @@ public interface EamDb { * @return List of cases containing this artifact with instances marked as * bad * - * @throws EamDbException + * @throws CentralRepoException */ - List getListCasesHavingArtifactInstances(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException; + List getListCasesHavingArtifactInstances(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Remove a reference set and all values contained in it. * * @param referenceSetID * - * @throws EamDbException + * @throws CentralRepoException */ - public void deleteReferenceSet(int referenceSetID) throws EamDbException; + public void deleteReferenceSet(int referenceSetID) throws CentralRepoException; /** * Check whether a reference set with the given parameters exists in the @@ -509,9 +509,9 @@ public interface EamDb { * * @return true if a matching entry exists in the central repository * - * @throws EamDbException + * @throws CentralRepoException */ - public boolean referenceSetIsValid(int referenceSetID, String referenceSetName, String version) throws EamDbException; + public boolean referenceSetIsValid(int referenceSetID, String referenceSetName, String version) throws CentralRepoException; /** * Check whether a reference set with the given name/version is in the @@ -523,9 +523,9 @@ public interface EamDb { * * @return true if a matching set is found * - * @throws EamDbException + * @throws CentralRepoException */ - public boolean referenceSetExists(String referenceSetName, String version) throws EamDbException; + public boolean referenceSetExists(String referenceSetName, String version) throws CentralRepoException; /** * Check if the given file hash is in this reference set. Only searches the @@ -536,9 +536,9 @@ public interface EamDb { * * @return true if the hash is found in the reference set * - * @throws EamDbException + * @throws CentralRepoException */ - public boolean isFileHashInReferenceSet(String hash, int referenceSetID) throws EamDbException, CorrelationAttributeNormalizationException; + public boolean isFileHashInReferenceSet(String hash, int referenceSetID) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Check if the given value is in a specific reference set @@ -549,7 +549,7 @@ public interface EamDb { * * @return true if the hash is found in the reference set */ - public boolean isValueInReferenceSet(String value, int referenceSetID, int correlationTypeID) throws EamDbException, CorrelationAttributeNormalizationException; + public boolean isValueInReferenceSet(String value, int referenceSetID, int correlationTypeID) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Is the artifact known as bad according to the reference entries? @@ -559,7 +559,7 @@ public interface EamDb { * * @return Global known status of the artifact */ - boolean isArtifactKnownBadByReference(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException; + boolean isArtifactKnownBadByReference(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Add a new organization @@ -568,18 +568,18 @@ public interface EamDb { * * @return The organization with the org ID set. * - * @throws EamDbException + * @throws CentralRepoException */ - EamOrganization newOrganization(EamOrganization eamOrg) throws EamDbException; + CentralRepoOrganization newOrganization(CentralRepoOrganization eamOrg) throws CentralRepoException; /** * Get all organizations * * @return A list of all organizations * - * @throws EamDbException + * @throws CentralRepoException */ - List getOrganizations() throws EamDbException; + List getOrganizations() throws CentralRepoException; /** * Get an organization having the given ID @@ -588,9 +588,9 @@ public interface EamDb { * * @return The organization with the given ID * - * @throws EamDbException + * @throws CentralRepoException */ - EamOrganization getOrganizationByID(int orgID) throws EamDbException; + CentralRepoOrganization getOrganizationByID(int orgID) throws CentralRepoException; /** * Get the organization associated with the given reference set. @@ -599,9 +599,9 @@ public interface EamDb { * * @return The organization object * - * @throws EamDbException + * @throws CentralRepoException */ - EamOrganization getReferenceSetOrganization(int referenceSetID) throws EamDbException; + CentralRepoOrganization getReferenceSetOrganization(int referenceSetID) throws CentralRepoException; /** * Update an existing organization. @@ -609,18 +609,18 @@ public interface EamDb { * @param updatedOrganization the values the Organization with the same ID * will be updated to in the database. * - * @throws EamDbException + * @throws CentralRepoException */ - void updateOrganization(EamOrganization updatedOrganization) throws EamDbException; + void updateOrganization(CentralRepoOrganization updatedOrganization) throws CentralRepoException; /** * Delete an organization if it is not being used by any case. * * @param organizationToDelete the organization to be deleted * - * @throws EamDbException + * @throws CentralRepoException */ - void deleteOrganization(EamOrganization organizationToDelete) throws EamDbException; + void deleteOrganization(CentralRepoOrganization organizationToDelete) throws CentralRepoException; /** * Add a new Global Set @@ -629,9 +629,9 @@ public interface EamDb { * * @return The ID of the new global set * - * @throws EamDbException + * @throws CentralRepoException */ - int newReferenceSet(EamGlobalSet eamGlobalSet) throws EamDbException; + int newReferenceSet(CentralRepoFileSet eamGlobalSet) throws CentralRepoException; /** * Get a global set by ID @@ -640,9 +640,9 @@ public interface EamDb { * * @return The global set associated with the ID * - * @throws EamDbException + * @throws CentralRepoException */ - EamGlobalSet getReferenceSetByID(int globalSetID) throws EamDbException; + CentralRepoFileSet getReferenceSetByID(int globalSetID) throws CentralRepoException; /** * Get all reference sets @@ -651,9 +651,9 @@ public interface EamDb { * * @return List of all reference sets in the central repository * - * @throws EamDbException + * @throws CentralRepoException */ - List getAllReferenceSets(CorrelationAttributeInstance.Type correlationType) throws EamDbException; + List getAllReferenceSets(CorrelationAttributeInstance.Type correlationType) throws CentralRepoException; /** * Add a new reference instance @@ -662,9 +662,9 @@ public interface EamDb { * @param correlationType Correlation Type that this Reference * Instance is * - * @throws EamDbException + * @throws CentralRepoException */ - void addReferenceInstance(EamGlobalFileInstance eamGlobalFileInstance, CorrelationAttributeInstance.Type correlationType) throws EamDbException; + void addReferenceInstance(CentralRepoFileInstance eamGlobalFileInstance, CorrelationAttributeInstance.Type correlationType) throws CentralRepoException; /** * Insert the bulk collection of Global File Instances @@ -673,9 +673,9 @@ public interface EamDb { * db. * @param contentType the Type of the global instances * - * @throws EamDbException + * @throws CentralRepoException */ - void bulkInsertReferenceTypeEntries(Set globalInstances, CorrelationAttributeInstance.Type contentType) throws EamDbException; + void bulkInsertReferenceTypeEntries(Set globalInstances, CorrelationAttributeInstance.Type contentType) throws CentralRepoException; /** * Get all reference entries having a given correlation type and value @@ -685,9 +685,9 @@ public interface EamDb { * * @return List of all global file instances with a type and value * - * @throws EamDbException + * @throws CentralRepoException */ - List getReferenceInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String aValue) throws EamDbException, CorrelationAttributeNormalizationException; + List getReferenceInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String aValue) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Add a new EamArtifact.Type to the db. @@ -696,9 +696,9 @@ public interface EamDb { * * @return Type.ID for newType * - * @throws EamDbException + * @throws CentralRepoException */ - int newCorrelationType(CorrelationAttributeInstance.Type newType) throws EamDbException; + int newCorrelationType(CorrelationAttributeInstance.Type newType) throws CentralRepoException; /** * Get the list of EamArtifact.Type's that are defined in the DB and can be @@ -707,9 +707,9 @@ public interface EamDb { * @return List of EamArtifact.Type's. If none are defined in the database, * the default list will be returned. * - * @throws EamDbException + * @throws CentralRepoException */ - List getDefinedCorrelationTypes() throws EamDbException; + List getDefinedCorrelationTypes() throws CentralRepoException; /** * Get the list of enabled EamArtifact.Type's that will be used to correlate @@ -718,9 +718,9 @@ public interface EamDb { * @return List of enabled EamArtifact.Type's. If none are defined in the * database, the default list will be returned. * - * @throws EamDbException + * @throws CentralRepoException */ - List getEnabledCorrelationTypes() throws EamDbException; + List getEnabledCorrelationTypes() throws CentralRepoException; /** * Get the list of supported EamArtifact.Type's that can be used to @@ -729,18 +729,18 @@ public interface EamDb { * @return List of supported EamArtifact.Type's. If none are defined in the * database, the default list will be returned. * - * @throws EamDbException + * @throws CentralRepoException */ - List getSupportedCorrelationTypes() throws EamDbException; + List getSupportedCorrelationTypes() throws CentralRepoException; /** * Update a EamArtifact.Type. * * @param aType EamArtifact.Type to update. * - * @throws EamDbException + * @throws CentralRepoException */ - void updateCorrelationType(CorrelationAttributeInstance.Type aType) throws EamDbException; + void updateCorrelationType(CorrelationAttributeInstance.Type aType) throws CentralRepoException; /** * Get the EamArtifact.Type that has the given Type.Id. @@ -749,16 +749,16 @@ public interface EamDb { * * @return EamArtifact.Type or null if it doesn't exist. * - * @throws EamDbException + * @throws CentralRepoException */ - CorrelationAttributeInstance.Type getCorrelationTypeById(int typeId) throws EamDbException; + CorrelationAttributeInstance.Type getCorrelationTypeById(int typeId) throws CentralRepoException; /** * Upgrade the schema of the database (if needed) * - * @throws EamDbException + * @throws CentralRepoException */ - public void upgradeSchema() throws EamDbException, SQLException, IncompatibleCentralRepoException; + public void upgradeSchema() throws CentralRepoException, SQLException, IncompatibleCentralRepoException; /** * Gets an exclusive lock (if applicable). Will return the lock if @@ -768,10 +768,10 @@ public interface EamDb { * * @return the lock, or null if locking is not supported * - * @throws EamDbException if the coordination service is running but we fail + * @throws CentralRepoException if the coordination service is running but we fail * to get the lock */ - public CoordinationService.Lock getExclusiveMultiUserDbLock() throws EamDbException; + public CoordinationService.Lock getExclusiveMultiUserDbLock() throws CentralRepoException; /** * Process the Artifact instance in the EamDb @@ -779,9 +779,9 @@ public interface EamDb { * @param type EamArtifact.Type to search for * @param instanceTableCallback callback to process the instance * - * @throws EamDbException + * @throws CentralRepoException */ - void processInstanceTable(CorrelationAttributeInstance.Type type, InstanceTableCallback instanceTableCallback) throws EamDbException; + void processInstanceTable(CorrelationAttributeInstance.Type type, InstanceTableCallback instanceTableCallback) throws CentralRepoException; /** * Process the Artifact instance in the EamDb @@ -790,9 +790,9 @@ public interface EamDb { * @param instanceTableCallback callback to process the instance * @param whereClause query string to execute * - * @throws EamDbException + * @throws CentralRepoException */ - void processInstanceTableWhere(CorrelationAttributeInstance.Type type, String whereClause, InstanceTableCallback instanceTableCallback) throws EamDbException; + void processInstanceTableWhere(CorrelationAttributeInstance.Type type, String whereClause, InstanceTableCallback instanceTableCallback) throws CentralRepoException; /** * Process a SELECT query @@ -800,7 +800,7 @@ public interface EamDb { * @param selectClause query string to execute * @param instanceTableCallback callback to process the instance * - * @throws EamDbException + * @throws CentralRepoException */ - public void processSelectClause(String selectClause, InstanceTableCallback instanceTableCallback) throws EamDbException; + public void processSelectClause(String selectClause, InstanceTableCallback instanceTableCallback) throws CentralRepoException; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java index 727b5ecb0b..f13b27787d 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java @@ -58,7 +58,7 @@ public class CorrelationAttributeInstance implements Serializable { String filePath, String comment, TskData.FileKnown knownStatus, - long fileObjectId) throws EamDbException, CorrelationAttributeNormalizationException { + long fileObjectId) throws CentralRepoException, CorrelationAttributeNormalizationException { this(correlationType, correlationValue, -1, eamCase, eamDataSource, filePath, comment, knownStatus, fileObjectId); } @@ -72,9 +72,9 @@ public class CorrelationAttributeInstance implements Serializable { String comment, TskData.FileKnown knownStatus, Long fileObjectId - ) throws EamDbException, CorrelationAttributeNormalizationException { + ) throws CentralRepoException, CorrelationAttributeNormalizationException { if (filePath == null) { - throw new EamDbException("file path is null"); + throw new CentralRepoException("file path is null"); } this.correlationType = type; @@ -224,7 +224,7 @@ public class CorrelationAttributeInstance implements Serializable { /** * Load the default correlation types * - * @throws EamDbException if the Type's dbTableName has invalid + * @throws CentralRepoException if the Type's dbTableName has invalid * characters/format */ @Messages({"CorrelationType.FILES.displayName=Files", @@ -237,7 +237,7 @@ public class CorrelationAttributeInstance implements Serializable { "CorrelationType.IMEI.displayName=IMEI Number", "CorrelationType.IMSI.displayName=IMSI Number", "CorrelationType.ICCID.displayName=ICCID Number"}) - public static List getDefaultCorrelationTypes() throws EamDbException { + public static List getDefaultCorrelationTypes() throws CentralRepoException { List DEFAULT_CORRELATION_TYPES = new ArrayList<>(); DEFAULT_CORRELATION_TYPES.add(new CorrelationAttributeInstance.Type(FILES_TYPE_ID, Bundle.CorrelationType_FILES_displayName(), "file", true, true)); // NON-NLS DEFAULT_CORRELATION_TYPES.add(new CorrelationAttributeInstance.Type(DOMAIN_TYPE_ID, Bundle.CorrelationType_DOMAIN_displayName(), "domain", true, true)); // NON-NLS @@ -278,9 +278,9 @@ public class CorrelationAttributeInstance implements Serializable { */ @Messages({"CorrelationAttributeInstance.nullName.message=Database name is null.", "CorrelationAttributeInstance.invalidName.message=Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'."}) - public Type(int typeId, String displayName, String dbTableName, Boolean supported, Boolean enabled) throws EamDbException { + public Type(int typeId, String displayName, String dbTableName, Boolean supported, Boolean enabled) throws CentralRepoException { if (dbTableName == null) { - throw new EamDbException("dbTableName is null", Bundle.CorrelationAttributeInstance_nullName_message()); + throw new CentralRepoException("dbTableName is null", Bundle.CorrelationAttributeInstance_nullName_message()); } this.typeId = typeId; this.displayName = displayName; @@ -288,7 +288,7 @@ public class CorrelationAttributeInstance implements Serializable { this.supported = supported; this.enabled = enabled; if (!Pattern.matches(DB_NAMES_REGEX, dbTableName)) { - throw new EamDbException("Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'.", Bundle.CorrelationAttributeInstance_invalidName_message()); // NON-NLS + throw new CentralRepoException("Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'.", Bundle.CorrelationAttributeInstance_invalidName_message()); // NON-NLS } } @@ -305,7 +305,7 @@ public class CorrelationAttributeInstance implements Serializable { * @param supported Is this Type currently supported * @param enabled Is this Type currently enabled. */ - public Type(String displayName, String dbTableName, Boolean supported, Boolean enabled) throws EamDbException { + public Type(String displayName, String dbTableName, Boolean supported, Boolean enabled) throws CentralRepoException { this(-1, displayName, dbTableName, supported, enabled); } @@ -468,11 +468,11 @@ public class CorrelationAttributeInstance implements Serializable { * letter and can only contain lowercase letters, * numbers, and '_' characters. * - * @throws EamDbException if dbTableName contains invalid characters + * @throws CentralRepoException if dbTableName contains invalid characters */ - public void setDbTableName(String dbTableName) throws EamDbException { + public void setDbTableName(String dbTableName) throws CentralRepoException { if (!Pattern.matches(DB_NAMES_REGEX, dbTableName)) { - throw new EamDbException("Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'."); // NON-NLS + throw new CentralRepoException("Invalid database table name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'."); // NON-NLS } this.dbTableName = dbTableName; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizer.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizer.java index 08ed088cf1..4e5811a0c8 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizer.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeNormalizer.java @@ -103,7 +103,7 @@ final public class CorrelationAttributeNormalizer { } else { throw new CorrelationAttributeNormalizationException(String.format("Given attributeTypeId did not correspond to any known Attribute: %s", attributeTypeId)); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { throw new CorrelationAttributeNormalizationException(ex); } } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamArtifactUtil.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeUtil.java similarity index 89% rename from Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamArtifactUtil.java rename to Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeUtil.java index 18a21d0ab6..07eb454ac5 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamArtifactUtil.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeUtil.java @@ -1,7 +1,7 @@ /* * Central Repository * - * Copyright 2015-2019 Basis Technology Corp. + * Copyright 2015-2020 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -38,9 +38,9 @@ import org.sleuthkit.datamodel.TskData; /** * Utility class for correlation attributes in the central repository */ -public class EamArtifactUtil { +public class CorrelationAttributeUtil { - private static final Logger logger = Logger.getLogger(EamArtifactUtil.class.getName()); + private static final Logger logger = Logger.getLogger(CorrelationAttributeUtil.class.getName()); @Messages({"EamArtifactUtil.emailaddresses.text=Email Addresses"}) public static String getEmailAddressAttrString() { @@ -78,7 +78,7 @@ public class EamArtifactUtil { if (artifactTypeID == ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) { BlackboardAttribute setNameAttr = artifactForInstance.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME)); if (setNameAttr != null - && EamArtifactUtil.getEmailAddressAttrString().equals(setNameAttr.getValueString())) { + && CorrelationAttributeUtil.getEmailAddressAttrString().equals(setNameAttr.getValueString())) { addCorrelationAttributeToList(eamArtifacts, artifactForInstance, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_KEYWORD, CorrelationAttributeInstance.EMAIL_TYPE_ID); } } else if (artifactTypeID == ARTIFACT_TYPE.TSK_WEB_BOOKMARK.getTypeID() @@ -108,7 +108,7 @@ public class EamArtifactUtil { // Only add the correlation attribute if the resulting phone number large enough to be of use // (these 3-5 digit numbers can be valid, but are not useful for correlation) if (value.length() > 5) { - CorrelationAttributeInstance inst = makeCorrelationAttributeInstanceUsingTypeValue(artifactForInstance, EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.PHONE_TYPE_ID), value); + CorrelationAttributeInstance inst = makeCorrelationAttributeInstanceUsingTypeValue(artifactForInstance, CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.PHONE_TYPE_ID), value); if (inst != null) { eamArtifacts.add(inst); } @@ -135,7 +135,7 @@ public class EamArtifactUtil { addCorrelationAttributeToList(eamArtifacts, artifactForInstance, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL, CorrelationAttributeInstance.EMAIL_TYPE_ID); } } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Error getting defined correlation types.", ex); // NON-NLS return eamArtifacts; } catch (TskCoreException ex) { @@ -163,15 +163,15 @@ public class EamArtifactUtil { * @param typeId the integer type id of the * CorrelationAttributeInstance type * - * @throws EamDbException + * @throws CentralRepoException * @throws TskCoreException */ - private static void addCorrelationAttributeToList(List eamArtifacts, BlackboardArtifact artifact, ATTRIBUTE_TYPE bbAttributeType, int typeId) throws EamDbException, TskCoreException { + private static void addCorrelationAttributeToList(List eamArtifacts, BlackboardArtifact artifact, ATTRIBUTE_TYPE bbAttributeType, int typeId) throws CentralRepoException, TskCoreException { BlackboardAttribute attribute = artifact.getAttribute(new BlackboardAttribute.Type(bbAttributeType)); if (attribute != null) { String value = attribute.getValueString(); if ((null != value) && (value.isEmpty() == false)) { - CorrelationAttributeInstance inst = makeCorrelationAttributeInstanceUsingTypeValue(artifact, EamDb.getInstance().getCorrelationTypeById(typeId), value); + CorrelationAttributeInstance inst = makeCorrelationAttributeInstanceUsingTypeValue(artifact, CentralRepository.getInstance().getCorrelationTypeById(typeId), value); if (inst != null) { eamArtifacts.add(inst); } @@ -200,7 +200,7 @@ public class EamArtifactUtil { } // make an instance for the BB source file - CorrelationCase correlationCase = EamDb.getInstance().getCase(Case.getCurrentCaseThrows()); + CorrelationCase correlationCase = CentralRepository.getInstance().getCase(Case.getCurrentCaseThrows()); return new CorrelationAttributeInstance( correlationType, value, @@ -214,7 +214,7 @@ public class EamArtifactUtil { } catch (TskCoreException ex) { logger.log(Level.SEVERE, "Error getting AbstractFile for artifact: " + bbArtifact.toString(), ex); // NON-NLS return null; - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { logger.log(Level.WARNING, "Error creating artifact instance for artifact: " + bbArtifact.toString(), ex); // NON-NLS return null; } catch (NoCurrentCaseException ex) { @@ -247,14 +247,14 @@ public class EamArtifactUtil { CorrelationDataSource correlationDataSource; try { - type = EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID); - correlationCase = EamDb.getInstance().getCase(Case.getCurrentCaseThrows()); + type = CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID); + correlationCase = CentralRepository.getInstance().getCase(Case.getCurrentCaseThrows()); if (null == correlationCase) { //if the correlationCase is not in the Central repo then attributes generated in relation to it will not be return null; } correlationDataSource = CorrelationDataSource.fromTSKDataSource(correlationCase, file.getDataSource()); - } catch (TskCoreException | EamDbException ex) { + } catch (TskCoreException | CentralRepoException ex) { logger.log(Level.SEVERE, "Error retrieving correlation attribute.", ex); return null; } catch (NoCurrentCaseException ex) { @@ -264,8 +264,8 @@ public class EamArtifactUtil { CorrelationAttributeInstance correlationAttributeInstance; try { - correlationAttributeInstance = EamDb.getInstance().getCorrelationAttributeInstance(type, correlationCase, correlationDataSource, file.getId()); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + correlationAttributeInstance = CentralRepository.getInstance().getCorrelationAttributeInstance(type, correlationCase, correlationDataSource, file.getId()); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { logger.log(Level.WARNING, String.format( "Correlation attribute could not be retrieved for '%s' (id=%d): ", content.getName(), content.getId()), ex); @@ -275,8 +275,8 @@ public class EamArtifactUtil { if (correlationAttributeInstance == null && file.getMd5Hash() != null) { String filePath = (file.getParentPath() + file.getName()).toLowerCase(); try { - correlationAttributeInstance = EamDb.getInstance().getCorrelationAttributeInstance(type, correlationCase, correlationDataSource, file.getMd5Hash(), filePath); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + correlationAttributeInstance = CentralRepository.getInstance().getCorrelationAttributeInstance(type, correlationCase, correlationDataSource, file.getMd5Hash(), filePath); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { logger.log(Level.WARNING, String.format( "Correlation attribute could not be retrieved for '%s' (id=%d): ", content.getName(), content.getId()), ex); @@ -319,9 +319,9 @@ public class EamArtifactUtil { } try { - CorrelationAttributeInstance.Type filesType = EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID); + CorrelationAttributeInstance.Type filesType = CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID); - CorrelationCase correlationCase = EamDb.getInstance().getCase(Case.getCurrentCaseThrows()); + CorrelationCase correlationCase = CentralRepository.getInstance().getCase(Case.getCurrentCaseThrows()); return new CorrelationAttributeInstance( filesType, af.getMd5Hash(), @@ -332,7 +332,7 @@ public class EamArtifactUtil { TskData.FileKnown.UNKNOWN, af.getId()); - } catch (TskCoreException | EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (TskCoreException | CentralRepoException | CorrelationAttributeNormalizationException ex) { logger.log(Level.SEVERE, "Error making correlation attribute.", ex); return null; } catch (NoCurrentCaseException ex) { @@ -377,7 +377,7 @@ public class EamArtifactUtil { /** * Constructs a new EamArtifactUtil */ - private EamArtifactUtil() { + private CorrelationAttributeUtil() { //empty constructor } } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationCase.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationCase.java index 284b351c68..3d843e0c77 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationCase.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationCase.java @@ -36,7 +36,7 @@ public class CorrelationCase implements Serializable { private int databaseId; private String caseUUID; // globally unique - private EamOrganization org; + private CentralRepoOrganization org; private String displayName; private String creationDate; private String caseNumber; @@ -56,7 +56,7 @@ public class CorrelationCase implements Serializable { CorrelationCase(int ID, String caseUUID, - EamOrganization org, + CentralRepoOrganization org, String displayName, String creationDate, String caseNumber, @@ -172,14 +172,14 @@ public class CorrelationCase implements Serializable { /** * @return the org */ - public EamOrganization getOrg() { + public CentralRepoOrganization getOrg() { return org; } /** * @param org the org to set */ - public void setOrg(EamOrganization org) { + public void setOrg(CentralRepoOrganization org) { this.org = org; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationDataSource.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationDataSource.java index 8b8ed63699..ac17a1e962 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationDataSource.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationDataSource.java @@ -108,20 +108,20 @@ public class CorrelationDataSource implements Serializable { * * @return * - * @throws EamDbException + * @throws CentralRepoException */ - public static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource) throws EamDbException { + public static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource) throws CentralRepoException { Case curCase; try { curCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { - throw new EamDbException("Autopsy case is closed"); + throw new CentralRepoException("Autopsy case is closed"); } CorrelationDataSource correlationDataSource = null; - boolean useCR = EamDb.isEnabled(); + boolean useCR = CentralRepository.isEnabled(); if (useCR) { - correlationDataSource = EamDb.getInstance().getDataSource(correlationCase, dataSource.getId()); + correlationDataSource = CentralRepository.getInstance().getDataSource(correlationCase, dataSource.getId()); } if (correlationDataSource == null) { @@ -139,13 +139,13 @@ public class CorrelationDataSource implements Serializable { sha256 = image.getSha256(); } } catch (TskDataException | TskCoreException ex) { - throw new EamDbException("Error getting data source info: " + ex.getMessage()); + throw new CentralRepoException("Error getting data source info: " + ex.getMessage()); } correlationDataSource = new CorrelationDataSource(correlationCase, deviceId, dataSource.getName(), dataSource.getId(), md5, sha1, sha256); if (useCR) { //add the correlation data source to the central repository and fill in the Central repository data source id in the object - correlationDataSource = EamDb.getInstance().newDataSource(correlationDataSource); + correlationDataSource = CentralRepository.getInstance().newDataSource(correlationDataSource); } } return correlationDataSource; @@ -217,15 +217,14 @@ public class CorrelationDataSource implements Serializable { * Set the MD5 hash value and persist to the Central Repository if available. * * @param md5Hash The MD5 hash value. - * - * @exception EamDbException If there's an issue updating the Central - * Repository. + * @throws CentralRepoException If there's an issue updating the Central + Repository. */ - public void setMd5(String md5Hash) throws EamDbException { + public void setMd5(String md5Hash) throws CentralRepoException { this.md5Hash = md5Hash; if (dataSourceObjectID != -1) { - EamDb.getInstance().updateDataSourceMd5Hash(this); + CentralRepository.getInstance().updateDataSourceMd5Hash(this); } } @@ -242,11 +241,11 @@ public class CorrelationDataSource implements Serializable { * * @param sha1Hash The SHA-1 hash value. */ - public void setSha1(String sha1Hash) throws EamDbException { + public void setSha1(String sha1Hash) throws CentralRepoException { this.sha1Hash = sha1Hash; if (dataSourceObjectID != -1) { - EamDb.getInstance().updateDataSourceSha1Hash(this); + CentralRepository.getInstance().updateDataSourceSha1Hash(this); } } @@ -263,11 +262,11 @@ public class CorrelationDataSource implements Serializable { * * @param sha256Hash The SHA-256 hash value. */ - public void setSha256(String sha256Hash) throws EamDbException { + public void setSha256(String sha256Hash) throws CentralRepoException { this.sha256Hash = sha256Hash; if (dataSourceObjectID != -1) { - EamDb.getInstance().updateDataSourceSha256Hash(this); + CentralRepository.getInstance().updateDataSourceSha256Hash(this); } } } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/DataSourceUpdateService.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/DataSourceUpdateService.java index f1e52b03e4..2450ca3440 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/DataSourceUpdateService.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/DataSourceUpdateService.java @@ -41,9 +41,9 @@ public class DataSourceUpdateService implements AutopsyService { @Override public void openCaseResources(CaseContext context) throws AutopsyServiceException { - if (EamDb.isEnabled()) { + if (CentralRepository.isEnabled()) { try { - EamDb centralRepository = EamDb.getInstance(); + 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) { @@ -59,7 +59,7 @@ public class DataSourceUpdateService implements AutopsyService { } } } - } catch (EamDbException | TskCoreException ex) { + } catch (CentralRepoException | TskCoreException ex) { throw new AutopsyServiceException("Unabe to update datasources in central repository", ex); } } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepo.java similarity index 80% rename from Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDb.java rename to Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepo.java index dabfeba7a1..1ac8df25ff 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepo.java @@ -33,30 +33,30 @@ import org.sleuthkit.autopsy.coreutils.Logger; /** * Central Repository database implementation using Postgres as a backend */ -final class PostgresEamDb extends AbstractSqlEamDb { +final class PostgresCentralRepo extends AbstractCentralRepo { - private final static Logger LOGGER = Logger.getLogger(PostgresEamDb.class.getName()); + private final static Logger LOGGER = Logger.getLogger(PostgresCentralRepo.class.getName()); private final static String CONFLICT_CLAUSE = "ON CONFLICT DO NOTHING"; - private static PostgresEamDb instance; + private static PostgresCentralRepo instance; private static final int CONN_POOL_SIZE = 10; private BasicDataSource connectionPool = null; - private final PostgresEamDbSettings dbSettings; + private final PostgresCentralRepoSettings dbSettings; /** * Get the singleton instance of PostgresEamDb * * @return the singleton instance of PostgresEamDb * - * @throws EamDbException if one or more default correlation type(s) have an + * @throws CentralRepoException if one or more default correlation type(s) have an * invalid db table name. */ - public synchronized static PostgresEamDb getInstance() throws EamDbException { + public synchronized static PostgresCentralRepo getInstance() throws CentralRepoException { if (instance == null) { - instance = new PostgresEamDb(); + instance = new PostgresCentralRepo(); } return instance; @@ -64,17 +64,17 @@ final class PostgresEamDb extends AbstractSqlEamDb { /** * - * @throws EamDbException if the AbstractSqlEamDb class has one or more + * @throws CentralRepoException if the AbstractSqlEamDb class has one or more * default correlation type(s) having an invalid db * table name. */ - private PostgresEamDb() throws EamDbException { - dbSettings = new PostgresEamDbSettings(); + private PostgresCentralRepo() throws CentralRepoException { + dbSettings = new PostgresCentralRepoSettings(); bulkArtifactsThreshold = dbSettings.getBulkThreshold(); } @Override - public void shutdownConnections() throws EamDbException { + public void shutdownConnections() throws CentralRepoException { try { synchronized (this) { if (connectionPool != null) { @@ -84,7 +84,7 @@ final class PostgresEamDb extends AbstractSqlEamDb { clearCaches(); } } catch (SQLException ex) { - throw new EamDbException("Failed to close existing database connections.", ex); // NON-NLS + throw new CentralRepoException("Failed to close existing database connections.", ex); // NON-NLS } } @@ -104,7 +104,7 @@ final class PostgresEamDb extends AbstractSqlEamDb { } @Override - public void reset() throws EamDbException { + public void reset() throws CentralRepoException { Connection conn = connect(); try { @@ -128,7 +128,7 @@ final class PostgresEamDb extends AbstractSqlEamDb { } catch (SQLException ex) { LOGGER.log(Level.WARNING, "Failed to reset database.", ex); } finally { - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeConnection(conn); } dbSettings.insertDefaultDatabaseContent(); @@ -138,7 +138,7 @@ final class PostgresEamDb extends AbstractSqlEamDb { * Setup a connection pool for db connections. * */ - private void setupConnectionPool() throws EamDbException { + private void setupConnectionPool() throws CentralRepoException { connectionPool = new BasicDataSource(); connectionPool.setUsername(dbSettings.getUserName()); connectionPool.setPassword(dbSettings.getPassword()); @@ -169,10 +169,10 @@ final class PostgresEamDb extends AbstractSqlEamDb { * * @return A connection from the connection pool. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - protected Connection connect(boolean foreignKeys) throws EamDbException { + protected Connection connect(boolean foreignKeys) throws CentralRepoException { //foreignKeys boolean is ignored for postgres return connect(); } @@ -182,15 +182,15 @@ final class PostgresEamDb extends AbstractSqlEamDb { * * @return A connection from the connection pool. * - * @throws EamDbException + * @throws CentralRepoException */ @Messages({"PostgresEamDb.centralRepoDisabled.message=Central Repository module is not enabled.", "PostgresEamDb.connectionFailed.message=Error getting connection to database."}) @Override - protected Connection connect() throws EamDbException { + protected Connection connect() throws CentralRepoException { synchronized (this) { - if (!EamDb.isEnabled()) { - throw new EamDbException("Central Repository module is not enabled", Bundle.PostgresEamDb_centralRepoDisabled_message()); // NON-NLS + if (!CentralRepository.isEnabled()) { + throw new CentralRepoException("Central Repository module is not enabled", Bundle.PostgresEamDb_centralRepoDisabled_message()); // NON-NLS } if (connectionPool == null) { @@ -200,7 +200,7 @@ final class PostgresEamDb extends AbstractSqlEamDb { try { return connectionPool.getConnection(); } catch (SQLException ex) { - throw new EamDbException("Error getting connection from connection pool.", Bundle.PostgresEamDb_connectionFailed_message(), ex); // NON-NLS + throw new CentralRepoException("Error getting connection from connection pool.", Bundle.PostgresEamDb_connectionFailed_message(), ex); // NON-NLS } } @@ -217,12 +217,12 @@ final class PostgresEamDb extends AbstractSqlEamDb { * * @return the lock, or null if locking is not supported * - * @throws EamDbException if the coordination service is running but we fail + * @throws CentralRepoException if the coordination service is running but we fail * to get the lock */ @Override @Messages({"PostgresEamDb.multiUserLockError.message=Error acquiring database lock"}) - public CoordinationService.Lock getExclusiveMultiUserDbLock() throws EamDbException { + public CoordinationService.Lock getExclusiveMultiUserDbLock() throws CentralRepoException { try { // First check if multi user mode is enabled - if not there's no point trying to get a lock if (!UserPreferences.getIsMultiUserModeEnabled()) { @@ -235,9 +235,9 @@ final class PostgresEamDb extends AbstractSqlEamDb { if (lock != null) { return lock; } - throw new EamDbException("Error acquiring database lock", Bundle.PostgresEamDb_multiUserLockError_message()); + throw new CentralRepoException("Error acquiring database lock", Bundle.PostgresEamDb_multiUserLockError_message()); } catch (InterruptedException ex) { - throw new EamDbException("Error acquiring database lock", Bundle.PostgresEamDb_multiUserLockError_message(), ex); + throw new CentralRepoException("Error acquiring database lock", Bundle.PostgresEamDb_multiUserLockError_message(), ex); } catch (CoordinationService.CoordinationServiceException ex) { // This likely just means the coordination service isn't running, which is ok return null; @@ -257,8 +257,8 @@ final class PostgresEamDb extends AbstractSqlEamDb { columnExists = resultSet.getBoolean(1); } } finally { - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeStatement(statement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(statement); } return columnExists; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDbSettings.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepoSettings.java similarity index 89% rename from Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDbSettings.java rename to Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepoSettings.java index a4ab17906b..4d689e675c 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDbSettings.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepoSettings.java @@ -32,7 +32,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.TextConverter; import org.sleuthkit.autopsy.coreutils.TextConverterException; -import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractSqlEamDb.SOFTWARE_CR_DB_SCHEMA_VERSION; +import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractCentralRepo.SOFTWARE_CR_DB_SCHEMA_VERSION; /** * Settings for the Postgres implementation of the Central Repository database @@ -40,9 +40,9 @@ import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractSqlEamDb * NOTE: This is public scope because the options panel calls it directly to * set/get */ -public final class PostgresEamDbSettings { +public final class PostgresCentralRepoSettings { - private final static Logger LOGGER = Logger.getLogger(PostgresEamDbSettings.class.getName()); + private final static Logger LOGGER = Logger.getLogger(PostgresCentralRepoSettings.class.getName()); private final static String DEFAULT_HOST = ""; // NON-NLS private final static int DEFAULT_PORT = 5432; private final static String DEFAULT_DBNAME = "central_repository"; // NON-NLS @@ -60,7 +60,7 @@ public final class PostgresEamDbSettings { private String userName; private String password; - public PostgresEamDbSettings() { + public PostgresCentralRepoSettings() { loadSettings(); } @@ -92,15 +92,15 @@ public final class PostgresEamDbSettings { try { String bulkThresholdString = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.bulkThreshold"); // NON-NLS if (bulkThresholdString == null || bulkThresholdString.isEmpty()) { - this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = AbstractCentralRepo.DEFAULT_BULK_THRESHHOLD; } else { this.bulkThreshold = Integer.parseInt(bulkThresholdString); if (getBulkThreshold() <= 0) { - this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = AbstractCentralRepo.DEFAULT_BULK_THRESHHOLD; } } } catch (NumberFormatException ex) { - this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = AbstractCentralRepo.DEFAULT_BULK_THRESHHOLD; } userName = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.user"); // NON-NLS @@ -193,8 +193,8 @@ public final class PostgresEamDbSettings { return false; } - boolean result = EamDbUtil.executeValidationQuery(conn, VALIDATION_QUERY); - EamDbUtil.closeConnection(conn); + boolean result = CentralRepoDbUtil.executeValidationQuery(conn, VALIDATION_QUERY); + CentralRepoDbUtil.closeConnection(conn); return result; } @@ -223,9 +223,9 @@ public final class PostgresEamDbSettings { LOGGER.log(Level.SEVERE, "Failed to execute database existance query.", ex); // NON-NLS return false; } finally { - EamDbUtil.closeStatement(ps); - EamDbUtil.closeResultSet(rs); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeStatement(ps); + CentralRepoDbUtil.closeResultSet(rs); + CentralRepoDbUtil.closeConnection(conn); } return false; } @@ -242,9 +242,9 @@ public final class PostgresEamDbSettings { return false; } - boolean result = EamDbUtil.schemaVersionIsSet(conn); + boolean result = CentralRepoDbUtil.schemaVersionIsSet(conn); - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeConnection(conn); return result; } @@ -263,7 +263,7 @@ public final class PostgresEamDbSettings { LOGGER.log(Level.SEVERE, "Failed to execute create database statement.", ex); // NON-NLS return false; } finally { - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeConnection(conn); } return true; @@ -284,7 +284,7 @@ public final class PostgresEamDbSettings { LOGGER.log(Level.SEVERE, "Failed to execute drop database statement.", ex); // NON-NLS return false; } finally { - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeConnection(conn); } return true; @@ -420,10 +420,10 @@ public final class PostgresEamDbSettings { * name column could be the primary key. */ stmt.execute("CREATE TABLE db_info (id SERIAL, name TEXT UNIQUE NOT NULL, value TEXT NOT NULL)"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.CREATION_SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.CREATION_SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.CREATION_SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.CREATION_SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); // Create a separate instance and reference table for each correlation type List DEFAULT_CORRELATION_TYPES = CorrelationAttributeInstance.getDefaultCorrelationTypes(); @@ -431,8 +431,8 @@ public final class PostgresEamDbSettings { String reference_type_dbname; String instance_type_dbname; for (CorrelationAttributeInstance.Type type : DEFAULT_CORRELATION_TYPES) { - reference_type_dbname = EamDbUtil.correlationTypeToReferenceTableName(type); - instance_type_dbname = EamDbUtil.correlationTypeToInstanceTableName(type); + reference_type_dbname = CentralRepoDbUtil.correlationTypeToReferenceTableName(type); + instance_type_dbname = CentralRepoDbUtil.correlationTypeToInstanceTableName(type); stmt.execute(String.format(createArtifactInstancesTableTemplate, instance_type_dbname, instance_type_dbname)); stmt.execute(String.format(instancesCaseIdIdx, instance_type_dbname, instance_type_dbname)); @@ -452,11 +452,11 @@ public final class PostgresEamDbSettings { } catch (SQLException ex) { LOGGER.log(Level.SEVERE, "Error initializing db schema.", ex); // NON-NLS return false; - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error getting default correlation types. Likely due to one or more Type's with an invalid db table name."); // NON-NLS return false; } finally { - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeConnection(conn); } return true; } @@ -587,8 +587,8 @@ public final class PostgresEamDbSettings { return false; } - boolean result = EamDbUtil.insertDefaultCorrelationTypes(conn) && EamDbUtil.insertDefaultOrganization(conn); - EamDbUtil.closeConnection(conn); + boolean result = CentralRepoDbUtil.insertDefaultCorrelationTypes(conn) && CentralRepoDbUtil.insertDefaultOrganization(conn); + CentralRepoDbUtil.closeConnection(conn); return result; } @@ -616,11 +616,11 @@ public final class PostgresEamDbSettings { /** * @param host the host to set */ - public void setHost(String host) throws EamDbException { + public void setHost(String host) throws CentralRepoException { if (null != host && !host.isEmpty()) { this.host = host; } else { - throw new EamDbException("Invalid host name. Cannot be empty."); // NON-NLS + throw new CentralRepoException("Invalid host name. Cannot be empty."); // NON-NLS } } @@ -634,11 +634,11 @@ public final class PostgresEamDbSettings { /** * @param port the port to set */ - public void setPort(int port) throws EamDbException { + public void setPort(int port) throws CentralRepoException { if (port > 0 && port < 65535) { this.port = port; } else { - throw new EamDbException("Invalid port. Must be a number greater than 0."); // NON-NLS + throw new CentralRepoException("Invalid port. Must be a number greater than 0."); // NON-NLS } } @@ -655,11 +655,11 @@ public final class PostgresEamDbSettings { /** * @param dbName the dbName to set */ - public void setDbName(String dbName) throws EamDbException { + public void setDbName(String dbName) throws CentralRepoException { if (dbName == null || dbName.isEmpty()) { - throw new EamDbException("Invalid database name. Cannot be empty."); // NON-NLS + throw new CentralRepoException("Invalid database name. Cannot be empty."); // NON-NLS } else if (!Pattern.matches(DB_NAMES_REGEX, dbName)) { - throw new EamDbException("Invalid database name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'."); // NON-NLS + throw new CentralRepoException("Invalid database name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'."); // NON-NLS } this.dbName = dbName.toLowerCase(); @@ -675,11 +675,11 @@ public final class PostgresEamDbSettings { /** * @param bulkThreshold the bulkThreshold to set */ - public void setBulkThreshold(int bulkThreshold) throws EamDbException { + public void setBulkThreshold(int bulkThreshold) throws CentralRepoException { if (bulkThreshold > 0) { this.bulkThreshold = bulkThreshold; } else { - throw new EamDbException("Invalid bulk threshold."); // NON-NLS + throw new CentralRepoException("Invalid bulk threshold."); // NON-NLS } } @@ -693,11 +693,11 @@ public final class PostgresEamDbSettings { /** * @param userName the userName to set */ - public void setUserName(String userName) throws EamDbException { + public void setUserName(String userName) throws CentralRepoException { if (userName == null || userName.isEmpty()) { - throw new EamDbException("Invalid user name. Cannot be empty."); // NON-NLS + throw new CentralRepoException("Invalid user name. Cannot be empty."); // NON-NLS } else if (!Pattern.matches(DB_USER_NAMES_REGEX, userName)) { - throw new EamDbException("Invalid user name. Name must start with a letter and can only contain letters, numbers, and '_'."); // NON-NLS + throw new CentralRepoException("Invalid user name. Name must start with a letter and can only contain letters, numbers, and '_'."); // NON-NLS } this.userName = userName; } @@ -712,9 +712,9 @@ public final class PostgresEamDbSettings { /** * @param password the password to set */ - public void setPassword(String password) throws EamDbException { + public void setPassword(String password) throws CentralRepoException { if (password == null || password.isEmpty()) { - throw new EamDbException("Invalid user password. Cannot be empty."); // NON-NLS + throw new CentralRepoException("Invalid user password. Cannot be empty."); // NON-NLS } this.password = password; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepo.java similarity index 81% rename from Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java rename to Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepo.java index 28374a1311..413a3a813a 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepo.java @@ -1,7 +1,7 @@ /* * Central Repository * - * Copyright 2015-2019 Basis Technology Corp. + * Copyright 2015-2020 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -39,15 +39,15 @@ import org.sleuthkit.autopsy.coordinationservice.CoordinationService; * AbstractSqlEamDb that read or write to the database should be overriden here * and use appropriate locking. */ -final class SqliteEamDb extends AbstractSqlEamDb { +final class SqliteCentralRepo extends AbstractCentralRepo { - private final static Logger LOGGER = Logger.getLogger(SqliteEamDb.class.getName()); + private final static Logger LOGGER = Logger.getLogger(SqliteCentralRepo.class.getName()); - private static SqliteEamDb instance; + private static SqliteCentralRepo instance; private BasicDataSource connectionPool = null; - private final SqliteEamDbSettings dbSettings; + private final SqliteCentralRepoSettings dbSettings; // While the Sqlite database should only be used for single users, it is still // possible for multiple threads to attempt to write to the database simultaneously. @@ -58,12 +58,12 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @return the singleton instance of SqliteEamDb * - * @throws EamDbException if one or more default correlation type(s) have an + * @throws CentralRepoException if one or more default correlation type(s) have an * invalid db table name. */ - public synchronized static SqliteEamDb getInstance() throws EamDbException { + public synchronized static SqliteCentralRepo getInstance() throws CentralRepoException { if (instance == null) { - instance = new SqliteEamDb(); + instance = new SqliteCentralRepo(); } return instance; @@ -71,17 +71,17 @@ final class SqliteEamDb extends AbstractSqlEamDb { /** * - * @throws EamDbException if the AbstractSqlEamDb class has one or more + * @throws CentralRepoException if the AbstractSqlEamDb class has one or more * default correlation type(s) having an invalid db * table name. */ - private SqliteEamDb() throws EamDbException { - dbSettings = new SqliteEamDbSettings(); + private SqliteCentralRepo() throws CentralRepoException { + dbSettings = new SqliteCentralRepoSettings(); bulkArtifactsThreshold = dbSettings.getBulkThreshold(); } @Override - public void shutdownConnections() throws EamDbException { + public void shutdownConnections() throws CentralRepoException { try { synchronized (this) { if (null != connectionPool) { @@ -91,7 +91,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { clearCaches(); } } catch (SQLException ex) { - throw new EamDbException("Failed to close existing database connections.", ex); // NON-NLS + throw new CentralRepoException("Failed to close existing database connections.", ex); // NON-NLS } } @@ -111,7 +111,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { } @Override - public void reset() throws EamDbException { + public void reset() throws CentralRepoException { try { acquireExclusiveLock(); @@ -141,7 +141,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { } catch (SQLException ex) { LOGGER.log(Level.WARNING, "Failed to reset database.", ex); } finally { - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeConnection(conn); } dbSettings.insertDefaultDatabaseContent(); @@ -155,10 +155,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * */ @Messages({"SqliteEamDb.databaseMissing.message=Central repository database missing"}) - private void setupConnectionPool(boolean foreignKeysEnabled) throws EamDbException { + private void setupConnectionPool(boolean foreignKeysEnabled) throws CentralRepoException { if (dbSettings.dbFileExists() == false) { - throw new EamDbException("Central repository database missing", Bundle.SqliteEamDb_databaseMissing_message()); + throw new CentralRepoException("Central repository database missing", Bundle.SqliteEamDb_databaseMissing_message()); } connectionPool = new BasicDataSource(); @@ -186,15 +186,15 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @return A connection from the connection pool. * - * @throws EamDbException + * @throws CentralRepoException */ @Messages({"SqliteEamDb.connectionFailedMessage.message=Error getting connection to database.", "SqliteEamDb.centralRepositoryDisabled.message=Central Repository module is not enabled."}) @Override - protected Connection connect(boolean foreignKeys) throws EamDbException { + protected Connection connect(boolean foreignKeys) throws CentralRepoException { synchronized (this) { - if (!EamDb.isEnabled()) { - throw new EamDbException("Central repository database missing", Bundle.SqliteEamDb_centralRepositoryDisabled_message()); // NON-NLS + if (!CentralRepository.isEnabled()) { + throw new CentralRepoException("Central repository database missing", Bundle.SqliteEamDb_centralRepositoryDisabled_message()); // NON-NLS } if (connectionPool == null) { setupConnectionPool(foreignKeys); @@ -202,7 +202,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { try { return connectionPool.getConnection(); } catch (SQLException ex) { - throw new EamDbException("Error getting connection from connection pool.", Bundle.SqliteEamDb_connectionFailedMessage_message(), ex); // NON-NLS + throw new CentralRepoException("Error getting connection from connection pool.", Bundle.SqliteEamDb_connectionFailedMessage_message(), ex); // NON-NLS } } } @@ -213,10 +213,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @return A connection from the connection pool. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - protected Connection connect() throws EamDbException { + protected Connection connect() throws CentralRepoException { return connect(true); } @@ -232,10 +232,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @param name Key to set * @param value Value to set * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void newDbInfo(String name, String value) throws EamDbException { + public void newDbInfo(String name, String value) throws CentralRepoException { try { acquireExclusiveLock(); super.newDbInfo(name, value); @@ -251,10 +251,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @return value associated with name. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public String getDbInfo(String name) throws EamDbException { + public String getDbInfo(String name) throws CentralRepoException { try { acquireSharedLock(); return super.getDbInfo(name); @@ -269,10 +269,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @param name Name to find * @param value Value to assign to name. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void updateDbInfo(String name, String value) throws EamDbException { + public void updateDbInfo(String name, String value) throws CentralRepoException { try { acquireExclusiveLock(); super.updateDbInfo(name, value); @@ -287,7 +287,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @param autopsyCase The case to add */ @Override - public CorrelationCase newCase(Case autopsyCase) throws EamDbException { + public CorrelationCase newCase(Case autopsyCase) throws CentralRepoException { try { acquireExclusiveLock(); return super.newCase(autopsyCase); @@ -297,7 +297,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { } @Override - public void addDataSourceObjectId(int rowId, long dataSourceObjectId) throws EamDbException { + public void addDataSourceObjectId(int rowId, long dataSourceObjectId) throws CentralRepoException { try { acquireExclusiveLock(); super.addDataSourceObjectId(rowId, dataSourceObjectId); @@ -314,7 +314,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @param eamCase The case to add */ @Override - public CorrelationCase newCase(CorrelationCase eamCase) throws EamDbException { + public CorrelationCase newCase(CorrelationCase eamCase) throws CentralRepoException { try { acquireExclusiveLock(); return super.newCase(eamCase); @@ -329,7 +329,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @param eamCase The case to update */ @Override - public void updateCase(CorrelationCase eamCase) throws EamDbException { + public void updateCase(CorrelationCase eamCase) throws CentralRepoException { try { acquireExclusiveLock(); super.updateCase(eamCase); @@ -346,7 +346,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @return The retrieved case */ @Override - public CorrelationCase getCaseByUUID(String caseUUID) throws EamDbException { + public CorrelationCase getCaseByUUID(String caseUUID) throws CentralRepoException { try { acquireSharedLock(); return super.getCaseByUUID(caseUUID); @@ -363,7 +363,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @return The retrieved case */ @Override - public CorrelationCase getCaseById(int caseId) throws EamDbException { + public CorrelationCase getCaseById(int caseId) throws CentralRepoException { try { acquireSharedLock(); return super.getCaseById(caseId); @@ -379,7 +379,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @return List of cases */ @Override - public List getCases() throws EamDbException { + public List getCases() throws CentralRepoException { try { acquireSharedLock(); return super.getCases(); @@ -394,7 +394,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @param eamDataSource the data source to add */ @Override - public CorrelationDataSource newDataSource(CorrelationDataSource eamDataSource) throws EamDbException { + public CorrelationDataSource newDataSource(CorrelationDataSource eamDataSource) throws CentralRepoException { try { acquireExclusiveLock(); return super.newDataSource(eamDataSource); @@ -413,7 +413,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @return The data source */ @Override - public CorrelationDataSource getDataSource(CorrelationCase correlationCase, Long caseDbDataSourceId) throws EamDbException { + public CorrelationDataSource getDataSource(CorrelationCase correlationCase, Long caseDbDataSourceId) throws CentralRepoException { try { acquireSharedLock(); return super.getDataSource(correlationCase, caseDbDataSourceId); @@ -432,7 +432,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @return The data source */ @Override - public CorrelationDataSource getDataSourceById(CorrelationCase correlationCase, int dataSourceId) throws EamDbException { + public CorrelationDataSource getDataSourceById(CorrelationCase correlationCase, int dataSourceId) throws CentralRepoException { try { acquireSharedLock(); return super.getDataSourceById(correlationCase, dataSourceId); @@ -447,7 +447,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @return list of data sources in the DB */ @Override - public List getDataSources() throws EamDbException { + public List getDataSources() throws CentralRepoException { try { acquireSharedLock(); return super.getDataSources(); @@ -462,10 +462,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @param eamDataSource The data source * @param newName The new name * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void updateDataSourceName(CorrelationDataSource eamDataSource, String newName) throws EamDbException { + public void updateDataSourceName(CorrelationDataSource eamDataSource, String newName) throws CentralRepoException { try { acquireExclusiveLock(); super.updateDataSourceName(eamDataSource, newName); @@ -480,7 +480,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @param eamDataSource The data source to update */ @Override - public void updateDataSourceMd5Hash(CorrelationDataSource eamDataSource) throws EamDbException { + public void updateDataSourceMd5Hash(CorrelationDataSource eamDataSource) throws CentralRepoException { try { acquireExclusiveLock(); super.updateDataSourceMd5Hash(eamDataSource); @@ -495,7 +495,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @param eamDataSource The data source to update */ @Override - public void updateDataSourceSha1Hash(CorrelationDataSource eamDataSource) throws EamDbException { + public void updateDataSourceSha1Hash(CorrelationDataSource eamDataSource) throws CentralRepoException { try { acquireExclusiveLock(); super.updateDataSourceSha1Hash(eamDataSource); @@ -511,7 +511,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @param eamDataSource The data source to update */ @Override - public void updateDataSourceSha256Hash(CorrelationDataSource eamDataSource) throws EamDbException { + public void updateDataSourceSha256Hash(CorrelationDataSource eamDataSource) throws CentralRepoException { try { acquireExclusiveLock(); super.updateDataSourceSha256Hash(eamDataSource); @@ -527,7 +527,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @param eamArtifact The artifact to add */ @Override - public void addArtifactInstance(CorrelationAttributeInstance eamArtifact) throws EamDbException { + public void addArtifactInstance(CorrelationAttributeInstance eamArtifact) throws CentralRepoException { try { acquireExclusiveLock(); super.addArtifactInstance(eamArtifact); @@ -537,7 +537,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { } @Override - public List getArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException { + public List getArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException { try { acquireSharedLock(); return super.getArtifactInstancesByTypeValue(aType, value); @@ -547,7 +547,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { } @Override - public List getArtifactInstancesByTypeValues(CorrelationAttributeInstance.Type aType, List values) throws EamDbException, CorrelationAttributeNormalizationException { + public List getArtifactInstancesByTypeValues(CorrelationAttributeInstance.Type aType, List values) throws CentralRepoException, CorrelationAttributeNormalizationException { try { acquireSharedLock(); return super.getArtifactInstancesByTypeValues(aType, values); @@ -557,7 +557,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { } @Override - public List getArtifactInstancesByTypeValuesAndCases(CorrelationAttributeInstance.Type aType, List values, List caseIds) throws EamDbException, CorrelationAttributeNormalizationException { + public List getArtifactInstancesByTypeValuesAndCases(CorrelationAttributeInstance.Type aType, List values, List caseIds) throws CentralRepoException, CorrelationAttributeNormalizationException { try { acquireSharedLock(); return super.getArtifactInstancesByTypeValuesAndCases(aType, values, caseIds); @@ -576,10 +576,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @return Number of artifact instances having ArtifactType and * ArtifactValue. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public Long getCountArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException { + public Long getCountArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException { try { acquireSharedLock(); return super.getCountArtifactInstancesByTypeValue(aType, value); @@ -589,7 +589,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { } @Override - public int getFrequencyPercentage(CorrelationAttributeInstance corAttr) throws EamDbException, CorrelationAttributeNormalizationException { + public int getFrequencyPercentage(CorrelationAttributeInstance corAttr) throws CentralRepoException, CorrelationAttributeNormalizationException { try { acquireSharedLock(); return super.getFrequencyPercentage(corAttr); @@ -608,10 +608,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @return Number of unique tuples * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public Long getCountUniqueCaseDataSourceTuplesHavingTypeValue(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException { + public Long getCountUniqueCaseDataSourceTuplesHavingTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException { try { acquireSharedLock(); return super.getCountUniqueCaseDataSourceTuplesHavingTypeValue(aType, value); @@ -621,7 +621,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { } @Override - public Long getCountUniqueDataSources() throws EamDbException { + public Long getCountUniqueDataSources() throws CentralRepoException { try { acquireSharedLock(); return super.getCountUniqueDataSources(); @@ -642,7 +642,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * dataSource */ @Override - public Long getCountArtifactInstancesByCaseDataSource(CorrelationDataSource correlationDataSource) throws EamDbException { + public Long getCountArtifactInstancesByCaseDataSource(CorrelationDataSource correlationDataSource) throws CentralRepoException { try { acquireSharedLock(); return super.getCountArtifactInstancesByCaseDataSource(correlationDataSource); @@ -656,7 +656,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * addAttributeInstanceBulk() method */ @Override - public void commitAttributeInstancesBulk() throws EamDbException { + public void commitAttributeInstancesBulk() throws CentralRepoException { try { acquireExclusiveLock(); super.commitAttributeInstancesBulk(); @@ -669,7 +669,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * Executes a bulk insert of the cases */ @Override - public void bulkInsertCases(List cases) throws EamDbException { + public void bulkInsertCases(List cases) throws CentralRepoException { try { acquireExclusiveLock(); super.bulkInsertCases(cases); @@ -689,7 +689,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * KNOWN */ @Override - public void setAttributeInstanceKnownStatus(CorrelationAttributeInstance eamArtifact, TskData.FileKnown knownStatus) throws EamDbException { + public void setAttributeInstanceKnownStatus(CorrelationAttributeInstance eamArtifact, TskData.FileKnown knownStatus) throws CentralRepoException { try { acquireExclusiveLock(); super.setAttributeInstanceKnownStatus(eamArtifact, knownStatus); @@ -707,7 +707,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @return Number of matching eamArtifacts */ @Override - public Long getCountArtifactInstancesKnownBad(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException { + public Long getCountArtifactInstancesKnownBad(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException { try { acquireSharedLock(); return super.getCountArtifactInstancesKnownBad(aType, value); @@ -726,10 +726,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @return List of cases containing this artifact with instances marked as * bad * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public List getListCasesHavingArtifactInstancesKnownBad(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException { + public List getListCasesHavingArtifactInstancesKnownBad(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException { try { acquireSharedLock(); return super.getListCasesHavingArtifactInstancesKnownBad(aType, value); @@ -743,10 +743,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @param referenceSetID * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void deleteReferenceSet(int referenceSetID) throws EamDbException { + public void deleteReferenceSet(int referenceSetID) throws CentralRepoException { try { acquireExclusiveLock(); super.deleteReferenceSet(referenceSetID); @@ -765,7 +765,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @return true if the hash is found in the reference set */ @Override - public boolean isValueInReferenceSet(String value, int referenceSetID, int correlationTypeID) throws EamDbException, CorrelationAttributeNormalizationException { + public boolean isValueInReferenceSet(String value, int referenceSetID, int correlationTypeID) throws CentralRepoException, CorrelationAttributeNormalizationException { try { acquireSharedLock(); return super.isValueInReferenceSet(value, referenceSetID, correlationTypeID); @@ -780,10 +780,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @param type EamArtifact.Type to search for * @param instanceTableCallback callback to process the instance * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void processInstanceTable(CorrelationAttributeInstance.Type type, InstanceTableCallback instanceTableCallback) throws EamDbException { + public void processInstanceTable(CorrelationAttributeInstance.Type type, InstanceTableCallback instanceTableCallback) throws CentralRepoException { try { acquireSharedLock(); super.processInstanceTable(type, instanceTableCallback); @@ -798,10 +798,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @param type EamArtifact.Type to search for * @param instanceTableCallback callback to process the instance * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void processInstanceTableWhere(CorrelationAttributeInstance.Type type, String whereClause, InstanceTableCallback instanceTableCallback) throws EamDbException { + public void processInstanceTableWhere(CorrelationAttributeInstance.Type type, String whereClause, InstanceTableCallback instanceTableCallback) throws CentralRepoException { try { acquireSharedLock(); super.processInstanceTableWhere(type, whereClause, instanceTableCallback); @@ -816,10 +816,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @param selectClause query string to execute * @param instanceTableCallback callback to process the instance * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void processSelectClause(String selectClause, InstanceTableCallback instanceTableCallback) throws EamDbException { + public void processSelectClause(String selectClause, InstanceTableCallback instanceTableCallback) throws CentralRepoException { try { acquireSharedLock(); super.processSelectClause(selectClause, instanceTableCallback); @@ -838,10 +838,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @return true if a matching set is found * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public boolean referenceSetExists(String referenceSetName, String version) throws EamDbException { + public boolean referenceSetExists(String referenceSetName, String version) throws CentralRepoException { try { acquireSharedLock(); return super.referenceSetExists(referenceSetName, version); @@ -859,7 +859,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @return Global known status of the artifact */ @Override - public boolean isArtifactKnownBadByReference(CorrelationAttributeInstance.Type aType, String value) throws EamDbException, CorrelationAttributeNormalizationException { + public boolean isArtifactKnownBadByReference(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException { try { acquireSharedLock(); return super.isArtifactKnownBadByReference(aType, value); @@ -875,10 +875,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @param eamOrg The organization to add * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public EamOrganization newOrganization(EamOrganization eamOrg) throws EamDbException { + public CentralRepoOrganization newOrganization(CentralRepoOrganization eamOrg) throws CentralRepoException { try { acquireExclusiveLock(); return super.newOrganization(eamOrg); @@ -892,10 +892,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @return A list of all organizations * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public List getOrganizations() throws EamDbException { + public List getOrganizations() throws CentralRepoException { try { acquireSharedLock(); return super.getOrganizations(); @@ -911,10 +911,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @return The organization with the given ID * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public EamOrganization getOrganizationByID(int orgID) throws EamDbException { + public CentralRepoOrganization getOrganizationByID(int orgID) throws CentralRepoException { try { acquireSharedLock(); return super.getOrganizationByID(orgID); @@ -924,7 +924,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { } @Override - public void updateOrganization(EamOrganization updatedOrganization) throws EamDbException { + public void updateOrganization(CentralRepoOrganization updatedOrganization) throws CentralRepoException { try { acquireExclusiveLock(); super.updateOrganization(updatedOrganization); @@ -934,7 +934,7 @@ final class SqliteEamDb extends AbstractSqlEamDb { } @Override - public void deleteOrganization(EamOrganization organizationToDelete) throws EamDbException { + public void deleteOrganization(CentralRepoOrganization organizationToDelete) throws CentralRepoException { try { acquireExclusiveLock(); super.deleteOrganization(organizationToDelete); @@ -950,10 +950,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @return The ID of the new global set * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public int newReferenceSet(EamGlobalSet eamGlobalSet) throws EamDbException { + public int newReferenceSet(CentralRepoFileSet eamGlobalSet) throws CentralRepoException { try { acquireExclusiveLock(); return super.newReferenceSet(eamGlobalSet); @@ -969,10 +969,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @return The global set associated with the ID * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public EamGlobalSet getReferenceSetByID(int referenceSetID) throws EamDbException { + public CentralRepoFileSet getReferenceSetByID(int referenceSetID) throws CentralRepoException { try { acquireSharedLock(); return super.getReferenceSetByID(referenceSetID); @@ -988,10 +988,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @return List of all reference sets in the central repository * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public List getAllReferenceSets(CorrelationAttributeInstance.Type correlationType) throws EamDbException { + public List getAllReferenceSets(CorrelationAttributeInstance.Type correlationType) throws CentralRepoException { try { acquireSharedLock(); return super.getAllReferenceSets(correlationType); @@ -1007,10 +1007,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @param correlationType Correlation Type that this Reference * Instance is * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void addReferenceInstance(EamGlobalFileInstance eamGlobalFileInstance, CorrelationAttributeInstance.Type correlationType) throws EamDbException { + public void addReferenceInstance(CentralRepoFileInstance eamGlobalFileInstance, CorrelationAttributeInstance.Type correlationType) throws CentralRepoException { try { acquireExclusiveLock(); super.addReferenceInstance(eamGlobalFileInstance, correlationType); @@ -1022,10 +1022,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { /** * Insert the bulk collection of Reference Type Instances * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void bulkInsertReferenceTypeEntries(Set globalInstances, CorrelationAttributeInstance.Type contentType) throws EamDbException { + public void bulkInsertReferenceTypeEntries(Set globalInstances, CorrelationAttributeInstance.Type contentType) throws CentralRepoException { try { acquireExclusiveLock(); super.bulkInsertReferenceTypeEntries(globalInstances, contentType); @@ -1042,10 +1042,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @return List of all global file instances with a type and value * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public List getReferenceInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String aValue) throws EamDbException, CorrelationAttributeNormalizationException { + public List getReferenceInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String aValue) throws CentralRepoException, CorrelationAttributeNormalizationException { try { acquireSharedLock(); return super.getReferenceInstancesByTypeValue(aType, aValue); @@ -1061,10 +1061,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @return ID of this new Correlation Type * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public int newCorrelationType(CorrelationAttributeInstance.Type newType) throws EamDbException { + public int newCorrelationType(CorrelationAttributeInstance.Type newType) throws CentralRepoException { try { acquireExclusiveLock(); return super.newCorrelationType(newType); @@ -1080,10 +1080,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @return List of EamArtifact.Type's. If none are defined in the database, * the default list will be returned. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public List getDefinedCorrelationTypes() throws EamDbException { + public List getDefinedCorrelationTypes() throws CentralRepoException { try { acquireSharedLock(); return super.getDefinedCorrelationTypes(); @@ -1099,10 +1099,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @return List of enabled EamArtifact.Type's. If none are defined in the * database, the default list will be returned. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public List getEnabledCorrelationTypes() throws EamDbException { + public List getEnabledCorrelationTypes() throws CentralRepoException { try { acquireSharedLock(); return super.getEnabledCorrelationTypes(); @@ -1118,10 +1118,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * @return List of supported EamArtifact.Type's. If none are defined in the * database, the default list will be returned. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public List getSupportedCorrelationTypes() throws EamDbException { + public List getSupportedCorrelationTypes() throws CentralRepoException { try { acquireSharedLock(); return super.getSupportedCorrelationTypes(); @@ -1135,10 +1135,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @param aType EamArtifact.Type to update. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void updateCorrelationType(CorrelationAttributeInstance.Type aType) throws EamDbException { + public void updateCorrelationType(CorrelationAttributeInstance.Type aType) throws CentralRepoException { try { acquireExclusiveLock(); super.updateCorrelationType(aType); @@ -1154,10 +1154,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @return EamArtifact.Type or null if it doesn't exist. * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public CorrelationAttributeInstance.Type getCorrelationTypeById(int typeId) throws EamDbException { + public CorrelationAttributeInstance.Type getCorrelationTypeById(int typeId) throws CentralRepoException { try { acquireSharedLock(); return super.getCorrelationTypeById(typeId); @@ -1169,10 +1169,10 @@ final class SqliteEamDb extends AbstractSqlEamDb { /** * Upgrade the schema of the database (if needed) * - * @throws EamDbException + * @throws CentralRepoException */ @Override - public void upgradeSchema() throws EamDbException, SQLException, IncompatibleCentralRepoException { + public void upgradeSchema() throws CentralRepoException, SQLException, IncompatibleCentralRepoException { try { acquireExclusiveLock(); super.upgradeSchema(); @@ -1189,11 +1189,11 @@ final class SqliteEamDb extends AbstractSqlEamDb { * * @return the lock, or null if locking is not supported * - * @throws EamDbException if the coordination service is running but we fail + * @throws CentralRepoException if the coordination service is running but we fail * to get the lock */ @Override - public CoordinationService.Lock getExclusiveMultiUserDbLock() throws EamDbException { + public CoordinationService.Lock getExclusiveMultiUserDbLock() throws CentralRepoException { // Multiple users are not supported for SQLite return null; } @@ -1251,8 +1251,8 @@ final class SqliteEamDb extends AbstractSqlEamDb { } } } finally { - EamDbUtil.closeResultSet(resultSet); - EamDbUtil.closeStatement(statement); + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(statement); } return columnExists; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDbSettings.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepoSettings.java similarity index 91% rename from Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDbSettings.java rename to Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepoSettings.java index c76ab19783..6493cca0a5 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDbSettings.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepoSettings.java @@ -1,7 +1,7 @@ /* * Central Repository * - * Copyright 2015-2019 Basis Technology Corp. + * Copyright 2015-2020 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,7 +32,7 @@ import java.util.regex.Pattern; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.PlatformUtil; -import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractSqlEamDb.SOFTWARE_CR_DB_SCHEMA_VERSION; +import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractCentralRepo.SOFTWARE_CR_DB_SCHEMA_VERSION; /** * Settings for the sqlite implementation of the Central Repository database @@ -40,9 +40,9 @@ import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractSqlEamDb * NOTE: This is public scope because the options panel calls it directly to * set/get */ -public final class SqliteEamDbSettings { +public final class SqliteCentralRepoSettings { - private final static Logger LOGGER = Logger.getLogger(SqliteEamDbSettings.class.getName()); + private final static Logger LOGGER = Logger.getLogger(SqliteCentralRepoSettings.class.getName()); private final static String DEFAULT_DBNAME = "central_repository.db"; // NON-NLS private final static String DEFAULT_DBDIRECTORY = PlatformUtil.getUserDirectory() + File.separator + "central_repository"; // NON-NLS private final static String JDBC_DRIVER = "org.sqlite.JDBC"; // NON-NLS @@ -60,7 +60,7 @@ public final class SqliteEamDbSettings { private String dbDirectory; private int bulkThreshold; - public SqliteEamDbSettings() { + public SqliteCentralRepoSettings() { loadSettings(); } @@ -78,15 +78,15 @@ public final class SqliteEamDbSettings { try { String bulkThresholdString = ModuleSettings.getConfigSetting("CentralRepository", "db.sqlite.bulkThreshold"); // NON-NLS if (bulkThresholdString == null || bulkThresholdString.isEmpty()) { - this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = AbstractCentralRepo.DEFAULT_BULK_THRESHHOLD; } else { this.bulkThreshold = Integer.parseInt(bulkThresholdString); if (getBulkThreshold() <= 0) { - this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = AbstractCentralRepo.DEFAULT_BULK_THRESHHOLD; } } } catch (NumberFormatException ex) { - this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = AbstractCentralRepo.DEFAULT_BULK_THRESHHOLD; } } @@ -211,8 +211,8 @@ public final class SqliteEamDbSettings { return false; } - boolean result = EamDbUtil.executeValidationQuery(conn, VALIDATION_QUERY); - EamDbUtil.closeConnection(conn); + boolean result = CentralRepoDbUtil.executeValidationQuery(conn, VALIDATION_QUERY); + CentralRepoDbUtil.closeConnection(conn); return result; } @@ -228,8 +228,8 @@ public final class SqliteEamDbSettings { return false; } - boolean result = EamDbUtil.schemaVersionIsSet(conn); - EamDbUtil.closeConnection(conn); + boolean result = CentralRepoDbUtil.schemaVersionIsSet(conn); + CentralRepoDbUtil.closeConnection(conn); return result; } @@ -369,10 +369,10 @@ public final class SqliteEamDbSettings { * name column could be the primary key. */ stmt.execute("CREATE TABLE db_info (id INTEGER PRIMARY KEY, name TEXT UNIQUE NOT NULL, value TEXT NOT NULL)"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.CREATION_SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractSqlEamDb.CREATION_SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.CREATION_SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.CREATION_SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); // Create a separate instance and reference table for each artifact type List DEFAULT_CORRELATION_TYPES = CorrelationAttributeInstance.getDefaultCorrelationTypes(); @@ -380,8 +380,8 @@ public final class SqliteEamDbSettings { String reference_type_dbname; String instance_type_dbname; for (CorrelationAttributeInstance.Type type : DEFAULT_CORRELATION_TYPES) { - reference_type_dbname = EamDbUtil.correlationTypeToReferenceTableName(type); - instance_type_dbname = EamDbUtil.correlationTypeToInstanceTableName(type); + reference_type_dbname = CentralRepoDbUtil.correlationTypeToReferenceTableName(type); + instance_type_dbname = CentralRepoDbUtil.correlationTypeToInstanceTableName(type); stmt.execute(String.format(createArtifactInstancesTableTemplate, instance_type_dbname, instance_type_dbname)); stmt.execute(String.format(instancesCaseIdIdx, instance_type_dbname, instance_type_dbname)); @@ -400,11 +400,11 @@ public final class SqliteEamDbSettings { } catch (SQLException ex) { LOGGER.log(Level.SEVERE, "Error initializing db schema.", ex); // NON-NLS return false; - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error getting default correlation types. Likely due to one or more Type's with an invalid db table name."); // NON-NLS return false; } finally { - EamDbUtil.closeConnection(conn); + CentralRepoDbUtil.closeConnection(conn); } return true; } @@ -534,8 +534,8 @@ public final class SqliteEamDbSettings { return false; } - boolean result = EamDbUtil.insertDefaultCorrelationTypes(conn) && EamDbUtil.insertDefaultOrganization(conn); - EamDbUtil.closeConnection(conn); + boolean result = CentralRepoDbUtil.insertDefaultCorrelationTypes(conn) && CentralRepoDbUtil.insertDefaultOrganization(conn); + CentralRepoDbUtil.closeConnection(conn); return result; } @@ -561,11 +561,11 @@ public final class SqliteEamDbSettings { * * @param dbName the dbName to set */ - public void setDbName(String dbName) throws EamDbException { + public void setDbName(String dbName) throws CentralRepoException { if (dbName == null || dbName.isEmpty()) { - throw new EamDbException("Invalid database file name. Cannot be null or empty."); // NON-NLS + throw new CentralRepoException("Invalid database file name. Cannot be null or empty."); // NON-NLS } else if (!Pattern.matches(DB_NAMES_REGEX, dbName)) { - throw new EamDbException("Invalid database file name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'."); // NON-NLS + throw new CentralRepoException("Invalid database file name. Name must start with a lowercase letter and can only contain lowercase letters, numbers, and '_'."); // NON-NLS } this.dbName = dbName; @@ -581,11 +581,11 @@ public final class SqliteEamDbSettings { /** * @param bulkThreshold the bulkThreshold to set */ - void setBulkThreshold(int bulkThreshold) throws EamDbException { + void setBulkThreshold(int bulkThreshold) throws CentralRepoException { if (bulkThreshold > 0) { this.bulkThreshold = bulkThreshold; } else { - throw new EamDbException("Invalid bulk threshold."); // NON-NLS + throw new CentralRepoException("Invalid bulk threshold."); // NON-NLS } } @@ -603,11 +603,11 @@ public final class SqliteEamDbSettings { * * @param dbDirectory the dbDirectory to set */ - public void setDbDirectory(String dbDirectory) throws EamDbException { + public void setDbDirectory(String dbDirectory) throws CentralRepoException { if (dbDirectory != null && !dbDirectory.isEmpty()) { this.dbDirectory = dbDirectory; } else { - throw new EamDbException("Invalid directory for sqlite database. Cannot empty"); // NON-NLS + throw new CentralRepoException("Invalid directory for sqlite database. Cannot empty"); // NON-NLS } } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java index 1874729135..c5f6ebdbe2 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java @@ -39,11 +39,10 @@ import org.sleuthkit.autopsy.casemodule.events.DataSourceNameChangedEvent; import org.sleuthkit.autopsy.casemodule.services.TagsManager; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationDataSource; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.coreutils.ThreadUtils; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact; @@ -54,6 +53,7 @@ import org.sleuthkit.datamodel.TagName; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskData; import org.sleuthkit.datamodel.TskDataException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Listen for case events and update entries in the Central Repository database @@ -76,10 +76,10 @@ final class CaseEventListener implements PropertyChangeListener { @Override public void propertyChange(PropertyChangeEvent evt) { - EamDb dbManager; + CentralRepository dbManager; try { - dbManager = EamDb.getInstance(); - } catch (EamDbException ex) { + dbManager = CentralRepository.getInstance(); + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Failed to get instance of db manager.", ex); return; } @@ -117,17 +117,17 @@ final class CaseEventListener implements PropertyChangeListener { private final class ContentTagTask implements Runnable { - private final EamDb dbManager; + private final CentralRepository dbManager; private final PropertyChangeEvent event; - private ContentTagTask(EamDb db, PropertyChangeEvent evt) { + private ContentTagTask(CentralRepository db, PropertyChangeEvent evt) { dbManager = db; event = evt; } @Override public void run() { - if (!EamDb.isEnabled()) { + if (!CentralRepository.isEnabled()) { return; } @@ -197,13 +197,13 @@ final class CaseEventListener implements PropertyChangeListener { } } - final CorrelationAttributeInstance eamArtifact = EamArtifactUtil.makeInstanceFromContent(af); + final CorrelationAttributeInstance eamArtifact = CorrelationAttributeUtil.makeInstanceFromContent(af); if (eamArtifact != null) { // send update to Central Repository db try { dbManager.setAttributeInstanceKnownStatus(eamArtifact, knownStatus); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error connecting to Central Repository database while setting artifact known status.", ex); //NON-NLS } } @@ -212,17 +212,17 @@ final class CaseEventListener implements PropertyChangeListener { private final class BlackboardTagTask implements Runnable { - private final EamDb dbManager; + private final CentralRepository dbManager; private final PropertyChangeEvent event; - private BlackboardTagTask(EamDb db, PropertyChangeEvent evt) { + private BlackboardTagTask(CentralRepository db, PropertyChangeEvent evt) { dbManager = db; event = evt; } @Override public void run() { - if (!EamDb.isEnabled()) { + if (!CentralRepository.isEnabled()) { return; } @@ -297,12 +297,12 @@ final class CaseEventListener implements PropertyChangeListener { return; } - List convertedArtifacts = EamArtifactUtil.makeInstancesFromBlackboardArtifact(bbArtifact, true); + List convertedArtifacts = CorrelationAttributeUtil.makeInstancesFromBlackboardArtifact(bbArtifact, true); for (CorrelationAttributeInstance eamArtifact : convertedArtifacts) { eamArtifact.setComment(comment); try { dbManager.setAttributeInstanceKnownStatus(eamArtifact, knownStatus); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error connecting to Central Repository database while setting artifact known status.", ex); //NON-NLS } } @@ -320,7 +320,7 @@ final class CaseEventListener implements PropertyChangeListener { @Override public void run() { - if (!EamDb.isEnabled()) { + if (!CentralRepository.isEnabled()) { return; } //get the display name of the tag that has had it's definition modified @@ -370,9 +370,9 @@ final class CaseEventListener implements PropertyChangeListener { if (!hasTagWithConflictingKnownStatus) { //Get the correlation atttributes that correspond to the current BlackboardArtifactTag if their status should be changed //with the initial set of correlation attributes this should be a single correlation attribute - List convertedArtifacts = EamArtifactUtil.makeInstancesFromBlackboardArtifact(bbTag.getArtifact(), true); + List convertedArtifacts = CorrelationAttributeUtil.makeInstancesFromBlackboardArtifact(bbTag.getArtifact(), true); for (CorrelationAttributeInstance eamArtifact : convertedArtifacts) { - EamDb.getInstance().setAttributeInstanceKnownStatus(eamArtifact, tagName.getKnownStatus()); + CentralRepository.getInstance().setAttributeInstanceKnownStatus(eamArtifact, tagName.getKnownStatus()); } } } @@ -406,15 +406,15 @@ final class CaseEventListener implements PropertyChangeListener { } //if the file will have no tags with a status which would prevent the current status from being changed if (!hasTagWithConflictingKnownStatus) { - final CorrelationAttributeInstance eamArtifact = EamArtifactUtil.makeInstanceFromContent(contentTag.getContent()); + final CorrelationAttributeInstance eamArtifact = CorrelationAttributeUtil.makeInstanceFromContent(contentTag.getContent()); if (eamArtifact != null) { - EamDb.getInstance().setAttributeInstanceKnownStatus(eamArtifact, tagName.getKnownStatus()); + CentralRepository.getInstance().setAttributeInstanceKnownStatus(eamArtifact, tagName.getKnownStatus()); } } } } catch (TskCoreException ex) { LOGGER.log(Level.SEVERE, "Cannot update known status in central repository for tag: " + modifiedTagName, ex); //NON-NLS - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Cannot get central repository for tag: " + modifiedTagName, ex); //NON-NLS } catch (NoCurrentCaseException ex) { LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS @@ -424,17 +424,17 @@ final class CaseEventListener implements PropertyChangeListener { private final class DataSourceAddedTask implements Runnable { - private final EamDb dbManager; + private final CentralRepository dbManager; private final PropertyChangeEvent event; - private DataSourceAddedTask(EamDb db, PropertyChangeEvent evt) { + private DataSourceAddedTask(CentralRepository db, PropertyChangeEvent evt) { dbManager = db; event = evt; } @Override public void run() { - if (!EamDb.isEnabled()) { + if (!CentralRepository.isEnabled()) { return; } Case openCase; @@ -453,7 +453,7 @@ final class CaseEventListener implements PropertyChangeListener { if (null == dbManager.getDataSource(correlationCase, newDataSource.getId())) { CorrelationDataSource.fromTSKDataSource(correlationCase, newDataSource); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error adding new data source to the central repository", ex); //NON-NLS } } // DATA_SOURCE_ADDED @@ -461,10 +461,10 @@ final class CaseEventListener implements PropertyChangeListener { private final class CurrentCaseTask implements Runnable { - private final EamDb dbManager; + private final CentralRepository dbManager; private final PropertyChangeEvent event; - private CurrentCaseTask(EamDb db, PropertyChangeEvent evt) { + private CurrentCaseTask(CentralRepository db, PropertyChangeEvent evt) { dbManager = db; event = evt; } @@ -479,7 +479,7 @@ final class CaseEventListener implements PropertyChangeListener { Case curCase = (Case) event.getNewValue(); IngestEventsListener.resetCeModuleInstanceCount(); - if (!EamDb.isEnabled()) { + if (!CentralRepository.isEnabled()) { return; } @@ -489,7 +489,7 @@ final class CaseEventListener implements PropertyChangeListener { if (dbManager.getCase(curCase) == null) { dbManager.newCase(curCase); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error connecting to Central Repository database.", ex); //NON-NLS } } @@ -498,10 +498,10 @@ final class CaseEventListener implements PropertyChangeListener { private final class DataSourceNameChangedTask implements Runnable { - private final EamDb dbManager; + private final CentralRepository dbManager; private final PropertyChangeEvent event; - private DataSourceNameChangedTask(EamDb db, PropertyChangeEvent evt) { + private DataSourceNameChangedTask(CentralRepository db, PropertyChangeEvent evt) { dbManager = db; event = evt; } @@ -515,7 +515,7 @@ final class CaseEventListener implements PropertyChangeListener { if (! StringUtils.isEmpty(newName)) { - if (!EamDb.isEnabled()) { + if (!CentralRepository.isEnabled()) { return; } @@ -523,7 +523,7 @@ final class CaseEventListener implements PropertyChangeListener { CorrelationCase correlationCase = dbManager.getCase(Case.getCurrentCaseThrows()); CorrelationDataSource existingEamDataSource = dbManager.getDataSource(correlationCase, dataSource.getId()); dbManager.updateDataSourceName(existingEamDataSource, newName); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error updating data source with ID " + dataSource.getId() + " to " + newName, ex); //NON-NLS } catch (NoCurrentCaseException ex) { LOGGER.log(Level.SEVERE, "No open case", ex); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/IngestEventsListener.java b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/IngestEventsListener.java index 355c7c8dbc..803f20b8c4 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/IngestEventsListener.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/IngestEventsListener.java @@ -39,8 +39,8 @@ import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.ingest.ModuleDataEvent; @@ -51,7 +51,6 @@ import org.sleuthkit.datamodel.Blackboard; import org.sleuthkit.datamodel.BlackboardArtifact; import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT; import org.sleuthkit.datamodel.BlackboardAttribute; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; import org.sleuthkit.autopsy.coreutils.ThreadUtils; import static org.sleuthkit.autopsy.ingest.IngestManager.IngestModuleEvent.DATA_ADDED; import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT; @@ -62,6 +61,7 @@ import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.Image; import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TskCoreException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Listen for ingest events and update entries in the Central Repository @@ -280,10 +280,10 @@ public class IngestEventsListener { //sometimes artifacts are generated by DSPs or other sources while ingest is not running //in these cases we still want to create correlation attributesForNewArtifact for those artifacts when appropriate if (!IngestManager.getInstance().isIngestRunning() || getCeModuleInstanceCount() > 0) { - EamDb dbManager; + CentralRepository dbManager; try { - dbManager = EamDb.getInstance(); - } catch (EamDbException ex) { + dbManager = CentralRepository.getInstance(); + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Failed to connect to Central Repository database.", ex); return; } @@ -307,10 +307,10 @@ public class IngestEventsListener { @Override public void propertyChange(PropertyChangeEvent evt) { - EamDb dbManager; + CentralRepository dbManager; try { - dbManager = EamDb.getInstance(); - } catch (EamDbException ex) { + dbManager = CentralRepository.getInstance(); + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Failed to connect to Central Repository database.", ex); return; } @@ -329,10 +329,10 @@ public class IngestEventsListener { private final class AnalysisCompleteTask implements Runnable { - private final EamDb dbManager; + private final CentralRepository dbManager; private final PropertyChangeEvent event; - private AnalysisCompleteTask(EamDb db, PropertyChangeEvent evt) { + private AnalysisCompleteTask(CentralRepository db, PropertyChangeEvent evt) { dbManager = db; event = evt; } @@ -349,7 +349,7 @@ public class IngestEventsListener { * Ensure the data source in the Central Repository has hash values * that match those in the case database. */ - if (!EamDb.isEnabled()) { + if (!CentralRepository.isEnabled()) { return; } Content dataSource; @@ -412,7 +412,7 @@ public class IngestEventsListener { } } } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, String.format( "Unable to fetch data from the Central Repository for data source '%s' (obj_id=%d)", dataSourceName, dataSourceObjectId), ex); @@ -428,13 +428,13 @@ public class IngestEventsListener { private final class DataAddedTask implements Runnable { - private final EamDb dbManager; + private final CentralRepository dbManager; private final PropertyChangeEvent event; private final boolean flagNotableItemsEnabled; private final boolean flagPreviousItemsEnabled; private final boolean createCorrelationAttributes; - private DataAddedTask(EamDb db, PropertyChangeEvent evt, boolean flagNotableItemsEnabled, boolean flagPreviousItemsEnabled, boolean createCorrelationAttributes) { + private DataAddedTask(CentralRepository db, PropertyChangeEvent evt, boolean flagNotableItemsEnabled, boolean flagPreviousItemsEnabled, boolean createCorrelationAttributes) { this.dbManager = db; this.event = evt; this.flagNotableItemsEnabled = flagNotableItemsEnabled; @@ -444,7 +444,7 @@ public class IngestEventsListener { @Override public void run() { - if (!EamDb.isEnabled()) { + if (!CentralRepository.isEnabled()) { return; } final ModuleDataEvent mde = (ModuleDataEvent) event.getOldValue(); @@ -456,7 +456,7 @@ public class IngestEventsListener { for (BlackboardArtifact bbArtifact : bbArtifacts) { // eamArtifact will be null OR a EamArtifact containing one EamArtifactInstance. - List convertedArtifacts = EamArtifactUtil.makeInstancesFromBlackboardArtifact(bbArtifact, true); + List convertedArtifacts = CorrelationAttributeUtil.makeInstancesFromBlackboardArtifact(bbArtifact, true); for (CorrelationAttributeInstance eamArtifact : convertedArtifacts) { try { // Only do something with this artifact if it's unique within the job @@ -502,7 +502,7 @@ public class IngestEventsListener { eamArtifacts.add(eamArtifact); } } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error counting notable artifacts.", ex); } } @@ -511,7 +511,7 @@ public class IngestEventsListener { for (CorrelationAttributeInstance eamArtifact : eamArtifacts) { try { dbManager.addArtifactInstance(eamArtifact); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error adding artifact to database.", ex); //NON-NLS } } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java index 690fb9189d..272a9047bb 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/Installer.java @@ -23,8 +23,8 @@ import org.openide.modules.ModuleInstall; import org.openide.util.NbBundle; import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.casemodule.Case; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbUtil; import org.sleuthkit.autopsy.core.RuntimeProperties; import org.sleuthkit.autopsy.coreutils.Logger; @@ -59,8 +59,8 @@ public class Installer extends ModuleInstall { // Perform the database upgrade and inform the user if it fails try { - EamDbUtil.upgradeDatabase(); - } catch (EamDbException ex) { + CentralRepoDbUtil.upgradeDatabase(); + } catch (CentralRepoException ex) { if (RuntimeProperties.runningWithGUI()) { WindowManager.getDefault().invokeWhenUIReady(() -> { JOptionPane.showMessageDialog(null, diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/ingestmodule/CentralRepoIngestModule.java b/Core/src/org/sleuthkit/autopsy/centralrepository/ingestmodule/CentralRepoIngestModule.java index bea9b801b8..ec00dffe88 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/ingestmodule/CentralRepoIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/ingestmodule/CentralRepoIngestModule.java @@ -30,10 +30,9 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeIns import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationDataSource; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbPlatformEnum; +import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoPlatforms; import org.sleuthkit.autopsy.centralrepository.eventlisteners.IngestEventsListener; import org.sleuthkit.autopsy.core.RuntimeProperties; import org.sleuthkit.autopsy.coreutils.Logger; @@ -55,6 +54,7 @@ import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET import org.sleuthkit.datamodel.HashUtility; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskData; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Ingest module for inserting entries into the Central Repository database on @@ -96,7 +96,7 @@ final class CentralRepoIngestModule implements FileIngestModule { @Override public ProcessResult process(AbstractFile abstractFile) { - if (EamDb.isEnabled() == false) { + if (CentralRepository.isEnabled() == false) { /* * Not signaling an error for now. This is a workaround for the way * all newly didscovered ingest modules are automatically anabled. @@ -113,7 +113,7 @@ final class CentralRepoIngestModule implements FileIngestModule { return ProcessResult.ERROR; } - if (!EamArtifactUtil.isSupportedAbstractFileType(abstractFile)) { + if (!CorrelationAttributeUtil.isSupportedAbstractFileType(abstractFile)) { return ProcessResult.OK; } @@ -121,10 +121,10 @@ final class CentralRepoIngestModule implements FileIngestModule { return ProcessResult.OK; } - EamDb dbManager; + CentralRepository dbManager; try { - dbManager = EamDb.getInstance(); - } catch (EamDbException ex) { + dbManager = CentralRepository.getInstance(); + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Error connecting to Central Repository database.", ex); return ProcessResult.ERROR; } @@ -152,7 +152,7 @@ final class CentralRepoIngestModule implements FileIngestModule { if (!caseDisplayNamesList.isEmpty()) { postCorrelatedBadFileToBlackboard(abstractFile, caseDisplayNamesList); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Error searching database for artifact.", ex); // NON-NLS return ProcessResult.ERROR; } catch (CorrelationAttributeNormalizationException ex) { @@ -175,7 +175,7 @@ final class CentralRepoIngestModule implements FileIngestModule { , abstractFile.getId()); dbManager.addAttributeInstanceBulk(cefi); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Error adding artifact to bulk artifacts.", ex); // NON-NLS return ProcessResult.ERROR; } catch (CorrelationAttributeNormalizationException ex) { @@ -190,25 +190,25 @@ final class CentralRepoIngestModule implements FileIngestModule { public void shutDown() { IngestEventsListener.decrementCorrelationEngineModuleCount(); - if ((EamDb.isEnabled() == false) || (eamCase == null) || (eamDataSource == null)) { + if ((CentralRepository.isEnabled() == false) || (eamCase == null) || (eamDataSource == null)) { return; } - EamDb dbManager; + CentralRepository dbManager; try { - dbManager = EamDb.getInstance(); - } catch (EamDbException ex) { + dbManager = CentralRepository.getInstance(); + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Error connecting to Central Repository database.", ex); return; } try { dbManager.commitAttributeInstancesBulk(); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Error doing bulk insert of artifacts.", ex); // NON-NLS } try { Long count = dbManager.getCountArtifactInstancesByCaseDataSource(eamDataSource); logger.log(Level.INFO, "{0} artifacts in db for case: {1} ds:{2}", new Object[]{count, eamCase.getDisplayName(), eamDataSource.getName()}); // NON-NLS - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Error counting artifacts.", ex); // NON-NLS } @@ -249,7 +249,7 @@ final class CentralRepoIngestModule implements FileIngestModule { IngestEventsListener.setCreateCrProperties(createCorrelationProperties); } - if (EamDb.isEnabled() == false) { + if (CentralRepository.isEnabled() == false) { /* * Not throwing the customary exception for now. This is a * workaround for the way all newly didscovered ingest modules are @@ -274,36 +274,36 @@ final class CentralRepoIngestModule implements FileIngestModule { // Don't allow sqlite central repo databases to be used for multi user cases if ((autopsyCase.getCaseType() == Case.CaseType.MULTI_USER_CASE) - && (EamDbPlatformEnum.getSelectedPlatform() == EamDbPlatformEnum.SQLITE)) { + && (CentralRepoPlatforms.getSelectedPlatform() == CentralRepoPlatforms.SQLITE)) { logger.log(Level.SEVERE, "Cannot run correlation engine on a multi-user case with a SQLite central repository."); throw new IngestModuleException("Cannot run on a multi-user case with a SQLite central repository."); // NON-NLS } jobId = context.getJobId(); - EamDb centralRepoDb; + CentralRepository centralRepoDb; try { - centralRepoDb = EamDb.getInstance(); - } catch (EamDbException ex) { + centralRepoDb = CentralRepository.getInstance(); + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Error connecting to central repository database.", ex); // NON-NLS throw new IngestModuleException("Error connecting to central repository database.", ex); // NON-NLS } try { filesType = centralRepoDb.getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Error getting correlation type FILES in ingest module start up.", ex); // NON-NLS throw new IngestModuleException("Error getting correlation type FILES in ingest module start up.", ex); // NON-NLS } try { eamCase = centralRepoDb.getCase(autopsyCase); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { throw new IngestModuleException("Unable to get case from central repository database ", ex); } try { eamDataSource = CorrelationDataSource.fromTSKDataSource(eamCase, context.getDataSource()); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Error getting data source info.", ex); // NON-NLS throw new IngestModuleException("Error getting data source info.", ex); // NON-NLS } @@ -317,7 +317,7 @@ final class CentralRepoIngestModule implements FileIngestModule { if (null == centralRepoDb.getDataSource(eamCase, eamDataSource.getDataSourceObjectID())) { centralRepoDb.newDataSource(eamDataSource); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Error adding data source to Central Repository.", ex); // NON-NLS throw new IngestModuleException("Error adding data source to Central Repository.", ex); // NON-NLS } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/AddNewOrganizationDialog.java b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/AddNewOrganizationDialog.java index 79ce921dfe..291fdb8589 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/AddNewOrganizationDialog.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/AddNewOrganizationDialog.java @@ -29,9 +29,9 @@ import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.NbBundle.Messages; import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamOrganization; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoOrganization; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Dialog to add a new organization to the Central Repository database @@ -45,8 +45,8 @@ class AddNewOrganizationDialog extends javax.swing.JDialog { private final Collection textBoxes; private final TextBoxChangedListener textBoxChangedListener; private boolean hasChanged; - private EamOrganization newOrg; - private final EamOrganization organizationToEdit; + private CentralRepoOrganization newOrg; + private final CentralRepoOrganization organizationToEdit; /** * Creates new form AddNewOrganizationDialog @@ -67,7 +67,7 @@ class AddNewOrganizationDialog extends javax.swing.JDialog { } // populates the dialog with existing case information to edit - public AddNewOrganizationDialog(EamOrganization orgToEdit) { + public AddNewOrganizationDialog(CentralRepoOrganization orgToEdit) { super((JFrame) WindowManager.getDefault().getMainWindow(), Bundle.AddNewOrganizationDialog_addNewOrg_msg(), true); // NON-NLS @@ -208,7 +208,7 @@ class AddNewOrganizationDialog extends javax.swing.JDialog { * * @return Org that was added or changed. null if nothing changed */ - public EamOrganization getNewOrg() { + public CentralRepoOrganization getNewOrg() { return newOrg; } @@ -341,7 +341,7 @@ class AddNewOrganizationDialog extends javax.swing.JDialog { private void bnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnOKActionPerformed try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); if (organizationToEdit != null) { // make a copy in case the update fails newOrg = dbManager.getOrganizationByID(organizationToEdit.getOrgID()); @@ -351,7 +351,7 @@ class AddNewOrganizationDialog extends javax.swing.JDialog { newOrg.setPocPhone(tfPocPhone.getText()); dbManager.updateOrganization(newOrg); } else { - newOrg = new EamOrganization( + newOrg = new CentralRepoOrganization( tfOrganizationName.getText(), tfPocName.getText(), tfPocEmail.getText(), @@ -360,7 +360,7 @@ class AddNewOrganizationDialog extends javax.swing.JDialog { } hasChanged = true; dispose(); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { lbWarningMsg.setText(Bundle.AddNewOrganizationDialog_bnOk_addFailed_text()); logger.log(Level.SEVERE, "Failed adding new organization.", ex); newOrg = null; diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/CaseDataSourcesWrapper.java b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/CaseDataSourcesWrapper.java index 34695fc354..c0a21f4ff3 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/CaseDataSourcesWrapper.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/CaseDataSourcesWrapper.java @@ -22,7 +22,7 @@ import java.util.Collections; import java.util.List; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationDataSource; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamOrganization; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoOrganization; /** * An object to contain both a CorrelationCase and the list of @@ -80,7 +80,7 @@ class CaseDataSourcesWrapper { * @return the organization name of the CorrelationCase. */ String getOrganizationName() { - EamOrganization org = eamCase.getOrg(); + CentralRepoOrganization org = eamCase.getOrg(); return org == null ? "" : org.getName(); } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/EamDbSettingsDialog.form b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/EamDbSettingsDialog.form index b063773f48..0f39326bec 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/EamDbSettingsDialog.form +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/EamDbSettingsDialog.form @@ -320,7 +320,7 @@ - + @@ -330,7 +330,7 @@ - + @@ -410,4 +410,4 @@ - + \ No newline at end of file diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/EamDbSettingsDialog.java b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/EamDbSettingsDialog.java index 5c68b51b92..271a8a4f04 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/EamDbSettingsDialog.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/EamDbSettingsDialog.java @@ -1,7 +1,7 @@ /* * Central Repository * - * Copyright 2015-2018 Basis Technology Corp. + * Copyright 2015-2020 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -37,14 +37,14 @@ import javax.swing.filechooser.FileFilter; import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.NbBundle.Messages; import org.openide.windows.WindowManager; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; import org.sleuthkit.autopsy.corecomponents.TextPrompt; import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbPlatformEnum; -import static org.sleuthkit.autopsy.centralrepository.datamodel.EamDbPlatformEnum.SQLITE; -import org.sleuthkit.autopsy.centralrepository.datamodel.PostgresEamDbSettings; -import org.sleuthkit.autopsy.centralrepository.datamodel.SqliteEamDbSettings; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoPlatforms; +import static org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoPlatforms.SQLITE; +import org.sleuthkit.autopsy.centralrepository.datamodel.PostgresCentralRepoSettings; +import org.sleuthkit.autopsy.centralrepository.datamodel.SqliteCentralRepoSettings; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Configuration dialog for Central Repository database settings. @@ -59,10 +59,10 @@ public class EamDbSettingsDialog extends JDialog { private final Collection textBoxes; private final TextBoxChangedListener textBoxChangedListener; - private final PostgresEamDbSettings dbSettingsPostgres; - private final SqliteEamDbSettings dbSettingsSqlite; + private final PostgresCentralRepoSettings dbSettingsPostgres; + private final SqliteCentralRepoSettings dbSettingsSqlite; private DatabaseTestResult testingStatus; - private EamDbPlatformEnum selectedPlatform; + private CentralRepoPlatforms selectedPlatform; private boolean configurationChanged = false; /** @@ -80,11 +80,11 @@ public class EamDbSettingsDialog extends JDialog { textBoxes = new ArrayList<>(); textBoxChangedListener = new TextBoxChangedListener(); - dbSettingsPostgres = new PostgresEamDbSettings(); - dbSettingsSqlite = new SqliteEamDbSettings(); - selectedPlatform = EamDbPlatformEnum.getSelectedPlatform(); - if (selectedPlatform == null || selectedPlatform.equals(EamDbPlatformEnum.DISABLED)) { - selectedPlatform = EamDbPlatformEnum.POSTGRESQL; + dbSettingsPostgres = new PostgresCentralRepoSettings(); + dbSettingsSqlite = new SqliteCentralRepoSettings(); + selectedPlatform = CentralRepoPlatforms.getSelectedPlatform(); + if (selectedPlatform == null || selectedPlatform.equals(CentralRepoPlatforms.DISABLED)) { + selectedPlatform = CentralRepoPlatforms.POSTGRESQL; } initComponents(); @@ -226,7 +226,7 @@ public class EamDbSettingsDialog extends JDialog { jpDbPassword.setPreferredSize(new java.awt.Dimension(509, 20)); - cbDatabaseType.setModel(new javax.swing.DefaultComboBoxModel<>(new EamDbPlatformEnum[]{EamDbPlatformEnum.POSTGRESQL, EamDbPlatformEnum.SQLITE})); + cbDatabaseType.setModel(new javax.swing.DefaultComboBoxModel<>(new CentralRepoPlatforms[]{CentralRepoPlatforms.POSTGRESQL, CentralRepoPlatforms.SQLITE})); cbDatabaseType.setPreferredSize(new java.awt.Dimension(120, 20)); cbDatabaseType.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -372,7 +372,7 @@ public class EamDbSettingsDialog extends JDialog { break; } - displayDatabaseSettings(selectedPlatform.equals(EamDbPlatformEnum.POSTGRESQL)); + displayDatabaseSettings(selectedPlatform.equals(CentralRepoPlatforms.POSTGRESQL)); } private void display() { @@ -548,12 +548,12 @@ public class EamDbSettingsDialog extends JDialog { * using those new settings. */ try { - EamDb previousDbManager = EamDb.getInstance(); + CentralRepository previousDbManager = CentralRepository.getInstance(); if (null != previousDbManager) { // NOTE: do not set/save the seleted platform before calling this. - EamDb.getInstance().shutdownConnections(); + CentralRepository.getInstance().shutdownConnections(); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Failed to close database connections in previously selected platform.", ex); // NON-NLS SwingUtilities.invokeLater(() -> { JOptionPane.showMessageDialog(this, @@ -566,8 +566,8 @@ public class EamDbSettingsDialog extends JDialog { // Even if we fail to close the existing connections, make sure that we // save the new connection settings, so an Autopsy restart will correctly // start with the new settings. - EamDbPlatformEnum.setSelectedPlatform(selectedPlatform.name()); - EamDbPlatformEnum.saveSelectedPlatform(); + CentralRepoPlatforms.setSelectedPlatform(selectedPlatform.name()); + CentralRepoPlatforms.saveSelectedPlatform(); switch (selectedPlatform) { case POSTGRESQL: @@ -576,9 +576,9 @@ public class EamDbSettingsDialog extends JDialog { // Load those newly saved settings into the postgres db manager instance // in case we are still using the same instance. try { - EamDb.getInstance().updateSettings(); + CentralRepository.getInstance().updateSettings(); configurationChanged = true; - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, Bundle.EamDbSettingsDialog_okButton_connectionErrorMsg_text(), ex); //NON-NLS setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); return; @@ -591,9 +591,9 @@ public class EamDbSettingsDialog extends JDialog { // Load those newly saved settings into the sqlite db manager instance // in case we are still using the same instance. try { - EamDb.getInstance().updateSettings(); + CentralRepository.getInstance().updateSettings(); configurationChanged = true; - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, Bundle.EamDbSettingsDialog_okButton_connectionErrorMsg_text(), ex); //NON-NLS setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); return; @@ -613,7 +613,7 @@ public class EamDbSettingsDialog extends JDialog { private void cbDatabaseTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbDatabaseTypeActionPerformed - selectedPlatform = (EamDbPlatformEnum) cbDatabaseType.getSelectedItem(); + selectedPlatform = (CentralRepoPlatforms) cbDatabaseType.getSelectedItem(); customizeComponents(); }//GEN-LAST:event_cbDatabaseTypeActionPerformed @@ -770,35 +770,35 @@ public class EamDbSettingsDialog extends JDialog { case POSTGRESQL: try { dbSettingsPostgres.setHost(tbDbHostname.getText().trim()); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { guidanceText.append(ex.getMessage()); result = false; } try { dbSettingsPostgres.setPort(Integer.valueOf(tbDbPort.getText().trim())); - } catch (NumberFormatException | EamDbException ex) { + } catch (NumberFormatException | CentralRepoException ex) { guidanceText.append(ex.getMessage()); result = false; } try { dbSettingsPostgres.setDbName(CENTRAL_REPO_DB_NAME); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { guidanceText.append(ex.getMessage()); result = false; } try { dbSettingsPostgres.setUserName(tbDbUsername.getText().trim()); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { guidanceText.append(ex.getMessage()); result = false; } try { dbSettingsPostgres.setPassword(new String(jpDbPassword.getPassword())); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { guidanceText.append(ex.getMessage()); result = false; } @@ -808,7 +808,7 @@ public class EamDbSettingsDialog extends JDialog { File databasePath = new File(tfDatabasePath.getText()); dbSettingsSqlite.setDbName(CENTRAL_REPO_DB_NAME + CENTRAL_REPO_SQLITE_EXT); dbSettingsSqlite.setDbDirectory(databasePath.getPath()); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { guidanceText.append(ex.getMessage()); result = false; } @@ -889,7 +889,7 @@ public class EamDbSettingsDialog extends JDialog { private javax.swing.JButton bnDatabasePathFileOpen; private javax.swing.ButtonGroup bnGrpDatabasePlatforms; private javax.swing.JButton bnOk; - private javax.swing.JComboBox cbDatabaseType; + private javax.swing.JComboBox cbDatabaseType; private javax.swing.JScrollPane dataBaseFileScrollPane; private javax.swing.JTextArea dataBaseFileTextArea; private javax.swing.JFileChooser fcDatabasePath; diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/GlobalSettingsPanel.java b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/GlobalSettingsPanel.java index 37718a8d7c..ebd85ba527 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/GlobalSettingsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/GlobalSettingsPanel.java @@ -1,7 +1,7 @@ /* * Central Repository * - * Copyright 2015-2019 Basis Technology Corp. + * Copyright 2015-2020 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,16 +31,16 @@ import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.NbBundle; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.casemodule.Case; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.corecomponents.OptionsPanel; import org.sleuthkit.autopsy.events.AutopsyEvent; import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.ingest.IngestModuleGlobalSettingsPanel; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbPlatformEnum; -import static org.sleuthkit.autopsy.centralrepository.datamodel.EamDbPlatformEnum.DISABLED; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil; -import org.sleuthkit.autopsy.centralrepository.datamodel.PostgresEamDbSettings; -import org.sleuthkit.autopsy.centralrepository.datamodel.SqliteEamDbSettings; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoPlatforms; +import static org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoPlatforms.DISABLED; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.PostgresCentralRepoSettings; +import org.sleuthkit.autopsy.centralrepository.datamodel.SqliteCentralRepoSettings; /** * Main settings panel for the Central Repository @@ -80,15 +80,15 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i @Messages({"GlobalSettingsPanel.updateFailed.title=Central repository disabled"}) private void updateDatabase() { - if (EamDbPlatformEnum.getSelectedPlatform().equals(DISABLED)) { + if (CentralRepoPlatforms.getSelectedPlatform().equals(DISABLED)) { return; } setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try { - EamDbUtil.upgradeDatabase(); + CentralRepoDbUtil.upgradeDatabase(); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); JOptionPane.showMessageDialog(this, ex.getUserMessage(), @@ -456,25 +456,25 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i public void load() { tbOops.setText(""); enableButtonSubComponents(false); - EamDbPlatformEnum selectedPlatform = EamDbPlatformEnum.getSelectedPlatform(); - cbUseCentralRepo.setSelected(EamDbUtil.allowUseOfCentralRepository()); // NON-NLS + CentralRepoPlatforms selectedPlatform = CentralRepoPlatforms.getSelectedPlatform(); + cbUseCentralRepo.setSelected(CentralRepoDbUtil.allowUseOfCentralRepository()); // NON-NLS switch (selectedPlatform) { case POSTGRESQL: - PostgresEamDbSettings dbSettingsPg = new PostgresEamDbSettings(); - lbDbPlatformValue.setText(EamDbPlatformEnum.POSTGRESQL.toString()); + PostgresCentralRepoSettings dbSettingsPg = new PostgresCentralRepoSettings(); + lbDbPlatformValue.setText(CentralRepoPlatforms.POSTGRESQL.toString()); lbDbNameValue.setText(dbSettingsPg.getDbName()); lbDbLocationValue.setText(dbSettingsPg.getHost()); enableButtonSubComponents(cbUseCentralRepo.isSelected()); break; case SQLITE: - SqliteEamDbSettings dbSettingsSqlite = new SqliteEamDbSettings(); - lbDbPlatformValue.setText(EamDbPlatformEnum.SQLITE.toString()); + SqliteCentralRepoSettings dbSettingsSqlite = new SqliteCentralRepoSettings(); + lbDbPlatformValue.setText(CentralRepoPlatforms.SQLITE.toString()); lbDbNameValue.setText(dbSettingsSqlite.getDbName()); lbDbLocationValue.setText(dbSettingsSqlite.getDbDirectory()); enableButtonSubComponents(cbUseCentralRepo.isSelected()); break; default: - lbDbPlatformValue.setText(EamDbPlatformEnum.DISABLED.toString()); + lbDbPlatformValue.setText(CentralRepoPlatforms.DISABLED.toString()); lbDbNameValue.setText(""); lbDbLocationValue.setText(""); tbOops.setText(Bundle.GlobalSettingsPanel_validationerrMsg_mustConfigure()); @@ -485,7 +485,7 @@ public final class GlobalSettingsPanel extends IngestModuleGlobalSettingsPanel i @Override public void store() { // Click OK or Apply on Options Panel - EamDbUtil.setUseCentralRepo(cbUseCentralRepo.isSelected()); + CentralRepoDbUtil.setUseCentralRepo(cbUseCentralRepo.isSelected()); } /** diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageCasesDialog.java b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageCasesDialog.java index f782af67c5..687aba7ff6 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageCasesDialog.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageCasesDialog.java @@ -28,10 +28,10 @@ import javax.swing.event.ListSelectionListener; import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationDataSource; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.coreutils.Logger; import org.openide.util.NbBundle.Messages; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * A dialog which displays cases existing in the central repository and the @@ -55,7 +55,7 @@ final class ManageCasesDialog extends javax.swing.JDialog { true); initComponents(); try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); Map> dataSourcesByCaseId = new HashMap<>(); for (CorrelationDataSource dataSource : dbManager.getDataSources()) { int caseID = dataSource.getCaseID(); @@ -66,7 +66,7 @@ final class ManageCasesDialog extends javax.swing.JDialog { for (CorrelationCase eamCase : dbManager.getCases()) { casesTableModel.addEamCase(eamCase, dataSourcesByCaseId.getOrDefault(eamCase.getID(), new ArrayList<>())); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Error getting list of cases from database.", ex); // NON-NLS } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageCorrelationPropertiesDialog.java b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageCorrelationPropertiesDialog.java index e426534742..2aafcb7310 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageCorrelationPropertiesDialog.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageCorrelationPropertiesDialog.java @@ -30,8 +30,8 @@ import org.openide.util.NbBundle.Messages; import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Dialog to handle management of artifact types handled by the Central @@ -69,10 +69,10 @@ final class ManageCorrelationPropertiesDialog extends javax.swing.JDialog { private void loadData() { DefaultTableModel model = (DefaultTableModel) tbCorrelatableTypes.getModel(); try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); correlationTypes.clear(); correlationTypes.addAll(dbManager.getDefinedCorrelationTypes()); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.WARNING, "Error loading data", ex); } @@ -243,10 +243,10 @@ final class ManageCorrelationPropertiesDialog extends javax.swing.JDialog { if (0 == correlationTypes.size()) { dispose(); } else { - EamDb dbManager; + CentralRepository dbManager; try { - dbManager = EamDb.getInstance(); - } catch (EamDbException ex) { + dbManager = CentralRepository.getInstance(); + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Failed to connect to central repository database.", ex); lbWarningMsg.setText(Bundle.ManageCorrelationPropertiesDialog_okbutton_failure()); return; @@ -255,7 +255,7 @@ final class ManageCorrelationPropertiesDialog extends javax.swing.JDialog { try { dbManager.updateCorrelationType(aType); dispose(); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Failed to update correlation properties with selections from dialog.", ex); // NON-NLS lbWarningMsg.setText(Bundle.ManageCorrelationPropertiesDialog_okbutton_failure()); } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageOrganizationsDialog.form b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageOrganizationsDialog.form index 33c03ebf9d..965ba5da5c 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageOrganizationsDialog.form +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageOrganizationsDialog.form @@ -183,7 +183,7 @@ - + @@ -357,4 +357,4 @@ - + \ No newline at end of file diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageOrganizationsDialog.java b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageOrganizationsDialog.java index 04403be0f4..8df751ba57 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageOrganizationsDialog.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/ManageOrganizationsDialog.java @@ -30,11 +30,11 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.openide.util.NbBundle.Messages; import org.openide.windows.WindowManager; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamOrganization; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoOrganization; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Configuration dialog to manage organizations for the Central Repository. @@ -44,9 +44,9 @@ public final class ManageOrganizationsDialog extends JDialog { private static final long serialVersionUID = 1L; - private EamDb dbManager; - private EamOrganization newOrg; - private final DefaultListModel rulesListModel = new DefaultListModel<>(); + private CentralRepository dbManager; + private CentralRepoOrganization newOrg; + private final DefaultListModel rulesListModel = new DefaultListModel<>(); private final static Logger logger = Logger.getLogger(ManageOrganizationsDialog.class.getName()); @Messages({"ManageOrganizationsDialog.title.text=Manage Organizations"}) @@ -59,7 +59,7 @@ public final class ManageOrganizationsDialog extends JDialog { true); // NON-NLS initComponents(); try { - this.dbManager = EamDb.getInstance(); + this.dbManager = CentralRepository.getInstance(); organizationList.setCellRenderer(new DefaultListCellRenderer() { private static final long serialVersionUID = 1L; @@ -67,7 +67,7 @@ public final class ManageOrganizationsDialog extends JDialog { @Override public Component getListCellRendererComponent(javax.swing.JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - setText(((EamOrganization) value).getName()); + setText(((CentralRepoOrganization) value).getName()); return c; } }); @@ -76,7 +76,7 @@ public final class ManageOrganizationsDialog extends JDialog { populateList(); setButtonsEnabled(organizationList.getSelectedValue()); newOrg = null; - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.WARNING, "Error getting Central Repo for Organizations dialog", ex); } display(); @@ -87,11 +87,11 @@ public final class ManageOrganizationsDialog extends JDialog { setVisible(true); } - private void populateListAndSelect(EamOrganization selected) throws EamDbException { + private void populateListAndSelect(CentralRepoOrganization selected) throws CentralRepoException { rulesListModel.clear(); - List orgs = dbManager.getOrganizations(); + List orgs = dbManager.getOrganizations(); if (orgs.size() > 0) { - for (EamOrganization org : orgs) { + for (CentralRepoOrganization org : orgs) { rulesListModel.addElement(org); if (selected != null && org.getOrgID() == selected.getOrgID()) { selected = org; @@ -107,8 +107,8 @@ public final class ManageOrganizationsDialog extends JDialog { } } - private void populateList() throws EamDbException { - EamOrganization selected = organizationList.getSelectedValue(); + private void populateList() throws CentralRepoException { + CentralRepoOrganization selected = organizationList.getSelectedValue(); populateListAndSelect(selected); } @@ -344,16 +344,16 @@ public final class ManageOrganizationsDialog extends JDialog { }// //GEN-END:initComponents private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed - EamOrganization orgToDelete = organizationList.getSelectedValue(); + CentralRepoOrganization orgToDelete = organizationList.getSelectedValue(); if (orgToDelete != null) { if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(WindowManager.getDefault().getMainWindow(), Bundle.ManageOrganizationsDialog_confirmDeletion_message(), Bundle.ManageOrganizationsDialog_confirmDeletion_title(), JOptionPane.YES_NO_OPTION)) { try { - EamDb.getInstance().deleteOrganization(orgToDelete); + CentralRepository.getInstance().deleteOrganization(orgToDelete); populateList(); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { JOptionPane.showMessageDialog(this, ex.getMessage(), Bundle.ManageOrganizationsDialog_unableToDeleteOrg_title(), JOptionPane.WARNING_MESSAGE); logger.log(Level.INFO, "Was unable to delete organization from central repository", ex); @@ -372,21 +372,21 @@ public final class ManageOrganizationsDialog extends JDialog { try { newOrg = dialogO.getNewOrg(); populateListAndSelect(dialogO.getNewOrg()); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { } } }//GEN-LAST:event_newButtonActionPerformed private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed - EamOrganization orgToEdit = organizationList.getSelectedValue(); + CentralRepoOrganization orgToEdit = organizationList.getSelectedValue(); if (orgToEdit != null) { AddNewOrganizationDialog dialogO = new AddNewOrganizationDialog(orgToEdit); if (dialogO.isChanged()) { try { newOrg = dialogO.getNewOrg(); populateListAndSelect(dialogO.getNewOrg()); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { } } @@ -409,7 +409,7 @@ public final class ManageOrganizationsDialog extends JDialog { private javax.swing.JScrollPane orgListScrollPane; private javax.swing.JLabel orgNameLabel; private javax.swing.JTextField orgNameTextField; - private javax.swing.JList organizationList; + private javax.swing.JList organizationList; private javax.swing.JLabel pocEmailLabel; private javax.swing.JTextField pocEmailTextField; private javax.swing.JLabel pocNameLabel; @@ -421,15 +421,15 @@ public final class ManageOrganizationsDialog extends JDialog { return newOrg != null; } - public EamOrganization getNewOrg() { + public CentralRepoOrganization getNewOrg() { return newOrg; } - private void setButtonsEnabled(EamOrganization selectedOrg) { + private void setButtonsEnabled(CentralRepoOrganization selectedOrg) { boolean isSelected = (selectedOrg != null); boolean isDefaultOrg = false; if(selectedOrg != null){ - isDefaultOrg = EamDbUtil.isDefaultOrg(selectedOrg); + isDefaultOrg = CentralRepoDbUtil.isDefaultOrg(selectedOrg); } editButton.setEnabled(isSelected && (! isDefaultOrg)); @@ -446,7 +446,7 @@ public final class ManageOrganizationsDialog extends JDialog { if (e.getValueIsAdjusting()) { return; } - EamOrganization selected = organizationList.getSelectedValue(); + CentralRepoOrganization selected = organizationList.getSelectedValue(); setButtonsEnabled(selected); if (selected != null) { orgNameTextField.setText(selected.getName()); diff --git a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/AbstractCommonAttributeSearcher.java b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/AbstractCommonAttributeSearcher.java index 1880489cc4..e241908042 100644 --- a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/AbstractCommonAttributeSearcher.java +++ b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/AbstractCommonAttributeSearcher.java @@ -29,7 +29,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.datamodel.TskCoreException; /** @@ -60,9 +60,9 @@ public abstract class AbstractCommonAttributeSearcher { * @throws TskCoreException * @throws NoCurrentCaseException * @throws SQLException - * @throws EamDbException + * @throws CentralRepoException */ - public abstract CommonAttributeCountSearchResults findMatchesByCount() throws TskCoreException, NoCurrentCaseException, SQLException, EamDbException; + public abstract CommonAttributeCountSearchResults findMatchesByCount() throws TskCoreException, NoCurrentCaseException, SQLException, CentralRepoException; /** * Implement this to search for files with common attributes. Creates an @@ -78,9 +78,9 @@ public abstract class AbstractCommonAttributeSearcher { * @throws TskCoreException * @throws NoCurrentCaseException * @throws SQLException - * @throws EamDbException + * @throws CentralRepoException */ - public abstract CommonAttributeCaseSearchResults findMatchesByCase() throws TskCoreException, NoCurrentCaseException, SQLException, EamDbException; + public abstract CommonAttributeCaseSearchResults findMatchesByCase() throws TskCoreException, NoCurrentCaseException, SQLException, CentralRepoException; /** * Implement this to create a descriptive string for the tab which will diff --git a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/AllInterCaseCommonAttributeSearcher.java b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/AllInterCaseCommonAttributeSearcher.java index ee9c70211f..b41d484b12 100644 --- a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/AllInterCaseCommonAttributeSearcher.java +++ b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/AllInterCaseCommonAttributeSearcher.java @@ -26,7 +26,7 @@ import java.util.Set; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance.Type; import static org.sleuthkit.autopsy.commonpropertiessearch.AbstractCommonAttributeSearcher.MEDIA_PICS_VIDEO_MIME_TYPES; @@ -47,14 +47,14 @@ public class AllInterCaseCommonAttributeSearcher extends InterCaseCommonAttribut * @param percentageThreshold omit any matches with frequency above this * threshold * - * @throws EamDbException + * @throws CentralRepoException */ - public AllInterCaseCommonAttributeSearcher(boolean filterByMediaMimeType, boolean filterByDocMimeType, Type corAttrType, int percentageThreshold) throws EamDbException { + public AllInterCaseCommonAttributeSearcher(boolean filterByMediaMimeType, boolean filterByDocMimeType, Type corAttrType, int percentageThreshold) throws CentralRepoException { super(filterByMediaMimeType, filterByDocMimeType, corAttrType, percentageThreshold); } @Override - public CommonAttributeCountSearchResults findMatchesByCount() throws TskCoreException, NoCurrentCaseException, SQLException, EamDbException { + public CommonAttributeCountSearchResults findMatchesByCount() throws TskCoreException, NoCurrentCaseException, SQLException, CentralRepoException { InterCaseSearchResultsProcessor eamDbAttrInst = new InterCaseSearchResultsProcessor(corAttrType); Set mimeTypesToFilterOn = new HashSet<>(); if (isFilterByMedia()) { @@ -68,7 +68,7 @@ public class AllInterCaseCommonAttributeSearcher extends InterCaseCommonAttribut } @Override - public CommonAttributeCaseSearchResults findMatchesByCase() throws TskCoreException, NoCurrentCaseException, SQLException, EamDbException { + public CommonAttributeCaseSearchResults findMatchesByCase() throws TskCoreException, NoCurrentCaseException, SQLException, CentralRepoException { InterCaseSearchResultsProcessor eamDbAttrInst = new InterCaseSearchResultsProcessor(corAttrType); Set mimeTypesToFilterOn = new HashSet<>(); if (isFilterByMedia()) { diff --git a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeCaseSearchResults.java b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeCaseSearchResults.java index 3ff7d40070..0f87533504 100644 --- a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeCaseSearchResults.java +++ b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeCaseSearchResults.java @@ -30,9 +30,9 @@ import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Stores the results from the various types of common attribute searching @@ -116,7 +116,7 @@ final public class CommonAttributeCaseSearchResults { try { currentCaseName = Case.getCurrentCaseThrows().getDisplayName(); } catch (NoCurrentCaseException ex) { - throw new EamDbException("Unable to get current case while performing filtering", ex); + throw new CentralRepoException("Unable to get current case while performing filtering", ex); } Map currentCaseDataSourceMap = metadata.get(currentCaseName); Map> filteredCaseNameToDataSourcesTree = new HashMap<>(); @@ -129,7 +129,7 @@ final public class CommonAttributeCaseSearchResults { .filter(filterType -> filterType.getId() == resultTypeId) .findFirst().get(); //Call countUniqueDataSources once to reduce the number of DB queries needed to get the frequencyPercentage - Double uniqueCaseDataSourceTuples = EamDb.getInstance().getCountUniqueDataSources().doubleValue(); + Double uniqueCaseDataSourceTuples = CentralRepository.getInstance().getCountUniqueDataSources().doubleValue(); Map valuesToKeepCurrentCase = getValuesToKeepFromCurrentCase(currentCaseDataSourceMap, attributeType, percentageThreshold, uniqueCaseDataSourceTuples); for (Entry> mapOfDataSources : Collections.unmodifiableMap(metadata).entrySet()) { if (!mapOfDataSources.getKey().equals(currentCaseName)) { @@ -141,7 +141,7 @@ final public class CommonAttributeCaseSearchResults { } } return filteredCaseNameToDataSourcesTree; - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.INFO, "Unable to perform filtering returning unfiltered result set", ex); return metadata; } @@ -164,9 +164,9 @@ final public class CommonAttributeCaseSearchResults { * @return a map of correlation value to CommonAttributeValue for results * from the current case * - * @throws EamDbException + * @throws CentralRepoException */ - private Map getValuesToKeepFromCurrentCase(Map dataSourceToValueList, CorrelationAttributeInstance.Type attributeType, int maximumPercentageThreshold, Double uniqueCaseDataSourceTuples) throws EamDbException { + private Map getValuesToKeepFromCurrentCase(Map dataSourceToValueList, CorrelationAttributeInstance.Type attributeType, int maximumPercentageThreshold, Double uniqueCaseDataSourceTuples) throws CentralRepoException { Map valuesToKeep = new HashMap<>(); Set valuesToRemove = new HashSet<>(); for (Entry mapOfValueLists : Collections.unmodifiableMap(dataSourceToValueList).entrySet()) { @@ -194,9 +194,9 @@ final public class CommonAttributeCaseSearchResults { * * @return the modified results for the case * - * @throws EamDbException + * @throws CentralRepoException */ - private Map createTreeForCase(Map valuesToKeepCurrentCase, Map dataSourceToValueList) throws EamDbException { + private Map createTreeForCase(Map valuesToKeepCurrentCase, Map dataSourceToValueList) throws CentralRepoException { Map treeForCase = new HashMap<>(); for (Entry mapOfValueLists : Collections.unmodifiableMap(dataSourceToValueList).entrySet()) { for (CommonAttributeValue value : mapOfValueLists.getValue().getDelayedMetadataSet()) { @@ -228,12 +228,12 @@ final public class CommonAttributeCaseSearchResults { * shown to the user, false if the value should not be removed and * the user will see it as a result * - * @throws EamDbException + * @throws CentralRepoException */ - private boolean filterValue(CorrelationAttributeInstance.Type attributeType, CommonAttributeValue value, int maximumPercentageThreshold, Double uniqueCaseDataSourceTuples) throws EamDbException { + private boolean filterValue(CorrelationAttributeInstance.Type attributeType, CommonAttributeValue value, int maximumPercentageThreshold, Double uniqueCaseDataSourceTuples) throws CentralRepoException { if (maximumPercentageThreshold != 0) { //only do the frequency filtering when a max % was set try { - Double uniqueTypeValueTuples = EamDb.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue( + Double uniqueTypeValueTuples = CentralRepository.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue( attributeType, value.getValue()).doubleValue(); Double commonalityPercentage = uniqueTypeValueTuples / uniqueCaseDataSourceTuples * 100; int frequencyPercentage = commonalityPercentage.intValue(); diff --git a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeCountSearchResults.java b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeCountSearchResults.java index 8265a8db25..18e7195f34 100644 --- a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeCountSearchResults.java +++ b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeCountSearchResults.java @@ -29,9 +29,9 @@ import java.util.TreeMap; import java.util.logging.Level; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Stores the results from the various types of common attribute searching @@ -107,9 +107,9 @@ final public class CommonAttributeCountSearchResults { /** * Filter the results based on the criteria the user specified * - * @throws EamDbException + * @throws CentralRepoException */ - public void filterMetadata() throws EamDbException { + public void filterMetadata() throws CentralRepoException { filterMetadata(this.percentageThreshold); } @@ -123,8 +123,8 @@ final public class CommonAttributeCountSearchResults { * * @return metadata */ - private void filterMetadata(int maximumPercentageThreshold) throws EamDbException { - if (!EamDb.isEnabled()) { + private void filterMetadata(int maximumPercentageThreshold) throws CentralRepoException { + if (!CentralRepository.isEnabled()) { return; } @@ -134,7 +134,7 @@ final public class CommonAttributeCountSearchResults { .filter(filterType -> filterType.getId() == this.resultTypeId) .findFirst().get(); - EamDb eamDb = EamDb.getInstance(); + CentralRepository eamDb = CentralRepository.getInstance(); Map> itemsToRemove = new HashMap<>(); //Call countUniqueDataSources once to reduce the number of DB queries needed to get diff --git a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributePanel.java b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributePanel.java index 73765acab8..f56f9dd9a8 100644 --- a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributePanel.java +++ b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributePanel.java @@ -49,8 +49,7 @@ import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationDataSource; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.centralrepository.ingestmodule.CentralRepoIngestModuleFactory; import org.sleuthkit.autopsy.corecomponentinterfaces.DataResultViewer; import org.sleuthkit.autopsy.corecomponents.DataResultTopComponent; @@ -65,6 +64,7 @@ import org.sleuthkit.datamodel.IngestJobInfo; import org.sleuthkit.datamodel.IngestModuleInfo; import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TskCoreException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Panel used for common files search configuration and configuration business @@ -162,13 +162,13 @@ final class CommonAttributePanel extends javax.swing.JDialog implements Observer */ static boolean isEamDbAvailableForIntercaseSearch() { try { - return EamDb.isEnabled() - && EamDb.getInstance() != null - && EamDb.getInstance().getCases().size() > 1 + return CentralRepository.isEnabled() + && CentralRepository.getInstance() != null + && CentralRepository.getInstance().getCases().size() > 1 && Case.isCaseOpen() && Case.getCurrentCase() != null - && EamDb.getInstance().getCase(Case.getCurrentCase()) != null; - } catch (EamDbException ex) { + && CentralRepository.getInstance().getCase(Case.getCurrentCase()) != null; + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Unexpected exception while checking for EamDB enabled.", ex); } return false; @@ -188,11 +188,11 @@ final class CommonAttributePanel extends javax.swing.JDialog implements Observer */ private static Long getNumberOfDataSourcesAvailable() { try { - if (EamDb.isEnabled() - && EamDb.getInstance() != null) { - return EamDb.getInstance().getCountUniqueDataSources(); + if (CentralRepository.isEnabled() + && CentralRepository.getInstance() != null) { + return CentralRepository.getInstance().getCountUniqueDataSources(); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Unexpected exception while checking for EamDB enabled.", ex); } return 0L; @@ -227,7 +227,7 @@ final class CommonAttributePanel extends javax.swing.JDialog implements Observer private ProgressHandle progress; @Override - protected CommonAttributeCountSearchResults doInBackground() throws TskCoreException, NoCurrentCaseException, SQLException, EamDbException { + protected CommonAttributeCountSearchResults doInBackground() throws TskCoreException, NoCurrentCaseException, SQLException, CentralRepoException { progress = ProgressHandle.createHandle(Bundle.CommonAttributePanel_search_done_searchProgressGathering()); progress.start(); progress.switchToIndeterminate(); @@ -344,7 +344,7 @@ final class CommonAttributePanel extends javax.swing.JDialog implements Observer private ProgressHandle progress; @Override - protected CommonAttributeCaseSearchResults doInBackground() throws TskCoreException, NoCurrentCaseException, SQLException, EamDbException { + protected CommonAttributeCaseSearchResults doInBackground() throws TskCoreException, NoCurrentCaseException, SQLException, CentralRepoException { progress = ProgressHandle.createHandle(Bundle.CommonAttributePanel_search_done_searchProgressGathering()); progress.start(); progress.switchToIndeterminate(); @@ -573,11 +573,11 @@ final class CommonAttributePanel extends javax.swing.JDialog implements Observer * * @return a map of Cases * - * @throws EamDbException + * @throws CentralRepoException */ - private Map mapCases(List cases) throws EamDbException { + private Map mapCases(List cases) throws CentralRepoException { Map casemap = new HashMap<>(); - CorrelationCase currentCorCase = EamDb.getInstance().getCase(Case.getCurrentCase()); + CorrelationCase currentCorCase = CentralRepository.getInstance().getCase(Case.getCurrentCase()); for (CorrelationCase correlationCase : cases) { if (currentCorCase.getID() != correlationCase.getID()) { // if not the current Case casemap.put(correlationCase.getID(), correlationCase.getDisplayName()); @@ -587,9 +587,9 @@ final class CommonAttributePanel extends javax.swing.JDialog implements Observer } @Override - protected Map doInBackground() throws EamDbException { + protected Map doInBackground() throws CentralRepoException { - List dataSources = EamDb.getInstance().getCases(); + List dataSources = CentralRepository.getInstance().getCases(); Map caseMap = mapCases(dataSources); return caseMap; @@ -874,14 +874,14 @@ final class CommonAttributePanel extends javax.swing.JDialog implements Observer @Override protected List doInBackground() throws Exception { List unCorrelatedDataSources = new ArrayList<>(); - if (!interCaseRadio.isSelected() || !EamDb.isEnabled() || EamDb.getInstance() == null) { + if (!interCaseRadio.isSelected() || !CentralRepository.isEnabled() || CentralRepository.getInstance() == null) { return unCorrelatedDataSources; } //if the eamdb is enabled and an instance is able to be retrieved check if each data source has been processed into the cr HashMap dataSourceCorrelationMap = new HashMap<>(); //keep track of the status of all data sources that have been ingested String correlationEngineModuleName = CentralRepoIngestModuleFactory.getModuleName(); SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase(); - List correlatedDataSources = EamDb.getInstance().getDataSources(); + List correlatedDataSources = CentralRepository.getInstance().getDataSources(); List ingestJobs = skCase.getIngestJobs(); for (IngestJobInfo jobInfo : ingestJobs) { //get the data source for each ingest job diff --git a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeSearchAction.java b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeSearchAction.java index f53b96a38b..bca07d757d 100644 --- a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeSearchAction.java +++ b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeSearchAction.java @@ -28,8 +28,8 @@ import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.actions.CallableSystemAction; import org.sleuthkit.autopsy.casemodule.Case; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Encapsulates a menu action which triggers the common files search dialog. @@ -107,19 +107,19 @@ final public class CommonAttributeSearchAction extends CallableSystemAction { } else { reason += Bundle.CommonAttributeSearchAction_openPanel_notEnoughDataSources(); } - if (!EamDb.isEnabled()) { + if (!CentralRepository.isEnabled()) { reason += Bundle.CommonAttributeSearchAction_openPanel_centralRepoDisabled(); return false; } - if (EamDb.getInstance() == null) { + if (CentralRepository.getInstance() == null) { reason += Bundle.CommonAttributeSearchAction_openPanel_centralRepoInvalid(); return false; } - if (EamDb.getInstance().getCases().size() < 2) { + if (CentralRepository.getInstance().getCases().size() < 2) { reason += Bundle.CommonAttributeSearchAction_openPanel_notEnoughCases(); return false; } - if (EamDb.getInstance().getCase(Case.getCurrentCase()) == null) { + if (CentralRepository.getInstance().getCase(Case.getCurrentCase()) == null) { reason += Bundle.CommonAttributeSearchAction_openPanel_caseNotInCentralRepo(); return false; } diff --git a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseCommonAttributeSearcher.java b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseCommonAttributeSearcher.java index 381ccf441c..543a46c87d 100644 --- a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseCommonAttributeSearcher.java +++ b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseCommonAttributeSearcher.java @@ -20,9 +20,9 @@ package org.sleuthkit.autopsy.commonpropertiessearch; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance.Type; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Provides logic for selecting common files from all data sources and all cases @@ -30,7 +30,7 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeIns */ abstract class InterCaseCommonAttributeSearcher extends AbstractCommonAttributeSearcher { - private final EamDb dbManager; + private final CentralRepository dbManager; /** * The Correlation Type to find matches on. */ @@ -45,15 +45,15 @@ abstract class InterCaseCommonAttributeSearcher extends AbstractCommonAttributeS * @param filterByDocMimeType match only on files whose mime types can be * broadly categorized as document types * - * @throws EamDbException + * @throws CentralRepoException */ - InterCaseCommonAttributeSearcher(boolean filterByMediaMimeType, boolean filterByDocMimeType, Type corAttrType, int percentageThreshold) throws EamDbException { + InterCaseCommonAttributeSearcher(boolean filterByMediaMimeType, boolean filterByDocMimeType, Type corAttrType, int percentageThreshold) throws CentralRepoException { super(filterByMediaMimeType, filterByDocMimeType, percentageThreshold); - dbManager = EamDb.getInstance(); + dbManager = CentralRepository.getInstance(); this.corAttrType = corAttrType; } - protected CorrelationCase getCorrelationCaseFromId(int correlationCaseId) throws EamDbException { + protected CorrelationCase getCorrelationCaseFromId(int correlationCaseId) throws CentralRepoException { for (CorrelationCase cCase : this.dbManager.getCases()) { if (cCase.getID() == correlationCaseId) { return cCase; diff --git a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCasePanel.java b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCasePanel.java index bdd5d1fb56..88d60db3be 100644 --- a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCasePanel.java +++ b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCasePanel.java @@ -30,7 +30,7 @@ import java.util.Observer; import java.util.logging.Level; import javax.swing.ComboBoxModel; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.coreutils.Logger; /** @@ -122,7 +122,7 @@ public final class InterCasePanel extends javax.swing.JPanel { correlationTypeFilters.put(type.getDisplayName(), type); this.correlationTypeComboBox.addItem(type.getDisplayName()); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.WARNING, "Error getting correlation types", ex); } this.correlationTypeComboBox.setSelectedIndex(0); diff --git a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseSearchResultsProcessor.java b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseSearchResultsProcessor.java index a6dd6833b3..6d321f0340 100644 --- a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseSearchResultsProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseSearchResultsProcessor.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2018-2019 Basis Technology Corp. + * Copyright 2018-2020 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -38,8 +38,7 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeIns import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationDataSource; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.centralrepository.datamodel.InstanceTableCallback; import org.sleuthkit.autopsy.commonpropertiessearch.AbstractCommonAttributeInstance.NODE_TYPE; import org.sleuthkit.autopsy.coreutils.Logger; @@ -47,6 +46,7 @@ import org.sleuthkit.datamodel.CaseDbAccessManager; import org.sleuthkit.datamodel.TskData; import org.sleuthkit.datamodel.HashUtility; import org.sleuthkit.datamodel.TskCoreException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Used to process and return CorrelationCase values from the EamDB for @@ -83,12 +83,12 @@ final class InterCaseSearchResultsProcessor { try { InterCaseCommonAttributeRowCallback instancetableCallback = new InterCaseCommonAttributeRowCallback(); - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); dbManager.processInstanceTableWhere(correlationType, String.format("id = %s", attrbuteId), instancetableCallback); return instancetableCallback.getCorrelationAttribute(); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { LOGGER.log(Level.SEVERE, "Error accessing EamDb processing InstanceTable row.", ex); } @@ -104,9 +104,9 @@ final class InterCaseSearchResultsProcessor { * @return the portion of a query which follows the SELECT keyword for * finding MD5s which we are correlating on * - * @throws EamDbException + * @throws CentralRepoException */ - private String getFileQuery(Set mimeTypesToFilterOn) throws EamDbException { + private String getFileQuery(Set mimeTypesToFilterOn) throws CentralRepoException { String query; query = "md5 AS value FROM tsk_files WHERE known!=" + TskData.FileKnown.KNOWN.getFileKnownValue() + " AND md5 IS NOT NULL"; //NON-NLS if (!mimeTypesToFilterOn.isEmpty()) { @@ -129,7 +129,7 @@ final class InterCaseSearchResultsProcessor { Map> findInterCaseValuesByCase(Case currentCase, Set mimeTypesToFilterOn) { try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); int caseId = dbManager.getCase(currentCase).getID(); InterCaseByCaseCallback instancetableCallback = new InterCaseByCaseCallback(caseId); if (correlationType.getId() == CorrelationAttributeInstance.FILES_TYPE_ID) { @@ -141,7 +141,7 @@ final class InterCaseSearchResultsProcessor { } return instancetableCallback.getInstanceCollatedCommonFiles(); - } catch (EamDbException | TskCoreException ex) { + } catch (CentralRepoException | TskCoreException ex) { LOGGER.log(Level.SEVERE, "Error accessing EamDb processing CaseInstancesTable.", ex); } return new HashMap<>(); @@ -159,7 +159,7 @@ final class InterCaseSearchResultsProcessor { Map findInterCaseValuesByCount(Case currentCase, Set mimeTypesToFilterOn) { try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); int caseId = dbManager.getCase(currentCase).getID(); InterCaseByCountCallback instancetableCallback = new InterCaseByCountCallback(caseId); @@ -172,7 +172,7 @@ final class InterCaseSearchResultsProcessor { } return instancetableCallback.getInstanceCollatedCommonFiles(); - } catch (EamDbException | TskCoreException ex) { + } catch (CentralRepoException | TskCoreException ex) { LOGGER.log(Level.SEVERE, "Error accessing EamDb processing CaseInstancesTable.", ex); } return new TreeMap<>(); @@ -192,7 +192,7 @@ final class InterCaseSearchResultsProcessor { */ Map findSingleInterCaseValuesByCount(Case currentCase, Set mimeTypesToFilterOn, CorrelationCase singleCase) { try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); int caseId = dbManager.getCase(currentCase).getID(); int targetCaseId = singleCase.getID(); InterCaseByCountCallback instancetableCallback = new InterCaseByCountCallback(caseId, targetCaseId); @@ -204,7 +204,7 @@ final class InterCaseSearchResultsProcessor { instancetableCallback); } return instancetableCallback.getInstanceCollatedCommonFiles(); - } catch (EamDbException | TskCoreException ex) { + } catch (CentralRepoException | TskCoreException ex) { LOGGER.log(Level.SEVERE, "Error accessing EamDb processing CaseInstancesTable.", ex); } return new TreeMap<>(); @@ -226,7 +226,7 @@ final class InterCaseSearchResultsProcessor { Map> findSingleInterCaseValuesByCase(Case currentCase, Set mimeTypesToFilterOn, CorrelationCase singleCase) { try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); int caseId = dbManager.getCase(currentCase).getID(); int targetCaseId = singleCase.getID(); InterCaseByCaseCallback instancetableCallback = new InterCaseByCaseCallback(caseId, targetCaseId); @@ -238,7 +238,7 @@ final class InterCaseSearchResultsProcessor { instancetableCallback); } return instancetableCallback.getInstanceCollatedCommonFiles(); - } catch (EamDbException | TskCoreException ex) { + } catch (CentralRepoException | TskCoreException ex) { LOGGER.log(Level.SEVERE, "Error accessing EamDb processing CaseInstancesTable.", ex); } return new HashMap<>(); @@ -282,9 +282,9 @@ final class InterCaseSearchResultsProcessor { for (String corValue : values) { List instances; if (targetCases.isEmpty()) { - instances = EamDb.getInstance().getArtifactInstancesByTypeValues(correlationType, Arrays.asList(corValue)); + instances = CentralRepository.getInstance().getArtifactInstancesByTypeValues(correlationType, Arrays.asList(corValue)); } else { - instances = EamDb.getInstance().getArtifactInstancesByTypeValuesAndCases(correlationType, Arrays.asList(corValue), targetCases); + instances = CentralRepository.getInstance().getArtifactInstancesByTypeValuesAndCases(correlationType, Arrays.asList(corValue), targetCases); } int size = instances.stream().map(instance -> instance.getCorrelationDataSource().getID()).collect(Collectors.toSet()).size(); if (size > 1) { @@ -307,7 +307,7 @@ final class InterCaseSearchResultsProcessor { } } } - } catch (SQLException | EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (SQLException | CentralRepoException | CorrelationAttributeNormalizationException ex) { LOGGER.log(Level.WARNING, "Error getting artifact instances from database.", ex); // NON-NLS } } @@ -356,9 +356,9 @@ final class InterCaseSearchResultsProcessor { for (List valuesChunk : Iterables.partition(values, VALUE_BATCH_SIZE)) { List instances; if (targetCases.isEmpty()) { - instances = EamDb.getInstance().getArtifactInstancesByTypeValues(correlationType, valuesChunk); + instances = CentralRepository.getInstance().getArtifactInstancesByTypeValues(correlationType, valuesChunk); } else { - instances = EamDb.getInstance().getArtifactInstancesByTypeValuesAndCases(correlationType, valuesChunk, targetCases); + instances = CentralRepository.getInstance().getArtifactInstancesByTypeValuesAndCases(correlationType, valuesChunk, targetCases); } if (instances.size() > 1) { for (CorrelationAttributeInstance instance : instances) { @@ -385,7 +385,7 @@ final class InterCaseSearchResultsProcessor { } } } - } catch (EamDbException | SQLException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | SQLException | CorrelationAttributeNormalizationException ex) { LOGGER.log(Level.WARNING, "Error getting artifact instances from database.", ex); // NON-NLS } } @@ -406,7 +406,7 @@ final class InterCaseSearchResultsProcessor { @Override public void process(ResultSet resultSet) { try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); while (resultSet.next()) { CorrelationCase correlationCase = dbManager.getCaseById(InstanceTableCallback.getCaseId(resultSet)); @@ -428,7 +428,7 @@ final class InterCaseSearchResultsProcessor { } } - } catch (SQLException | EamDbException ex) { + } catch (SQLException | CentralRepoException ex) { LOGGER.log(Level.WARNING, "Error getting single correlation artifact instance from database.", ex); // NON-NLS } } diff --git a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/IntraCaseCommonAttributeSearcher.java b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/IntraCaseCommonAttributeSearcher.java index dac83a333e..83187bf7bf 100644 --- a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/IntraCaseCommonAttributeSearcher.java +++ b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/IntraCaseCommonAttributeSearcher.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.Set; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.datamodel.HashUtility; import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.SleuthkitCase.CaseDbQuery; @@ -143,8 +143,8 @@ public abstract class IntraCaseCommonAttributeSearcher extends AbstractCommonAtt } @Override - public CommonAttributeCaseSearchResults findMatchesByCase() throws TskCoreException, NoCurrentCaseException, SQLException, EamDbException { - throw new EamDbException("Not Supported at the moment"); + public CommonAttributeCaseSearchResults findMatchesByCase() throws TskCoreException, NoCurrentCaseException, SQLException, CentralRepoException { + throw new CentralRepoException("Not Supported at the moment"); } /** diff --git a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/SingleInterCaseCommonAttributeSearcher.java b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/SingleInterCaseCommonAttributeSearcher.java index 8d0cca8412..ed8b8bdc27 100644 --- a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/SingleInterCaseCommonAttributeSearcher.java +++ b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/SingleInterCaseCommonAttributeSearcher.java @@ -27,7 +27,7 @@ import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance.Type; import static org.sleuthkit.autopsy.commonpropertiessearch.AbstractCommonAttributeSearcher.MEDIA_PICS_VIDEO_MIME_TYPES; @@ -49,10 +49,10 @@ public class SingleInterCaseCommonAttributeSearcher extends InterCaseCommonAttri * @param corAttrType * @param percentageThreshold * - * @throws EamDbException + * @throws CentralRepoException */ public SingleInterCaseCommonAttributeSearcher(int correlationCaseId, boolean filterByMediaMimeType, - boolean filterByDocMimeType, Type corAttrType, int percentageThreshold) throws EamDbException { + boolean filterByDocMimeType, Type corAttrType, int percentageThreshold) throws CentralRepoException { super(filterByMediaMimeType, filterByDocMimeType, corAttrType, percentageThreshold); this.corrleationCaseId = correlationCaseId; @@ -68,10 +68,10 @@ public class SingleInterCaseCommonAttributeSearcher extends InterCaseCommonAttri * @throws TskCoreException * @throws NoCurrentCaseException * @throws SQLException - * @throws EamDbException + * @throws CentralRepoException */ @Override - public CommonAttributeCountSearchResults findMatchesByCount() throws TskCoreException, NoCurrentCaseException, SQLException, EamDbException { + public CommonAttributeCountSearchResults findMatchesByCount() throws TskCoreException, NoCurrentCaseException, SQLException, CentralRepoException { CorrelationCase correlationCase = this.getCorrelationCaseFromId(this.corrleationCaseId); this.correlationCaseName = correlationCase.getDisplayName(); @@ -97,10 +97,10 @@ public class SingleInterCaseCommonAttributeSearcher extends InterCaseCommonAttri * @throws TskCoreException * @throws NoCurrentCaseException * @throws SQLException - * @throws EamDbException + * @throws CentralRepoException */ @Override - public CommonAttributeCaseSearchResults findMatchesByCase() throws TskCoreException, NoCurrentCaseException, SQLException, EamDbException { + public CommonAttributeCaseSearchResults findMatchesByCase() throws TskCoreException, NoCurrentCaseException, SQLException, CentralRepoException { CorrelationCase correlationCase = this.getCorrelationCaseFromId(this.corrleationCaseId); this.correlationCaseName = correlationCase.getDisplayName(); diff --git a/Core/src/org/sleuthkit/autopsy/communications/relationships/CorrelationCaseChildNodeFactory.java b/Core/src/org/sleuthkit/autopsy/communications/relationships/CorrelationCaseChildNodeFactory.java index 564c8e4f54..5105f1628d 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/relationships/CorrelationCaseChildNodeFactory.java +++ b/Core/src/org/sleuthkit/autopsy/communications/relationships/CorrelationCaseChildNodeFactory.java @@ -31,11 +31,11 @@ import org.openide.nodes.Sheet; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.datamodel.NodeProperty; import org.sleuthkit.datamodel.Account; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * ChildFactory for CorrelationCases. Finds the cases that reference the given @@ -59,14 +59,14 @@ final class CorrelationCaseChildNodeFactory extends ChildFactory list) { - if (!EamDb.isEnabled()) { + if (!CentralRepository.isEnabled()) { return true; } - EamDb dbInstance; + CentralRepository dbInstance; try { - dbInstance = EamDb.getInstance(); - } catch (EamDbException ex) { + dbInstance = CentralRepository.getInstance(); + } catch (CentralRepoException ex) { logger.log(Level.SEVERE, "Unable to connect to the Central Repository database.", ex); //NON-NLS return false; } @@ -83,7 +83,7 @@ final class CorrelationCaseChildNodeFactory extends ChildFactory(); List correcationTypeList = CorrelationAttributeInstance.getDefaultCorrelationTypes(); diff --git a/Core/src/org/sleuthkit/autopsy/communications/relationships/SummaryViewer.java b/Core/src/org/sleuthkit/autopsy/communications/relationships/SummaryViewer.java index f373b8a333..fbfc28e493 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/relationships/SummaryViewer.java +++ b/Core/src/org/sleuthkit/autopsy/communications/relationships/SummaryViewer.java @@ -27,8 +27,8 @@ import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.util.Lookup; import org.openide.util.NbBundle.Messages; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; import org.sleuthkit.datamodel.Account; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Account Summary View Panel. This panel shows a list of various counts related @@ -92,7 +92,7 @@ public class SummaryViewer extends javax.swing.JPanel implements RelationshipsVi @Override public void setSelectionInfo(SelectionInfo info) { - if (!EamDb.isEnabled()) { + if (!CentralRepository.isEnabled()) { caseReferencesPanel.hideOutlineView(Bundle.SummaryViewer_CentralRepository_Message()); } else { caseReferencesPanel.showOutlineView(); diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/AnnotationsContentViewer.java b/Core/src/org/sleuthkit/autopsy/contentviewers/AnnotationsContentViewer.java index 72343ec616..9116ff9b45 100755 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/AnnotationsContentViewer.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/AnnotationsContentViewer.java @@ -34,9 +34,8 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeIns import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationDataSource; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact; @@ -46,6 +45,7 @@ import org.sleuthkit.datamodel.ContentTag; import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.Tag; import org.sleuthkit.datamodel.TskCoreException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Annotations view of file contents. @@ -194,19 +194,19 @@ public class AnnotationsContentViewer extends javax.swing.JPanel implements Data * artifact. */ private void populateCentralRepositoryData(StringBuilder html, BlackboardArtifact artifact, AbstractFile sourceFile) { - if (EamDb.isEnabled()) { + if (CentralRepository.isEnabled()) { startSection(html, "Central Repository Comments"); List instancesList = new ArrayList<>(); if (artifact != null) { - instancesList.addAll(EamArtifactUtil.makeInstancesFromBlackboardArtifact(artifact, false)); + instancesList.addAll(CorrelationAttributeUtil.makeInstancesFromBlackboardArtifact(artifact, false)); } try { - List artifactTypes = EamDb.getInstance().getDefinedCorrelationTypes(); + List artifactTypes = CentralRepository.getInstance().getDefinedCorrelationTypes(); String md5 = sourceFile.getMd5Hash(); if (md5 != null && !md5.isEmpty() && null != artifactTypes && !artifactTypes.isEmpty()) { for (CorrelationAttributeInstance.Type attributeType : artifactTypes) { if (attributeType.getId() == CorrelationAttributeInstance.FILES_TYPE_ID) { - CorrelationCase correlationCase = EamDb.getInstance().getCase(Case.getCurrentCase()); + CorrelationCase correlationCase = CentralRepository.getInstance().getCase(Case.getCurrentCase()); instancesList.add(new CorrelationAttributeInstance( attributeType, md5, @@ -225,7 +225,7 @@ public class AnnotationsContentViewer extends javax.swing.JPanel implements Data for (CorrelationAttributeInstance instance : instancesList) { List correlatedInstancesList - = EamDb.getInstance().getArtifactInstancesByTypeValue(instance.getCorrelationType(), instance.getCorrelationValue()); + = CentralRepository.getInstance().getArtifactInstancesByTypeValue(instance.getCorrelationType(), instance.getCorrelationValue()); for (CorrelationAttributeInstance correlatedInstance : correlatedInstancesList) { if (correlatedInstance.getComment() != null && correlatedInstance.getComment().isEmpty() == false) { commentDataFound = true; @@ -237,7 +237,7 @@ public class AnnotationsContentViewer extends javax.swing.JPanel implements Data if (commentDataFound == false) { addMessage(html, "There is no comment data for the selected content in the Central Repository."); } - } catch (EamDbException | TskCoreException ex) { + } catch (CentralRepoException | TskCoreException ex) { logger.log(Level.SEVERE, "Error connecting to the Central Repository database.", ex); // NON-NLS } catch (CorrelationAttributeNormalizationException ex) { logger.log(Level.SEVERE, "Error normalizing instance from Central Repository database.", ex); // NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/ViewPreferencesPanel.java b/Core/src/org/sleuthkit/autopsy/corecomponents/ViewPreferencesPanel.java index 93aadeed65..fb85efcf0c 100755 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/ViewPreferencesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/ViewPreferencesPanel.java @@ -27,11 +27,11 @@ import javax.swing.JSpinner; import org.netbeans.spi.options.OptionsPanelController; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.CasePreferences; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.coreutils.TimeZoneUtils; import org.sleuthkit.autopsy.directorytree.DirectoryTreeTopComponent; import org.sleuthkit.autopsy.texttranslation.TextTranslationService; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Panel for configuring view preferences. diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/AbstractAbstractFileNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/AbstractAbstractFileNode.java index 21ca3fddac..1c756a7427 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/AbstractAbstractFileNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/AbstractAbstractFileNode.java @@ -41,9 +41,8 @@ import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent; import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable.HasCommentStatus; @@ -66,6 +65,7 @@ import org.sleuthkit.datamodel.ContentTag; import org.sleuthkit.datamodel.Tag; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskData; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * An abstract node that encapsulates AbstractFile data @@ -329,7 +329,7 @@ public abstract class AbstractAbstractFileNode extends A if (!UserPreferences.getHideSCOColumns()) { properties.add(new NodeProperty<>(SCORE.toString(), SCORE.toString(), VALUE_LOADING, "")); properties.add(new NodeProperty<>(COMMENT.toString(), COMMENT.toString(), VALUE_LOADING, "")); - if (EamDb.isEnabled()) { + if (CentralRepository.isEnabled()) { properties.add(new NodeProperty<>(OCCURRENCES.toString(), OCCURRENCES.toString(), VALUE_LOADING, "")); } // Get the SCO columns data in a background task @@ -405,12 +405,12 @@ public abstract class AbstractAbstractFileNode extends A try { //don't perform the query if there is no correlation value if (attributeType != null && StringUtils.isNotBlank(attributeValue)) { - count = EamDb.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(attributeType, attributeValue); + count = CentralRepository.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(attributeType, attributeValue); description = Bundle.AbstractAbstractFileNode_createSheet_count_description(count); } else if (attributeType != null) { description = Bundle.AbstractAbstractFileNode_createSheet_count_hashLookupNotRun_description(); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.WARNING, "Error getting count of datasources with correlation attribute", ex); } catch (CorrelationAttributeNormalizationException ex) { logger.log(Level.WARNING, "Unable to normalize data to get count of datasources with correlation attribute", ex); @@ -538,8 +538,8 @@ public abstract class AbstractAbstractFileNode extends A @Override protected CorrelationAttributeInstance getCorrelationAttributeInstance() { CorrelationAttributeInstance attribute = null; - if (EamDb.isEnabled() && !UserPreferences.getHideSCOColumns()) { - attribute = EamArtifactUtil.getInstanceFromContent(content); + if (CentralRepository.isEnabled() && !UserPreferences.getHideSCOColumns()) { + attribute = CorrelationAttributeUtil.getInstanceFromContent(content); } return attribute; } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java index 5a02ba9a55..45b0b3fbb2 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java @@ -54,9 +54,8 @@ import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance.Type; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable.Score; @@ -77,6 +76,7 @@ import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.Tag; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskData; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Node wrapping a blackboard artifact object. This is generated from several @@ -370,7 +370,7 @@ public class BlackboardArtifactNode extends AbstractContentNode(Bundle.BlackboardArtifactNode_createSheet_score_name(), Bundle.BlackboardArtifactNode_createSheet_score_displayName(), VALUE_LOADING, "")); sheetSet.put(new NodeProperty<>(Bundle.BlackboardArtifactNode_createSheet_comment_name(), Bundle.BlackboardArtifactNode_createSheet_comment_displayName(), VALUE_LOADING, "")); - if (EamDb.isEnabled()) { + if (CentralRepository.isEnabled()) { sheetSet.put(new NodeProperty<>(Bundle.BlackboardArtifactNode_createSheet_count_name(), Bundle.BlackboardArtifactNode_createSheet_count_displayName(), VALUE_LOADING, "")); } // Get the SCO columns data in a background task @@ -595,8 +595,8 @@ public class BlackboardArtifactNode extends AbstractContentNode sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,9 +26,8 @@ import java.util.logging.Level; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance.Type; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamArtifactUtil; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.events.AutopsyEvent; @@ -36,6 +35,7 @@ import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.Tag; import org.sleuthkit.datamodel.TskCoreException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Background task to get Score, Comment and Occurrences values for an Abstract @@ -73,7 +73,7 @@ class GetSCOTask implements Runnable { CorrelationAttributeInstance fileAttribute = contentNode.getCorrelationAttributeInstance(); scoData.setComment(contentNode.getCommentProperty(tags, fileAttribute)); - if (EamDb.isEnabled()) { + if (CentralRepository.isEnabled()) { Type type = null; String value = null; String description = Bundle.GetSCOTask_occurrences_defaultDescription(); @@ -93,11 +93,11 @@ class GetSCOTask implements Runnable { type = CorrelationAttributeInstance.getDefaultCorrelationTypes().get(CorrelationAttributeInstance.FILES_TYPE_ID); value = ((AbstractFile) bbArtifact.getParent()).getMd5Hash(); } - } catch (TskCoreException | EamDbException ex) { + } catch (TskCoreException | CentralRepoException ex) { logger.log(Level.WARNING, "Unable to get correlation type or value to determine value for O column for artifact", ex); } } else { - List listOfPossibleAttributes = EamArtifactUtil.makeInstancesFromBlackboardArtifact(bbArtifact, false); + List listOfPossibleAttributes = CorrelationAttributeUtil.makeInstancesFromBlackboardArtifact(bbArtifact, false); if (listOfPossibleAttributes.size() > 1) { //Don't display anything if there is more than 1 correlation property for an artifact but let the user know description = Bundle.GetSCOTask_occurrences_multipleProperties(); @@ -112,7 +112,7 @@ class GetSCOTask implements Runnable { try { type = CorrelationAttributeInstance.getDefaultCorrelationTypes().get(CorrelationAttributeInstance.FILES_TYPE_ID); value = ((AbstractFile) contentNode.getContent()).getMd5Hash(); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.WARNING, "Unable to get correlation type to determine value for O column for file", ex); } } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/FileSearch.java b/Core/src/org/sleuthkit/autopsy/filequery/FileSearch.java index 495b70f4e4..8e55eb50e6 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/FileSearch.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/FileSearch.java @@ -50,9 +50,8 @@ import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbUtil; import org.sleuthkit.autopsy.centralrepository.datamodel.InstanceTableCallback; import org.sleuthkit.autopsy.corelibs.ScalrWrapper; import org.sleuthkit.autopsy.coreutils.ImageUtils; @@ -71,6 +70,7 @@ import org.sleuthkit.datamodel.ContentTag; import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskData; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Main class to perform the file search. @@ -108,7 +108,7 @@ class FileSearch { AttributeType groupAttributeType, FileGroup.GroupSortingAlgorithm groupSortingType, FileSorter.SortingMethod fileSortingMethod, - SleuthkitCase caseDb, EamDb centralRepoDb) throws FileSearchException { + SleuthkitCase caseDb, CentralRepository centralRepoDb) throws FileSearchException { // Make a list of attributes that we want to add values for. This ensures the // ResultFile objects will have all needed fields set when it's time to group // and sort them. For example, if we're grouping by central repo frequency, we need @@ -160,7 +160,7 @@ class FileSearch { AttributeType groupAttributeType, FileGroup.GroupSortingAlgorithm groupSortingType, FileSorter.SortingMethod fileSortingMethod, - SleuthkitCase caseDb, EamDb centralRepoDb) throws FileSearchException { + SleuthkitCase caseDb, CentralRepository centralRepoDb) throws FileSearchException { Map> searchResults = runFileSearch(userName, filters, groupAttributeType, groupSortingType, fileSortingMethod, caseDb, centralRepoDb); LinkedHashMap groupSizes = new LinkedHashMap<>(); @@ -200,7 +200,7 @@ class FileSearch { GroupKey groupKey, int startingEntry, int numberOfEntries, - SleuthkitCase caseDb, EamDb centralRepoDb) throws FileSearchException { + SleuthkitCase caseDb, CentralRepository centralRepoDb) throws FileSearchException { //the group should be in the cache at this point List filesInGroup = null; SearchKey searchKey = new SearchKey(userName, filters, groupAttributeType, groupSortingType, fileSortingMethod); @@ -261,7 +261,7 @@ class FileSearch { AttributeType groupAttributeType, FileGroup.GroupSortingAlgorithm groupSortingType, FileSorter.SortingMethod fileSortingMethod, - SleuthkitCase caseDb, EamDb centralRepoDb) throws FileSearchException { + SleuthkitCase caseDb, CentralRepository centralRepoDb) throws FileSearchException { // Make a list of attributes that we want to add values for. This ensures the // ResultFile objects will have all needed fields set when it's time to group @@ -302,7 +302,7 @@ class FileSearch { * * @throws FileSearchException */ - private static void addAttributes(List attrs, List resultFiles, SleuthkitCase caseDb, EamDb centralRepoDb) + private static void addAttributes(List attrs, List resultFiles, SleuthkitCase caseDb, CentralRepository centralRepoDb) throws FileSearchException { for (AttributeType attr : attrs) { attr.addAttributeToResultFiles(resultFiles, caseDb, centralRepoDb); @@ -316,7 +316,7 @@ class FileSearch { * @param hashesToLookUp Hashes to find the frequency of * @param currentFiles List of files to update with frequencies */ - private static void computeFrequency(Set hashesToLookUp, List currentFiles, EamDb centralRepoDb) { + private static void computeFrequency(Set hashesToLookUp, List currentFiles, CentralRepository centralRepoDb) { if (hashesToLookUp.isEmpty()) { return; @@ -326,7 +326,7 @@ class FileSearch { hashes = "'" + hashes + "'"; try { CorrelationAttributeInstance.Type attributeType = centralRepoDb.getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID); - String tableName = EamDbUtil.correlationTypeToInstanceTableName(attributeType); + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(attributeType); String selectClause = " value, COUNT(value) FROM " + "(SELECT DISTINCT case_id, value FROM " + tableName @@ -337,7 +337,7 @@ class FileSearch { FrequencyCallback callback = new FrequencyCallback(currentFiles); centralRepoDb.processSelectClause(selectClause, callback); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { logger.log(Level.WARNING, "Error getting frequency counts from Central Repository", ex); // NON-NLS } @@ -646,7 +646,7 @@ class FileSearch { * * @throws FileSearchException */ - void addAttributeToResultFiles(List files, SleuthkitCase caseDb, EamDb centralRepoDb) throws FileSearchException { + void addAttributeToResultFiles(List files, SleuthkitCase caseDb, CentralRepository centralRepoDb) throws FileSearchException { // Default is to do nothing } } @@ -1044,7 +1044,7 @@ class FileSearch { @Override void addAttributeToResultFiles(List files, SleuthkitCase caseDb, - EamDb centralRepoDb) throws FileSearchException { + CentralRepository centralRepoDb) throws FileSearchException { // Get pairs of (object ID, keyword list name) for all files in the list of files that have // keyword list hits. @@ -1199,7 +1199,7 @@ class FileSearch { @Override void addAttributeToResultFiles(List files, SleuthkitCase caseDb, - EamDb centralRepoDb) throws FileSearchException { + CentralRepository centralRepoDb) throws FileSearchException { if (centralRepoDb == null) { for (ResultFile file : files) { if (file.getFrequency() == Frequency.UNKNOWN && file.getFirstInstance().getKnown() == TskData.FileKnown.KNOWN) { @@ -1220,7 +1220,7 @@ class FileSearch { * @param centralRepoDb The central repository currently in use. */ private void processResultFilesForCR(List files, - EamDb centralRepoDb) { + CentralRepository centralRepoDb) { List currentFiles = new ArrayList<>(); Set hashesToLookUp = new HashSet<>(); for (ResultFile file : files) { @@ -1347,7 +1347,7 @@ class FileSearch { @Override void addAttributeToResultFiles(List files, SleuthkitCase caseDb, - EamDb centralRepoDb) throws FileSearchException { + CentralRepository centralRepoDb) throws FileSearchException { // Get pairs of (object ID, hash set name) for all files in the list of files that have // hash set hits. @@ -1499,7 +1499,7 @@ class FileSearch { @Override void addAttributeToResultFiles(List files, SleuthkitCase caseDb, - EamDb centralRepoDb) throws FileSearchException { + CentralRepository centralRepoDb) throws FileSearchException { // Get pairs of (object ID, interesting item set name) for all files in the list of files that have // interesting file set hits. @@ -1653,7 +1653,7 @@ class FileSearch { @Override void addAttributeToResultFiles(List files, SleuthkitCase caseDb, - EamDb centralRepoDb) throws FileSearchException { + CentralRepository centralRepoDb) throws FileSearchException { // Get pairs of (object ID, object type name) for all files in the list of files that have // objects detected @@ -1806,7 +1806,7 @@ class FileSearch { @Override void addAttributeToResultFiles(List files, SleuthkitCase caseDb, - EamDb centralRepoDb) throws FileSearchException { + CentralRepository centralRepoDb) throws FileSearchException { try { for (ResultFile resultFile : files) { diff --git a/Core/src/org/sleuthkit/autopsy/filequery/FileSearchFiltering.java b/Core/src/org/sleuthkit/autopsy/filequery/FileSearchFiltering.java index 7c558ef592..7dab641c79 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/FileSearchFiltering.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/FileSearchFiltering.java @@ -20,8 +20,7 @@ package org.sleuthkit.autopsy.filequery; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.filequery.FileSearchData.FileSize; import org.sleuthkit.autopsy.filequery.FileSearchData.FileType; import org.sleuthkit.autopsy.filequery.FileSearchData.Frequency; @@ -38,6 +37,7 @@ import org.openide.util.NbBundle; import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.TskData; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Run various filters to return a subset of files from the current case. @@ -54,7 +54,7 @@ class FileSearchFiltering { * * @return */ - static List runQueries(List filters, SleuthkitCase caseDb, EamDb centralRepoDb) throws FileSearchException { + static List runQueries(List filters, SleuthkitCase caseDb, CentralRepository centralRepoDb) throws FileSearchException { if (caseDb == null) { throw new FileSearchException("Case DB parameter is null"); // NON-NLS } @@ -94,7 +94,7 @@ class FileSearchFiltering { * @throws TskCoreException * @throws FileSearchException */ - private static List getResultList(List filters, String combinedQuery, SleuthkitCase caseDb, EamDb centralRepoDb) throws TskCoreException, FileSearchException { + private static List getResultList(List filters, String combinedQuery, SleuthkitCase caseDb, CentralRepository centralRepoDb) throws TskCoreException, FileSearchException { // Get all matching abstract files List resultList = new ArrayList<>(); List sqlResults = caseDb.findAllFilesWhere(combinedQuery); @@ -161,7 +161,7 @@ class FileSearchFiltering { * @throws FileSearchException */ List applyAlternateFilter(List currentResults, SleuthkitCase caseDb, - EamDb centralRepoDb) throws FileSearchException { + CentralRepository centralRepoDb) throws FileSearchException { return new ArrayList<>(); } @@ -562,7 +562,7 @@ class FileSearchFiltering { @Override List applyAlternateFilter(List currentResults, SleuthkitCase caseDb, - EamDb centralRepoDb) throws FileSearchException { + CentralRepository centralRepoDb) throws FileSearchException { // We have to have run some kind of SQL filter before getting to this point, // and should have checked afterward to see if the results were empty. @@ -895,7 +895,7 @@ class FileSearchFiltering { @Override List applyAlternateFilter(List currentResults, SleuthkitCase caseDb, - EamDb centralRepoDb) throws FileSearchException { + CentralRepository centralRepoDb) throws FileSearchException { if (centralRepoDb == null) { throw new FileSearchException("Can not run Previously Notable filter with null Central Repository DB"); // NON-NLS @@ -924,7 +924,7 @@ class FileSearchFiltering { } } return notableResults; - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { throw new FileSearchException("Error querying central repository", ex); // NON-NLS } } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/FileSearchPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/FileSearchPanel.java index f81d3d1945..2c03e17d2b 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/FileSearchPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/FileSearchPanel.java @@ -36,8 +36,7 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.filequery.FileGroup.GroupSortingAlgorithm; import org.sleuthkit.autopsy.filequery.FileSearch.GroupingAttributeType; @@ -52,6 +51,7 @@ import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.DataSource; import org.sleuthkit.datamodel.TagName; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Dialog to allow the user to choose filtering and grouping options. @@ -461,7 +461,7 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener int[] selectedSizeIndices = {1, 2, 3, 4, 5}; sizeFilterSettings(true, enabled, resetSelected || sizeCheckbox.isSelected(), resetSelected == true ? selectedSizeIndices : null); int[] selectedFrequencyIndices; - if (!EamDb.isEnabled()) { + if (!CentralRepository.isEnabled()) { selectedFrequencyIndices = new int[]{0}; } else { selectedFrequencyIndices = new int[]{1, 2, 3, 4, 5, 6, 7}; @@ -493,7 +493,7 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener dataSourceFilterSettings(true, enabled, !resetSelected && dataSourceCheckbox.isSelected(), null); sizeFilterSettings(true, enabled, !resetSelected && sizeCheckbox.isSelected(), null); int[] selectedFrequencyIndices; - if (!EamDb.isEnabled()) { + if (!CentralRepository.isEnabled()) { selectedFrequencyIndices = new int[]{0}; } else { selectedFrequencyIndices = new int[]{1, 2, 3, 4, 5, 6, 7}; @@ -553,7 +553,7 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener groupByCombobox.removeAllItems(); // Set up the grouping attributes for (FileSearch.GroupingAttributeType type : FileSearch.GroupingAttributeType.getOptionsForGrouping()) { - if ((type != GroupingAttributeType.FREQUENCY || EamDb.isEnabled()) + if ((type != GroupingAttributeType.FREQUENCY || CentralRepository.isEnabled()) && (type != GroupingAttributeType.OBJECT_DETECTED || objectsList.getModel().getSize() > 0) && (type != GroupingAttributeType.INTERESTING_ITEM_SET || interestingItemsList.getModel().getSize() > 0) && (type != GroupingAttributeType.HASH_LIST_NAME || hashSetList.getModel().getSize() > 0)) { @@ -564,7 +564,7 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener orderByCombobox.removeAllItems(); // Set up the file order list for (FileSorter.SortingMethod method : FileSorter.SortingMethod.getOptionsForOrdering()) { - if (method != SortingMethod.BY_FREQUENCY || EamDb.isEnabled()) { + if (method != SortingMethod.BY_FREQUENCY || CentralRepository.isEnabled()) { orderByCombobox.addItem(method); } } @@ -623,7 +623,7 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener int count = 0; DefaultListModel frequencyListModel = (DefaultListModel) crFrequencyList.getModel(); frequencyListModel.removeAllElements(); - if (!EamDb.isEnabled()) { + if (!CentralRepository.isEnabled()) { for (FileSearchData.Frequency freq : FileSearchData.Frequency.getOptionsForFilteringWithoutCr()) { frequencyListModel.add(count, freq); } @@ -1739,11 +1739,11 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener // Get the file sorting method FileSorter.SortingMethod fileSort = getFileSortingMethod(); - EamDb centralRepoDb = null; - if (EamDb.isEnabled()) { + CentralRepository centralRepoDb = null; + if (CentralRepository.isEnabled()) { try { - centralRepoDb = EamDb.getInstance(); - } catch (EamDbException ex) { + centralRepoDb = CentralRepository.getInstance(); + } catch (CentralRepoException ex) { centralRepoDb = null; logger.log(Level.SEVERE, "Error loading central repository database, no central repository options will be available for File Discovery", ex); } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/PageWorker.java b/Core/src/org/sleuthkit/autopsy/filequery/PageWorker.java index f90d11bd32..04ee8b05bd 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/PageWorker.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/PageWorker.java @@ -23,9 +23,9 @@ import java.util.ArrayList; import java.util.logging.Level; import javax.swing.SwingWorker; import org.sleuthkit.autopsy.casemodule.Case; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.filequery.FileSearch.GroupKey; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * SwingWorker to retrieve the contents of a page. @@ -42,7 +42,7 @@ final class PageWorker extends SwingWorker { private final int startingEntry; private final int pageSize; private final FileSearchData.FileType resultType; - private final EamDb centralRepo; + private final CentralRepository centralRepo; private final List results = new ArrayList<>(); /** @@ -63,7 +63,7 @@ final class PageWorker extends SwingWorker { */ PageWorker(List searchfilters, FileSearch.AttributeType groupingAttribute, FileGroup.GroupSortingAlgorithm groupSort, FileSorter.SortingMethod fileSortMethod, GroupKey groupKey, - int startingEntry, int pageSize, FileSearchData.FileType resultType, EamDb centralRepo) { + int startingEntry, int pageSize, FileSearchData.FileType resultType, CentralRepository centralRepo) { this.searchfilters = searchfilters; this.groupingAttribute = groupingAttribute; this.groupSort = groupSort; diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ResultsPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/ResultsPanel.java index eaeb0b3c06..4b0781c939 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ResultsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ResultsPanel.java @@ -41,8 +41,7 @@ import javax.swing.event.ListSelectionListener; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.actions.AddContentTagAction; import org.sleuthkit.autopsy.actions.DeleteFileContentTagAction; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.coreutils.ImageUtils; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.datamodel.FileNode; @@ -53,6 +52,7 @@ import org.sleuthkit.autopsy.filequery.FileSearch.GroupKey; import org.sleuthkit.autopsy.modules.hashdatabase.AddContentToHashDbAction; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.TskCoreException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Panel for displaying of file discovery results and handling the paging of @@ -320,11 +320,11 @@ public class ResultsPanel extends javax.swing.JPanel { if (pageWorker != null && !pageWorker.isDone()) { pageWorker.cancel(true); } - EamDb centralRepo = null; - if (EamDb.isEnabled()) { + CentralRepository centralRepo = null; + if (CentralRepository.isEnabled()) { try { - centralRepo = EamDb.getInstance(); - } catch (EamDbException ex) { + centralRepo = CentralRepository.getInstance(); + } catch (CentralRepoException ex) { centralRepo = null; logger.log(Level.SEVERE, "Error loading central repository database, no central repository options will be available for File Discovery", ex); } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/SearchWorker.java b/Core/src/org/sleuthkit/autopsy/filequery/SearchWorker.java index 279a470f3a..74196e7b01 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/SearchWorker.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/SearchWorker.java @@ -24,9 +24,9 @@ import java.util.List; import java.util.Map; import java.util.logging.Level; import org.sleuthkit.autopsy.casemodule.Case; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.filequery.FileSearch.GroupKey; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * SwingWorker to perform search on a background thread @@ -39,7 +39,7 @@ final class SearchWorker extends SwingWorker { private final FileSearch.AttributeType groupingAttr; private final FileSorter.SortingMethod fileSort; private final FileGroup.GroupSortingAlgorithm groupSortAlgorithm; - private final EamDb centralRepoDb; + private final CentralRepository centralRepoDb; private final Map results = new LinkedHashMap<>(); /** @@ -51,7 +51,7 @@ final class SearchWorker extends SwingWorker { * @param groupSort the Algorithm to sort groups by * @param fileSortMethod the SortingMethod to use for files */ - SearchWorker(EamDb centralRepo, List searchfilters, FileSearch.AttributeType groupingAttribute, FileGroup.GroupSortingAlgorithm groupSort, FileSorter.SortingMethod fileSortMethod) { + SearchWorker(CentralRepository centralRepo, List searchfilters, FileSearch.AttributeType groupingAttribute, FileGroup.GroupSortingAlgorithm groupSort, FileSorter.SortingMethod fileSortMethod) { centralRepoDb = centralRepo; filters = searchfilters; groupingAttr = groupingAttribute; diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbCreateDatabaseDialog.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbCreateDatabaseDialog.java index fd4978ef09..6f68a3defc 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbCreateDatabaseDialog.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbCreateDatabaseDialog.java @@ -30,11 +30,10 @@ import org.apache.commons.io.FilenameUtils; import org.openide.util.NbBundle; import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamOrganization; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamGlobalSet; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoOrganization; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoFileSet; import org.sleuthkit.autopsy.centralrepository.optionspanel.ManageOrganizationsDialog; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ModuleSettings; @@ -44,6 +43,7 @@ import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb.KnownFile import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDbManagerException; import org.sleuthkit.datamodel.TskData; import org.sleuthkit.datamodel.TskCoreException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Instances of this class allow a user to create a new hash database and add it @@ -58,8 +58,8 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog { private JFileChooser fileChooser = null; private HashDb newHashDb = null; private final static String LAST_FILE_PATH_KEY = "HashDbCreate_Path"; - private EamOrganization selectedOrg = null; - private List orgs = null; + private CentralRepoOrganization selectedOrg = null; + private List orgs = null; static final String HASH_DATABASE_DIR_NAME = "HashDatabases"; /** @@ -127,7 +127,7 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog { private void enableComponents(){ - if(! EamDb.isEnabled()){ + if(! CentralRepository.isEnabled()){ centralRepoRadioButton.setEnabled(false); fileTypeRadioButton.setSelected(true); } else { @@ -151,11 +151,11 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog { private void populateCombobox() { orgComboBox.removeAllItems(); try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); orgs = dbManager.getOrganizations(); orgs.forEach((org) -> { orgComboBox.addItem(org.getName()); - if(EamDbUtil.isDefaultOrg(org)){ + if(CentralRepoDbUtil.isDefaultOrg(org)){ orgComboBox.setSelectedItem(org.getName()); selectedOrg = org; } @@ -163,7 +163,7 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog { if ((selectedOrg == null) && (!orgs.isEmpty())) { selectedOrg = orgs.get(0); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { JOptionPane.showMessageDialog(this, Bundle.HashDbCreateDatabaseDialog_populateOrgsError_message()); Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE, "Failure loading organizations", ex); } @@ -511,7 +511,7 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog { } else { // Check if a hash set with the same name/version already exists try{ - if(EamDb.getInstance().referenceSetExists(hashSetNameTextField.getText(), "")){ + if(CentralRepository.getInstance().referenceSetExists(hashSetNameTextField.getText(), "")){ JOptionPane.showMessageDialog(this, NbBundle.getMessage(this.getClass(), "HashDbCreateDatabaseDialog.duplicateName"), @@ -520,7 +520,7 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog { JOptionPane.ERROR_MESSAGE); return; } - } catch (EamDbException ex){ + } catch (CentralRepoException ex){ Logger.getLogger(HashDbImportDatabaseDialog.class.getName()).log(Level.SEVERE, "Error looking up reference set", ex); JOptionPane.showMessageDialog(this, NbBundle.getMessage(this.getClass(), @@ -532,12 +532,12 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog { } try{ - int referenceSetID = EamDb.getInstance().newReferenceSet(new EamGlobalSet(selectedOrg.getOrgID(), hashSetNameTextField.getText(), - "", fileKnown, false, EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID))); + int referenceSetID = CentralRepository.getInstance().newReferenceSet(new CentralRepoFileSet(selectedOrg.getOrgID(), hashSetNameTextField.getText(), + "", fileKnown, false, CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID))); newHashDb = HashDbManager.getInstance().addExistingCentralRepoHashSet(hashSetNameTextField.getText(), "", referenceSetID, true, sendIngestMessagesCheckbox.isSelected(), type, false); - } catch (EamDbException | TskCoreException ex){ + } catch (CentralRepoException | TskCoreException ex){ Logger.getLogger(HashDbImportDatabaseDialog.class.getName()).log(Level.SEVERE, "Error creating new reference set", ex); JOptionPane.showMessageDialog(this, NbBundle.getMessage(this.getClass(), @@ -567,7 +567,7 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog { private void orgComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_orgComboBoxActionPerformed if (null == orgComboBox.getSelectedItem()) return; String orgName = this.orgComboBox.getSelectedItem().toString(); - for (EamOrganization org : orgs) { + for (CentralRepoOrganization org : orgs) { if (org.getName().equals(orgName)) { selectedOrg = org; return; diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbImportDatabaseDialog.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbImportDatabaseDialog.java index db27f27365..1e34c9bbda 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbImportDatabaseDialog.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbImportDatabaseDialog.java @@ -31,10 +31,9 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.openide.util.NbBundle; import org.openide.windows.WindowManager; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamOrganization; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoOrganization; import org.sleuthkit.autopsy.centralrepository.optionspanel.ManageOrganizationsDialog; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ModuleSettings; @@ -42,6 +41,7 @@ import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb.KnownFilesType; import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDbManagerException; import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Instances of this class allow a user to select an existing hash database and @@ -55,8 +55,8 @@ final class HashDbImportDatabaseDialog extends javax.swing.JDialog { private String selectedFilePath = ""; private HashDb selectedHashDb = null; private final static String LAST_FILE_PATH_KEY = "HashDbImport_Path"; - private EamOrganization selectedOrg = null; - private List orgs = null; + private CentralRepoOrganization selectedOrg = null; + private List orgs = null; /** * Displays a dialog that allows a user to select an existing hash database @@ -109,7 +109,7 @@ final class HashDbImportDatabaseDialog extends javax.swing.JDialog { private void enableComponents(){ - if(! EamDb.isEnabled()){ + if(! CentralRepository.isEnabled()){ centralRepoRadioButton.setEnabled(false); fileTypeRadioButton.setSelected(true); } else { @@ -132,11 +132,11 @@ final class HashDbImportDatabaseDialog extends javax.swing.JDialog { private void populateCombobox() { orgComboBox.removeAllItems(); try { - EamDb dbManager = EamDb.getInstance(); + CentralRepository dbManager = CentralRepository.getInstance(); orgs = dbManager.getOrganizations(); orgs.forEach((org) -> { orgComboBox.addItem(org.getName()); - if(EamDbUtil.isDefaultOrg(org)){ + if(CentralRepoDbUtil.isDefaultOrg(org)){ orgComboBox.setSelectedItem(org.getName()); selectedOrg = org; } @@ -144,7 +144,7 @@ final class HashDbImportDatabaseDialog extends javax.swing.JDialog { if ((selectedOrg == null) && (!orgs.isEmpty())) { selectedOrg = orgs.get(0); } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { JOptionPane.showMessageDialog(this, Bundle.HashDbImportDatabaseDialog_populateOrgsError_message()); Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE, "Failure loading organizations", ex); } @@ -555,7 +555,7 @@ final class HashDbImportDatabaseDialog extends javax.swing.JDialog { // Check if a hash set with the same name/version already exists try{ - if(EamDb.getInstance().referenceSetExists(hashSetNameTextField.getText(), versionTextField.getText())){ + if(CentralRepository.getInstance().referenceSetExists(hashSetNameTextField.getText(), versionTextField.getText())){ JOptionPane.showMessageDialog(this, NbBundle.getMessage(this.getClass(), "HashDbImportDatabaseDialog.duplicateName"), @@ -564,7 +564,7 @@ final class HashDbImportDatabaseDialog extends javax.swing.JDialog { JOptionPane.ERROR_MESSAGE); return; } - } catch (EamDbException ex){ + } catch (CentralRepoException ex){ Logger.getLogger(HashDbImportDatabaseDialog.class.getName()).log(Level.SEVERE, "Error looking up reference set", ex); JOptionPane.showMessageDialog(this, NbBundle.getMessage(this.getClass(), @@ -615,7 +615,7 @@ final class HashDbImportDatabaseDialog extends javax.swing.JDialog { private void orgComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_orgComboBoxActionPerformed if (null == orgComboBox.getSelectedItem()) return; String orgName = this.orgComboBox.getSelectedItem().toString(); - for (EamOrganization org : orgs) { + for (CentralRepoOrganization org : orgs) { if (org.getName().equals(orgName)) { selectedOrg = org; return; diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbManager.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbManager.java index 3b90240ebc..c6ae0d5ef4 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbManager.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbManager.java @@ -42,10 +42,9 @@ import org.openide.util.NbBundle.Messages; import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamGlobalFileInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamGlobalSet; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoFileInstance; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoFileSet; import org.sleuthkit.autopsy.core.RuntimeProperties; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; @@ -58,6 +57,7 @@ import org.sleuthkit.datamodel.HashHitInfo; import org.sleuthkit.datamodel.SleuthkitJNI; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskData; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * This class implements a singleton that manages the set of hash databases used @@ -278,7 +278,7 @@ public class HashDbManager implements PropertyChangeListener { boolean searchDuringIngest, boolean sendIngestMessages, HashDb.KnownFilesType knownFilesType, boolean readOnly) throws TskCoreException{ - if(! EamDb.isEnabled()){ + if(! CentralRepository.isEnabled()){ throw new TskCoreException("Could not load central repository hash set " + hashSetName + " - central repository is not enabled"); } @@ -491,10 +491,10 @@ public class HashDbManager implements PropertyChangeListener { private List getCentralRepoHashSetsFromDatabase(){ List crHashSets = new ArrayList<>(); - if(EamDb.isEnabled()){ + if(CentralRepository.isEnabled()){ try{ - List crSets = EamDb.getInstance().getAllReferenceSets(EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID)); - for(EamGlobalSet globalSet:crSets){ + List crSets = CentralRepository.getInstance().getAllReferenceSets(CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID)); + for(CentralRepoFileSet globalSet:crSets){ // Defaults for fields not stored in the central repository: // searchDuringIngest: false @@ -503,7 +503,7 @@ public class HashDbManager implements PropertyChangeListener { crHashSets.add(new HashDbInfo(globalSet.getSetName(), globalSet.getVersion(), globalSet.getGlobalSetID(), convertFileKnown(globalSet.getFileKnownStatus()), globalSet.isReadOnly(), false, sendIngestMessages)); } - } catch (EamDbException ex){ + } catch (CentralRepoException ex){ Logger.getLogger(HashDbManager.class.getName()).log(Level.SEVERE, "Error loading central repository hash sets", ex); //NON-NLS } } @@ -573,7 +573,7 @@ public class HashDbManager implements PropertyChangeListener { allDatabasesLoadedCorrectly = false; } } else { - if(EamDb.isEnabled()){ + if(CentralRepository.isEnabled()){ addExistingCentralRepoHashSet(hashDbInfo.getHashSetName(), hashDbInfo.getVersion(), hashDbInfo.getReferenceSetID(), hashDbInfo.getSearchDuringIngest(), hashDbInfo.getSendIngestMessages(), @@ -591,7 +591,7 @@ public class HashDbManager implements PropertyChangeListener { } } - if(EamDb.isEnabled()){ + if(CentralRepository.isEnabled()){ try{ updateHashSetsFromCentralRepository(); } catch (TskCoreException ex){ @@ -624,7 +624,7 @@ public class HashDbManager implements PropertyChangeListener { } private void updateHashSetsFromCentralRepository() throws TskCoreException { - if(EamDb.isEnabled()){ + if(CentralRepository.isEnabled()){ List crHashDbInfoList = getCentralRepoHashSetsFromDatabase(); for(HashDbInfo hashDbInfo : crHashDbInfoList) { if(hashDbInfoIsNew(hashDbInfo)){ @@ -1093,8 +1093,8 @@ public class HashDbManager implements PropertyChangeListener { this.readOnly = readOnly; try{ - orgName = EamDb.getInstance().getReferenceSetOrganization(referenceSetID).getName(); - } catch (EamDbException ex){ + orgName = CentralRepository.getInstance().getReferenceSetOrganization(referenceSetID).getName(); + } catch (CentralRepoException ex){ Logger.getLogger(SleuthkitHashSet.class.getName()).log(Level.SEVERE, "Error looking up central repository organization for reference set " + referenceSetID, ex); //NON-NLS orgName = Bundle.HashDbManager_CentralRepoHashDb_orgError(); } @@ -1237,10 +1237,10 @@ public class HashDbManager implements PropertyChangeListener { } try{ - EamGlobalFileInstance fileInstance = new EamGlobalFileInstance(referenceSetID, file.getMd5Hash(), + CentralRepoFileInstance fileInstance = new CentralRepoFileInstance(referenceSetID, file.getMd5Hash(), type, comment); - EamDb.getInstance().addReferenceInstance(fileInstance,EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID)); - } catch (EamDbException | CorrelationAttributeNormalizationException ex){ + CentralRepository.getInstance().addReferenceInstance(fileInstance,CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID)); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex){ throw new TskCoreException("Error adding hashes to " + getDisplayName(), ex); //NON-NLS } } @@ -1256,7 +1256,7 @@ public class HashDbManager implements PropertyChangeListener { */ @Override public void addHashes(List hashes) throws TskCoreException { - Set globalFileInstances = new HashSet<>(); + Set globalFileInstances = new HashSet<>(); for(HashEntry hashEntry:hashes){ TskData.FileKnown type; if(knownFilesType.equals(HashDb.KnownFilesType.KNOWN_BAD)){ @@ -1265,16 +1265,16 @@ public class HashDbManager implements PropertyChangeListener { type = TskData.FileKnown.KNOWN; } try { - globalFileInstances.add(new EamGlobalFileInstance(referenceSetID, hashEntry.getMd5Hash(), type, hashEntry.getComment())); - } catch (EamDbException | CorrelationAttributeNormalizationException ex){ + globalFileInstances.add(new CentralRepoFileInstance(referenceSetID, hashEntry.getMd5Hash(), type, hashEntry.getComment())); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex){ throw new TskCoreException("Error adding hashes to " + getDisplayName(), ex); } } try{ - EamDb.getInstance().bulkInsertReferenceTypeEntries(globalFileInstances, - EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID)); - } catch (EamDbException ex){ + CentralRepository.getInstance().bulkInsertReferenceTypeEntries(globalFileInstances, + CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID)); + } catch (CentralRepoException ex){ throw new TskCoreException("Error adding hashes to " + getDisplayName(), ex); } } @@ -1296,8 +1296,8 @@ public class HashDbManager implements PropertyChangeListener { AbstractFile file = (AbstractFile) content; if (null != file.getMd5Hash()) { try{ - return EamDb.getInstance().isFileHashInReferenceSet(file.getMd5Hash(), this.referenceSetID); - } catch (EamDbException | CorrelationAttributeNormalizationException ex){ + return CentralRepository.getInstance().isFileHashInReferenceSet(file.getMd5Hash(), this.referenceSetID); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex){ Logger.getLogger(SleuthkitHashSet.class.getName()).log(Level.SEVERE, "Error performing central reposiotry hash lookup for hash " + file.getMd5Hash() + " in reference set " + referenceSetID, ex); //NON-NLS throw new TskCoreException("Error performing central reposiotry hash lookup", ex); @@ -1325,11 +1325,11 @@ public class HashDbManager implements PropertyChangeListener { AbstractFile file = (AbstractFile) content; if (null != file.getMd5Hash()) { try{ - if(EamDb.getInstance().isFileHashInReferenceSet(file.getMd5Hash(), this.referenceSetID)){ + if(CentralRepository.getInstance().isFileHashInReferenceSet(file.getMd5Hash(), this.referenceSetID)){ // Make a bare-bones HashHitInfo for now result = new HashHitInfo(file.getMd5Hash(), "", ""); } - } catch (EamDbException | CorrelationAttributeNormalizationException ex){ + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex){ Logger.getLogger(SleuthkitHashSet.class.getName()).log(Level.SEVERE, "Error performing central reposiotry hash lookup for hash " + file.getMd5Hash() + " in reference set " + referenceSetID, ex); //NON-NLS throw new TskCoreException("Error performing central reposiotry hash lookup", ex); @@ -1346,12 +1346,12 @@ public class HashDbManager implements PropertyChangeListener { */ @Override boolean isValid() { - if(! EamDb.isEnabled()) { + if(! CentralRepository.isEnabled()) { return false; } try{ - return EamDb.getInstance().referenceSetIsValid(this.referenceSetID, this.hashSetName, this.version); - } catch (EamDbException ex){ + return CentralRepository.getInstance().referenceSetIsValid(this.referenceSetID, this.hashSetName, this.version); + } catch (CentralRepoException ex){ Logger.getLogger(CentralRepoHashSet.class.getName()).log(Level.SEVERE, "Error validating hash set " + hashSetName, ex); //NON-NLS return false; } diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettingsPanel.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettingsPanel.java index ebe59fe535..6c38ea7557 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettingsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashLookupSettingsPanel.java @@ -40,8 +40,7 @@ import javax.swing.table.TableCellRenderer; import org.netbeans.spi.options.OptionsPanelController; import org.openide.util.NbBundle; import org.openide.util.NbBundle.Messages; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.corecomponents.OptionsPanel; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.PlatformUtil; @@ -53,6 +52,7 @@ import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.CentralRepoHashS import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb.KnownFilesType; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Instances of this class provide a comprehensive UI for managing the hash sets @@ -360,14 +360,14 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan // Remove any new central repo hash sets from the database for (int refID : newReferenceSetIDs) { try { - if (EamDb.isEnabled()) { - EamDb.getInstance().deleteReferenceSet(refID); + if (CentralRepository.isEnabled()) { + CentralRepository.getInstance().deleteReferenceSet(refID); } else { // This is the case where the user imported a database, then switched over to the central // repo panel and disabled it before cancelling. We can't delete the database at this point. Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.WARNING, "Error reverting central repository hash sets"); //NON-NLS } - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Logger.getLogger(HashLookupSettingsPanel.class.getName()).log(Level.SEVERE, "Error reverting central repository hash sets", ex); //NON-NLS } } diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/ImportCentralRepoDbProgressDialog.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/ImportCentralRepoDbProgressDialog.java index 84235e9abb..f25471b0e0 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/ImportCentralRepoDbProgressDialog.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/ImportCentralRepoDbProgressDialog.java @@ -34,13 +34,13 @@ import java.util.concurrent.Executors; import org.openide.util.NbBundle; import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamGlobalFileInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamGlobalSet; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoFileInstance; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoFileSet; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskData; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Imports a hash set into the central repository and updates a progress dialog @@ -239,16 +239,16 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P } // Create an empty hashset in the central repository - EamDb dbManager = EamDb.getInstance(); - referenceSetID.set(dbManager.newReferenceSet(new EamGlobalSet(orgId, hashSetName, version, knownStatus, - readOnly, EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID)))); + CentralRepository dbManager = CentralRepository.getInstance(); + referenceSetID.set(dbManager.newReferenceSet(new CentralRepoFileSet(orgId, hashSetName, version, knownStatus, + readOnly, CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID)))); // Get the "FILES" content type. This is a database lookup so we // only want to do it once. CorrelationAttributeInstance.Type contentType = dbManager.getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID); // Holds the current batch of hashes that need to be written to the central repo - Set globalInstances = new HashSet<>(); + Set globalInstances = new HashSet<>(); while (!hashSetParser.doneReading()) { if (isCancelled()) { @@ -258,7 +258,7 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P String newHash = hashSetParser.getNextHash(); if (newHash != null) { - EamGlobalFileInstance eamGlobalFileInstance = new EamGlobalFileInstance( + CentralRepoFileInstance eamGlobalFileInstance = new CentralRepoFileInstance( referenceSetID.get(), newHash, knownStatus, @@ -299,8 +299,8 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P @Override public void run() { try { - EamDb.getInstance().deleteReferenceSet(referenceSetID.get()); - } catch (EamDbException ex2) { + CentralRepository.getInstance().deleteReferenceSet(referenceSetID.get()); + } catch (CentralRepoException ex2) { Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE, "Error deleting incomplete hash set from central repository", ex2); } } diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java index 9b90cdedc3..c95b58b874 100755 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java @@ -65,7 +65,7 @@ public class CentralRepoDatamodelTest extends TestCase { private static final Path testDirectory = Paths.get(System.getProperty("java.io.tmpdir"), "CentralRepoDatamodelTest"); private static final int DEFAULT_BULK_THRESHOLD = 1000; // hard coded from EamDb - SqliteEamDbSettings dbSettingsSqlite; + SqliteCentralRepoSettings dbSettingsSqlite; private static final long CASE_1_DATA_SOURCE_1_ID = 11; private static final long CASE_1_DATA_SOURCE_2_ID = 12; @@ -76,8 +76,8 @@ public class CentralRepoDatamodelTest extends TestCase { private CorrelationDataSource dataSource1fromCase1; private CorrelationDataSource dataSource2fromCase1; private CorrelationDataSource dataSource1fromCase2; - private EamOrganization org1; - private EamOrganization org2; + private CentralRepoOrganization org1; + private CentralRepoOrganization org2; CorrelationAttributeInstance.Type fileType; CorrelationAttributeInstance.Type usbDeviceType; @@ -92,16 +92,16 @@ public class CentralRepoDatamodelTest extends TestCase { @Override public void setUp() { - dbSettingsSqlite = new SqliteEamDbSettings(); + dbSettingsSqlite = new SqliteCentralRepoSettings(); // Delete the test directory, if it exists if (testDirectory.toFile().exists()) { try { - if (EamDb.isEnabled()) { - EamDb.getInstance().shutdownConnections(); + if (CentralRepository.isEnabled()) { + CentralRepository.getInstance().shutdownConnections(); } FileUtils.deleteDirectory(testDirectory.toFile()); - } catch (IOException | EamDbException ex) { + } catch (IOException | CentralRepoException ex) { Assert.fail(ex.getMessage()); } } @@ -129,10 +129,10 @@ public class CentralRepoDatamodelTest extends TestCase { assertTrue("Failed to initialize central repo database", result); dbSettingsSqlite.saveSettings(); - EamDbUtil.setUseCentralRepo(true); - EamDbPlatformEnum.setSelectedPlatform(EamDbPlatformEnum.SQLITE.name()); - EamDbPlatformEnum.saveSelectedPlatform(); - } catch (EamDbException ex) { + CentralRepoDbUtil.setUseCentralRepo(true); + CentralRepoPlatforms.setSelectedPlatform(CentralRepoPlatforms.SQLITE.name()); + CentralRepoPlatforms.saveSelectedPlatform(); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -143,41 +143,41 @@ public class CentralRepoDatamodelTest extends TestCase { // Set up some default objects to be used by the tests try { case1 = new CorrelationCase("case1_uuid", "case1"); - case1 = EamDb.getInstance().newCase(case1); + case1 = CentralRepository.getInstance().newCase(case1); assertTrue("Failed to create test object case1", case1 != null); case2 = new CorrelationCase("case2_uuid", "case2"); - case2 = EamDb.getInstance().newCase(case2); + case2 = CentralRepository.getInstance().newCase(case2); assertTrue("Failed to create test object case2", case2 != null); dataSource1fromCase1 = new CorrelationDataSource(case1, "dataSource1_deviceID", "dataSource1", CASE_1_DATA_SOURCE_1_ID, null, null, null); - EamDb.getInstance().newDataSource(dataSource1fromCase1); - dataSource1fromCase1 = EamDb.getInstance().getDataSource(case1, dataSource1fromCase1.getDataSourceObjectID()); + CentralRepository.getInstance().newDataSource(dataSource1fromCase1); + dataSource1fromCase1 = CentralRepository.getInstance().getDataSource(case1, dataSource1fromCase1.getDataSourceObjectID()); assertTrue("Failed to create test object dataSource1fromCase1", dataSource1fromCase1 != null); dataSource2fromCase1 = new CorrelationDataSource(case1, "dataSource2_deviceID", "dataSource2", CASE_1_DATA_SOURCE_2_ID, null, null, null); - EamDb.getInstance().newDataSource(dataSource2fromCase1); - dataSource2fromCase1 = EamDb.getInstance().getDataSource(case1, dataSource2fromCase1.getDataSourceObjectID()); + CentralRepository.getInstance().newDataSource(dataSource2fromCase1); + dataSource2fromCase1 = CentralRepository.getInstance().getDataSource(case1, dataSource2fromCase1.getDataSourceObjectID()); assertTrue("Failed to create test object dataSource2fromCase1", dataSource2fromCase1 != null); dataSource1fromCase2 = new CorrelationDataSource(case2, "dataSource3_deviceID", "dataSource3", CASE_2_DATA_SOURCE_1_ID, null, null, null); - EamDb.getInstance().newDataSource(dataSource1fromCase2); - dataSource1fromCase2 = EamDb.getInstance().getDataSource(case2, dataSource1fromCase2.getDataSourceObjectID()); + CentralRepository.getInstance().newDataSource(dataSource1fromCase2); + dataSource1fromCase2 = CentralRepository.getInstance().getDataSource(case2, dataSource1fromCase2.getDataSourceObjectID()); assertTrue("Failed to create test object dataSource1fromCase2", dataSource1fromCase2 != null); - org1 = new EamOrganization("org1"); - org1 = EamDb.getInstance().newOrganization(org1); + org1 = new CentralRepoOrganization("org1"); + org1 = CentralRepository.getInstance().newOrganization(org1); - org2 = new EamOrganization("org2"); - org2 = EamDb.getInstance().newOrganization(org2); + org2 = new CentralRepoOrganization("org2"); + org2 = CentralRepository.getInstance().newOrganization(org2); // Store the file type object for later use - fileType = EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID); + fileType = CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.FILES_TYPE_ID); assertTrue("getCorrelationTypeById(FILES_TYPE_ID) returned null", fileType != null); - usbDeviceType = EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.USBID_TYPE_ID); + usbDeviceType = CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.USBID_TYPE_ID); assertTrue("getCorrelationTypeById(USBID_TYPE_ID) returned null", usbDeviceType != null); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -191,11 +191,11 @@ public class CentralRepoDatamodelTest extends TestCase { // Close and delete the test case and central repo db try { - if (EamDb.isEnabled()) { - EamDb.getInstance().shutdownConnections(); + if (CentralRepository.isEnabled()) { + CentralRepository.getInstance().shutdownConnections(); } FileUtils.deleteDirectory(testDirectory.toFile()); - } catch (EamDbException | IOException ex) { + } catch (CentralRepoException | IOException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -240,19 +240,19 @@ public class CentralRepoDatamodelTest extends TestCase { CorrelationAttributeInstance attr1 = new CorrelationAttributeInstance(fileType, notableHashInBothCases, case1, dataSource1fromCase1, "path1", "", TskData.FileKnown.BAD, 0L); - EamDb.getInstance().addArtifactInstance(attr1); + CentralRepository.getInstance().addArtifactInstance(attr1); CorrelationAttributeInstance attr2 = new CorrelationAttributeInstance(fileType, notableHashInBothCases, case2, dataSource1fromCase2, "path2", "", TskData.FileKnown.BAD, 0L); - EamDb.getInstance().addArtifactInstance(attr2); + CentralRepository.getInstance().addArtifactInstance(attr2); - List attrs = EamDb.getInstance().getArtifactInstancesByTypeValue(fileType, notableHashInBothCases); + List attrs = CentralRepository.getInstance().getArtifactInstancesByTypeValue(fileType, notableHashInBothCases); assertTrue("getArtifactInstancesByTypeValue returned " + attrs.size() + " values - expected 2", attrs.size() == 2); for (CorrelationAttributeInstance a : attrs) { assertTrue("Artifact did not have expected BAD status", a.getKnownStatus().equals(TskData.FileKnown.BAD)); } - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -263,15 +263,15 @@ public class CentralRepoDatamodelTest extends TestCase { "", TskData.FileKnown.BAD, 0L); - EamDb.getInstance().addArtifactInstance(attr1); + CentralRepository.getInstance().addArtifactInstance(attr1); CorrelationAttributeInstance attr2 = new CorrelationAttributeInstance(fileType, notableHashInOneCaseKnownOther, case2, dataSource1fromCase2, "path4", "", TskData.FileKnown.KNOWN, 0L); - EamDb.getInstance().addArtifactInstance(attr2); + CentralRepository.getInstance().addArtifactInstance(attr2); - List attrs = EamDb.getInstance().getArtifactInstancesByTypeValue(fileType, notableHashInOneCaseKnownOther); + List attrs = CentralRepository.getInstance().getArtifactInstancesByTypeValue(fileType, notableHashInOneCaseKnownOther); assertTrue("getArtifactInstancesByTypeValue returned " + attrs.size() + " values - expected 2", attrs.size() == 2); for (CorrelationAttributeInstance a : attrs) { if (case1.getCaseUUID().equals(a.getCorrelationCase().getCaseUUID())) { @@ -282,7 +282,7 @@ public class CentralRepoDatamodelTest extends TestCase { fail("getArtifactInstancesByTypeValue returned unexpected case"); } } - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -293,14 +293,14 @@ public class CentralRepoDatamodelTest extends TestCase { "", TskData.FileKnown.KNOWN, 0L); - EamDb.getInstance().addArtifactInstance(attr); + CentralRepository.getInstance().addArtifactInstance(attr); - EamDb.getInstance().setAttributeInstanceKnownStatus(attr, TskData.FileKnown.BAD); + CentralRepository.getInstance().setAttributeInstanceKnownStatus(attr, TskData.FileKnown.BAD); - List attrs = EamDb.getInstance().getArtifactInstancesByTypeValue(fileType, hashToChangeToNotable); + List attrs = CentralRepository.getInstance().getArtifactInstancesByTypeValue(fileType, hashToChangeToNotable); assertTrue("getArtifactInstancesByTypeValue returned " + attrs.size() + " values - expected 1", attrs.size() == 1); assertTrue("Artifact status did not change to BAD", attrs.get(0).getKnownStatus().equals(TskData.FileKnown.BAD)); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -314,17 +314,17 @@ public class CentralRepoDatamodelTest extends TestCase { "", TskData.FileKnown.KNOWN, 0L); - EamDb.getInstance().setAttributeInstanceKnownStatus(attr1, TskData.FileKnown.BAD); - EamDb.getInstance().setAttributeInstanceKnownStatus(attr2, TskData.FileKnown.BAD); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + CentralRepository.getInstance().setAttributeInstanceKnownStatus(attr1, TskData.FileKnown.BAD); + CentralRepository.getInstance().setAttributeInstanceKnownStatus(attr2, TskData.FileKnown.BAD); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Assert.fail("setArtifactInstanceKnownStatus threw an exception for sequential Correlation Attribute Instances updates"); } // Try to update null artifact try { - EamDb.getInstance().setAttributeInstanceKnownStatus(null, TskData.FileKnown.BAD); + CentralRepository.getInstance().setAttributeInstanceKnownStatus(null, TskData.FileKnown.BAD); fail("setArtifactInstanceKnownStatus failed to throw exception for null correlation attribute"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior } @@ -334,9 +334,9 @@ public class CentralRepoDatamodelTest extends TestCase { "", TskData.FileKnown.KNOWN, 0L); - EamDb.getInstance().setAttributeInstanceKnownStatus(attr, null); + CentralRepository.getInstance().setAttributeInstanceKnownStatus(attr, null); fail("setArtifactInstanceKnownStatus failed to throw exception for null known status"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior } catch (CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); @@ -349,9 +349,9 @@ public class CentralRepoDatamodelTest extends TestCase { "", TskData.FileKnown.KNOWN, 0L); - EamDb.getInstance().setAttributeInstanceKnownStatus(attr, TskData.FileKnown.BAD); + CentralRepository.getInstance().setAttributeInstanceKnownStatus(attr, TskData.FileKnown.BAD); fail("setArtifactInstanceKnownStatus failed to throw exception for null case"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior } catch (CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); @@ -364,9 +364,9 @@ public class CentralRepoDatamodelTest extends TestCase { "", TskData.FileKnown.KNOWN, 0L); - EamDb.getInstance().setAttributeInstanceKnownStatus(attr, TskData.FileKnown.BAD); + CentralRepository.getInstance().setAttributeInstanceKnownStatus(attr, TskData.FileKnown.BAD); fail("setArtifactInstanceKnownStatus failed to throw exception for null case"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior } catch (CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); @@ -375,27 +375,27 @@ public class CentralRepoDatamodelTest extends TestCase { // Test getting count of two notable instances try { - long count = EamDb.getInstance().getCountArtifactInstancesKnownBad(fileType, notableHashInBothCases); + long count = CentralRepository.getInstance().getCountArtifactInstancesKnownBad(fileType, notableHashInBothCases); assertTrue("getCountArtifactInstancesKnownBad returned " + count + " values - expected 2", count == 2); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting notable instance count where one instance is notable and the other is known try { - long count = EamDb.getInstance().getCountArtifactInstancesKnownBad(fileType, notableHashInOneCaseKnownOther); + long count = CentralRepository.getInstance().getCountArtifactInstancesKnownBad(fileType, notableHashInOneCaseKnownOther); assertTrue("getCountArtifactInstancesKnownBad returned " + count + " values - expected 1", count == 1); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting notable instance count with null type try { - EamDb.getInstance().getCountArtifactInstancesKnownBad(null, notableHashInOneCaseKnownOther); + CentralRepository.getInstance().getCountArtifactInstancesKnownBad(null, notableHashInOneCaseKnownOther); fail("getCountArtifactInstancesKnownBad failed to throw exception for null type"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail(ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -405,8 +405,8 @@ public class CentralRepoDatamodelTest extends TestCase { // Test getting notable instance count with null value (should throw an exception) try { - EamDb.getInstance().getCountArtifactInstancesKnownBad(fileType, null); - } catch (EamDbException ex) { + CentralRepository.getInstance().getCountArtifactInstancesKnownBad(fileType, null); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail(ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -416,28 +416,28 @@ public class CentralRepoDatamodelTest extends TestCase { // Test getting cases with notable instances (all instances are notable) try { - List cases = EamDb.getInstance().getListCasesHavingArtifactInstancesKnownBad(fileType, notableHashInBothCases); + List cases = CentralRepository.getInstance().getListCasesHavingArtifactInstancesKnownBad(fileType, notableHashInBothCases); assertTrue("getListCasesHavingArtifactInstancesKnownBad returned " + cases.size() + " values - expected 2", cases.size() == 2); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting cases with notable instances (only one instance is notable) try { - List cases = EamDb.getInstance().getListCasesHavingArtifactInstancesKnownBad(fileType, notableHashInOneCaseKnownOther); + List cases = CentralRepository.getInstance().getListCasesHavingArtifactInstancesKnownBad(fileType, notableHashInOneCaseKnownOther); assertTrue("getListCasesHavingArtifactInstancesKnownBad returned " + cases.size() + " values - expected 1", cases.size() == 1); assertTrue("getListCasesHavingArtifactInstancesKnownBad returned unexpected case " + cases.get(0), case1.getDisplayName().equals(cases.get(0))); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting cases with null type try { - EamDb.getInstance().getListCasesHavingArtifactInstancesKnownBad(null, notableHashInOneCaseKnownOther); + CentralRepository.getInstance().getListCasesHavingArtifactInstancesKnownBad(null, notableHashInOneCaseKnownOther); fail("getListCasesHavingArtifactInstancesKnownBad failed to throw exception for null type"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail(ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -447,9 +447,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test getting cases with null value (should throw exception) try { - List cases = EamDb.getInstance().getListCasesHavingArtifactInstancesKnownBad(fileType, null); + List cases = CentralRepository.getInstance().getListCasesHavingArtifactInstancesKnownBad(fileType, null); assertTrue("getListCasesHavingArtifactInstancesKnownBad returned " + cases.size() + " values - expected ", cases.isEmpty()); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail(ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -483,7 +483,7 @@ public class CentralRepoDatamodelTest extends TestCase { // - Verify that the database now has all the artifacts try { // Make sure there are no artifacts in the database to start - long originalArtifactCount = EamDb.getInstance().getCountArtifactInstancesByCaseDataSource(dataSource1fromCase1); + long originalArtifactCount = CentralRepository.getInstance().getCountArtifactInstancesByCaseDataSource(dataSource1fromCase1); assertTrue("getCountArtifactInstancesByCaseDataSource returned non-zero count", originalArtifactCount == 0); // Create the first list, which will have (bulkThreshold / 2) entries @@ -499,12 +499,12 @@ public class CentralRepoDatamodelTest extends TestCase { // Queue up the current list. There should not be enough to trigger the insert for (CorrelationAttributeInstance attr : list1) { - EamDb.getInstance().addAttributeInstanceBulk(attr); + CentralRepository.getInstance().addAttributeInstanceBulk(attr); } // Check that nothing has been written yet assertTrue("Artifacts written to database before threshold was reached", - originalArtifactCount == EamDb.getInstance().getCountArtifactInstancesByCaseDataSource(dataSource1fromCase1)); + originalArtifactCount == CentralRepository.getInstance().getCountArtifactInstancesByCaseDataSource(dataSource1fromCase1)); // Make a second list with length equal to bulkThreshold List list2 = new ArrayList<>(); @@ -519,20 +519,20 @@ public class CentralRepoDatamodelTest extends TestCase { // Queue up the current list. This will trigger an insert partway through for (CorrelationAttributeInstance attr : list2) { - EamDb.getInstance().addAttributeInstanceBulk(attr); + CentralRepository.getInstance().addAttributeInstanceBulk(attr); } // There should now be bulkThreshold artifacts in the database - long count = EamDb.getInstance().getCountArtifactInstancesByCaseDataSource(dataSource1fromCase1); + long count = CentralRepository.getInstance().getCountArtifactInstancesByCaseDataSource(dataSource1fromCase1); assertTrue("Artifact count " + count + " does not match bulkThreshold " + DEFAULT_BULK_THRESHOLD, count == DEFAULT_BULK_THRESHOLD); // Now call commitAttributeInstancesBulk() to insert the rest of queue - EamDb.getInstance().commitAttributeInstancesBulk(); - count = EamDb.getInstance().getCountArtifactInstancesByCaseDataSource(dataSource1fromCase1); + CentralRepository.getInstance().commitAttributeInstancesBulk(); + count = CentralRepository.getInstance().getCountArtifactInstancesByCaseDataSource(dataSource1fromCase1); int expectedCount = list1.size() + list2.size(); assertTrue("Artifact count " + count + " does not match expected count " + expectedCount, count == expectedCount); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -540,9 +540,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test preparing artifact with null type try { CorrelationAttributeInstance attr = new CorrelationAttributeInstance(null, randomHash(), null, null, FILE_PATH, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addAttributeInstanceBulk(attr); + CentralRepository.getInstance().addAttributeInstanceBulk(attr); fail("prepareBulkArtifact failed to throw exception for null type"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail(ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -554,10 +554,10 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance attr = new CorrelationAttributeInstance(fileType, randomHash(), null, dataSource1fromCase1, "path", null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addAttributeInstanceBulk(attr); - EamDb.getInstance().commitAttributeInstancesBulk(); + CentralRepository.getInstance().addAttributeInstanceBulk(attr); + CentralRepository.getInstance().commitAttributeInstancesBulk(); fail("bulkInsertArtifacts failed to throw exception for null case"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } catch (CorrelationAttributeNormalizationException ex) { @@ -569,10 +569,10 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance attr = new CorrelationAttributeInstance(fileType, randomHash(), case1, null, "path", null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addAttributeInstanceBulk(attr); - EamDb.getInstance().commitAttributeInstancesBulk(); + CentralRepository.getInstance().addAttributeInstanceBulk(attr); + CentralRepository.getInstance().commitAttributeInstancesBulk(); fail("prepareBulkArtifact failed to throw exception for null data source"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } catch (CorrelationAttributeNormalizationException ex) { @@ -586,7 +586,7 @@ public class CentralRepoDatamodelTest extends TestCase { new CorrelationAttributeInstance(fileType, randomHash(), case1, dataSource1fromCase1, null, null, TskData.FileKnown.UNKNOWN, 0L); fail("CorrelationAttributeInstance failed to throw exception for null path"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } catch (CorrelationAttributeNormalizationException ex) { @@ -598,10 +598,10 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance attr = new CorrelationAttributeInstance(fileType, randomHash(), case1, dataSource1fromCase1, "path", "comment", null, 0L); - EamDb.getInstance().addAttributeInstanceBulk(attr); - EamDb.getInstance().commitAttributeInstancesBulk(); + CentralRepository.getInstance().addAttributeInstanceBulk(attr); + CentralRepository.getInstance().commitAttributeInstancesBulk(); fail("prepareBulkArtifact failed to throw exception for null known status"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } catch (CorrelationAttributeNormalizationException ex) { @@ -672,9 +672,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Store the email type CorrelationAttributeInstance.Type emailType; //used again for other portions of this test try { - emailType = EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.EMAIL_TYPE_ID); + emailType = CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.EMAIL_TYPE_ID); assertEquals("Unexpected Correlation Type retrieved for Email type id", CorrelationAttributeInstance.EMAIL_TYPE_ID, emailType.getId()); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error thrown while attempting to get email attribute " + ex.getMessage()); return; @@ -684,8 +684,8 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance attr = new CorrelationAttributeInstance(fileType, onlyInDataSource3Hash, case2, dataSource1fromCase2, onlyInDataSource3Path, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addArtifactInstance(attr); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + CentralRepository.getInstance().addArtifactInstance(attr); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error thrown while attempting to add file attribute from single datasource the first time " + ex.getMessage()); } @@ -694,15 +694,15 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance attr1 = new CorrelationAttributeInstance(fileType, inAllDataSourcesHash, case1, dataSource1fromCase1, inAllDataSourcesPath, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addArtifactInstance(attr1); + CentralRepository.getInstance().addArtifactInstance(attr1); CorrelationAttributeInstance attr2 = new CorrelationAttributeInstance(fileType, inAllDataSourcesHash, case1, dataSource2fromCase1, inAllDataSourcesPath, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addArtifactInstance(attr2); + CentralRepository.getInstance().addArtifactInstance(attr2); CorrelationAttributeInstance attr3 = new CorrelationAttributeInstance(fileType, inAllDataSourcesHash, case2, dataSource1fromCase2, inAllDataSourcesPath, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addArtifactInstance(attr3); + CentralRepository.getInstance().addArtifactInstance(attr3); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error thrown while attempting to add file attribute from all 3 datasources " + ex.getMessage()); } @@ -711,12 +711,12 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance attr1 = new CorrelationAttributeInstance(fileType, inDataSource1twiceHash, case1, dataSource1fromCase1, inDataSource1twicePath1, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addArtifactInstance(attr1); + CentralRepository.getInstance().addArtifactInstance(attr1); CorrelationAttributeInstance attr2 = new CorrelationAttributeInstance(fileType, inDataSource1twiceHash, case1, dataSource1fromCase1, inDataSource1twicePath2, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addArtifactInstance(attr2); + CentralRepository.getInstance().addArtifactInstance(attr2); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error thrown while attempting to add file attribute from single datasource the second time " + ex.getMessage()); } @@ -726,8 +726,8 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance attr = new CorrelationAttributeInstance(emailType, emailValue, case1, dataSource1fromCase1, emailPath, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addArtifactInstance(attr); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + CentralRepository.getInstance().addArtifactInstance(attr); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error thrown while attempting to add email attribute from single datasource " + ex.getMessage()); } @@ -735,28 +735,28 @@ public class CentralRepoDatamodelTest extends TestCase { // Test adding a phone artifact try { CorrelationAttributeInstance attr = new CorrelationAttributeInstance( - EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.PHONE_TYPE_ID), + CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.PHONE_TYPE_ID), phoneValue, case1, dataSource1fromCase1, phonePath, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addArtifactInstance(attr); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + CentralRepository.getInstance().addArtifactInstance(attr); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error thrown while attempting to add phone attribute from single datasource " + ex.getMessage()); } // Test adding a domain artifact try { - CorrelationAttributeInstance.Type type = EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.DOMAIN_TYPE_ID); + CorrelationAttributeInstance.Type type = CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.DOMAIN_TYPE_ID); assertEquals("Unexpected Correlation Type retrieved for Domain type id", CorrelationAttributeInstance.DOMAIN_TYPE_ID, type.getId()); CorrelationAttributeInstance attr = new CorrelationAttributeInstance( type, domainValue, case1, dataSource1fromCase1, domainPath, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addArtifactInstance(attr); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + CentralRepository.getInstance().addArtifactInstance(attr); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error thrown while attempting to add domain attribute from single datasource " + ex.getMessage()); } @@ -764,13 +764,13 @@ public class CentralRepoDatamodelTest extends TestCase { // Test adding a device ID artifact try { CorrelationAttributeInstance attr = new CorrelationAttributeInstance( - EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.USBID_TYPE_ID), + CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.USBID_TYPE_ID), devIdValue, case1, dataSource1fromCase1, devIdPath, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addArtifactInstance(attr); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + CentralRepository.getInstance().addArtifactInstance(attr); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error thrown while attempting to add device ID attribute from single datasource " + ex.getMessage()); } @@ -779,7 +779,7 @@ public class CentralRepoDatamodelTest extends TestCase { try { new CorrelationAttributeInstance(fileType, randomHash(), null, null, FILE_PATH, null, TskData.FileKnown.UNKNOWN, 0L); - } catch (CorrelationAttributeNormalizationException | EamDbException ex) { + } catch (CorrelationAttributeNormalizationException | CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error Creating correlation attribute instance " + ex.getMessage()); } @@ -788,9 +788,9 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance failAttrInst = new CorrelationAttributeInstance(fileType, "badInstances", null, dataSource1fromCase2, BAD_PATH, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addArtifactInstance(failAttrInst); + CentralRepository.getInstance().addArtifactInstance(failAttrInst); fail("Error CorrelationAttributeNormalizationException was expected to be thrown making and adding a CorrelationAttributeInstance with null case and was not"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { fail("Error CorrelationAttributeNormalizationException was expected to be thrown making and adding a CorrelationAttributeInstance with null case, EamDbException was thrown instead " + ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { // This is the expected behavior @@ -801,9 +801,9 @@ public class CentralRepoDatamodelTest extends TestCase { CorrelationCase badCase = new CorrelationCase("badCaseUuid", "badCaseName"); CorrelationAttributeInstance failAttrInst2 = new CorrelationAttributeInstance(fileType, randomHash(), badCase, dataSource1fromCase2, BAD_PATH, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addArtifactInstance(failAttrInst2); + CentralRepository.getInstance().addArtifactInstance(failAttrInst2); fail("Error EamDbException was expected to be thrown making and adding a CorrelationAttributeInstance with invalid case ID and was not"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior } catch (CorrelationAttributeNormalizationException ex) { fail("Error EamDbException was expected to be thrown making and adding a CorrelationAttributeInstance with invalid case ID, CorrelationAttributeNormalizationException was thrown instead " + ex.getMessage()); @@ -813,9 +813,9 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance failAttrInst3 = new CorrelationAttributeInstance(fileType, randomHash(), case1, null, BAD_PATH, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addArtifactInstance(failAttrInst3); + CentralRepository.getInstance().addArtifactInstance(failAttrInst3); fail("Error EamDbException was expected to be thrown making and adding a CorrelationAttributeInstance with null data source and was not"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior } catch (CorrelationAttributeNormalizationException ex) { fail("Error EamDbException was expected to be thrown making and adding a CorrelationAttributeInstance with null data source, CorrelationAttributeNormalizationException was thrown instead " + ex.getMessage()); @@ -827,9 +827,9 @@ public class CentralRepoDatamodelTest extends TestCase { 0L, null, null, null); CorrelationAttributeInstance failAttrInst4 = new CorrelationAttributeInstance(fileType, randomHash(), case1, badDS, BAD_PATH, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addArtifactInstance(failAttrInst4); + CentralRepository.getInstance().addArtifactInstance(failAttrInst4); fail("Error EamDbException was expected to be thrown making and adding a CorrelationAttributeInstance with invalid data source ID and was not"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior } catch (CorrelationAttributeNormalizationException ex) { fail("Error EamDbException was expected to be thrown making and adding a CorrelationAttributeInstance with invalid data source ID, CorrelationAttributeNormalizationException was thrown instead " + ex.getMessage()); @@ -841,7 +841,7 @@ public class CentralRepoDatamodelTest extends TestCase { new CorrelationAttributeInstance(fileType, randomHash(), case1, dataSource1fromCase1, null, null, TskData.FileKnown.UNKNOWN, 0L); fail("Error EamDbException was expected to be thrown making a CorrelationAttributeInstance with null path and was not"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior } catch (CorrelationAttributeNormalizationException ex) { fail("Error EamDbException was expected to be thrown making a CorrelationAttributeInstance with null path, CorrelationAttributeNormalizationException was thrown instead " + ex.getMessage()); @@ -851,9 +851,9 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance failAttrInst5 = new CorrelationAttributeInstance(fileType, "badInstances", case1, dataSource1fromCase1, null, "comment", null, 0L); - EamDb.getInstance().addArtifactInstance(failAttrInst5); + CentralRepository.getInstance().addArtifactInstance(failAttrInst5); fail("Error EamDbException was expected to be thrown making and adding a CorrelationAttributeInstance with null known status and was not"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior } catch (CorrelationAttributeNormalizationException ex) { fail("Error EamDbException was expected to be thrown making and adding a CorrelationAttributeInstance with null known status, CorrelationAttributeNormalizationException was thrown instead " + ex.getMessage()); @@ -864,9 +864,9 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance attr = new CorrelationAttributeInstance(null, randomHash(), null, null, FILE_PATH, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().addArtifactInstance(attr); + CentralRepository.getInstance().addArtifactInstance(attr); fail("Error CorrelationAttributeNormalizationException was expected to be thrown making and adding a CorrelationAttributeInstance with null type and was not"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail("Error CorrelationAttributeNormalizationException was expected to be thrown making and adding a CorrelationAttributeInstance with null type, EamDbException was thrown instead " + ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -881,13 +881,13 @@ public class CentralRepoDatamodelTest extends TestCase { fail("Error CorrelationAttributeNormalizationException was expected to be thrown making a CorrelationAttributeInstance with null type and was not"); } catch (CorrelationAttributeNormalizationException ex) { // This is the expected behavior - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { fail("Error CorrelationAttributeNormalizationException was expected to be thrown making a CorrelationAttributeInstance with null type, EamDbException was thrown instead " + ex.getMessage()); } // Test getting instances with expected results try { - List instances = EamDb.getInstance().getArtifactInstancesByTypeValue(fileType, inAllDataSourcesHash); + List instances = CentralRepository.getInstance().getArtifactInstancesByTypeValue(fileType, inAllDataSourcesHash); assertEquals("Unexpected number of fileType instances gotten by type value for hash that should be in all 3 data sources", 3, instances.size()); // This test works because all the instances of this hash were set to the same path @@ -895,16 +895,16 @@ public class CentralRepoDatamodelTest extends TestCase { assertTrue("getArtifactInstancesByTypeValue returned file instance with unexpected path " + inst.getFilePath() + " expected " + inAllDataSourcesPath, inAllDataSourcesPath.equalsIgnoreCase(inst.getFilePath())); } - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error exception thrown while getting attributes by type value " + ex.getMessage()); } // Test getting instances with mismatched data / data-type and expect an exception try { - EamDb.getInstance().getArtifactInstancesByTypeValue(emailType, inAllDataSourcesHash); + CentralRepository.getInstance().getArtifactInstancesByTypeValue(emailType, inAllDataSourcesHash); fail("Error CorrelationAttributeNormalizationException was expected to be thrown attempting to get email type attributes with a hash value"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail("Error CorrelationAttributeNormalizationException was expected to be thrown attempting to get email type attributes with a hash value, EamDbException was thrown instead " + ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -913,9 +913,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test getting instances with null type try { - EamDb.getInstance().getArtifactInstancesByTypeValue(null, inAllDataSourcesHash); + CentralRepository.getInstance().getArtifactInstancesByTypeValue(null, inAllDataSourcesHash); fail("Error CorrelationAttributeNormalizationException was expected to be thrown attempting to get null type attributes with a hash value"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail("Error CorrelationAttributeNormalizationException was expected to be thrown attempting to get null type attributes with a hash value, EamDbException was thrown instead " + ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -924,9 +924,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test getting instances with null value try { - EamDb.getInstance().getArtifactInstancesByTypeValue(fileType, null); + CentralRepository.getInstance().getArtifactInstancesByTypeValue(fileType, null); fail("Error CorrelationAttributeNormalizationException was expected to be thrown attempting to get file type attributes with a null value"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail("Error CorrelationAttributeNormalizationException was expected to be thrown attempting to get file type attributes with a null value, EamDbException was thrown instead " + ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -935,27 +935,27 @@ public class CentralRepoDatamodelTest extends TestCase { // Test getting instance count with path that should produce results try { - long count = EamDb.getInstance().getCountArtifactInstancesByTypeValue(fileType, inAllDataSourcesHash); + long count = CentralRepository.getInstance().getCountArtifactInstancesByTypeValue(fileType, inAllDataSourcesHash); assertEquals("Unexpected number of fileType instances retrieved when getting count of file type value for hash that should be in all 3 data sources", 3, count); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error Exception thrown while getting count of file type value for hash that should exist" + ex.getMessage()); } // Test getting instance count with path that should not produce results try { - long count = EamDb.getInstance().getCountArtifactInstancesByTypeValue(fileType, unusedHashValue); + long count = CentralRepository.getInstance().getCountArtifactInstancesByTypeValue(fileType, unusedHashValue); assertEquals("Unexpected number of fileType instances retrieved when getting count of file type value for hash that should not be in any data sources", 0, count); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error Exception thrown while getting count of file type value for hash that should not exist" + ex.getMessage()); } // Test getting instance count with null type try { - EamDb.getInstance().getCountArtifactInstancesByTypeValue(null, inAllDataSourcesHash); + CentralRepository.getInstance().getCountArtifactInstancesByTypeValue(null, inAllDataSourcesHash); fail("Error CorrelationAttributeNormalizationException was expected to be thrown attempting to get count of null type attributes with a hash value"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail("Error CorrelationAttributeNormalizationException was expected to be thrown attempting to get count of null type attributes with a hash value, EamDbException was thrown instead " + ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -964,9 +964,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test getting instance count with null value try { - EamDb.getInstance().getCountArtifactInstancesByTypeValue(fileType, null); + CentralRepository.getInstance().getCountArtifactInstancesByTypeValue(fileType, null); fail("Error CorrelationAttributeNormalizationException was expected to be thrown attempting to get count of file type attributes with a null hash value"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail("Error CorrelationAttributeNormalizationException was expected to be thrown attempting to get count of null type attributes with a null hash value, EamDbException was thrown instead " + ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -977,9 +977,9 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance attr = new CorrelationAttributeInstance(fileType, inAllDataSourcesHash, null, null, FILE_PATH, null, TskData.FileKnown.UNKNOWN, 0L); - int freq = EamDb.getInstance().getFrequencyPercentage(attr); + int freq = CentralRepository.getInstance().getFrequencyPercentage(attr); assertEquals("Unexpected frequency value of file type returned for value that should exist in all data sources", 100, freq); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error Exception thrown while getting frequency of file type value for hash that should exist in all data sources" + ex.getMessage()); } @@ -988,9 +988,9 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance attr = new CorrelationAttributeInstance(fileType, inDataSource1twiceHash, null, null, FILE_PATH, null, TskData.FileKnown.UNKNOWN, 0L); - int freq = EamDb.getInstance().getFrequencyPercentage(attr); + int freq = CentralRepository.getInstance().getFrequencyPercentage(attr); assertEquals("Unexpected frequency value of file type returned for value that should exist in one of three data sources", 33, freq); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error Exception thrown while getting frequency of file type value for hash that should exist in one of three data sources" + ex.getMessage()); } @@ -999,9 +999,9 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance attr = new CorrelationAttributeInstance(emailType, emailValue, null, null, FILE_PATH, null, TskData.FileKnown.UNKNOWN, 0L); - int freq = EamDb.getInstance().getFrequencyPercentage(attr); + int freq = CentralRepository.getInstance().getFrequencyPercentage(attr); assertEquals("Unexpected frequency value of email type returned for value that should exist in one of three data sources", 33, freq); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error Exception thrown while getting frequency of eamil type value for value that should exist in one of three data sources" + ex.getMessage()); } @@ -1010,9 +1010,9 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance attr = new CorrelationAttributeInstance(fileType, unusedHashValue, null, null, FILE_PATH, null, TskData.FileKnown.UNKNOWN, 0L); - int freq = EamDb.getInstance().getFrequencyPercentage(attr); + int freq = CentralRepository.getInstance().getFrequencyPercentage(attr); assertEquals("Unexpected frequency value of file type returned for value that should not exist in any data sources", 0, freq); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error Exception thrown while getting frequency of eamil type value for value that should not exist in any data sources" + ex.getMessage()); } @@ -1021,17 +1021,17 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance attr = new CorrelationAttributeInstance(null, "randomValue", null, null, FILE_PATH, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb.getInstance().getFrequencyPercentage(attr); + CentralRepository.getInstance().getFrequencyPercentage(attr); fail("Error Exception was expected to be thrown when getting frequency of null type attribute"); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { // This is the expected behavior } // Test getting frequency with null attribute try { - EamDb.getInstance().getFrequencyPercentage(null); + CentralRepository.getInstance().getFrequencyPercentage(null); fail("Error EamDbException was expected to be thrown when getting frequency of null attribute"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior } catch (CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); @@ -1043,64 +1043,64 @@ public class CentralRepoDatamodelTest extends TestCase { try { String comment = "new comment"; - CorrelationAttributeInstance correlationAttribute = EamDb.getInstance().getCorrelationAttributeInstance( + CorrelationAttributeInstance correlationAttribute = CentralRepository.getInstance().getCorrelationAttributeInstance( usbDeviceType, case1, dataSource1fromCase1, devIdValue, devIdPath); assertNotNull("Correlation Attribute returned was null when it should not have been", correlationAttribute); correlationAttribute.setComment(comment); - EamDb.getInstance().updateAttributeInstanceComment(correlationAttribute); + CentralRepository.getInstance().updateAttributeInstanceComment(correlationAttribute); // Get a fresh copy to verify the update. - correlationAttribute = EamDb.getInstance().getCorrelationAttributeInstance( + correlationAttribute = CentralRepository.getInstance().getCorrelationAttributeInstance( usbDeviceType, case1, dataSource1fromCase1, devIdValue, devIdPath); assertEquals("Comment was not successfully set to expected value", comment, correlationAttribute.getComment()); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error Exception thrown when setting and getting comment for attribute " + ex.getMessage()); } // Test getting count for dataSource1fromCase1 (includes all types) try { - long count = EamDb.getInstance().getCountArtifactInstancesByCaseDataSource(dataSource1fromCase1); + long count = CentralRepository.getInstance().getCountArtifactInstancesByCaseDataSource(dataSource1fromCase1); assertEquals("Unexpected count of artifact instances retrieved when getting count for case 1, data source 1", 7, count); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error EamDbException thrown when getting count of artifact instances for case 1, data source 1" + ex.getMessage()); } // Test getting data source count for entry that is in all three try { - long count = EamDb.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(fileType, inAllDataSourcesHash); + long count = CentralRepository.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(fileType, inAllDataSourcesHash); assertEquals("Unexpected count of data sources retrieved when getting count for file types with a hash that should exist in all three data sources", 3, count); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error Exception thrown when getting count of data sources for file types with a hash that should exist in all three data sources" + ex.getMessage()); } // Test getting data source count for entry that is in one data source twice try { - long count = EamDb.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(fileType, inDataSource1twiceHash); + long count = CentralRepository.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(fileType, inDataSource1twiceHash); assertEquals("Unexpected count of data sources retrieved when getting count for file types with a hash that should exist in a single data source twice", 1, count); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error Exception thrown when getting count of data sources for file types with a hash that should exist in a single data source twice" + ex.getMessage()); } // Test getting data source count for entry that is not in any data sources try { - long count = EamDb.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(fileType, unusedHashValue); + long count = CentralRepository.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(fileType, unusedHashValue); assertEquals("Unexpected count of data sources retrieved when getting count for file types with a hash that should not exist in any data source", 0, count); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error Exception thrown when getting count of data sources for file types with a hash that should not exist in any data source" + ex.getMessage()); } // Test getting data source count for null type try { - EamDb.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(null, unusedHashValue); + CentralRepository.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(null, unusedHashValue); fail("Error CorrelationAttributeNormalizationException was expected to be thrown when getting number of datasources containing null type attribute"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail("Error CorrelationAttributeNormalizationException was expected to be thrown when getting number of datasources containing null type attribute, EamDbException was thrown instead " + ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -1109,9 +1109,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test getting data source count for null value try { - EamDb.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(fileType, null); + CentralRepository.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(fileType, null); fail("Error CorrelationAttributeNormalizationException was expected to be thrown when getting number of datasources containing file type attribute with null hash"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail("Error CorrelationAttributeNormalizationException was expected to be thrown when getting number of datasources containing file type attribute with null hash, EamDbException was thrown instead " + ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -1125,7 +1125,7 @@ public class CentralRepoDatamodelTest extends TestCase { null, TskData.FileKnown.UNKNOWN, 0L); CorrelationAttributeInstance attr2 = new CorrelationAttributeInstance(fileType, callbackTestFileHash, case1, dataSource1fromCase1, callbackTestFilePath2, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb DbManager = EamDb.getInstance(); + CentralRepository DbManager = CentralRepository.getInstance(); DbManager.addArtifactInstance(attr1); DbManager.addArtifactInstance(attr2); AttributeInstanceTableCallback instancetableCallback = new AttributeInstanceTableCallback(); @@ -1136,16 +1136,16 @@ public class CentralRepoDatamodelTest extends TestCase { //if the test code is changed to add additional Correlation Attributes which also have "processinstancecallback" in their path the first of these comparisons will need to change assertEquals("Counter for items matching naming convention from AttributeInstaceTableCallback indicates an unexepected number of results when processed with DbManager.processInstanceTable", 2, count2); assertTrue("Counter for items which do not match naming convention from AttributeInstaceTableCallback indicates an unexepected number of results when processed with DbManager.processInstanceTable. Count indicated: " + count1 + " - expected a number greater than 0", count1 > 0); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error Exception thrown when calling processInstanceTable " + ex.getMessage()); } try { //test null inputs - EamDb.getInstance().processInstanceTable(null, null); + CentralRepository.getInstance().processInstanceTable(null, null); fail("Error EamDbException was expected to be thrown when calling processInstanceTable with null inputs"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior } @@ -1156,7 +1156,7 @@ public class CentralRepoDatamodelTest extends TestCase { null, TskData.FileKnown.UNKNOWN, 0L); CorrelationAttributeInstance attr2 = new CorrelationAttributeInstance(fileType, callbackTestFileHash, case1, dataSource1fromCase1, callbackTestFilePath2, null, TskData.FileKnown.UNKNOWN, 0L); - EamDb DbManager = EamDb.getInstance(); + CentralRepository DbManager = CentralRepository.getInstance(); //these redundant addArtifactInstance calls allow code to be rearranged if necessary DbManager.addArtifactInstance(attr1); DbManager.addArtifactInstance(attr2); @@ -1169,15 +1169,15 @@ public class CentralRepoDatamodelTest extends TestCase { //if the test code is changed to add additional Correlation Attributes with the same callbackTestFileHash value that is used here these comparisons will need to change assertEquals("Counter for items matching naming convention from AttributeInstaceTableCallback indicates an unexepected number of results when processed with DbManager.processInstanceTableWhere", 2, count2); assertEquals("Counter for items which do not match naming convention from AttributeInstaceTableCallback indicates an unexepected number of results when processed with DbManager.processInstanceTableWhere", 0, count1); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail("Error Exception thrown when calling processInstanceTableWhere " + ex.getMessage()); } try { //test null inputs - EamDb.getInstance().processInstanceTableWhere(null, null, null); + CentralRepository.getInstance().processInstanceTableWhere(null, null, null); fail("Error EamDbException was expected to be thrown when calling processInstanceTableWhere with null inputs"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior } } @@ -1205,8 +1205,8 @@ public class CentralRepoDatamodelTest extends TestCase { // Test new type with valid data try { customType = new CorrelationAttributeInstance.Type(customTypeName, customTypeDb, false, false); - customType.setId(EamDb.getInstance().newCorrelationType(customType)); - } catch (EamDbException ex) { + customType.setId(CentralRepository.getInstance().newCorrelationType(customType)); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); return; @@ -1215,9 +1215,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test new type with duplicate data try { CorrelationAttributeInstance.Type temp = new CorrelationAttributeInstance.Type(customTypeName, customTypeDb, false, false); - EamDb.getInstance().newCorrelationType(temp); + CentralRepository.getInstance().newCorrelationType(temp); fail("newCorrelationType failed to throw exception for duplicate name/db table"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -1225,9 +1225,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test new type with null name try { CorrelationAttributeInstance.Type temp = new CorrelationAttributeInstance.Type(null, "temp_type", false, false); - EamDb.getInstance().newCorrelationType(temp); + CentralRepository.getInstance().newCorrelationType(temp); fail("newCorrelationType failed to throw exception for null name table"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -1237,68 +1237,68 @@ public class CentralRepoDatamodelTest extends TestCase { try { new CorrelationAttributeInstance.Type("temp", null, false, false); Assert.fail("CorrelationAttributeInstance.Type failed to throw exception for null db table name"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test new type with null type try { - EamDb.getInstance().newCorrelationType(null); + CentralRepository.getInstance().newCorrelationType(null); fail("newCorrelationType failed to throw exception for null type"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test getting all correlation types try { - List types = EamDb.getInstance().getDefinedCorrelationTypes(); + List types = CentralRepository.getInstance().getDefinedCorrelationTypes(); // We expect 11 total - 10 default and the custom one made earlier assertTrue("getDefinedCorrelationTypes returned " + types.size() + " entries - expected 11", types.size() == 11); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting enabled correlation types try { - List types = EamDb.getInstance().getEnabledCorrelationTypes(); + List types = CentralRepository.getInstance().getEnabledCorrelationTypes(); // We expect 10 - the custom type is disabled assertTrue("getDefinedCorrelationTypes returned " + types.size() + " enabled entries - expected 10", types.size() == 10); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting supported correlation types try { - List types = EamDb.getInstance().getSupportedCorrelationTypes(); + List types = CentralRepository.getInstance().getSupportedCorrelationTypes(); // We expect 10 - the custom type is not supported assertTrue("getDefinedCorrelationTypes returned " + types.size() + " supported entries - expected 10", types.size() == 10); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting the type with a valid ID try { - CorrelationAttributeInstance.Type temp = EamDb.getInstance().getCorrelationTypeById(customType.getId()); + CorrelationAttributeInstance.Type temp = CentralRepository.getInstance().getCorrelationTypeById(customType.getId()); assertTrue("getCorrelationTypeById returned type with unexpected name " + temp.getDisplayName(), customTypeName.equals(temp.getDisplayName())); assertTrue("getCorrelationTypeById returned type with unexpected db table name " + temp.getDbTableName(), customTypeDb.equals(temp.getDbTableName())); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting the type with a invalid ID try { - EamDb.getInstance().getCorrelationTypeById(5555); + CentralRepository.getInstance().getCorrelationTypeById(5555); fail("getCorrelationTypeById failed to throw exception for invalid ID"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -1312,16 +1312,16 @@ public class CentralRepoDatamodelTest extends TestCase { customType.setEnabled(true); // These were originally false customType.setSupported(true); - EamDb.getInstance().updateCorrelationType(customType); + CentralRepository.getInstance().updateCorrelationType(customType); // Get a fresh copy from the database - CorrelationAttributeInstance.Type temp = EamDb.getInstance().getCorrelationTypeById(customType.getId()); + CorrelationAttributeInstance.Type temp = CentralRepository.getInstance().getCorrelationTypeById(customType.getId()); assertTrue("updateCorrelationType failed to update name", newName.equals(temp.getDisplayName())); assertTrue("updateCorrelationType failed to update db table name", newDbTable.equals(temp.getDbTableName())); assertTrue("updateCorrelationType failed to update enabled status", temp.isEnabled()); assertTrue("updateCorrelationType failed to update supported status", temp.isSupported()); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -1331,8 +1331,8 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationAttributeInstance.Type temp = new CorrelationAttributeInstance.Type(customTypeName, customTypeDb, false, false); temp.setId(12345); - EamDb.getInstance().updateCorrelationType(temp); - } catch (EamDbException ex) { + CentralRepository.getInstance().updateCorrelationType(temp); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -1340,9 +1340,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test updating a type to a null name try { customType.setDisplayName(null); - EamDb.getInstance().updateCorrelationType(customType); + CentralRepository.getInstance().updateCorrelationType(customType); fail("updateCorrelationType failed to throw exception for null name"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -1350,9 +1350,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test updating a null type try { customType.setDisplayName(null); - EamDb.getInstance().updateCorrelationType(customType); + CentralRepository.getInstance().updateCorrelationType(customType); fail("updateCorrelationType failed to throw exception for null type"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -1373,9 +1373,9 @@ public class CentralRepoDatamodelTest extends TestCase { */ public void testOrganizations() { - EamOrganization orgA; + CentralRepoOrganization orgA; String orgAname = "orgA"; - EamOrganization orgB; + CentralRepoOrganization orgB; String orgBname = "orgB"; String orgBpocName = "pocName"; String orgBpocEmail = "pocEmail"; @@ -1383,10 +1383,10 @@ public class CentralRepoDatamodelTest extends TestCase { // Test adding a basic organization try { - orgA = new EamOrganization(orgAname); - orgA = EamDb.getInstance().newOrganization(orgA); + orgA = new CentralRepoOrganization(orgAname); + orgA = CentralRepository.getInstance().newOrganization(orgA); assertTrue("Organization ID is still -1 after adding to db", orgA.getOrgID() != -1); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); return; @@ -1394,10 +1394,10 @@ public class CentralRepoDatamodelTest extends TestCase { // Test adding an organization with additional fields try { - orgB = new EamOrganization(orgBname, orgBpocName, orgBpocEmail, orgBpocPhone); - orgB = EamDb.getInstance().newOrganization(orgB); + orgB = new CentralRepoOrganization(orgBname, orgBpocName, orgBpocEmail, orgBpocPhone); + orgB = CentralRepository.getInstance().newOrganization(orgB); assertTrue("Organization ID is still -1 after adding to db", orgB.getOrgID() != -1); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); return; @@ -1405,29 +1405,29 @@ public class CentralRepoDatamodelTest extends TestCase { // Test adding a duplicate organization try { - EamOrganization temp = new EamOrganization(orgAname); - EamDb.getInstance().newOrganization(temp); + CentralRepoOrganization temp = new CentralRepoOrganization(orgAname); + CentralRepository.getInstance().newOrganization(temp); fail("newOrganization failed to throw exception for duplicate org name"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test adding null organization try { - EamDb.getInstance().newOrganization(null); + CentralRepository.getInstance().newOrganization(null); fail("newOrganization failed to throw exception for null org"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test adding organization with null name try { - EamOrganization temp = new EamOrganization(null); - EamDb.getInstance().newOrganization(temp); + CentralRepoOrganization temp = new CentralRepoOrganization(null); + CentralRepository.getInstance().newOrganization(temp); fail("newOrganization failed to throw exception for null name"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -1435,32 +1435,32 @@ public class CentralRepoDatamodelTest extends TestCase { // Test getting organizations // We expect five - the default org, two from setUp, and two from this method try { - List orgs = EamDb.getInstance().getOrganizations(); + List orgs = CentralRepository.getInstance().getOrganizations(); assertTrue("getOrganizations returned null list", orgs != null); assertTrue("getOrganizations returned " + orgs.size() + " orgs - expected 5", orgs.size() == 5); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting org with valid ID try { - EamOrganization temp = EamDb.getInstance().getOrganizationByID(orgB.getOrgID()); + CentralRepoOrganization temp = CentralRepository.getInstance().getOrganizationByID(orgB.getOrgID()); assertTrue("getOrganizationByID returned null for valid ID", temp != null); assertTrue("getOrganizationByID returned unexpected name for organization", orgBname.equals(temp.getName())); assertTrue("getOrganizationByID returned unexpected poc name for organization", orgBpocName.equals(temp.getPocName())); assertTrue("getOrganizationByID returned unexpected poc email for organization", orgBpocEmail.equals(temp.getPocEmail())); assertTrue("getOrganizationByID returned unexpected poc phone for organization", orgBpocPhone.equals(temp.getPocPhone())); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting org with invalid ID try { - EamDb.getInstance().getOrganizationByID(12345); + CentralRepository.getInstance().getOrganizationByID(12345); fail("getOrganizationByID failed to throw exception for invalid ID"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -1476,59 +1476,59 @@ public class CentralRepoDatamodelTest extends TestCase { orgA.setPocEmail(newPocEmail); orgA.setPocPhone(newPocPhone); - EamDb.getInstance().updateOrganization(orgA); + CentralRepository.getInstance().updateOrganization(orgA); - EamOrganization copyOfA = EamDb.getInstance().getOrganizationByID(orgA.getOrgID()); + CentralRepoOrganization copyOfA = CentralRepository.getInstance().getOrganizationByID(orgA.getOrgID()); assertTrue("getOrganizationByID returned null for valid ID", copyOfA != null); assertTrue("updateOrganization failed to update org name", newName.equals(copyOfA.getName())); assertTrue("updateOrganization failed to update poc name", newPocName.equals(copyOfA.getPocName())); assertTrue("updateOrganization failed to update poc email", newPocEmail.equals(copyOfA.getPocEmail())); assertTrue("updateOrganization failed to update poc phone", newPocPhone.equals(copyOfA.getPocPhone())); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test updating invalid org try { - EamOrganization temp = new EamOrganization("invalidOrg"); - EamDb.getInstance().updateOrganization(temp); + CentralRepoOrganization temp = new CentralRepoOrganization("invalidOrg"); + CentralRepository.getInstance().updateOrganization(temp); fail("updateOrganization worked for invalid ID"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // this is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test updating null org try { - EamDb.getInstance().updateOrganization(null); + CentralRepository.getInstance().updateOrganization(null); fail("updateOrganization failed to throw exception for null org"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test updating org to null name try { - EamOrganization copyOfA = EamDb.getInstance().getOrganizationByID(orgA.getOrgID()); + CentralRepoOrganization copyOfA = CentralRepository.getInstance().getOrganizationByID(orgA.getOrgID()); copyOfA.setName(null); - EamDb.getInstance().updateOrganization(copyOfA); + CentralRepository.getInstance().updateOrganization(copyOfA); fail("updateOrganization failed to throw exception for null name"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test deleting existing org that isn't in use try { - EamOrganization orgToDelete = new EamOrganization("deleteThis"); - orgToDelete = EamDb.getInstance().newOrganization(orgToDelete); - int orgCount = EamDb.getInstance().getOrganizations().size(); + CentralRepoOrganization orgToDelete = new CentralRepoOrganization("deleteThis"); + orgToDelete = CentralRepository.getInstance().newOrganization(orgToDelete); + int orgCount = CentralRepository.getInstance().getOrganizations().size(); - EamDb.getInstance().deleteOrganization(orgToDelete); - assertTrue("getOrganizations returned unexpected count after deletion", orgCount - 1 == EamDb.getInstance().getOrganizations().size()); - } catch (EamDbException ex) { + CentralRepository.getInstance().deleteOrganization(orgToDelete); + assertTrue("getOrganizations returned unexpected count after deletion", orgCount - 1 == CentralRepository.getInstance().getOrganizations().size()); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -1536,36 +1536,36 @@ public class CentralRepoDatamodelTest extends TestCase { // Test deleting existing org that is in use try { // Make a new org - EamOrganization inUseOrg = new EamOrganization("inUseOrg"); - inUseOrg = EamDb.getInstance().newOrganization(inUseOrg); + CentralRepoOrganization inUseOrg = new CentralRepoOrganization("inUseOrg"); + inUseOrg = CentralRepository.getInstance().newOrganization(inUseOrg); // Make a reference set that uses it - EamGlobalSet tempSet = new EamGlobalSet(inUseOrg.getOrgID(), "inUseOrgTest", "1.0", TskData.FileKnown.BAD, false, fileType); - EamDb.getInstance().newReferenceSet(tempSet); + CentralRepoFileSet tempSet = new CentralRepoFileSet(inUseOrg.getOrgID(), "inUseOrgTest", "1.0", TskData.FileKnown.BAD, false, fileType); + CentralRepository.getInstance().newReferenceSet(tempSet); // It should now throw an exception if we try to delete it - EamDb.getInstance().deleteOrganization(inUseOrg); + CentralRepository.getInstance().deleteOrganization(inUseOrg); fail("deleteOrganization failed to throw exception for in use organization"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test deleting non-existent org try { - EamOrganization temp = new EamOrganization("temp"); - EamDb.getInstance().deleteOrganization(temp); + CentralRepoOrganization temp = new CentralRepoOrganization("temp"); + CentralRepository.getInstance().deleteOrganization(temp); fail("deleteOrganization failed to throw exception for non-existent organization"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test deleting null org try { - EamDb.getInstance().deleteOrganization(null); + CentralRepository.getInstance().deleteOrganization(null); fail("deleteOrganization failed to throw exception for null organization"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -1601,11 +1601,11 @@ public class CentralRepoDatamodelTest extends TestCase { // notableSet1 - notableHash1, inAllSetsHash // notableSet2 - inAllSetsHash // knownSet1 - knownHash1, inAllSetsHash - EamGlobalSet notableSet1; + CentralRepoFileSet notableSet1; int notableSet1id; - EamGlobalSet notableSet2; + CentralRepoFileSet notableSet2; int notableSet2id; - EamGlobalSet knownSet1; + CentralRepoFileSet knownSet1; int knownSet1id; String notableHash1 = "d46feecd663c41648dbf690d9343cf4b"; @@ -1616,9 +1616,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Store the email type object for later use try { - emailType = EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.EMAIL_TYPE_ID); + emailType = CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.EMAIL_TYPE_ID); assertTrue("getCorrelationTypeById(EMAIL_TYPE_ID) returned null", emailType != null); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); return; @@ -1626,13 +1626,13 @@ public class CentralRepoDatamodelTest extends TestCase { // Set up a few reference sets try { - notableSet1 = new EamGlobalSet(org1.getOrgID(), "notable set 1", "1.0", TskData.FileKnown.BAD, false, fileType); - notableSet1id = EamDb.getInstance().newReferenceSet(notableSet1); - notableSet2 = new EamGlobalSet(org1.getOrgID(), "notable set 2", "2.4", TskData.FileKnown.BAD, false, fileType); - notableSet2id = EamDb.getInstance().newReferenceSet(notableSet2); - knownSet1 = new EamGlobalSet(org1.getOrgID(), "known set 1", "5.5.4", TskData.FileKnown.KNOWN, false, fileType); - knownSet1id = EamDb.getInstance().newReferenceSet(knownSet1); - } catch (EamDbException ex) { + notableSet1 = new CentralRepoFileSet(org1.getOrgID(), "notable set 1", "1.0", TskData.FileKnown.BAD, false, fileType); + notableSet1id = CentralRepository.getInstance().newReferenceSet(notableSet1); + notableSet2 = new CentralRepoFileSet(org1.getOrgID(), "notable set 2", "2.4", TskData.FileKnown.BAD, false, fileType); + notableSet2id = CentralRepository.getInstance().newReferenceSet(notableSet2); + knownSet1 = new CentralRepoFileSet(org1.getOrgID(), "known set 1", "5.5.4", TskData.FileKnown.KNOWN, false, fileType); + knownSet1id = CentralRepository.getInstance().newReferenceSet(knownSet1); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); return; @@ -1640,31 +1640,31 @@ public class CentralRepoDatamodelTest extends TestCase { // Test adding file instances with valid data try { - EamGlobalFileInstance temp = new EamGlobalFileInstance(notableSet1id, inAllSetsHash, TskData.FileKnown.BAD, "comment1"); - EamDb.getInstance().addReferenceInstance(temp, fileType); + CentralRepoFileInstance temp = new CentralRepoFileInstance(notableSet1id, inAllSetsHash, TskData.FileKnown.BAD, "comment1"); + CentralRepository.getInstance().addReferenceInstance(temp, fileType); - temp = new EamGlobalFileInstance(notableSet2id, inAllSetsHash, TskData.FileKnown.BAD, "comment2"); - EamDb.getInstance().addReferenceInstance(temp, fileType); + temp = new CentralRepoFileInstance(notableSet2id, inAllSetsHash, TskData.FileKnown.BAD, "comment2"); + CentralRepository.getInstance().addReferenceInstance(temp, fileType); - temp = new EamGlobalFileInstance(knownSet1id, inAllSetsHash, TskData.FileKnown.KNOWN, "comment3"); - EamDb.getInstance().addReferenceInstance(temp, fileType); + temp = new CentralRepoFileInstance(knownSet1id, inAllSetsHash, TskData.FileKnown.KNOWN, "comment3"); + CentralRepository.getInstance().addReferenceInstance(temp, fileType); - temp = new EamGlobalFileInstance(notableSet1id, notableHash1, TskData.FileKnown.BAD, "comment4"); - EamDb.getInstance().addReferenceInstance(temp, fileType); + temp = new CentralRepoFileInstance(notableSet1id, notableHash1, TskData.FileKnown.BAD, "comment4"); + CentralRepository.getInstance().addReferenceInstance(temp, fileType); - temp = new EamGlobalFileInstance(knownSet1id, knownHash1, TskData.FileKnown.KNOWN, "comment5"); - EamDb.getInstance().addReferenceInstance(temp, fileType); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + temp = new CentralRepoFileInstance(knownSet1id, knownHash1, TskData.FileKnown.KNOWN, "comment5"); + CentralRepository.getInstance().addReferenceInstance(temp, fileType); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test adding file instance with invalid reference set ID try { - EamGlobalFileInstance temp = new EamGlobalFileInstance(2345, inAllSetsHash, TskData.FileKnown.BAD, "comment"); - EamDb.getInstance().addReferenceInstance(temp, fileType); + CentralRepoFileInstance temp = new CentralRepoFileInstance(2345, inAllSetsHash, TskData.FileKnown.BAD, "comment"); + CentralRepository.getInstance().addReferenceInstance(temp, fileType); fail("addReferenceInstance failed to throw exception for invalid ID"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } catch (CorrelationAttributeNormalizationException ex) { @@ -1676,9 +1676,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Since it isn't possible to get a null hash into the EamGlobalFileInstance, skip trying to // call addReferenceInstance and just test the EamGlobalFileInstance constructor try { - new EamGlobalFileInstance(notableSet1id, null, TskData.FileKnown.BAD, "comment"); + new CentralRepoFileInstance(notableSet1id, null, TskData.FileKnown.BAD, "comment"); fail("EamGlobalFileInstance failed to throw exception for null hash"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail(ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -1690,9 +1690,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Since it isn't possible to get a null known status into the EamGlobalFileInstance, skip trying to // call addReferenceInstance and just test the EamGlobalFileInstance constructor try { - new EamGlobalFileInstance(notableSet1id, inAllSetsHash, null, "comment"); + new CentralRepoFileInstance(notableSet1id, inAllSetsHash, null, "comment"); fail("EamGlobalFileInstance failed to throw exception for null type"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } catch (CorrelationAttributeNormalizationException ex) { @@ -1702,10 +1702,10 @@ public class CentralRepoDatamodelTest extends TestCase { // Test adding file instance with null correlation type try { - EamGlobalFileInstance temp = new EamGlobalFileInstance(notableSet1id, inAllSetsHash, TskData.FileKnown.BAD, "comment"); - EamDb.getInstance().addReferenceInstance(temp, null); + CentralRepoFileInstance temp = new CentralRepoFileInstance(notableSet1id, inAllSetsHash, TskData.FileKnown.BAD, "comment"); + CentralRepository.getInstance().addReferenceInstance(temp, null); fail("addReferenceInstance failed to throw exception for null type"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } catch (CorrelationAttributeNormalizationException ex) { @@ -1716,40 +1716,40 @@ public class CentralRepoDatamodelTest extends TestCase { // Test bulk insert with large valid set try { // Create a list of global file instances. Make enough that the bulk threshold should be hit once. - Set instances = new HashSet<>(); + Set instances = new HashSet<>(); for (int i = 0; i < DEFAULT_BULK_THRESHOLD * 1.5; i++) { String hash = randomHash(); - instances.add(new EamGlobalFileInstance(notableSet2id, hash, TskData.FileKnown.BAD, null)); + instances.add(new CentralRepoFileInstance(notableSet2id, hash, TskData.FileKnown.BAD, null)); } // Insert the list - EamDb.getInstance().bulkInsertReferenceTypeEntries(instances, fileType); + CentralRepository.getInstance().bulkInsertReferenceTypeEntries(instances, fileType); // There's no way to get a count of the number of entries in the database, so just do a spot check if (DEFAULT_BULK_THRESHOLD > 10) { String hash = instances.stream().findFirst().get().getMD5Hash(); - assertTrue("Sample bulk insert instance not found", EamDb.getInstance().isFileHashInReferenceSet(hash, notableSet2id)); + assertTrue("Sample bulk insert instance not found", CentralRepository.getInstance().isFileHashInReferenceSet(hash, notableSet2id)); } - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test bulk add file instance with null list try { - EamDb.getInstance().bulkInsertReferenceTypeEntries(null, fileType); + CentralRepository.getInstance().bulkInsertReferenceTypeEntries(null, fileType); fail("bulkInsertReferenceTypeEntries failed to throw exception for null list"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test bulk add file instance with invalid reference set ID try { - Set tempSet = new HashSet<>(Arrays.asList(new EamGlobalFileInstance(2345, inAllSetsHash, TskData.FileKnown.BAD, "comment"))); - EamDb.getInstance().bulkInsertReferenceTypeEntries(tempSet, fileType); + Set tempSet = new HashSet<>(Arrays.asList(new CentralRepoFileInstance(2345, inAllSetsHash, TskData.FileKnown.BAD, "comment"))); + CentralRepository.getInstance().bulkInsertReferenceTypeEntries(tempSet, fileType); fail("bulkInsertReferenceTypeEntries failed to throw exception for invalid ID"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior } catch (CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); @@ -1758,10 +1758,10 @@ public class CentralRepoDatamodelTest extends TestCase { // Test bulk add file instance with null correlation type try { - Set tempSet = new HashSet<>(Arrays.asList(new EamGlobalFileInstance(notableSet1id, inAllSetsHash, TskData.FileKnown.BAD, "comment"))); - EamDb.getInstance().bulkInsertReferenceTypeEntries(tempSet, null); + Set tempSet = new HashSet<>(Arrays.asList(new CentralRepoFileInstance(notableSet1id, inAllSetsHash, TskData.FileKnown.BAD, "comment"))); + CentralRepository.getInstance().bulkInsertReferenceTypeEntries(tempSet, null); fail("bulkInsertReferenceTypeEntries failed to throw exception for null type"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } catch (CorrelationAttributeNormalizationException ex) { @@ -1771,36 +1771,36 @@ public class CentralRepoDatamodelTest extends TestCase { // Test getting reference instances with valid data try { - List temp = EamDb.getInstance().getReferenceInstancesByTypeValue(fileType, inAllSetsHash); + List temp = CentralRepository.getInstance().getReferenceInstancesByTypeValue(fileType, inAllSetsHash); assertTrue("getReferenceInstancesByTypeValue returned " + temp.size() + " instances - expected 3", temp.size() == 3); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting reference instances with non-existent data try { - List temp = EamDb.getInstance().getReferenceInstancesByTypeValue(fileType, randomHash()); + List temp = CentralRepository.getInstance().getReferenceInstancesByTypeValue(fileType, randomHash()); assertTrue("getReferenceInstancesByTypeValue returned " + temp.size() + " instances for non-existent value - expected 0", temp.isEmpty()); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting reference instances an invalid type (the email table is not yet implemented) try { - EamDb.getInstance().getReferenceInstancesByTypeValue(emailType, inAllSetsHash); + CentralRepository.getInstance().getReferenceInstancesByTypeValue(emailType, inAllSetsHash); fail("getReferenceInstancesByTypeValue failed to throw exception for invalid table"); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test getting reference instances with null type try { - EamDb.getInstance().getReferenceInstancesByTypeValue(null, inAllSetsHash); + CentralRepository.getInstance().getReferenceInstancesByTypeValue(null, inAllSetsHash); fail("getReferenceInstancesByTypeValue failed to throw exception for null type"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail(ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -1810,9 +1810,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test getting reference instances with null value try { - List temp = EamDb.getInstance().getReferenceInstancesByTypeValue(fileType, null); + List temp = CentralRepository.getInstance().getReferenceInstancesByTypeValue(fileType, null); fail("we should get an exception here"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail(ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -1822,33 +1822,33 @@ public class CentralRepoDatamodelTest extends TestCase { // Test checking existing hash/ID try { - assertTrue("isFileHashInReferenceSet returned false for valid data", EamDb.getInstance().isFileHashInReferenceSet(knownHash1, knownSet1id)); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + assertTrue("isFileHashInReferenceSet returned false for valid data", CentralRepository.getInstance().isFileHashInReferenceSet(knownHash1, knownSet1id)); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test checking non-existent (but valid) hash/ID try { - assertFalse("isFileHashInReferenceSet returned true for non-existent data", EamDb.getInstance().isFileHashInReferenceSet(knownHash1, notableSet1id)); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + assertFalse("isFileHashInReferenceSet returned true for non-existent data", CentralRepository.getInstance().isFileHashInReferenceSet(knownHash1, notableSet1id)); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test checking invalid reference set ID try { - assertFalse("isFileHashInReferenceSet returned true for invalid data", EamDb.getInstance().isFileHashInReferenceSet(knownHash1, 5678)); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + assertFalse("isFileHashInReferenceSet returned true for invalid data", CentralRepository.getInstance().isFileHashInReferenceSet(knownHash1, 5678)); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test checking null hash try { - EamDb.getInstance().isFileHashInReferenceSet(null, knownSet1id); + CentralRepository.getInstance().isFileHashInReferenceSet(null, knownSet1id); fail("This should throw an exception"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail(ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -1859,8 +1859,8 @@ public class CentralRepoDatamodelTest extends TestCase { // Test checking existing hash/ID try { assertTrue("isValueInReferenceSet returned false for valid data", - EamDb.getInstance().isValueInReferenceSet(knownHash1, knownSet1id, fileType.getId())); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + CentralRepository.getInstance().isValueInReferenceSet(knownHash1, knownSet1id, fileType.getId())); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -1868,8 +1868,8 @@ public class CentralRepoDatamodelTest extends TestCase { // Test checking non-existent (but valid) hash/ID try { assertFalse("isValueInReferenceSet returned true for non-existent data", - EamDb.getInstance().isValueInReferenceSet(knownHash1, notableSet1id, fileType.getId())); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + CentralRepository.getInstance().isValueInReferenceSet(knownHash1, notableSet1id, fileType.getId())); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -1877,17 +1877,17 @@ public class CentralRepoDatamodelTest extends TestCase { // Test checking invalid reference set ID try { assertFalse("isValueInReferenceSet returned true for invalid data", - EamDb.getInstance().isValueInReferenceSet(knownHash1, 5678, fileType.getId())); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + CentralRepository.getInstance().isValueInReferenceSet(knownHash1, 5678, fileType.getId())); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test checking null hash try { - EamDb.getInstance().isValueInReferenceSet(null, knownSet1id, fileType.getId()); + CentralRepository.getInstance().isValueInReferenceSet(null, knownSet1id, fileType.getId()); fail("we should get an exception here"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail(ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -1897,9 +1897,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test checking invalid type try { - EamDb.getInstance().isValueInReferenceSet(knownHash1, knownSet1id, emailType.getId()); + CentralRepository.getInstance().isValueInReferenceSet(knownHash1, knownSet1id, emailType.getId()); fail("isValueInReferenceSet failed to throw exception for invalid type"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail(ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -1910,8 +1910,8 @@ public class CentralRepoDatamodelTest extends TestCase { // Test known bad with notable data try { assertTrue("isArtifactKnownBadByReference returned false for notable value", - EamDb.getInstance().isArtifactKnownBadByReference(fileType, notableHash1)); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + CentralRepository.getInstance().isArtifactKnownBadByReference(fileType, notableHash1)); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -1919,8 +1919,8 @@ public class CentralRepoDatamodelTest extends TestCase { // Test known bad with known data try { assertFalse("isArtifactKnownBadByReference returned true for known value", - EamDb.getInstance().isArtifactKnownBadByReference(fileType, knownHash1)); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + CentralRepository.getInstance().isArtifactKnownBadByReference(fileType, knownHash1)); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -1928,17 +1928,17 @@ public class CentralRepoDatamodelTest extends TestCase { // Test known bad with non-existent data try { assertFalse("isArtifactKnownBadByReference returned true for non-existent value", - EamDb.getInstance().isArtifactKnownBadByReference(fileType, randomHash())); - } catch (EamDbException | CorrelationAttributeNormalizationException ex) { + CentralRepository.getInstance().isArtifactKnownBadByReference(fileType, randomHash())); + } catch (CentralRepoException | CorrelationAttributeNormalizationException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test known bad with null hash try { - EamDb.getInstance().isArtifactKnownBadByReference(fileType, null); + CentralRepository.getInstance().isArtifactKnownBadByReference(fileType, null); fail("we should have thrown an exception"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail(ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -1948,9 +1948,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test known bad with null type try { - EamDb.getInstance().isArtifactKnownBadByReference(null, knownHash1); + CentralRepository.getInstance().isArtifactKnownBadByReference(null, knownHash1); fail("isArtifactKnownBadByReference failed to throw exception from null type"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail(ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -1960,9 +1960,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test known bad with invalid type try { - EamDb.getInstance().isArtifactKnownBadByReference(emailType, null); + CentralRepository.getInstance().isArtifactKnownBadByReference(emailType, null); fail("should get an exception here"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); fail(ex.getMessage()); } catch (CorrelationAttributeNormalizationException ex) { @@ -1996,17 +1996,17 @@ public class CentralRepoDatamodelTest extends TestCase { public void testReferenceSets() { String set1name = "referenceSet1"; String set1version = "1.0"; - EamGlobalSet set1; + CentralRepoFileSet set1; int set1id; String set2name = "referenceSet2"; - EamGlobalSet set2; - EamGlobalSet set3; + CentralRepoFileSet set2; + CentralRepoFileSet set3; // Test creating a notable reference set try { - set1 = new EamGlobalSet(org1.getOrgID(), set1name, set1version, TskData.FileKnown.BAD, false, fileType); - set1id = EamDb.getInstance().newReferenceSet(set1); - } catch (EamDbException ex) { + set1 = new CentralRepoFileSet(org1.getOrgID(), set1name, set1version, TskData.FileKnown.BAD, false, fileType); + set1id = CentralRepository.getInstance().newReferenceSet(set1); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); return; @@ -2014,9 +2014,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test creating a known reference set try { - set2 = new EamGlobalSet(org2.getOrgID(), set2name, "", TskData.FileKnown.KNOWN, false, fileType); - EamDb.getInstance().newReferenceSet(set2); - } catch (EamDbException ex) { + set2 = new CentralRepoFileSet(org2.getOrgID(), set2name, "", TskData.FileKnown.KNOWN, false, fileType); + CentralRepository.getInstance().newReferenceSet(set2); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); return; @@ -2024,19 +2024,19 @@ public class CentralRepoDatamodelTest extends TestCase { // Test creating a reference set with the same name and version try { - EamGlobalSet temp = new EamGlobalSet(org1.getOrgID(), set1name, "1.0", TskData.FileKnown.BAD, false, fileType); - EamDb.getInstance().newReferenceSet(temp); + CentralRepoFileSet temp = new CentralRepoFileSet(org1.getOrgID(), set1name, "1.0", TskData.FileKnown.BAD, false, fileType); + CentralRepository.getInstance().newReferenceSet(temp); fail("newReferenceSet failed to throw exception from duplicate name/version pair"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test creating a reference set with the same name but different version try { - set3 = new EamGlobalSet(org1.getOrgID(), set1name, "2.0", TskData.FileKnown.BAD, false, fileType); - EamDb.getInstance().newReferenceSet(set3); - } catch (EamDbException ex) { + set3 = new CentralRepoFileSet(org1.getOrgID(), set1name, "2.0", TskData.FileKnown.BAD, false, fileType); + CentralRepository.getInstance().newReferenceSet(set3); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); return; @@ -2044,160 +2044,160 @@ public class CentralRepoDatamodelTest extends TestCase { // Test creating a reference set with invalid org ID try { - EamGlobalSet temp = new EamGlobalSet(5000, "tempName", "", TskData.FileKnown.BAD, false, fileType); - EamDb.getInstance().newReferenceSet(temp); + CentralRepoFileSet temp = new CentralRepoFileSet(5000, "tempName", "", TskData.FileKnown.BAD, false, fileType); + CentralRepository.getInstance().newReferenceSet(temp); fail("newReferenceSet failed to throw exception from invalid org ID"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test creating a reference set with null name try { - EamGlobalSet temp = new EamGlobalSet(org2.getOrgID(), null, "", TskData.FileKnown.BAD, false, fileType); - EamDb.getInstance().newReferenceSet(temp); + CentralRepoFileSet temp = new CentralRepoFileSet(org2.getOrgID(), null, "", TskData.FileKnown.BAD, false, fileType); + CentralRepository.getInstance().newReferenceSet(temp); fail("newReferenceSet failed to throw exception from null name"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test creating a reference set with null version try { - EamGlobalSet temp = new EamGlobalSet(org2.getOrgID(), "tempName", null, TskData.FileKnown.BAD, false, fileType); - EamDb.getInstance().newReferenceSet(temp); + CentralRepoFileSet temp = new CentralRepoFileSet(org2.getOrgID(), "tempName", null, TskData.FileKnown.BAD, false, fileType); + CentralRepository.getInstance().newReferenceSet(temp); fail("newReferenceSet failed to throw exception from null version"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test creating a reference set with null file known status try { - EamGlobalSet temp = new EamGlobalSet(org2.getOrgID(), "tempName", "", null, false, fileType); - EamDb.getInstance().newReferenceSet(temp); + CentralRepoFileSet temp = new CentralRepoFileSet(org2.getOrgID(), "tempName", "", null, false, fileType); + CentralRepository.getInstance().newReferenceSet(temp); fail("newReferenceSet failed to throw exception from null file known status"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test creating a reference set with null file type try { - EamGlobalSet temp = new EamGlobalSet(org2.getOrgID(), "tempName", "", TskData.FileKnown.BAD, false, null); - EamDb.getInstance().newReferenceSet(temp); + CentralRepoFileSet temp = new CentralRepoFileSet(org2.getOrgID(), "tempName", "", TskData.FileKnown.BAD, false, null); + CentralRepository.getInstance().newReferenceSet(temp); fail("newReferenceSet failed to throw exception from null file type"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior } // Test validation with a valid reference set try { - assertTrue("referenceSetIsValid returned false for valid reference set", EamDb.getInstance().referenceSetIsValid(set1id, set1name, set1version)); - } catch (EamDbException ex) { + assertTrue("referenceSetIsValid returned false for valid reference set", CentralRepository.getInstance().referenceSetIsValid(set1id, set1name, set1version)); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test validation with an invalid reference set try { - assertFalse("referenceSetIsValid returned true for invalid reference set", EamDb.getInstance().referenceSetIsValid(5000, set1name, set1version)); - } catch (EamDbException ex) { + assertFalse("referenceSetIsValid returned true for invalid reference set", CentralRepository.getInstance().referenceSetIsValid(5000, set1name, set1version)); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test validation with a null name try { - assertFalse("referenceSetIsValid returned true with null name", EamDb.getInstance().referenceSetIsValid(set1id, null, set1version)); - } catch (EamDbException ex) { + assertFalse("referenceSetIsValid returned true with null name", CentralRepository.getInstance().referenceSetIsValid(set1id, null, set1version)); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test validation with a null version try { - assertFalse("referenceSetIsValid returned true with null version", EamDb.getInstance().referenceSetIsValid(set1id, set1name, null)); - } catch (EamDbException ex) { + assertFalse("referenceSetIsValid returned true with null version", CentralRepository.getInstance().referenceSetIsValid(set1id, set1name, null)); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test existence with a valid reference set try { - assertTrue("referenceSetExists returned false for valid reference set", EamDb.getInstance().referenceSetExists(set1name, set1version)); - } catch (EamDbException ex) { + assertTrue("referenceSetExists returned false for valid reference set", CentralRepository.getInstance().referenceSetExists(set1name, set1version)); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test existence with an invalid reference set try { - assertFalse("referenceSetExists returned true for invalid reference set", EamDb.getInstance().referenceSetExists(set1name, "5.5")); - } catch (EamDbException ex) { + assertFalse("referenceSetExists returned true for invalid reference set", CentralRepository.getInstance().referenceSetExists(set1name, "5.5")); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test existence with null name try { - assertFalse("referenceSetExists returned true for null name", EamDb.getInstance().referenceSetExists(null, "1.0")); - } catch (EamDbException ex) { + assertFalse("referenceSetExists returned true for null name", CentralRepository.getInstance().referenceSetExists(null, "1.0")); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test existence with null version try { - assertFalse("referenceSetExists returned true for null version", EamDb.getInstance().referenceSetExists(set1name, null)); - } catch (EamDbException ex) { + assertFalse("referenceSetExists returned true for null version", CentralRepository.getInstance().referenceSetExists(set1name, null)); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting global set with valid ID try { - EamGlobalSet temp = EamDb.getInstance().getReferenceSetByID(set1id); + CentralRepoFileSet temp = CentralRepository.getInstance().getReferenceSetByID(set1id); assertTrue("getReferenceSetByID returned null for valid ID", temp != null); assertTrue("getReferenceSetByID returned set with incorrect name and/or version", set1name.equals(temp.getSetName()) && set1version.equals(temp.getVersion())); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting global set with invalid ID try { - EamGlobalSet temp = EamDb.getInstance().getReferenceSetByID(1234); + CentralRepoFileSet temp = CentralRepository.getInstance().getReferenceSetByID(1234); assertTrue("getReferenceSetByID returned non-null result for invalid ID", temp == null); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting all file reference sets try { - List referenceSets = EamDb.getInstance().getAllReferenceSets(fileType); + List referenceSets = CentralRepository.getInstance().getAllReferenceSets(fileType); assertTrue("getAllReferenceSets(FILES) returned unexpected number", referenceSets.size() == 3); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting all email reference sets try { - List referenceSets = EamDb.getInstance().getAllReferenceSets(EamDb.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.EMAIL_TYPE_ID)); + List referenceSets = CentralRepository.getInstance().getAllReferenceSets(CentralRepository.getInstance().getCorrelationTypeById(CorrelationAttributeInstance.EMAIL_TYPE_ID)); assertTrue("getAllReferenceSets(EMAIL) returned unexpected number", referenceSets.isEmpty()); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test null argument to getAllReferenceSets try { - EamDb.getInstance().getAllReferenceSets(null); + CentralRepository.getInstance().getAllReferenceSets(null); fail("getAllReferenceSets failed to throw exception from null type argument"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -2206,16 +2206,16 @@ public class CentralRepoDatamodelTest extends TestCase { // First: create a new reference set, check that it's in the database, and get the number of reference sets // Second: delete the reference set, check that it is no longer in the database, and the total number of sets decreased by one try { - EamGlobalSet setToDelete = new EamGlobalSet(org1.getOrgID(), "deleteThis", "deleteThisVersion", TskData.FileKnown.BAD, false, fileType); - int setToDeleteID = EamDb.getInstance().newReferenceSet(setToDelete); - assertTrue("setToDelete wasn't found in database", EamDb.getInstance().referenceSetIsValid(setToDeleteID, setToDelete.getSetName(), setToDelete.getVersion())); - int currentCount = EamDb.getInstance().getAllReferenceSets(fileType).size(); + CentralRepoFileSet setToDelete = new CentralRepoFileSet(org1.getOrgID(), "deleteThis", "deleteThisVersion", TskData.FileKnown.BAD, false, fileType); + int setToDeleteID = CentralRepository.getInstance().newReferenceSet(setToDelete); + assertTrue("setToDelete wasn't found in database", CentralRepository.getInstance().referenceSetIsValid(setToDeleteID, setToDelete.getSetName(), setToDelete.getVersion())); + int currentCount = CentralRepository.getInstance().getAllReferenceSets(fileType).size(); - EamDb.getInstance().deleteReferenceSet(setToDeleteID); - assertFalse("Deleted reference set was found in database", EamDb.getInstance().referenceSetIsValid(setToDeleteID, setToDelete.getSetName(), setToDelete.getVersion())); - assertTrue("Unexpected number of reference sets in database after deletion", currentCount - 1 == EamDb.getInstance().getAllReferenceSets(fileType).size()); + CentralRepository.getInstance().deleteReferenceSet(setToDeleteID); + assertFalse("Deleted reference set was found in database", CentralRepository.getInstance().referenceSetIsValid(setToDeleteID, setToDelete.getSetName(), setToDelete.getVersion())); + assertTrue("Unexpected number of reference sets in database after deletion", currentCount - 1 == CentralRepository.getInstance().getAllReferenceSets(fileType).size()); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -2223,29 +2223,29 @@ public class CentralRepoDatamodelTest extends TestCase { // Test deleting a non-existent reference set // The expectation is that nothing will happen try { - int currentCount = EamDb.getInstance().getAllReferenceSets(fileType).size(); - EamDb.getInstance().deleteReferenceSet(1234); - assertTrue("Number of reference sets changed after deleting non-existent set", currentCount == EamDb.getInstance().getAllReferenceSets(fileType).size()); - } catch (EamDbException ex) { + int currentCount = CentralRepository.getInstance().getAllReferenceSets(fileType).size(); + CentralRepository.getInstance().deleteReferenceSet(1234); + assertTrue("Number of reference sets changed after deleting non-existent set", currentCount == CentralRepository.getInstance().getAllReferenceSets(fileType).size()); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting reference set organization for valid ID with org set try { - EamOrganization org = EamDb.getInstance().getReferenceSetOrganization(set1id); + CentralRepoOrganization org = CentralRepository.getInstance().getReferenceSetOrganization(set1id); assertTrue("getReferenceSetOrganization returned null for valid set", org != null); assertTrue("getReferenceSetOrganization returned the incorrect organization", org.getOrgID() == org1.getOrgID()); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting reference set organization for non-existent reference set try { - EamDb.getInstance().getReferenceSetOrganization(4567); + CentralRepository.getInstance().getReferenceSetOrganization(4567); fail("getReferenceSetOrganization failed to throw exception for invalid reference set ID"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -2273,8 +2273,8 @@ public class CentralRepoDatamodelTest extends TestCase { try { dataSourceA = new CorrelationDataSource(case2, dataSourceAid, dataSourceAname, 0L, null, null, null); - EamDb.getInstance().newDataSource(dataSourceA); - } catch (EamDbException ex) { + CentralRepository.getInstance().newDataSource(dataSourceA); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); return; @@ -2284,8 +2284,8 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationDataSource temp = new CorrelationDataSource(case2, dataSourceAid, dataSourceAname, 0L, null, null, null); - EamDb.getInstance().newDataSource(temp); - } catch (EamDbException ex) { + CentralRepository.getInstance().newDataSource(temp); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); return; @@ -2295,8 +2295,8 @@ public class CentralRepoDatamodelTest extends TestCase { try { dataSourceB = new CorrelationDataSource(case1, dataSourceAid, dataSourceAname, 0L, null, null, null); - EamDb.getInstance().newDataSource(dataSourceB); - } catch (EamDbException ex) { + CentralRepository.getInstance().newDataSource(dataSourceB); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); return; @@ -2307,9 +2307,9 @@ public class CentralRepoDatamodelTest extends TestCase { CorrelationCase correlationCase = new CorrelationCase("1", "test"); CorrelationDataSource temp = new CorrelationDataSource(correlationCase, "tempID", "tempName", 0L, null, null, null); - EamDb.getInstance().newDataSource(temp); + CentralRepository.getInstance().newDataSource(temp); fail("newDataSource did not throw exception from invalid case ID"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -2318,9 +2318,9 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationDataSource temp = new CorrelationDataSource(case2, null, "tempName", 0L, null, null, null); - EamDb.getInstance().newDataSource(temp); + CentralRepository.getInstance().newDataSource(temp); fail("newDataSource did not throw exception from null device ID"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -2329,45 +2329,45 @@ public class CentralRepoDatamodelTest extends TestCase { try { CorrelationDataSource temp = new CorrelationDataSource(case2, "tempID", null, 0L, null, null, null); - EamDb.getInstance().newDataSource(temp); + CentralRepository.getInstance().newDataSource(temp); fail("newDataSource did not throw exception from null name"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test getting a data source with valid case and ID try { - CorrelationDataSource temp = EamDb.getInstance().getDataSource(case2, 0L); + CorrelationDataSource temp = CentralRepository.getInstance().getDataSource(case2, 0L); assertTrue("Failed to get data source", temp != null); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting a data source with non-existent ID try { - CorrelationDataSource temp = EamDb.getInstance().getDataSource(case2, 9999L); + CorrelationDataSource temp = CentralRepository.getInstance().getDataSource(case2, 9999L); assertTrue("getDataSource returned non-null value for non-existent data source", temp == null); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting a data source with a null case try { - EamDb.getInstance().getDataSource(null, 0L); + CentralRepository.getInstance().getDataSource(null, 0L); fail("getDataSource did not throw exception from null case"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test getting a data source with an invalid ID try { - CorrelationDataSource temp = EamDb.getInstance().getDataSource(case2, -1L); + CorrelationDataSource temp = CentralRepository.getInstance().getDataSource(case2, -1L); assertTrue("getDataSource returned non-null value for null data source", temp == null); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -2375,7 +2375,7 @@ public class CentralRepoDatamodelTest extends TestCase { // Test getting the list of data sources // There should be five data sources, and we'll check for the expected device IDs try { - List dataSources = EamDb.getInstance().getDataSources(); + List dataSources = CentralRepository.getInstance().getDataSources(); List devIdList = dataSources.stream().map(c -> c.getDeviceID()).collect(Collectors.toList()); assertTrue("getDataSources returned unexpected number of data sources", dataSources.size() == 5); @@ -2384,7 +2384,7 @@ public class CentralRepoDatamodelTest extends TestCase { && devIdList.contains(dataSource1fromCase1.getDeviceID()) && devIdList.contains(dataSource2fromCase1.getDeviceID()) && devIdList.contains(dataSource1fromCase2.getDeviceID())); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -2392,8 +2392,8 @@ public class CentralRepoDatamodelTest extends TestCase { // Test the data source count try { assertTrue("getCountUniqueDataSources returned unexpected number of data sources", - EamDb.getInstance().getCountUniqueDataSources() == 5); - } catch (EamDbException ex) { + CentralRepository.getInstance().getCountUniqueDataSources() == 5); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -2432,9 +2432,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test creating a case with valid name and uuid try { caseA = new CorrelationCase(caseAuuid, caseAname); - caseA = EamDb.getInstance().newCase(caseA); + caseA = CentralRepository.getInstance().newCase(caseA); assertTrue("Failed to create case", caseA != null); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); return; @@ -2443,9 +2443,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test null uuid try { CorrelationCase tempCase = new CorrelationCase(null, "nullUuidCase"); - EamDb.getInstance().newCase(tempCase); + CentralRepository.getInstance().newCase(tempCase); fail("newCase did not throw expected exception from null uuid"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -2453,9 +2453,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test null name try { CorrelationCase tempCase = new CorrelationCase("nullCaseUuid", null); - EamDb.getInstance().newCase(tempCase); + CentralRepository.getInstance().newCase(tempCase); fail("newCase did not throw expected exception from null name"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -2464,12 +2464,12 @@ public class CentralRepoDatamodelTest extends TestCase { // This should just return the existing case object. Check that the total // number of cases does not increase. try { - int nCases = EamDb.getInstance().getCases().size(); + int nCases = CentralRepository.getInstance().getCases().size(); CorrelationCase tempCase = new CorrelationCase(caseAuuid, "newCaseWithSameUUID"); - tempCase = EamDb.getInstance().newCase(tempCase); + tempCase = CentralRepository.getInstance().newCase(tempCase); assertTrue("newCase returned null for existing UUID", tempCase != null); - assertTrue("newCase created a new case for an already existing UUID", nCases == EamDb.getInstance().getCases().size()); - } catch (EamDbException ex) { + assertTrue("newCase created a new case for an already existing UUID", nCases == CentralRepository.getInstance().getCases().size()); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -2477,9 +2477,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test creating a case from an Autopsy case // The case may already be in the database - the result is the same either way try { - caseB = EamDb.getInstance().newCase(Case.getCurrentCaseThrows()); + caseB = CentralRepository.getInstance().newCase(Case.getCurrentCaseThrows()); assertTrue("Failed to create correlation case from Autopsy case", caseB != null); - } catch (EamDbException | NoCurrentCaseException ex) { + } catch (CentralRepoException | NoCurrentCaseException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); return; @@ -2488,9 +2488,9 @@ public class CentralRepoDatamodelTest extends TestCase { // Test null Autopsy case try { Case nullCase = null; - EamDb.getInstance().newCase(nullCase); + CentralRepository.getInstance().newCase(nullCase); fail("newCase did not throw expected exception from null case"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -2517,11 +2517,11 @@ public class CentralRepoDatamodelTest extends TestCase { caseA.setNotes(notes); caseA.setOrg(org1); - EamDb.getInstance().updateCase(caseA); + CentralRepository.getInstance().updateCase(caseA); // Retrievex a new copy of the case from the database to check that the // fields were properly updated - CorrelationCase updatedCase = EamDb.getInstance().getCaseByUUID(caseA.getCaseUUID()); + CorrelationCase updatedCase = CentralRepository.getInstance().getCaseByUUID(caseA.getCaseUUID()); assertTrue("updateCase failed to update case number", caseNumber.equals(updatedCase.getCaseNumber())); assertTrue("updateCase failed to update creation date", creationDate.equals(updatedCase.getCreationDate())); @@ -2532,43 +2532,43 @@ public class CentralRepoDatamodelTest extends TestCase { assertTrue("updateCase failed to update notes", notes.equals(updatedCase.getNotes())); assertTrue("updateCase failed to update org (org is null)", updatedCase.getOrg() != null); assertTrue("updateCase failed to update org (org ID is wrong)", org1.getOrgID() == updatedCase.getOrg().getOrgID()); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test update case with null case try { - EamDb.getInstance().updateCase(null); + CentralRepository.getInstance().updateCase(null); fail("updateCase did not throw expected exception from null case"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Test getting a case from an Autopsy case try { - CorrelationCase tempCase = EamDb.getInstance().getCase(Case.getCurrentCaseThrows()); + CorrelationCase tempCase = CentralRepository.getInstance().getCase(Case.getCurrentCaseThrows()); assertTrue("getCase returned null for current Autopsy case", tempCase != null); - } catch (EamDbException | NoCurrentCaseException ex) { + } catch (CentralRepoException | NoCurrentCaseException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting a case by UUID try { - CorrelationCase tempCase = EamDb.getInstance().getCaseByUUID(caseAuuid); + CorrelationCase tempCase = CentralRepository.getInstance().getCaseByUUID(caseAuuid); assertTrue("Failed to get case by UUID", tempCase != null); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test getting a case with a non-existent UUID try { - CorrelationCase tempCase = EamDb.getInstance().getCaseByUUID("badUUID"); + CorrelationCase tempCase = CentralRepository.getInstance().getCaseByUUID("badUUID"); assertTrue("getCaseByUUID returned non-null case for non-existent UUID", tempCase == null); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -2576,13 +2576,13 @@ public class CentralRepoDatamodelTest extends TestCase { // Test getting the list of cases // The test is to make sure the three cases we know are in the database are in the list try { - List caseList = EamDb.getInstance().getCases(); + List caseList = CentralRepository.getInstance().getCases(); List uuidList = caseList.stream().map(c -> c.getCaseUUID()).collect(Collectors.toList()); assertTrue("getCases is missing data for existing cases", uuidList.contains(case1.getCaseUUID()) && uuidList.contains(case2.getCaseUUID()) && (uuidList.contains(caseA.getCaseUUID())) && uuidList.contains(caseB.getCaseUUID())); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -2600,23 +2600,23 @@ public class CentralRepoDatamodelTest extends TestCase { } // Get the current case count - int nCases = EamDb.getInstance().getCases().size(); + int nCases = CentralRepository.getInstance().getCases().size(); // Insert the big list of cases - EamDb.getInstance().bulkInsertCases(cases); + CentralRepository.getInstance().bulkInsertCases(cases); // Check that the case count is what is expected - assertTrue("bulkInsertCases did not insert the expected number of cases", nCases + cases.size() == EamDb.getInstance().getCases().size()); - } catch (EamDbException ex) { + assertTrue("bulkInsertCases did not insert the expected number of cases", nCases + cases.size() == CentralRepository.getInstance().getCases().size()); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test bulk case insert with null list try { - EamDb.getInstance().bulkInsertCases(null); + CentralRepository.getInstance().bulkInsertCases(null); fail("bulkInsertCases did not throw expected exception from null list"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -2655,70 +2655,70 @@ public class CentralRepoDatamodelTest extends TestCase { // Test setting a valid value in DbInfo try { - EamDb.getInstance().newDbInfo(name1, value1); - } catch (EamDbException ex) { + CentralRepository.getInstance().newDbInfo(name1, value1); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Test null name try { - EamDb.getInstance().newDbInfo(null, value1); + CentralRepository.getInstance().newDbInfo(null, value1); fail("newDbInfo did not throw expected exception from null name"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior } // Test null value try { - EamDb.getInstance().newDbInfo(name2, null); + CentralRepository.getInstance().newDbInfo(name2, null); fail("newDbInfo did not throw expected exception from null value"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } // Try getting the dbInfo entry that should exist try { - String tempVal = EamDb.getInstance().getDbInfo(name1); + String tempVal = CentralRepository.getInstance().getDbInfo(name1); assertTrue("dbInfo value for name1 does not match", value1.equals(tempVal)); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Try getting the dbInfo entry that should not exist try { - String tempVal = EamDb.getInstance().getDbInfo(name3); + String tempVal = CentralRepository.getInstance().getDbInfo(name3); assertTrue("dbInfo value is unexpectedly non-null given non-existent name", tempVal == null); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Try getting dbInfo for a null value try { - String tempVal = EamDb.getInstance().getDbInfo(null); + String tempVal = CentralRepository.getInstance().getDbInfo(null); assertTrue("dbInfo value is unexpectedly non-null given null name", tempVal == null); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Try updating an existing value to a valid new value try { - EamDb.getInstance().updateDbInfo(name1, value2); - assertTrue("dbInfo value failed to update to expected value", value2.equals(EamDb.getInstance().getDbInfo(name1))); - } catch (EamDbException ex) { + CentralRepository.getInstance().updateDbInfo(name1, value2); + assertTrue("dbInfo value failed to update to expected value", value2.equals(CentralRepository.getInstance().getDbInfo(name1))); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Try updating an existing value to null try { - EamDb.getInstance().updateDbInfo(name1, null); + CentralRepository.getInstance().updateDbInfo(name1, null); fail("updateDbInfo did not throw expected exception from null value"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } @@ -2726,17 +2726,17 @@ public class CentralRepoDatamodelTest extends TestCase { // Try updating a null name // This seems like SQLite would throw an exception, but it does not try { - EamDb.getInstance().updateDbInfo(null, value1); - } catch (EamDbException ex) { + CentralRepository.getInstance().updateDbInfo(null, value1); + } catch (CentralRepoException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } // Try updating the value for a non-existant name try { - EamDb.getInstance().updateDbInfo(name1, null); + CentralRepository.getInstance().updateDbInfo(name1, null); fail("updateDbInfo did not throw expected exception from non-existent name"); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { // This is the expected behavior assertTrue(THIS_IS_THE_EXPECTED_BEHAVIOR, true); } diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeSearchInterCaseTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeSearchInterCaseTest.java index abc4ba5b9d..f6f4658bff 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeSearchInterCaseTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeSearchInterCaseTest.java @@ -28,7 +28,7 @@ import org.netbeans.junit.NbTestCase; import org.openide.util.Exceptions; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.commonpropertiessearch.AbstractCommonAttributeSearcher; import org.sleuthkit.autopsy.commonpropertiessearch.AllInterCaseCommonAttributeSearcher; import org.sleuthkit.autopsy.commonpropertiessearch.CommonAttributeCountSearchResults; diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeInterCaseTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeInterCaseTest.java index d21c14b93b..3b4a64936c 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeInterCaseTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeInterCaseTest.java @@ -29,7 +29,7 @@ import org.openide.util.Exceptions; import junit.framework.Assert; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.commonpropertiessearch.AbstractCommonAttributeSearcher; import org.sleuthkit.autopsy.commonpropertiessearch.AllInterCaseCommonAttributeSearcher; import org.sleuthkit.autopsy.commonpropertiessearch.CommonAttributeCountSearchResults; diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeIntraCaseTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeIntraCaseTest.java index b97c17cca9..457001a540 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeIntraCaseTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeIntraCaseTest.java @@ -30,7 +30,7 @@ import org.openide.util.Exceptions; import junit.framework.Assert; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.commonpropertiessearch.AbstractCommonAttributeSearcher; import org.sleuthkit.autopsy.commonpropertiessearch.AllIntraCaseCommonAttributeSearcher; import org.sleuthkit.autopsy.commonpropertiessearch.CommonAttributeCountSearchResults; @@ -126,7 +126,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTest extends NbTestCase { assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET3, 0)); assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET4, 0)); - } catch (NoCurrentCaseException | TskCoreException | SQLException | EamDbException ex) { + } catch (NoCurrentCaseException | TskCoreException | SQLException | CentralRepoExceptionex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -167,7 +167,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTest extends NbTestCase { assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET3, 0)); assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET4, 0)); - } catch (NoCurrentCaseException | TskCoreException | SQLException | EamDbException ex) { + } catch (NoCurrentCaseException | TskCoreException | SQLException | CentralRepoExceptionex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -208,7 +208,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTest extends NbTestCase { assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET3, 0)); assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET4, 0)); - } catch (NoCurrentCaseException | TskCoreException | SQLException | EamDbException ex) { + } catch (NoCurrentCaseException | TskCoreException | SQLException | CentralRepoExceptionex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -250,7 +250,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTest extends NbTestCase { assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET3, 0)); assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET4, 0)); - } catch (NoCurrentCaseException | TskCoreException | SQLException | EamDbException ex) { + } catch (NoCurrentCaseException | TskCoreException | SQLException | CentralRepoExceptionex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -292,7 +292,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTest extends NbTestCase { assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET3, 0)); assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET4, 0)); - } catch (NoCurrentCaseException | TskCoreException | SQLException | EamDbException ex) { + } catch (NoCurrentCaseException | TskCoreException | SQLException | CentralRepoExceptionex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -334,7 +334,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTest extends NbTestCase { assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET3, 0)); assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET4, 0)); - } catch (NoCurrentCaseException | TskCoreException | SQLException | EamDbException ex) { + } catch (NoCurrentCaseException | TskCoreException | SQLException | CentralRepoExceptionex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -376,7 +376,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTest extends NbTestCase { assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET3, 0)); assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET4, 0)); - } catch (NoCurrentCaseException | TskCoreException | SQLException | EamDbException ex) { + } catch (NoCurrentCaseException | TskCoreException | SQLException | CentralRepoExceptionex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -417,7 +417,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTest extends NbTestCase { assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET3, 0)); assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET4, 0)); - } catch (NoCurrentCaseException | TskCoreException | SQLException | EamDbException ex) { + } catch (NoCurrentCaseException | TskCoreException | SQLException | CentralRepoExceptionex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -458,7 +458,7 @@ public class IngestedWithHashAndFileTypeIntraCaseTest extends NbTestCase { assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET3, 0)); assertTrue(verifyInstanceExistanceAndCount(files, objectIdToDataSource, EMPTY, SET4, 0)); - } catch (NoCurrentCaseException | TskCoreException | SQLException | EamDbException ex) { + } catch (NoCurrentCaseException | TskCoreException | SQLException | CentralRepoExceptionex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseTestUtils.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseTestUtils.java index 04b2bb38d1..69dcdc71b9 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseTestUtils.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseTestUtils.java @@ -33,10 +33,10 @@ import org.netbeans.junit.NbTestCase; import org.openide.util.Exceptions; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.ImageDSProcessor; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbPlatformEnum; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil; -import org.sleuthkit.autopsy.centralrepository.datamodel.SqliteEamDbSettings; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoPlatforms; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoDbUtil; +import org.sleuthkit.autopsy.centralrepository.datamodel.SqliteCentralRepoSettings; import org.sleuthkit.autopsy.ingest.IngestJobSettings; import org.sleuthkit.autopsy.ingest.IngestJobSettings.IngestType; import org.sleuthkit.autopsy.ingest.IngestModuleTemplate; @@ -49,7 +49,6 @@ import junit.framework.Assert; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; import org.sleuthkit.autopsy.coreutils.TimeStampUtils; import org.sleuthkit.autopsy.datamodel.DisplayableItemNode; import org.sleuthkit.autopsy.datamodel.utils.DataSourceLoader; @@ -62,6 +61,7 @@ import org.sleuthkit.autopsy.modules.interestingitems.InterestingItemsIngestModu import org.sleuthkit.autopsy.modules.photoreccarver.PhotoRecCarverIngestModuleFactory; import org.sleuthkit.autopsy.modules.vmextractor.VMExtractorIngestModuleFactory; import org.sleuthkit.datamodel.AbstractFile; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; /** * Utilities for testing intercase correlation feature. @@ -229,7 +229,7 @@ class InterCaseTestUtils { EMAIL_TYPE = types.stream().filter(type -> type.getDisplayName().equals("Email Addresses")).findAny().get(); PHONE_TYPE = types.stream().filter(type -> type.getDisplayName().equals("Phone Numbers")).findAny().get(); - } catch (EamDbException ex) { + } catch (CentralRepoException ex) { Assert.fail(ex.getMessage()); //none of this really matters but satisfies the compiler @@ -244,11 +244,11 @@ class InterCaseTestUtils { void clearTestDir() { if (CENTRAL_REPO_DIRECTORY_PATH.toFile().exists()) { try { - if (EamDb.isEnabled()) { - EamDb.getInstance().shutdownConnections(); + if (CentralRepository.isEnabled()) { + CentralRepository.getInstance().shutdownConnections(); } FileUtils.deleteDirectory(CENTRAL_REPO_DIRECTORY_PATH.toFile()); - } catch (IOException | EamDbException ex) { + } catch (IOException | CentralRepoExceptionex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } @@ -259,12 +259,12 @@ class InterCaseTestUtils { return DataSourceLoader.getAllDataSources(); } - Map getCaseMap() throws EamDbException { + Map getCaseMap() throws CentralRepoException { - if (EamDb.isEnabled()) { + if (CentralRepository.isEnabled()) { Map mapOfCaseIdsToCase = new HashMap<>(); - for (CorrelationCase correlationCase : EamDb.getInstance().getCases()) { + for (CorrelationCase correlationCase : CentralRepository.getInstance().getCases()) { mapOfCaseIdsToCase.put(correlationCase.getDisplayName(), correlationCase.getID()); } return mapOfCaseIdsToCase; @@ -287,10 +287,10 @@ class InterCaseTestUtils { return this.kitchenShink; } - void enableCentralRepo() throws EamDbException { + void enableCentralRepo() throws CentralRepoException { - EamDbUtil.setUseCentralRepo(true); - SqliteEamDbSettings crSettings = new SqliteEamDbSettings(); + CentralRepoDbUtil.setUseCentralRepo(true); + SqliteCentralRepoSettings crSettings = new SqliteCentralRepoSettings(); crSettings.setDbName(CR_DB_NAME); crSettings.setDbDirectory(CENTRAL_REPO_DIRECTORY_PATH.toString()); if (!crSettings.dbDirectoryExists()) { @@ -300,8 +300,8 @@ class InterCaseTestUtils { crSettings.initializeDatabaseSchema(); crSettings.insertDefaultDatabaseContent(); crSettings.saveSettings(); - EamDbPlatformEnum.setSelectedPlatform(EamDbPlatformEnum.SQLITE.name()); - EamDbPlatformEnum.saveSelectedPlatform(); + CentralRepoPlatforms.setSelectedPlatform(CentralRepoPlatforms.SQLITE.name()); + CentralRepoPlatforms.saveSelectedPlatform(); } /** diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/MatchesInAtLeastTwoSourcesIntraCaseTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/MatchesInAtLeastTwoSourcesIntraCaseTest.java index 5663ec151c..4848064308 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/MatchesInAtLeastTwoSourcesIntraCaseTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/MatchesInAtLeastTwoSourcesIntraCaseTest.java @@ -31,7 +31,7 @@ import junit.framework.Assert; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.ImageDSProcessor; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; -import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.commonpropertiessearch.AbstractCommonAttributeSearcher; import org.sleuthkit.autopsy.commonpropertiessearch.AllIntraCaseCommonAttributeSearcher; import org.sleuthkit.autopsy.commonpropertiessearch.CommonAttributeCountSearchResults; @@ -121,7 +121,7 @@ public class MatchesInAtLeastTwoSourcesIntraCaseTest extends NbTestCase { assertTrue(IntraCaseTestUtils.verifyInstanceExistanceAndCount(files, dataSources, EMPTY, SET1, 0)); assertTrue(IntraCaseTestUtils.verifyInstanceExistanceAndCount(files, dataSources, EMPTY, SET4, 0)); - } catch (NoCurrentCaseException | TskCoreException | SQLException | EamDbException ex) { + } catch (NoCurrentCaseException | TskCoreException | SQLException | CentralRepoExceptionex) { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } From 9a724004e2e7375d85e49658695ff3b3617a33ee Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Wed, 29 Jan 2020 17:39:15 -0500 Subject: [PATCH 2/2] Rename central repository data model classes --- .../datamodel/CentralRepoDbUtil.java | 6 ++--- .../datamodel/PostgresCentralRepo.java | 2 +- .../PostgresCentralRepoSettings.java | 16 +++++++------- ...Repo.java => RelationalDbCentralRepo.java} | 22 +++++++++---------- .../datamodel/SqliteCentralRepo.java | 2 +- .../datamodel/SqliteCentralRepoSettings.java | 16 +++++++------- 6 files changed, 32 insertions(+), 32 deletions(-) rename Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/{AbstractCentralRepo.java => RelationalDbCentralRepo.java} (99%) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbUtil.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbUtil.java index 50e0c0252c..2d87fc9b74 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbUtil.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDbUtil.java @@ -30,7 +30,7 @@ import org.sleuthkit.autopsy.coordinationservice.CoordinationService; import org.sleuthkit.autopsy.coordinationservice.CoordinationService.CoordinationServiceException; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ModuleSettings; -import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractCentralRepo.SOFTWARE_CR_DB_SCHEMA_VERSION; +import static org.sleuthkit.autopsy.centralrepository.datamodel.RelationalDbCentralRepo.SOFTWARE_CR_DB_SCHEMA_VERSION; /** * @@ -135,8 +135,8 @@ public class CentralRepoDbUtil { */ static void updateSchemaVersion(Connection conn) throws SQLException { try (Statement statement = conn.createStatement()) { - statement.execute("UPDATE db_info SET value = '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "' WHERE name = '" + AbstractCentralRepo.SCHEMA_MAJOR_VERSION_KEY + "'"); - statement.execute("UPDATE db_info SET value = '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "' WHERE name = '" + AbstractCentralRepo.SCHEMA_MINOR_VERSION_KEY + "'"); + statement.execute("UPDATE db_info SET value = '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "' WHERE name = '" + RelationalDbCentralRepo.SCHEMA_MAJOR_VERSION_KEY + "'"); + statement.execute("UPDATE db_info SET value = '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "' WHERE name = '" + RelationalDbCentralRepo.SCHEMA_MINOR_VERSION_KEY + "'"); } } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepo.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepo.java index 1ac8df25ff..019957c241 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepo.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepo.java @@ -33,7 +33,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; /** * Central Repository database implementation using Postgres as a backend */ -final class PostgresCentralRepo extends AbstractCentralRepo { +final class PostgresCentralRepo extends RelationalDbCentralRepo { private final static Logger LOGGER = Logger.getLogger(PostgresCentralRepo.class.getName()); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepoSettings.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepoSettings.java index 4d689e675c..b29d12d450 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepoSettings.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepoSettings.java @@ -32,7 +32,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.TextConverter; import org.sleuthkit.autopsy.coreutils.TextConverterException; -import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractCentralRepo.SOFTWARE_CR_DB_SCHEMA_VERSION; +import static org.sleuthkit.autopsy.centralrepository.datamodel.RelationalDbCentralRepo.SOFTWARE_CR_DB_SCHEMA_VERSION; /** * Settings for the Postgres implementation of the Central Repository database @@ -92,15 +92,15 @@ public final class PostgresCentralRepoSettings { try { String bulkThresholdString = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.bulkThreshold"); // NON-NLS if (bulkThresholdString == null || bulkThresholdString.isEmpty()) { - this.bulkThreshold = AbstractCentralRepo.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = RelationalDbCentralRepo.DEFAULT_BULK_THRESHHOLD; } else { this.bulkThreshold = Integer.parseInt(bulkThresholdString); if (getBulkThreshold() <= 0) { - this.bulkThreshold = AbstractCentralRepo.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = RelationalDbCentralRepo.DEFAULT_BULK_THRESHHOLD; } } } catch (NumberFormatException ex) { - this.bulkThreshold = AbstractCentralRepo.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = RelationalDbCentralRepo.DEFAULT_BULK_THRESHHOLD; } userName = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.user"); // NON-NLS @@ -420,10 +420,10 @@ public final class PostgresCentralRepoSettings { * name column could be the primary key. */ stmt.execute("CREATE TABLE db_info (id SERIAL, name TEXT UNIQUE NOT NULL, value TEXT NOT NULL)"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.CREATION_SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.CREATION_SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + RelationalDbCentralRepo.SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + RelationalDbCentralRepo.SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + RelationalDbCentralRepo.CREATION_SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + RelationalDbCentralRepo.CREATION_SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); // Create a separate instance and reference table for each correlation type List DEFAULT_CORRELATION_TYPES = CorrelationAttributeInstance.getDefaultCorrelationTypes(); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractCentralRepo.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RelationalDbCentralRepo.java similarity index 99% rename from Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractCentralRepo.java rename to Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RelationalDbCentralRepo.java index 257465f5f0..e4a8225db4 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractCentralRepo.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RelationalDbCentralRepo.java @@ -55,9 +55,9 @@ import org.sleuthkit.datamodel.TskData; * Generic JDBC methods * */ -abstract class AbstractCentralRepo implements CentralRepository { +abstract class RelationalDbCentralRepo implements CentralRepository { - private final static Logger logger = Logger.getLogger(AbstractCentralRepo.class.getName()); + private final static Logger logger = Logger.getLogger(RelationalDbCentralRepo.class.getName()); static final String SCHEMA_MAJOR_VERSION_KEY = "SCHEMA_VERSION"; static final String SCHEMA_MINOR_VERSION_KEY = "SCHEMA_MINOR_VERSION"; static final String CREATION_SCHEMA_MAJOR_VERSION_KEY = "CREATION_SCHEMA_MAJOR_VERSION"; @@ -96,7 +96,7 @@ abstract class AbstractCentralRepo implements CentralRepository { * * @throws UnknownHostException, EamDbException */ - protected AbstractCentralRepo() throws CentralRepoException { + protected RelationalDbCentralRepo() throws CentralRepoException { bulkArtifactsCount = 0; bulkArtifacts = new HashMap<>(); @@ -3331,7 +3331,7 @@ abstract class AbstractCentralRepo implements CentralRepository { selectedPlatform = CentralRepoPlatforms.getSelectedPlatform(); int minorVersion = 0; String minorVersionStr = null; - resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name='" + AbstractCentralRepo.SCHEMA_MINOR_VERSION_KEY + "'"); + resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name='" + RelationalDbCentralRepo.SCHEMA_MINOR_VERSION_KEY + "'"); if (resultSet.next()) { minorVersionStr = resultSet.getString("value"); try { @@ -3345,7 +3345,7 @@ abstract class AbstractCentralRepo implements CentralRepository { int majorVersion = 0; String majorVersionStr = null; - resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name='" + AbstractCentralRepo.SCHEMA_MAJOR_VERSION_KEY + "'"); + resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name='" + RelationalDbCentralRepo.SCHEMA_MAJOR_VERSION_KEY + "'"); if (resultSet.next()) { majorVersionStr = resultSet.getString("value"); try { @@ -3541,14 +3541,14 @@ abstract class AbstractCentralRepo implements CentralRepository { * indicate that it is unknown. */ String creationMajorVer; - resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name = '" + AbstractCentralRepo.CREATION_SCHEMA_MAJOR_VERSION_KEY + "'"); + resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name = '" + RelationalDbCentralRepo.CREATION_SCHEMA_MAJOR_VERSION_KEY + "'"); if (resultSet.next()) { creationMajorVer = resultSet.getString("value"); } else { creationMajorVer = "0"; } String creationMinorVer; - resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name = '" + AbstractCentralRepo.CREATION_SCHEMA_MINOR_VERSION_KEY + "'"); + resultSet = statement.executeQuery("SELECT value FROM db_info WHERE name = '" + RelationalDbCentralRepo.CREATION_SCHEMA_MINOR_VERSION_KEY + "'"); if (resultSet.next()) { creationMinorVer = resultSet.getString("value"); } else { @@ -3560,10 +3560,10 @@ abstract class AbstractCentralRepo implements CentralRepository { } else { statement.execute("CREATE TABLE db_info (id INTEGER PRIMARY KEY, name TEXT UNIQUE NOT NULL, value TEXT NOT NULL)"); } - statement.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.SCHEMA_MAJOR_VERSION_KEY + "','" + majorVersionStr + "')"); - statement.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.SCHEMA_MINOR_VERSION_KEY + "','" + minorVersionStr + "')"); - statement.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.CREATION_SCHEMA_MAJOR_VERSION_KEY + "','" + creationMajorVer + "')"); - statement.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.CREATION_SCHEMA_MINOR_VERSION_KEY + "','" + creationMinorVer + "')"); + statement.execute("INSERT INTO db_info (name, value) VALUES ('" + RelationalDbCentralRepo.SCHEMA_MAJOR_VERSION_KEY + "','" + majorVersionStr + "')"); + statement.execute("INSERT INTO db_info (name, value) VALUES ('" + RelationalDbCentralRepo.SCHEMA_MINOR_VERSION_KEY + "','" + minorVersionStr + "')"); + statement.execute("INSERT INTO db_info (name, value) VALUES ('" + RelationalDbCentralRepo.CREATION_SCHEMA_MAJOR_VERSION_KEY + "','" + creationMajorVer + "')"); + statement.execute("INSERT INTO db_info (name, value) VALUES ('" + RelationalDbCentralRepo.CREATION_SCHEMA_MINOR_VERSION_KEY + "','" + creationMinorVer + "')"); } /* * Update to 1.3 diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepo.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepo.java index 413a3a813a..27bf860206 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepo.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepo.java @@ -39,7 +39,7 @@ import org.sleuthkit.autopsy.coordinationservice.CoordinationService; * AbstractSqlEamDb that read or write to the database should be overriden here * and use appropriate locking. */ -final class SqliteCentralRepo extends AbstractCentralRepo { +final class SqliteCentralRepo extends RelationalDbCentralRepo { private final static Logger LOGGER = Logger.getLogger(SqliteCentralRepo.class.getName()); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepoSettings.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepoSettings.java index 6493cca0a5..2efe91d812 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepoSettings.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepoSettings.java @@ -32,7 +32,7 @@ import java.util.regex.Pattern; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.PlatformUtil; -import static org.sleuthkit.autopsy.centralrepository.datamodel.AbstractCentralRepo.SOFTWARE_CR_DB_SCHEMA_VERSION; +import static org.sleuthkit.autopsy.centralrepository.datamodel.RelationalDbCentralRepo.SOFTWARE_CR_DB_SCHEMA_VERSION; /** * Settings for the sqlite implementation of the Central Repository database @@ -78,15 +78,15 @@ public final class SqliteCentralRepoSettings { try { String bulkThresholdString = ModuleSettings.getConfigSetting("CentralRepository", "db.sqlite.bulkThreshold"); // NON-NLS if (bulkThresholdString == null || bulkThresholdString.isEmpty()) { - this.bulkThreshold = AbstractCentralRepo.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = RelationalDbCentralRepo.DEFAULT_BULK_THRESHHOLD; } else { this.bulkThreshold = Integer.parseInt(bulkThresholdString); if (getBulkThreshold() <= 0) { - this.bulkThreshold = AbstractCentralRepo.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = RelationalDbCentralRepo.DEFAULT_BULK_THRESHHOLD; } } } catch (NumberFormatException ex) { - this.bulkThreshold = AbstractCentralRepo.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = RelationalDbCentralRepo.DEFAULT_BULK_THRESHHOLD; } } @@ -369,10 +369,10 @@ public final class SqliteCentralRepoSettings { * name column could be the primary key. */ stmt.execute("CREATE TABLE db_info (id INTEGER PRIMARY KEY, name TEXT UNIQUE NOT NULL, value TEXT NOT NULL)"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.CREATION_SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); - stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + AbstractCentralRepo.CREATION_SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + RelationalDbCentralRepo.SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + RelationalDbCentralRepo.SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + RelationalDbCentralRepo.CREATION_SCHEMA_MAJOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMajor() + "')"); + stmt.execute("INSERT INTO db_info (name, value) VALUES ('" + RelationalDbCentralRepo.CREATION_SCHEMA_MINOR_VERSION_KEY + "', '" + SOFTWARE_CR_DB_SCHEMA_VERSION.getMinor() + "')"); // Create a separate instance and reference table for each artifact type List DEFAULT_CORRELATION_TYPES = CorrelationAttributeInstance.getDefaultCorrelationTypes();