From 7d88e5a23a70956bb5f4a822fb78ab601ee81b48 Mon Sep 17 00:00:00 2001 From: "U-BASIS\\dgrove" Date: Fri, 25 May 2018 15:25:57 -0400 Subject: [PATCH 01/10] Fixed module ordering. --- .../org/sleuthkit/autopsy/ingest/DataSourceIngestJob.java | 6 +++--- .../sleuthkit/autopsy/ingest/IngestModuleFactoryLoader.java | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestJob.java b/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestJob.java index 93a1f1505d..6563dd3540 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestJob.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestJob.java @@ -22,7 +22,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.Date; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; @@ -224,8 +224,8 @@ public final class DataSourceIngestJob { /** * Make mappings of ingest module factory class names to templates. */ - Map dataSourceModuleTemplates = new HashMap<>(); - Map fileModuleTemplates = new HashMap<>(); + Map dataSourceModuleTemplates = new LinkedHashMap<>(); + Map fileModuleTemplates = new LinkedHashMap<>(); for (IngestModuleTemplate template : ingestModuleTemplates) { if (template.isDataSourceIngestModuleTemplate()) { dataSourceModuleTemplates.put(template.getModuleFactory().getClass().getCanonicalName(), template); diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleFactoryLoader.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleFactoryLoader.java index 3d2c66deb9..55c6a9f738 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleFactoryLoader.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleFactoryLoader.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2014 Basis Technology Corp. + * Copyright 2014-2018 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -38,6 +38,7 @@ import org.sleuthkit.autopsy.modules.hashdatabase.HashLookupModuleFactory; import org.sleuthkit.autopsy.modules.interestingitems.InterestingItemsIngestModuleFactory; import org.sleuthkit.autopsy.modules.photoreccarver.PhotoRecCarverIngestModuleFactory; import org.sleuthkit.autopsy.modules.embeddedfileextractor.EmbeddedFileExtractorModuleFactory; +import org.sleuthkit.autopsy.modules.encryptiondetection.EncryptionDetectionModuleFactory; import org.sleuthkit.autopsy.python.JythonModuleLoader; /** @@ -54,6 +55,7 @@ final class IngestModuleFactoryLoader { add("org.sleuthkit.autopsy.recentactivity.RecentActivityExtracterModuleFactory"); //NON-NLS add(HashLookupModuleFactory.class.getCanonicalName()); add(FileTypeIdModuleFactory.class.getCanonicalName()); + add(EncryptionDetectionModuleFactory.class.getCanonicalName()); add(EmbeddedFileExtractorModuleFactory.class.getCanonicalName()); add(ExifParserModuleFactory.class.getCanonicalName()); add("org.sleuthkit.autopsy.keywordsearch.KeywordSearchModuleFactory"); //NON-NLS From fa733a3acdf5c8ce335a2b4c6ed82c986c2df76e Mon Sep 17 00:00:00 2001 From: "U-BASIS\\dgrove" Date: Fri, 25 May 2018 15:31:24 -0400 Subject: [PATCH 02/10] Updated module ordering. --- .../org/sleuthkit/autopsy/ingest/IngestModuleFactoryLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleFactoryLoader.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleFactoryLoader.java index 55c6a9f738..a8df988a01 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleFactoryLoader.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleFactoryLoader.java @@ -55,13 +55,13 @@ final class IngestModuleFactoryLoader { add("org.sleuthkit.autopsy.recentactivity.RecentActivityExtracterModuleFactory"); //NON-NLS add(HashLookupModuleFactory.class.getCanonicalName()); add(FileTypeIdModuleFactory.class.getCanonicalName()); - add(EncryptionDetectionModuleFactory.class.getCanonicalName()); add(EmbeddedFileExtractorModuleFactory.class.getCanonicalName()); add(ExifParserModuleFactory.class.getCanonicalName()); add("org.sleuthkit.autopsy.keywordsearch.KeywordSearchModuleFactory"); //NON-NLS add("org.sleuthkit.autopsy.thunderbirdparser.EmailParserModuleFactory"); //NON-NLS add(FileExtMismatchDetectorModuleFactory.class.getCanonicalName()); add(E01VerifierModuleFactory.class.getCanonicalName()); + add(EncryptionDetectionModuleFactory.class.getCanonicalName()); add(InterestingItemsIngestModuleFactory.class.getCanonicalName()); add(PhotoRecCarverIngestModuleFactory.class.getCanonicalName()); } From e022f9666ce728b7f35d6f5150cd074d79d21345 Mon Sep 17 00:00:00 2001 From: Raman Date: Fri, 1 Jun 2018 08:17:22 -0400 Subject: [PATCH 03/10] 3877: Remove "Quick Tag" submenu --- .../autopsy/actions/AddTagAction.java | 49 +++++++++---------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/actions/AddTagAction.java b/Core/src/org/sleuthkit/autopsy/actions/AddTagAction.java index 7d0212b51c..6efb30e6a2 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/AddTagAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/AddTagAction.java @@ -83,7 +83,7 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup { */ // @@@ This user interface has some significant usability issues and needs // to be reworked. - private class TagMenu extends JMenu { + private final class TagMenu extends JMenu { private static final long serialVersionUID = 1L; @@ -99,13 +99,8 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup { Logger.getLogger(TagsManager.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS } - // Create a "Quick Tag" sub-menu. - JMenu quickTagMenu = new JMenu(NbBundle.getMessage(this.getClass(), "AddTagAction.quickTag")); - add(quickTagMenu); - - // Each tag name in the current set of tags gets its own menu item in - // the "Quick Tags" sub-menu. Selecting one of these menu items adds - // a tag with the associated tag name. + // Create a menu item for each of the existing and visible tags. + // Selecting one of these menu items adds a tag with the associated tag name. if (null != tagNamesMap && !tagNamesMap.isEmpty()) { for (Map.Entry entry : tagNamesMap.entrySet()) { String tagDisplayName = entry.getKey(); @@ -119,28 +114,15 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup { tagNameItem.addActionListener((ActionEvent e) -> { getAndAddTag(entry.getKey(), entry.getValue(), NO_COMMENT); }); - quickTagMenu.add(tagNameItem); + + add(tagNameItem); } - } else { - JMenuItem empty = new JMenuItem(NbBundle.getMessage(this.getClass(), "AddTagAction.noTags")); - empty.setEnabled(false); - quickTagMenu.add(empty); + } + + if (getItemCount() > 0) { + addSeparator(); } - quickTagMenu.addSeparator(); - - // The "Quick Tag" menu also gets an "Choose Tag..." menu item. - // Selecting this item initiates a dialog that can be used to create - // or select a tag name and adds a tag with the resulting name. - JMenuItem newTagMenuItem = new JMenuItem(NbBundle.getMessage(this.getClass(), "AddTagAction.newTag")); - newTagMenuItem.addActionListener((ActionEvent e) -> { - TagName tagName = GetTagNameDialog.doDialog(); - if (null != tagName) { - addTag(tagName, NO_COMMENT); - } - }); - quickTagMenu.add(newTagMenuItem); - // Create a "Choose Tag and Comment..." menu item. Selecting this item initiates // a dialog that can be used to create or select a tag name with an // optional comment and adds a tag with the resulting name. @@ -153,6 +135,19 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup { } }); add(tagAndCommentItem); + + // Create a "New Tag..." menu item. + // Selecting this item initiates a dialog that can be used to create + // or select a tag name and adds a tag with the resulting name. + JMenuItem newTagMenuItem = new JMenuItem(NbBundle.getMessage(this.getClass(), "AddTagAction.newTag")); + newTagMenuItem.addActionListener((ActionEvent e) -> { + TagName tagName = GetTagNameDialog.doDialog(); + if (null != tagName) { + addTag(tagName, NO_COMMENT); + } + }); + add(newTagMenuItem); + } /** From ebceb7e90d0c9b9c5e869bd3a319e97b4762916c Mon Sep 17 00:00:00 2001 From: rishwanth1995 Date: Mon, 4 Jun 2018 10:41:24 -0400 Subject: [PATCH 04/10] added new getArtifactBadInstances method to eamdb --- .../datamodel/AbstractSqlEamDb.java | 49 +++++++++++++++++++ .../centralrepository/datamodel/EamDb.java | 1 + .../datamodel/SqliteEamDb.java | 10 ++++ 3 files changed, 60 insertions(+) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java index 60cbb519e6..f8fdbadc4e 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java @@ -1245,6 +1245,55 @@ public abstract class AbstractSqlEamDb implements EamDb { return artifactInstances; } + + + @Override + public List getArtifactInstancesKnownBad(CorrelationAttribute.Type aType) throws EamDbException { + if (aType == null) { + throw new EamDbException("Correlation type is null"); + } + + Connection conn = connect(); + + List artifactInstances = new ArrayList<>(); + + CorrelationAttributeInstance artifactInstance; + PreparedStatement preparedStatement = null; + ResultSet resultSet = null; + + String tableName = EamDbUtil.correlationTypeToInstanceTableName(aType); + StringBuilder sql = new StringBuilder(); + sql.append("SELECT cases.case_name, cases.case_uid, data_sources.name, device_id, file_path, known_status, comment, data_sources.case_id FROM "); + sql.append(tableName); + sql.append(" LEFT JOIN cases ON "); + sql.append(tableName); + sql.append(".case_id=cases.id"); + sql.append(" LEFT JOIN data_sources ON "); + sql.append(tableName); + sql.append(".data_source_id=data_sources.id"); + sql.append(" WHERE known_status=?"); + sql.append(" GROUP BY "); + sql.append(tableName); + sql.append(".value"); + + try { + preparedStatement = conn.prepareStatement(sql.toString()); + preparedStatement.setByte(1, TskData.FileKnown.BAD.getFileKnownValue()); + resultSet = preparedStatement.executeQuery(); + while (resultSet.next()) { + artifactInstance = getEamArtifactInstanceFromResultSet(resultSet); + artifactInstances.add(artifactInstance); + } + } catch (SQLException ex) { + throw new EamDbException("Error getting notable artifact instances.", ex); // NON-NLS + } finally { + EamDbUtil.closePreparedStatement(preparedStatement); + EamDbUtil.closeResultSet(resultSet); + EamDbUtil.closeConnection(conn); + } + + return artifactInstances; + } /** * Count matching eamArtifacts instances that have knownStatus = "Bad". diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java index 2b05cb1d70..22aae11f48 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java @@ -329,6 +329,7 @@ public interface EamDb { */ List getArtifactInstancesKnownBad(CorrelationAttribute.Type aType, String value) throws EamDbException; + List getArtifactInstancesKnownBad(CorrelationAttribute.Type aType) throws EamDbException; /** * Count matching eamArtifacts instances that have knownStatus = "Bad". * diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java index d9d1ea2fa3..25d80be8a0 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java @@ -590,6 +590,16 @@ public class SqliteEamDb extends AbstractSqlEamDb { } } + @Override + public List getArtifactInstancesKnownBad(CorrelationAttribute.Type aType) throws EamDbException { + try{ + acquireSharedLock(); + return super.getArtifactInstancesKnownBad(aType); + } finally { + releaseSharedLock(); + } + } + /** * Count matching eamArtifacts instances that have knownStatus = "Bad". * From 3eb841bd519f2576abce9ca04028a3beb6384382 Mon Sep 17 00:00:00 2001 From: rishwanth1995 Date: Wed, 6 Jun 2018 09:24:25 -0400 Subject: [PATCH 05/10] added new getArtifactInstancesKnownBad --- .../centralrepository/datamodel/AbstractSqlEamDb.java | 9 ++++++++- .../autopsy/centralrepository/datamodel/EamDb.java | 8 ++++++++ .../autopsy/centralrepository/datamodel/SqliteEamDb.java | 8 ++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java index f8fdbadc4e..61eaad071f 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java @@ -1246,7 +1246,14 @@ public abstract class AbstractSqlEamDb implements EamDb { return artifactInstances; } - + /** + * + * Gets list of matching eamArtifact instances that have knownStatus = + * "Bad". + * @param aType EamArtifact.Type to search for + * @return List with 0 or more matching eamArtifact instances. + * @throws EamDbException + */ @Override public List getArtifactInstancesKnownBad(CorrelationAttribute.Type aType) throws EamDbException { if (aType == null) { diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java index 22aae11f48..dc02011892 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java @@ -329,6 +329,14 @@ public interface EamDb { */ List getArtifactInstancesKnownBad(CorrelationAttribute.Type aType, String value) throws EamDbException; + /** + * Gets list of matching eamArtifact instances that have knownStatus = + * "Bad". + * + * @param aType EamArtifact.Type to search for + * @return List with 0 or more matching eamArtifact instances. + * @throws EamDbException + */ List getArtifactInstancesKnownBad(CorrelationAttribute.Type aType) throws EamDbException; /** * Count matching eamArtifacts instances that have knownStatus = "Bad". diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java index 25d80be8a0..3d9fb6b6e1 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java @@ -590,6 +590,14 @@ public class SqliteEamDb extends AbstractSqlEamDb { } } + /** + * + * Gets list of matching eamArtifact instances that have knownStatus = + * "Bad". + * @param aType EamArtifact.Type to search for + * @return List with 0 or more matching eamArtifact instances. + * @throws EamDbException + */ @Override public List getArtifactInstancesKnownBad(CorrelationAttribute.Type aType) throws EamDbException { try{ From c6e3cc4c9433b27cb56b8e74944762f22a6779bf Mon Sep 17 00:00:00 2001 From: Brian Carrier Date: Wed, 6 Jun 2018 22:44:57 -0400 Subject: [PATCH 06/10] reduced public API, minor refactor, added some comments --- .../datamodel/AbstractSqlEamDb.java | 31 ++++++++++--------- .../CorrelationAttributeInstance.java | 15 --------- .../datamodel/CorrelationDataSource.java | 20 +++++++----- .../datamodel/EamArtifactUtil.java | 6 ++-- .../centralrepository/datamodel/EamDb.java | 4 +-- .../datamodel/EamOrganization.java | 4 +-- .../datamodel/PostgresEamDb.java | 4 +-- .../datamodel/PostgresEamDbSettings.java | 16 +++++----- .../datamodel/SqliteEamDb.java | 5 ++- .../datamodel/SqliteEamDbSettings.java | 16 +++++----- .../AddNewOrganizationDialog.java | 2 +- .../datamodel/CentralRepoDatamodelTest.java | 31 ++++++++++--------- 12 files changed, 75 insertions(+), 79 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java index 60cbb519e6..195f9c0612 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java @@ -46,10 +46,10 @@ import org.sleuthkit.datamodel.TskData; /** * - * SQLite manager implementation + * Generic JDBC methods * */ -public abstract class AbstractSqlEamDb implements EamDb { +abstract class AbstractSqlEamDb implements EamDb { private final static Logger LOGGER = Logger.getLogger(AbstractSqlEamDb.class.getName()); @@ -425,6 +425,12 @@ public abstract class AbstractSqlEamDb implements EamDb { */ @Override public void newDataSource(CorrelationDataSource eamDataSource) throws EamDbException { + if (eamDataSource.getCaseID() == -1) { + throw new EamDbException("Case ID is -1"); + } + else if (eamDataSource.getID() != -1) { + throw new EamDbException("Database ID is already set in object"); + } Connection conn = connect(); PreparedStatement preparedStatement = null; @@ -1527,20 +1533,15 @@ public abstract class AbstractSqlEamDb implements EamDb { return 0 < badInstances; } - /** - * Add a new organization - * - * @return the Organization ID of the newly created organization. - * - * @param eamOrg The organization to add - * - * @throws EamDbException - */ + @Override - public long newOrganization(EamOrganization eamOrg) throws EamDbException { - if(eamOrg == null) { + public EamOrganization newOrganization(EamOrganization eamOrg) throws EamDbException { + if (eamOrg == null) { throw new EamDbException("EamOrganization is null"); } + else if (eamOrg.getOrgID() != -1) { + throw new EamDbException("EamOrganization already has an ID"); + } Connection conn = connect(); ResultSet generatedKeys = null; @@ -1558,7 +1559,8 @@ public abstract class AbstractSqlEamDb implements EamDb { preparedStatement.executeUpdate(); generatedKeys = preparedStatement.getGeneratedKeys(); if (generatedKeys.next()) { - return generatedKeys.getLong(1); + eamOrg.setOrgID((int)generatedKeys.getLong(1)); + return eamOrg; } else { throw new SQLException("Creating user failed, no ID obtained."); } @@ -2351,6 +2353,7 @@ public abstract class AbstractSqlEamDb implements EamDb { if (null == resultSet) { return null; } + // @@@ We should have data source ID in the previous query instead of passing -1 into the below constructor CorrelationAttributeInstance eamArtifactInstance = new CorrelationAttributeInstance( new CorrelationCase(resultSet.getInt("case_id"), resultSet.getString("case_uid"), resultSet.getString("case_name")), new CorrelationDataSource(-1, resultSet.getInt("case_id"), resultSet.getString("device_id"), resultSet.getString("name")), diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java index 9e0c3b6cec..d20fbc3b29 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeInstance.java @@ -43,13 +43,6 @@ public class CorrelationAttributeInstance implements Serializable { private String comment; private TskData.FileKnown knownStatus; - public CorrelationAttributeInstance( - CorrelationCase eamCase, - CorrelationDataSource eamDataSource - ) throws EamDbException { - this(-1, eamCase, eamDataSource, "", null, TskData.FileKnown.UNKNOWN); - } - public CorrelationAttributeInstance( CorrelationCase eamCase, CorrelationDataSource eamDataSource, @@ -58,14 +51,6 @@ public class CorrelationAttributeInstance implements Serializable { this(-1, eamCase, eamDataSource, filePath, null, TskData.FileKnown.UNKNOWN); } - public CorrelationAttributeInstance( - CorrelationCase eamCase, - CorrelationDataSource eamDataSource, - String filePath, - String comment - ) throws EamDbException { - this(-1, eamCase, eamDataSource, filePath, comment, TskData.FileKnown.UNKNOWN); - } public CorrelationAttributeInstance( CorrelationCase eamCase, diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationDataSource.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationDataSource.java index 864bf50923..264c70fc66 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationDataSource.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationDataSource.java @@ -40,15 +40,21 @@ public class CorrelationDataSource implements Serializable { private final String name; /** - * - * @param caseId - * @param deviceId - * @param name + * @param correlationCase CorrelationCase object data source is associated with. Must have been created by EamDB and have a valid ID. + * @param deviceId User specified case-specific ID + * @param name Display name of data source */ - public CorrelationDataSource(int caseId, String deviceId, String name) { - this(caseId, -1, deviceId, name); + public CorrelationDataSource(CorrelationCase correlationCase, String deviceId, String name) { + this(correlationCase.getID(), -1, deviceId, name); } + /** + * + * @param caseId Row ID for Case in DB + * @param dataSourceId Row ID for this data source in DB (or -1) + * @param deviceId User specified ID for device (unique per case) + * @param name User specified name + */ CorrelationDataSource(int caseId, int dataSourceId, String deviceId, @@ -102,7 +108,7 @@ public class CorrelationDataSource implements Serializable { /** * Get the database row ID * - * @return the ID + * @return the ID or -1 if unknown */ int getID() { return dataSourceID; diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamArtifactUtil.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamArtifactUtil.java index 84c23256f0..155e88fe98 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamArtifactUtil.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamArtifactUtil.java @@ -76,9 +76,9 @@ public class EamArtifactUtil { // have switch based on artifact type for (CorrelationAttribute.Type aType : EamDb.getInstance().getDefinedCorrelationTypes()) { if ((checkEnabled && aType.isEnabled()) || !checkEnabled) { - CorrelationAttribute eamArtifact = EamArtifactUtil.getCorrelationAttributeFromBlackboardArtifact(aType, bbArtifact); - if (eamArtifact != null) { - eamArtifacts.add(eamArtifact); + CorrelationAttribute correlationAttribute = EamArtifactUtil.getCorrelationAttributeFromBlackboardArtifact(aType, bbArtifact); + if (correlationAttribute != null) { + eamArtifacts.add(correlationAttribute); } } } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java index 2b05cb1d70..2522a68080 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java @@ -422,11 +422,11 @@ public interface EamDb { * * @param eamOrg The organization to add * - * @return the Organization ID of the newly created organization. + * @return The organization with the org ID set. * * @throws EamDbException */ - long newOrganization(EamOrganization eamOrg) throws EamDbException; + EamOrganization newOrganization(EamOrganization eamOrg) throws EamDbException; /** * Get all organizations diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamOrganization.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamOrganization.java index 3bebf6d5f3..a59a346167 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamOrganization.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamOrganization.java @@ -84,7 +84,7 @@ public class EamOrganization { /** * @param orgID the orgID to set */ - public void setOrgID(int orgID) { + void setOrgID(int orgID) { this.orgID = orgID; } @@ -98,7 +98,7 @@ public class EamOrganization { /** * @param name the name to set */ - public void setName(String name) { + void setName(String name) { this.name = name; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDb.java index 46d579ad87..fa4301216e 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDb.java @@ -24,8 +24,6 @@ import java.sql.Statement; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import org.apache.commons.dbcp2.BasicDataSource; -import org.sleuthkit.autopsy.casemodule.CaseActionCancelledException; -import org.sleuthkit.autopsy.casemodule.CaseActionException; import org.sleuthkit.autopsy.coordinationservice.CoordinationService; import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.coreutils.Logger; @@ -34,7 +32,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; * Central Repository database implementation using Postgres as a * backend */ -public class PostgresEamDb extends AbstractSqlEamDb { +class PostgresEamDb extends AbstractSqlEamDb { private final static Logger LOGGER = Logger.getLogger(PostgresEamDb.class.getName()); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDbSettings.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDbSettings.java index 37a2970082..c0e3e53521 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDbSettings.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDbSettings.java @@ -35,6 +35,8 @@ import org.sleuthkit.autopsy.coreutils.TextConverterException; /** * Settings for the Postgres implementation of the Central Repository database + * + * NOTE: This is public scope because the options panel calls it directly to set/get */ public final class PostgresEamDbSettings { @@ -139,7 +141,7 @@ public final class PostgresEamDbSettings { * * @return */ - public String getConnectionURL(boolean usePostgresDb) { + String getConnectionURL(boolean usePostgresDb) { StringBuilder url = new StringBuilder(); url.append(getJDBCBaseURI()); url.append(getHost()); @@ -231,7 +233,7 @@ public final class PostgresEamDbSettings { * Use the current settings and the schema version query to test the * database schema. * - * @return true if successfull connection, else false. + * @return true if successful connection, else false. */ public boolean verifyDatabaseSchema() { Connection conn = getEphemeralConnection(false); @@ -493,7 +495,7 @@ public final class PostgresEamDbSettings { return result; } - public boolean isChanged() { + boolean isChanged() { String hostString = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.host"); // NON-NLS String portString = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.port"); // NON-NLS String dbNameString = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.dbName"); // NON-NLS @@ -568,7 +570,7 @@ public final class PostgresEamDbSettings { /** * @return the bulkThreshold */ - public int getBulkThreshold() { + int getBulkThreshold() { return bulkThreshold; } @@ -622,21 +624,21 @@ public final class PostgresEamDbSettings { /** * @return the VALIDATION_QUERY */ - public String getValidationQuery() { + String getValidationQuery() { return VALIDATION_QUERY; } /** * @return the POSTGRES_DRIVER */ - public String getDriver() { + String getDriver() { return JDBC_DRIVER; } /** * @return the JDBC_BASE_URI */ - public String getJDBCBaseURI() { + String getJDBCBaseURI() { return JDBC_BASE_URI; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java index d9d1ea2fa3..e0d8008f79 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java @@ -18,7 +18,6 @@ */ package org.sleuthkit.autopsy.centralrepository.datamodel; -import java.io.File; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; @@ -38,7 +37,7 @@ import org.sleuthkit.autopsy.coordinationservice.CoordinationService; * All methods in AbstractSqlEamDb that read or write to the database should * be overriden here and use appropriate locking. */ -public class SqliteEamDb extends AbstractSqlEamDb { +class SqliteEamDb extends AbstractSqlEamDb { private final static Logger LOGGER = Logger.getLogger(SqliteEamDb.class.getName()); @@ -708,7 +707,7 @@ public class SqliteEamDb extends AbstractSqlEamDb { * @throws EamDbException */ @Override - public long newOrganization(EamOrganization eamOrg) throws EamDbException { + public EamOrganization newOrganization(EamOrganization eamOrg) throws EamDbException { try{ acquireExclusiveLock(); return super.newOrganization(eamOrg); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDbSettings.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDbSettings.java index f006cc7e24..53f51d0038 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDbSettings.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDbSettings.java @@ -35,6 +35,8 @@ import org.sleuthkit.autopsy.coreutils.PlatformUtil; /** * Settings for the sqlite implementation of the Central Repository database + * + * NOTE: This is public scope because the options panel calls it directly to set/get */ public final class SqliteEamDbSettings { @@ -162,7 +164,7 @@ public final class SqliteEamDbSettings { * * @return */ - public String getConnectionURL() { + String getConnectionURL() { StringBuilder url = new StringBuilder(); url.append(getJDBCBaseURI()); url.append(getFileNameWithPath()); @@ -439,7 +441,7 @@ public final class SqliteEamDbSettings { return result; } - public boolean isChanged() { + boolean isChanged() { String dbNameString = ModuleSettings.getConfigSetting("CentralRepository", "db.sqlite.dbName"); // NON-NLS String dbDirectoryString = ModuleSettings.getConfigSetting("CentralRepository", "db.sqlite.dbDirectory"); // NON-NLS String bulkThresholdString = ModuleSettings.getConfigSetting("CentralRepository", "db.sqlite.bulkThreshold"); // NON-NLS @@ -474,14 +476,14 @@ public final class SqliteEamDbSettings { /** * @return the bulkThreshold */ - public int getBulkThreshold() { + int getBulkThreshold() { return bulkThreshold; } /** * @param bulkThreshold the bulkThreshold to set */ - public void setBulkThreshold(int bulkThreshold) throws EamDbException { + void setBulkThreshold(int bulkThreshold) throws EamDbException { if (bulkThreshold > 0) { this.bulkThreshold = bulkThreshold; } else { @@ -525,21 +527,21 @@ public final class SqliteEamDbSettings { /** * @return the DRIVER */ - public String getDriver() { + String getDriver() { return JDBC_DRIVER; } /** * @return the VALIDATION_QUERY */ - public String getValidationQuery() { + String getValidationQuery() { return VALIDATION_QUERY; } /** * @return the JDBC_BASE_URI */ - public String getJDBCBaseURI() { + String getJDBCBaseURI() { return JDBC_BASE_URI; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/AddNewOrganizationDialog.java b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/AddNewOrganizationDialog.java index 5ebfd1a629..c5823b131c 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/AddNewOrganizationDialog.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/AddNewOrganizationDialog.java @@ -345,7 +345,7 @@ public class AddNewOrganizationDialog extends javax.swing.JDialog { tfPocName.getText(), tfPocEmail.getText(), tfPocPhone.getText()); - newOrg.setOrgID((int)dbManager.newOrganization(newOrg)); + newOrg = dbManager.newOrganization(newOrg); } hasChanged = true; dispose(); 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 99dbd9204d..3cb33e7b1c 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 @@ -128,26 +128,26 @@ public class CentralRepoDatamodelTest extends TestCase { case2 = EamDb.getInstance().newCase(case2); assertTrue("Failed to create test object case2", case2 != null); - dataSource1fromCase1 = new CorrelationDataSource(case1.getID(), "dataSource1_deviceID", "dataSource1"); + dataSource1fromCase1 = new CorrelationDataSource(case1, "dataSource1_deviceID", "dataSource1"); EamDb.getInstance().newDataSource(dataSource1fromCase1); dataSource1fromCase1 = EamDb.getInstance().getDataSource(case1, dataSource1fromCase1.getDeviceID()); assertTrue("Failed to create test object dataSource1fromCase1", dataSource1fromCase1 != null); - dataSource2fromCase1 = new CorrelationDataSource(case1.getID(), "dataSource2_deviceID", "dataSource2"); + dataSource2fromCase1 = new CorrelationDataSource(case1, "dataSource2_deviceID", "dataSource2"); EamDb.getInstance().newDataSource(dataSource2fromCase1); dataSource2fromCase1 = EamDb.getInstance().getDataSource(case1, dataSource2fromCase1.getDeviceID()); assertTrue("Failed to create test object dataSource2fromCase1", dataSource2fromCase1 != null); - dataSource1fromCase2 = new CorrelationDataSource(case2.getID(), "dataSource3_deviceID", "dataSource3"); + dataSource1fromCase2 = new CorrelationDataSource(case2, "dataSource3_deviceID", "dataSource3"); EamDb.getInstance().newDataSource(dataSource1fromCase2); dataSource1fromCase2 = EamDb.getInstance().getDataSource(case2, dataSource1fromCase2.getDeviceID()); assertTrue("Failed to create test object dataSource1fromCase2", dataSource1fromCase2 != null); org1 = new EamOrganization("org1"); - org1.setOrgID((int) EamDb.getInstance().newOrganization(org1)); + org1 = EamDb.getInstance().newOrganization(org1); org2 = new EamOrganization("org2"); - org2.setOrgID((int) EamDb.getInstance().newOrganization(org2)); + org2 = EamDb.getInstance().newOrganization(org2); // Store the file type object for later use fileType = EamDb.getInstance().getCorrelationTypeById(CorrelationAttribute.FILES_TYPE_ID); @@ -781,7 +781,7 @@ public class CentralRepoDatamodelTest extends TestCase { // Test adding instance with invalid data source ID try { - CorrelationDataSource badDS = new CorrelationDataSource(case1.getID(), "badDSUuid", "badDSName"); + CorrelationDataSource badDS = new CorrelationDataSource(case1, "badDSUuid", "badDSName"); CorrelationAttributeInstance inst = new CorrelationAttributeInstance(case1, badDS, "badPath"); failAttr.addInstance(inst); EamDb.getInstance().addArtifact(failAttr); @@ -1283,7 +1283,7 @@ public class CentralRepoDatamodelTest extends TestCase { // Test adding a basic organization try { orgA = new EamOrganization(orgAname); - orgA.setOrgID((int) EamDb.getInstance().newOrganization(orgA)); + orgA = EamDb.getInstance().newOrganization(orgA); assertTrue("Organization ID is still -1 after adding to db", orgA.getOrgID() != -1); } catch (EamDbException ex) { Exceptions.printStackTrace(ex); @@ -1294,7 +1294,7 @@ public class CentralRepoDatamodelTest extends TestCase { // Test adding an organization with additional fields try { orgB = new EamOrganization(orgBname, orgBpocName, orgBpocEmail, orgBpocPhone); - orgB.setOrgID((int) EamDb.getInstance().newOrganization(orgB)); + orgB = EamDb.getInstance().newOrganization(orgB); assertTrue("Organization ID is still -1 after adding to db", orgB.getOrgID() != -1); } catch (EamDbException ex) { Exceptions.printStackTrace(ex); @@ -1417,7 +1417,7 @@ public class CentralRepoDatamodelTest extends TestCase { // Test deleting existing org that isn't in use try { EamOrganization orgToDelete = new EamOrganization("deleteThis"); - orgToDelete.setOrgID((int) EamDb.getInstance().newOrganization(orgToDelete)); + orgToDelete = EamDb.getInstance().newOrganization(orgToDelete); int orgCount = EamDb.getInstance().getOrganizations().size(); EamDb.getInstance().deleteOrganization(orgToDelete); @@ -2141,7 +2141,7 @@ public class CentralRepoDatamodelTest extends TestCase { // Test creating a data source with valid case, name, and ID try { - dataSourceA = new CorrelationDataSource(case2.getID(), dataSourceAid, dataSourceAname); + dataSourceA = new CorrelationDataSource(case2, dataSourceAid, dataSourceAname); EamDb.getInstance().newDataSource(dataSourceA); } catch (EamDbException ex) { Exceptions.printStackTrace(ex); @@ -2151,7 +2151,7 @@ public class CentralRepoDatamodelTest extends TestCase { // Test creating a data source with the same case, name, and ID try { - CorrelationDataSource temp = new CorrelationDataSource(case2.getID(), dataSourceAid, dataSourceAname); + CorrelationDataSource temp = new CorrelationDataSource(case2, dataSourceAid, dataSourceAname); EamDb.getInstance().newDataSource(temp); Assert.fail("newDataSource did not throw exception from duplicate data source"); } catch (EamDbException ex) { @@ -2160,7 +2160,7 @@ public class CentralRepoDatamodelTest extends TestCase { // Test creating a data source with the same name and ID but different case try { - dataSourceB = new CorrelationDataSource(case1.getID(), dataSourceAid, dataSourceAname); + dataSourceB = new CorrelationDataSource(case1, dataSourceAid, dataSourceAname); EamDb.getInstance().newDataSource(dataSourceB); } catch (EamDbException ex) { Exceptions.printStackTrace(ex); @@ -2170,7 +2170,8 @@ public class CentralRepoDatamodelTest extends TestCase { // Test creating a data source with an invalid case ID try { - CorrelationDataSource temp = new CorrelationDataSource(5000, "tempID", "tempName"); + CorrelationCase correlationCase = new CorrelationCase("1", "test"); + CorrelationDataSource temp = new CorrelationDataSource(correlationCase, "tempID", "tempName"); EamDb.getInstance().newDataSource(temp); Assert.fail("newDataSource did not throw exception from invalid case ID"); } catch (EamDbException ex) { @@ -2179,7 +2180,7 @@ public class CentralRepoDatamodelTest extends TestCase { // Test creating a data source with null device ID try { - CorrelationDataSource temp = new CorrelationDataSource(case2.getID(), null, "tempName"); + CorrelationDataSource temp = new CorrelationDataSource(case2, null, "tempName"); EamDb.getInstance().newDataSource(temp); Assert.fail("newDataSource did not throw exception from null device ID"); } catch (EamDbException ex) { @@ -2188,7 +2189,7 @@ public class CentralRepoDatamodelTest extends TestCase { // Test creating a data source with null name try { - CorrelationDataSource temp = new CorrelationDataSource(case2.getID(), "tempID", null); + CorrelationDataSource temp = new CorrelationDataSource(case2, "tempID", null); EamDb.getInstance().newDataSource(temp); Assert.fail("newDataSource did not throw exception from null name"); } catch (EamDbException ex) { From 7f51cc4402fd40afaa7a4ecb954b935bed3f5509 Mon Sep 17 00:00:00 2001 From: rishwanth1995 Date: Thu, 7 Jun 2018 10:18:11 -0400 Subject: [PATCH 07/10] added logic to respond for selection in view artifact added if-else logic to manually respond to the selection if the node remains the same in the tree view. --- .../directorytree/DirectoryTreeTopComponent.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java b/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java index 0fd19c98a1..24edc21909 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java @@ -1059,10 +1059,15 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat DisplayableItemNode undecoratedParentNode = (DisplayableItemNode) ((DirectoryTreeFilterNode) treeNode).getOriginal(); undecoratedParentNode.setChildNodeSelectionInfo(new ArtifactNodeSelectionInfo(art)); getTree().expandNode(treeNode); - try { - em.setExploredContextAndSelection(treeNode, new Node[]{treeNode}); - } catch (PropertyVetoException ex) { - LOGGER.log(Level.WARNING, "Property Veto: ", ex); //NON-NLS + if (this.getSelectedNode().equals(treeNode)) { + this.setDirectoryListingActive(); + this.respondSelection(em.getSelectedNodes(), new Node[]{treeNode}); + } else { + try { + em.setExploredContextAndSelection(treeNode, new Node[]{treeNode}); + } catch (PropertyVetoException ex) { + LOGGER.log(Level.WARNING, "Property Veto: ", ex); //NON-NLS + } } // Another thread is needed because we have to wait for dataResult to populate } From 15d4185c470bde5d2336ec5f47f8daa41849af68 Mon Sep 17 00:00:00 2001 From: Brian Carrier Date: Thu, 7 Jun 2018 13:45:04 -0400 Subject: [PATCH 08/10] fix tests, more API reduction --- .../datamodel/AbstractSqlEamDb.java | 24 +++++++++++---- .../centralrepository/datamodel/EamDb.java | 4 +++ .../datamodel/EamOrganization.java | 4 +-- .../datamodel/PostgresEamDbSettings.java | 7 ++--- .../datamodel/SqliteEamDbSettings.java | 7 ++--- .../AddNewOrganizationDialog.java | 27 ++++++++++++----- .../datamodel/CentralRepoDatamodelTest.java | 29 +++++++++---------- 7 files changed, 63 insertions(+), 39 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java index 195f9c0612..0d08c43209 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java @@ -1656,6 +1656,22 @@ abstract class AbstractSqlEamDb implements EamDb { return (getOrganizationByID(globalSet.getOrgID())); } + /** + * Tests that an organization passed in as an argument is valid + * + * @param org + * @throws EamDbException if invalid + */ + private void testArgument(EamOrganization org) throws EamDbException { + if(org == null) { + throw new EamDbException("Organization is null"); + } + else if (org.getOrgID() == -1) { + throw new EamDbException("Organization has -1 row ID"); + } + } + + /** * Update an existing organization. * @@ -1666,9 +1682,7 @@ abstract class AbstractSqlEamDb implements EamDb { */ @Override public void updateOrganization(EamOrganization updatedOrganization) throws EamDbException { - if(updatedOrganization == null) { - throw new EamDbException("null updatedOrganization"); - } + testArgument(updatedOrganization); Connection conn = connect(); PreparedStatement preparedStatement = null; @@ -1694,9 +1708,7 @@ abstract class AbstractSqlEamDb implements EamDb { "AbstractSqlEamDb.deleteOrganization.errorDeleting.message=Error executing query when attempting to delete organization by id."}) @Override public void deleteOrganization(EamOrganization organizationToDelete) throws EamDbException { - if(organizationToDelete == null) { - throw new EamDbException("Organization to delete is null"); - } + testArgument(organizationToDelete); Connection conn = connect(); PreparedStatement checkIfUsedStatement = null; diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java index 2522a68080..1eede8d129 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java @@ -35,6 +35,10 @@ public interface EamDb { public static final CaseDbSchemaVersionNumber CURRENT_DB_SCHEMA_VERSION = new CaseDbSchemaVersionNumber(1, 1); + // number of instances to keep in bulk queue before doing an insert. + // Update Test code if this changes. It's hard coded there. + static final int DEFAULT_BULK_THRESHHOLD = 1000; + /** * Get the instance * diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamOrganization.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamOrganization.java index a59a346167..ba88798128 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamOrganization.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamOrganization.java @@ -29,7 +29,7 @@ public class EamOrganization { private String pocEmail; private String pocPhone; - public EamOrganization( + EamOrganization( int orgID, String name, String pocName, @@ -98,7 +98,7 @@ public class EamOrganization { /** * @param name the name to set */ - void setName(String name) { + public void setName(String name) { this.name = name; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDbSettings.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDbSettings.java index c0e3e53521..9c78d9b275 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDbSettings.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDbSettings.java @@ -44,7 +44,6 @@ public final class PostgresEamDbSettings { private final String DEFAULT_HOST = ""; // NON-NLS private final int DEFAULT_PORT = 5432; private final String DEFAULT_DBNAME = "central_repository"; // NON-NLS - private final int DEFAULT_BULK_THRESHHOLD = 1000; private final String DEFAULT_USERNAME = ""; private final String DEFAULT_PASSWORD = ""; private final String VALIDATION_QUERY = "SELECT version()"; // NON-NLS @@ -91,15 +90,15 @@ public final class PostgresEamDbSettings { try { String bulkThresholdString = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.bulkThreshold"); // NON-NLS if (bulkThresholdString == null || bulkThresholdString.isEmpty()) { - this.bulkThreshold = DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = EamDb.DEFAULT_BULK_THRESHHOLD; } else { this.bulkThreshold = Integer.parseInt(bulkThresholdString); if (getBulkThreshold() <= 0) { - this.bulkThreshold = DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = EamDb.DEFAULT_BULK_THRESHHOLD; } } } catch (NumberFormatException ex) { - this.bulkThreshold = DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = EamDb.DEFAULT_BULK_THRESHHOLD; } userName = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.user"); // NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDbSettings.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDbSettings.java index 53f51d0038..4c463cadc2 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDbSettings.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDbSettings.java @@ -43,7 +43,6 @@ public final class SqliteEamDbSettings { private final static Logger LOGGER = Logger.getLogger(SqliteEamDbSettings.class.getName()); private final String DEFAULT_DBNAME = "central_repository.db"; // NON-NLS private final String DEFAULT_DBDIRECTORY = PlatformUtil.getUserDirectory() + File.separator + "central_repository"; // NON-NLS - private final int DEFAULT_BULK_THRESHHOLD = 1000; private final String JDBC_DRIVER = "org.sqlite.JDBC"; // NON-NLS private final String JDBC_BASE_URI = "jdbc:sqlite:"; // NON-NLS private final String VALIDATION_QUERY = "SELECT count(*) from sqlite_master"; // NON-NLS @@ -77,15 +76,15 @@ public final class SqliteEamDbSettings { try { String bulkThresholdString = ModuleSettings.getConfigSetting("CentralRepository", "db.sqlite.bulkThreshold"); // NON-NLS if (bulkThresholdString == null || bulkThresholdString.isEmpty()) { - this.bulkThreshold = DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = EamDb.DEFAULT_BULK_THRESHHOLD; } else { this.bulkThreshold = Integer.parseInt(bulkThresholdString); if (getBulkThreshold() <= 0) { - this.bulkThreshold = DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = EamDb.DEFAULT_BULK_THRESHHOLD; } } } catch (NumberFormatException ex) { - this.bulkThreshold = DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = EamDb.DEFAULT_BULK_THRESHHOLD; } } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/AddNewOrganizationDialog.java b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/AddNewOrganizationDialog.java index c5823b131c..ed62adb34a 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/AddNewOrganizationDialog.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/optionspanel/AddNewOrganizationDialog.java @@ -36,7 +36,7 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; /** * Dialog to add a new organization to the Central Repository database */ -public class AddNewOrganizationDialog extends javax.swing.JDialog { +class AddNewOrganizationDialog extends javax.swing.JDialog { private static final Logger LOGGER = Logger.getLogger(AddNewOrganizationDialog.class.getName()); private static final long serialVersionUID = 1L; @@ -51,7 +51,7 @@ public class AddNewOrganizationDialog extends javax.swing.JDialog { * Creates new form AddNewOrganizationDialog */ @Messages({"AddNewOrganizationDialog.addNewOrg.msg=Add New Organization"}) - public AddNewOrganizationDialog() { + AddNewOrganizationDialog() { super((JFrame) WindowManager.getDefault().getMainWindow(), Bundle.AddNewOrganizationDialog_addNewOrg_msg(), true); // NON-NLS @@ -65,6 +65,7 @@ public class AddNewOrganizationDialog extends javax.swing.JDialog { display(); } + // populates the dialog with existing case information to edit public AddNewOrganizationDialog(EamOrganization orgToEdit) { super((JFrame) WindowManager.getDefault().getMainWindow(), Bundle.AddNewOrganizationDialog_addNewOrg_msg(), @@ -193,10 +194,19 @@ public class AddNewOrganizationDialog extends javax.swing.JDialog { } } + /** + * + * @return True if new org was added or existing org changed + */ public boolean isChanged() { return hasChanged; } + /** + * Only valid if isChanged() is true. + * + * @return Org that was added or changed. null if nothing changed + */ public EamOrganization getNewOrg() { return newOrg; } @@ -332,12 +342,12 @@ public class AddNewOrganizationDialog extends javax.swing.JDialog { try { EamDb dbManager = EamDb.getInstance(); if (organizationToEdit != null) { - //check if new name exists with ID other than the one in use here - newOrg = new EamOrganization(organizationToEdit.getOrgID(), - tfOrganizationName.getText(), - tfPocName.getText(), - tfPocEmail.getText(), - tfPocPhone.getText()); + // make a copy in case the update fails + newOrg = dbManager.getOrganizationByID(organizationToEdit.getOrgID()); + newOrg.setName(tfOrganizationName.getText()); + newOrg.setPocName(tfPocName.getText()); + newOrg.setPocEmail(tfPocEmail.getText()); + newOrg.setPocPhone(tfPocPhone.getText()); dbManager.updateOrganization(newOrg); } else { newOrg = new EamOrganization( @@ -352,6 +362,7 @@ public class AddNewOrganizationDialog extends javax.swing.JDialog { } catch (EamDbException ex) { lbWarningMsg.setText(Bundle.AddNewOrganizationDialog_bnOk_addFailed_text()); LOGGER.log(Level.SEVERE, "Failed adding new organization.", ex); + newOrg = null; } }//GEN-LAST:event_bnOKActionPerformed 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 3cb33e7b1c..0f0e950ec6 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 @@ -51,6 +51,8 @@ public class CentralRepoDatamodelTest extends TestCase { private static final String PROPERTIES_FILE = "CentralRepository"; private static final String CR_DB_NAME = "testcentralrepo.db"; 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; private CorrelationCase case1; @@ -467,7 +469,7 @@ public class CentralRepoDatamodelTest extends TestCase { // Create the first list, which will have (bulkThreshold / 2) entries List list1 = new ArrayList<>(); - for (int i = 0; i < dbSettingsSqlite.getBulkThreshold() / 2; i++) { + for (int i = 0; i < DEFAULT_BULK_THRESHOLD / 2; i++) { String value = "bulkInsertValue1_" + String.valueOf(i); String path = "C:\\bulkInsertPath1\\file" + String.valueOf(i); @@ -487,7 +489,7 @@ public class CentralRepoDatamodelTest extends TestCase { // Make a second list with length equal to bulkThreshold List list2 = new ArrayList<>(); - for (int i = 0; i < dbSettingsSqlite.getBulkThreshold(); i++) { + for (int i = 0; i < DEFAULT_BULK_THRESHOLD; i++) { String value = "bulkInsertValue2_" + String.valueOf(i); String path = "C:\\bulkInsertPath2\\file" + String.valueOf(i); @@ -503,7 +505,7 @@ public class CentralRepoDatamodelTest extends TestCase { // There should now be bulkThreshold artifacts in the database long count = EamDb.getInstance().getCountArtifactInstancesByCaseDataSource(case1.getCaseUUID(), dataSource1fromCase1.getDeviceID()); - assertTrue("Artifact count " + count + " does not match bulkThreshold " + dbSettingsSqlite.getBulkThreshold(), count == dbSettingsSqlite.getBulkThreshold()); + assertTrue("Artifact count " + count + " does not match bulkThreshold " + DEFAULT_BULK_THRESHOLD, count == DEFAULT_BULK_THRESHOLD); // Now call bulkInsertArtifacts() to insert the rest of queue EamDb.getInstance().bulkInsertArtifacts(); @@ -1386,14 +1388,13 @@ public class CentralRepoDatamodelTest extends TestCase { } // Test updating invalid org - // Shouldn't do anything + try { EamOrganization temp = new EamOrganization("invalidOrg"); - temp.setOrgID(3434); EamDb.getInstance().updateOrganization(temp); + Assert.fail("updateOrganization worked for invalid ID"); } catch (EamDbException ex) { - Exceptions.printStackTrace(ex); - Assert.fail(ex); + // this is the expected behavior } // Test updating null org @@ -1431,7 +1432,7 @@ public class CentralRepoDatamodelTest extends TestCase { try { // Make a new org EamOrganization inUseOrg = new EamOrganization("inUseOrg"); - inUseOrg.setOrgID((int) EamDb.getInstance().newOrganization(inUseOrg)); + inUseOrg = EamDb.getInstance().newOrganization(inUseOrg); // Make a reference set that uses it EamGlobalSet tempSet = new EamGlobalSet(inUseOrg.getOrgID(), "inUseOrgTest", "1.0", TskData.FileKnown.BAD, false, fileType); @@ -1445,14 +1446,12 @@ public class CentralRepoDatamodelTest extends TestCase { } // Test deleting non-existent org - // Should do nothing try { EamOrganization temp = new EamOrganization("temp"); - temp.setOrgID(9876); EamDb.getInstance().deleteOrganization(temp); + Assert.fail("deleteOrganization failed to throw exception for non-existent organization"); } catch (EamDbException ex) { - Exceptions.printStackTrace(ex); - Assert.fail(ex); + // This is the expected behavior } // Test deleting null org @@ -1610,7 +1609,7 @@ public class CentralRepoDatamodelTest extends TestCase { // Create a list of global file instances. Make enough that the bulk threshold should be hit once. Set instances = new HashSet<>(); String bulkTestHash = "bulktesthash_"; - for (int i = 0; i < dbSettingsSqlite.getBulkThreshold() * 1.5; i++) { + for (int i = 0; i < DEFAULT_BULK_THRESHOLD * 1.5; i++) { String hash = bulkTestHash + String.valueOf(i); instances.add(new EamGlobalFileInstance(notableSet2id, hash, TskData.FileKnown.BAD, null)); } @@ -1619,7 +1618,7 @@ public class CentralRepoDatamodelTest extends TestCase { EamDb.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 (dbSettingsSqlite.getBulkThreshold() > 10) { + if (DEFAULT_BULK_THRESHOLD > 10) { String hash = bulkTestHash + "10"; assertTrue("Sample bulk insert instance not found", EamDb.getInstance().isFileHashInReferenceSet(hash, notableSet2id)); } @@ -2468,7 +2467,7 @@ public class CentralRepoDatamodelTest extends TestCase { List cases = new ArrayList<>(); String bulkTestUuid = "bulkTestUUID_"; String bulkTestName = "bulkTestName_"; - for (int i = 0; i < dbSettingsSqlite.getBulkThreshold() * 1.5; i++) { + for (int i = 0; i < DEFAULT_BULK_THRESHOLD * 1.5; i++) { String name = bulkTestUuid + String.valueOf(i); String uuid = bulkTestName + String.valueOf(i); cases.add(new CorrelationCase(uuid, name)); From d1ffa145006838efaca0b2ee11a0c3ac0d99836d Mon Sep 17 00:00:00 2001 From: Brian Carrier Date: Thu, 7 Jun 2018 14:03:30 -0400 Subject: [PATCH 09/10] codacy changes --- .../centralrepository/datamodel/AbstractSqlEamDb.java | 5 +++++ .../autopsy/centralrepository/datamodel/EamDb.java | 5 +---- .../autopsy/centralrepository/datamodel/PostgresEamDb.java | 2 +- .../centralrepository/datamodel/PostgresEamDbSettings.java | 6 +++--- .../autopsy/centralrepository/datamodel/SqliteEamDb.java | 2 +- .../centralrepository/datamodel/SqliteEamDbSettings.java | 6 +++--- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java index 0d08c43209..042c1d5c3e 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/AbstractSqlEamDb.java @@ -59,6 +59,11 @@ abstract class AbstractSqlEamDb implements EamDb { protected int bulkArtifactsThreshold; private final Map> bulkArtifacts; + // number of instances to keep in bulk queue before doing an insert. + // Update Test code if this changes. It's hard coded there. + static final int DEFAULT_BULK_THRESHHOLD = 1000; + + /** * Connect to the DB and initialize it. * diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java index 1eede8d129..83aa54dec8 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamDb.java @@ -34,10 +34,7 @@ public interface EamDb { public static final int SCHEMA_VERSION = 1; public static final CaseDbSchemaVersionNumber CURRENT_DB_SCHEMA_VERSION = new CaseDbSchemaVersionNumber(1, 1); - - // number of instances to keep in bulk queue before doing an insert. - // Update Test code if this changes. It's hard coded there. - static final int DEFAULT_BULK_THRESHHOLD = 1000; + /** * Get the instance diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDb.java index fa4301216e..8852a05d45 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDb.java @@ -32,7 +32,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; * Central Repository database implementation using Postgres as a * backend */ -class PostgresEamDb extends AbstractSqlEamDb { +final class PostgresEamDb extends AbstractSqlEamDb { private final static Logger LOGGER = Logger.getLogger(PostgresEamDb.class.getName()); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDbSettings.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDbSettings.java index 9c78d9b275..1154da273d 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDbSettings.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresEamDbSettings.java @@ -90,15 +90,15 @@ public final class PostgresEamDbSettings { try { String bulkThresholdString = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.bulkThreshold"); // NON-NLS if (bulkThresholdString == null || bulkThresholdString.isEmpty()) { - this.bulkThreshold = EamDb.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD; } else { this.bulkThreshold = Integer.parseInt(bulkThresholdString); if (getBulkThreshold() <= 0) { - this.bulkThreshold = EamDb.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD; } } } catch (NumberFormatException ex) { - this.bulkThreshold = EamDb.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD; } userName = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.user"); // NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java index e0d8008f79..158d449934 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDb.java @@ -37,7 +37,7 @@ import org.sleuthkit.autopsy.coordinationservice.CoordinationService; * All methods in AbstractSqlEamDb that read or write to the database should * be overriden here and use appropriate locking. */ -class SqliteEamDb extends AbstractSqlEamDb { +final class SqliteEamDb extends AbstractSqlEamDb { private final static Logger LOGGER = Logger.getLogger(SqliteEamDb.class.getName()); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDbSettings.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDbSettings.java index 4c463cadc2..c73fa55a0e 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDbSettings.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteEamDbSettings.java @@ -76,15 +76,15 @@ public final class SqliteEamDbSettings { try { String bulkThresholdString = ModuleSettings.getConfigSetting("CentralRepository", "db.sqlite.bulkThreshold"); // NON-NLS if (bulkThresholdString == null || bulkThresholdString.isEmpty()) { - this.bulkThreshold = EamDb.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD; } else { this.bulkThreshold = Integer.parseInt(bulkThresholdString); if (getBulkThreshold() <= 0) { - this.bulkThreshold = EamDb.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD; } } } catch (NumberFormatException ex) { - this.bulkThreshold = EamDb.DEFAULT_BULK_THRESHHOLD; + this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD; } } From 2b325f7ae18837aba946cf56366a1d414f6c518f Mon Sep 17 00:00:00 2001 From: Brian Carrier Date: Thu, 7 Jun 2018 17:54:05 -0400 Subject: [PATCH 10/10] renamed isValid... --- .../centralrepository/datamodel/EamArtifactUtil.java | 8 ++------ .../centralrepository/ingestmodule/IngestModule.java | 6 +++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamArtifactUtil.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamArtifactUtil.java index 155e88fe98..c5319dd044 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamArtifactUtil.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamArtifactUtil.java @@ -237,7 +237,7 @@ public class EamArtifactUtil { final AbstractFile af = (AbstractFile) content; - if (!isValidCentralRepoFile(af)) { + if (!isSupportedAbstractFileType(af)) { return null; } @@ -276,15 +276,11 @@ public class EamArtifactUtil { * @return true if the file should be added to the central repo, false * otherwise */ - public static boolean isValidCentralRepoFile(AbstractFile af) { + public static boolean isSupportedAbstractFileType(AbstractFile af) { if (af == null) { return false; } - if (af.getKnown() == TskData.FileKnown.KNOWN) { - return false; - } - switch (af.getType()) { case UNALLOC_BLOCKS: case UNUSED_BLOCKS: diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/ingestmodule/IngestModule.java b/Core/src/org/sleuthkit/autopsy/centralrepository/ingestmodule/IngestModule.java index 423f2b65a0..33f790d72e 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/ingestmodule/IngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/ingestmodule/IngestModule.java @@ -102,10 +102,14 @@ final class IngestModule implements FileIngestModule { return ProcessResult.ERROR; } - if (!EamArtifactUtil.isValidCentralRepoFile(abstractFile)) { + if (!EamArtifactUtil.isSupportedAbstractFileType(abstractFile)) { return ProcessResult.OK; } + if (abstractFile.getKnown() == TskData.FileKnown.KNOWN) { + return ProcessResult.OK; + } + EamDb dbManager; try { dbManager = EamDb.getInstance();