From 204d2e17d8dd91198f05725e543bf9a279c6e7fe Mon Sep 17 00:00:00 2001 From: Raman Arora Date: Fri, 1 May 2020 13:39:50 -0400 Subject: [PATCH] Defined a new class, CentralRepoExaminer, to disambiguate from the Examiner class in case database. --- .../datamodel/CentralRepoExaminer.java | 67 +++++++++++++++++++ .../datamodel/CentralRepository.java | 2 +- .../centralrepository/datamodel/Persona.java | 15 ++--- .../datamodel/PersonaAccount.java | 11 ++- .../datamodel/PersonaAlias.java | 11 ++- .../datamodel/PersonaMetadata.java | 10 +-- .../datamodel/RdbmsCentralRepo.java | 6 +- 7 files changed, 93 insertions(+), 29 deletions(-) create mode 100644 Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoExaminer.java diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoExaminer.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoExaminer.java new file mode 100644 index 0000000000..57e94f83a7 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoExaminer.java @@ -0,0 +1,67 @@ +/* + * Central Repository + * + * Copyright 2020 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.centralrepository.datamodel; + +/** + * Encapsulates the concept of an examiner associated with a case. + */ +final public class CentralRepoExaminer { + + private final long id; // Row id in the examiners table in central repo database. + private final String loginName; + private final String displayName; + + public CentralRepoExaminer(long id, String loginName, String displayName) { + this.id = id; + this.loginName = loginName; + this.displayName = displayName; + } + + /** + * Returns the id + * + * @return id + */ + public long getId() { + return id; + } + + /** + * Returns the login name of examiner + * + * @return login name + */ + public String getLoginName() { + return this.loginName; + } + + /** + * Returns the display name of examiner + * + * @return display name, may be a blank string + */ + public String getDisplayName() { + if (displayName == null) { + return ""; + } + + return this.displayName; + } + +} diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java index 21fd832c00..7044d24dca 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java @@ -177,7 +177,7 @@ public interface CentralRepository { * @return Examiner Current examiner. * @throws CentralRepoException */ - Examiner getCurrentCentralRepoExaminer() throws CentralRepoException; + CentralRepoExaminer getCurrentCentralRepoExaminer() throws CentralRepoException; /** * Retrieves Central Repo case based on an Autopsy Case diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/Persona.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/Persona.java index 0c40edcf35..14776bef74 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/Persona.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/Persona.java @@ -27,7 +27,6 @@ import java.util.Collections; import java.util.Objects; import java.util.UUID; import org.apache.commons.lang3.StringUtils; -import org.sleuthkit.datamodel.Examiner; import org.sleuthkit.datamodel.SleuthkitCase; /** @@ -126,7 +125,7 @@ public class Persona { private final long createdDate; private final long modifiedDate; private final PersonaStatus status; - private final Examiner examiner; + private final CentralRepoExaminer examiner; public long getId() { return id; @@ -156,11 +155,11 @@ public class Persona { return status; } - public Examiner getExaminer() { + public CentralRepoExaminer getExaminer() { return examiner; } - Persona(long id, String uuidStr, String name, String comment, long created_date, long modified_date, PersonaStatus status, Examiner examiner) { + Persona(long id, String uuidStr, String name, String comment, long created_date, long modified_date, PersonaStatus status, CentralRepoExaminer examiner) { this.id = id; this.uuidStr = uuidStr; this.name = name; @@ -207,7 +206,7 @@ public class Persona { private static Persona createPersona(String name, String comment, PersonaStatus status) throws CentralRepoException { // generate a UUID for the persona String uuidStr = UUID.randomUUID().toString(); - Examiner examiner = CentralRepository.getInstance().getCurrentCentralRepoExaminer(); + CentralRepoExaminer examiner = CentralRepository.getInstance().getCurrentCentralRepoExaminer(); Instant instant = Instant.now(); Long timeStampMillis = instant.toEpochMilli(); @@ -240,7 +239,7 @@ public class Persona { */ public PersonaAccount addAccountToPersona(CentralRepoAccount account, String justification, Persona.Confidence confidence) throws CentralRepoException { - Examiner currentExaminer = CentralRepository.getInstance().getCurrentCentralRepoExaminer(); + CentralRepoExaminer currentExaminer = CentralRepository.getInstance().getCurrentCentralRepoExaminer(); Instant instant = Instant.now(); Long timeStampMillis = instant.toEpochMilli(); @@ -269,7 +268,7 @@ public class Persona { public void process(ResultSet rs) throws SQLException { while (rs.next()) { - Examiner examiner = new Examiner( + CentralRepoExaminer examiner = new CentralRepoExaminer( rs.getInt("examiner_id"), rs.getString("login_name"), rs.getString("display_name")); @@ -612,7 +611,7 @@ public class Persona { while (resultSet.next()) { // examiner that created the persona - Examiner personaExaminer = new Examiner( + CentralRepoExaminer personaExaminer = new CentralRepoExaminer( resultSet.getInt("persona_examiner_id"), resultSet.getString("persona_examiner_login_name"), resultSet.getString("persona_examiner_display_name")); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PersonaAccount.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PersonaAccount.java index 4eacdbb6b2..72329583c9 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PersonaAccount.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PersonaAccount.java @@ -23,7 +23,6 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import org.sleuthkit.datamodel.Examiner; /** * This class represents an association between a Persona and an Account. @@ -39,9 +38,9 @@ public class PersonaAccount { private final String justification; private final Persona.Confidence confidence; private final long dateAdded; - private final Examiner examiner; + private final CentralRepoExaminer examiner; - public PersonaAccount(Persona persona, CentralRepoAccount account, String justification, Persona.Confidence confidence, long dateAdded, Examiner examiner) { + public PersonaAccount(Persona persona, CentralRepoAccount account, String justification, Persona.Confidence confidence, long dateAdded, CentralRepoExaminer examiner) { this.persona = persona; this.account = account; this.justification = justification; @@ -70,7 +69,7 @@ public class PersonaAccount { return dateAdded; } - public Examiner getExaminer() { + public CentralRepoExaminer getExaminer() { return examiner; } @@ -86,13 +85,13 @@ public class PersonaAccount { while (rs.next()) { // examiner that created the persona/account association - Examiner paExaminer = new Examiner( + CentralRepoExaminer paExaminer = new CentralRepoExaminer( rs.getInt("pa_examiner_id"), rs.getString("pa_examiner_login_name"), rs.getString("pa_examiner_display_name")); // examiner that created the persona - Examiner personaExaminer = new Examiner( + CentralRepoExaminer personaExaminer = new CentralRepoExaminer( rs.getInt("persona_examiner_id"), rs.getString("persona_examiner_login_name"), rs.getString("persona_examiner_display_name")); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PersonaAlias.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PersonaAlias.java index cff33619dd..31e30fb9d9 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PersonaAlias.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PersonaAlias.java @@ -25,7 +25,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import org.apache.commons.lang3.StringUtils; -import org.sleuthkit.datamodel.Examiner; import org.sleuthkit.datamodel.SleuthkitCase; /** @@ -40,7 +39,7 @@ public class PersonaAlias { private final String justification; private final Persona.Confidence confidence; private final long dateAdded; - private final Examiner examiner; + private final CentralRepoExaminer examiner; public long getPersonaId() { return personaId; @@ -62,11 +61,11 @@ public class PersonaAlias { return dateAdded; } - public Examiner getExaminer() { + public CentralRepoExaminer getExaminer() { return examiner; } - public PersonaAlias(long personaId, String alias, String justification, Persona.Confidence confidence, long dateAdded, Examiner examiner) { + public PersonaAlias(long personaId, String alias, String justification, Persona.Confidence confidence, long dateAdded, CentralRepoExaminer examiner) { this.personaId = personaId; this.alias = alias; this.justification = justification; @@ -88,7 +87,7 @@ public class PersonaAlias { */ static PersonaAlias addPersonaAlias(Persona persona, String alias, String justification, Persona.Confidence confidence) throws CentralRepoException { - Examiner examiner = CentralRepository.getInstance().getCurrentCentralRepoExaminer(); + CentralRepoExaminer examiner = CentralRepository.getInstance().getCurrentCentralRepoExaminer(); Instant instant = Instant.now(); Long timeStampMillis = instant.toEpochMilli(); @@ -118,7 +117,7 @@ public class PersonaAlias { public void process(ResultSet rs) throws SQLException { while (rs.next()) { - Examiner examiner = new Examiner( + CentralRepoExaminer examiner = new CentralRepoExaminer( rs.getInt("examiner_id"), rs.getString("login_name"), rs.getString("display_name")); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PersonaMetadata.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PersonaMetadata.java index 691772d264..ae34771e94 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PersonaMetadata.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PersonaMetadata.java @@ -43,7 +43,7 @@ public class PersonaMetadata { private final String justification; private final Persona.Confidence confidence; private final long dateAdded; - private final Examiner examiner; + private final CentralRepoExaminer examiner; public long getPersonaId() { return personaId; @@ -69,11 +69,11 @@ public class PersonaMetadata { return dateAdded; } - public Examiner getExaminer() { + public CentralRepoExaminer getExaminer() { return examiner; } - public PersonaMetadata(long personaId, String name, String value, String justification, Persona.Confidence confidence, long dateAdded, Examiner examiner) { + public PersonaMetadata(long personaId, String name, String value, String justification, Persona.Confidence confidence, long dateAdded, CentralRepoExaminer examiner) { this.personaId = personaId; this.name = name; this.value = value; @@ -97,7 +97,7 @@ public class PersonaMetadata { */ static PersonaMetadata addPersonaMetadata(long personaId, String name, String value, String justification, Persona.Confidence confidence) throws CentralRepoException { - Examiner examiner = CentralRepository.getInstance().getCurrentCentralRepoExaminer(); + CentralRepoExaminer examiner = CentralRepository.getInstance().getCurrentCentralRepoExaminer(); Instant instant = Instant.now(); Long timeStampMillis = instant.toEpochMilli(); @@ -128,7 +128,7 @@ public class PersonaMetadata { public void process(ResultSet rs) throws SQLException { while (rs.next()) { - Examiner examiner = new Examiner( + CentralRepoExaminer examiner = new CentralRepoExaminer( rs.getInt("examiner_id"), rs.getString("login_name"), rs.getString("display_name")); diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RdbmsCentralRepo.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RdbmsCentralRepo.java index 39f48b0e66..afaf1b14f1 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RdbmsCentralRepo.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RdbmsCentralRepo.java @@ -102,7 +102,7 @@ abstract class RdbmsCentralRepo implements CentralRepository { // Update Test code if this changes. It's hard coded there. static final int DEFAULT_BULK_THRESHHOLD = 1000; - private Examiner cachedCurrentExaminer = null; + private CentralRepoExaminer cachedCurrentExaminer = null; private static final int QUERY_STR_MAX_LEN = 1000; @@ -2557,7 +2557,7 @@ abstract class RdbmsCentralRepo implements CentralRepository { } @Override - public Examiner getCurrentCentralRepoExaminer() throws CentralRepoException { + public CentralRepoExaminer getCurrentCentralRepoExaminer() throws CentralRepoException { // return cached value if there's one if (cachedCurrentExaminer != null) { @@ -2575,7 +2575,7 @@ abstract class RdbmsCentralRepo implements CentralRepository { ResultSet resultSet = statement.executeQuery(querySQL);) { if (resultSet.next()) { - cachedCurrentExaminer = new Examiner(resultSet.getLong("id"), resultSet.getString("login_name"), resultSet.getString("display_name")); + cachedCurrentExaminer = new CentralRepoExaminer(resultSet.getLong("id"), resultSet.getString("login_name"), resultSet.getString("display_name")); return cachedCurrentExaminer; } else { throw new CentralRepoException("Error getting examiner for name = " + loginName);