Defined a new class, CentralRepoExaminer, to disambiguate from the Examiner class in case database.

This commit is contained in:
Raman Arora 2020-05-01 13:39:50 -04:00
parent 2b75a00256
commit 204d2e17d8
7 changed files with 93 additions and 29 deletions

View File

@ -0,0 +1,67 @@
/*
* Central Repository
*
* Copyright 2020 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.centralrepository.datamodel;
/**
* 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;
}
}

View File

@ -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

View File

@ -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"));

View File

@ -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"));

View File

@ -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"));

View File

@ -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"));

View File

@ -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);