diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java index bdae5a727be1848aaf509dcc2c4d99f62fe01c9d..a28b57e30a261262afebf44b612bb4198f9e1065 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java @@ -884,5 +884,18 @@ CorrelationAttributeInstance getCorrelationAttributeInstance(CorrelationAttribut * @throws CentralRepoException */ CentralRepoAccount getOrCreateAccount(CentralRepoAccount.CentralRepoAccountType crAccountType, String accountUniqueID) throws CentralRepoException; + + /** + * Gets an account from the accounts table matching the given type/ID, if + * one exists. + * + * @param crAccountType CR account type to look for or create + * @param accountUniqueID type specific unique account id + * + * @return CR account, if found, null otherwise. + * + * @throws CentralRepoException + */ + CentralRepoAccount getAccount(CentralRepoAccount.CentralRepoAccountType crAccountType, String accountUniqueID) throws CentralRepoException; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RdbmsCentralRepo.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RdbmsCentralRepo.java index d3195a6d3d77509214965ded35e8de81e5ef1f10..70c98f4eabb5f8d93f70f5e7586d5b64c6f1c30c 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RdbmsCentralRepo.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RdbmsCentralRepo.java @@ -1179,7 +1179,8 @@ private CentralRepoAccountType getCRAccountTypeFromDb(String accountTypeName) th * * @throws CentralRepoException */ - private CentralRepoAccount getAccount(CentralRepoAccountType crAccountType, String accountUniqueID) throws CentralRepoException { + @Override + public CentralRepoAccount getAccount(CentralRepoAccountType crAccountType, String accountUniqueID) throws CentralRepoException { CentralRepoAccount crAccount = accountsCache.getIfPresent(Pair.of(crAccountType, accountUniqueID)); if (crAccount == null) { diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/artifactviewers/ContactArtifactViewer.java b/Core/src/org/sleuthkit/autopsy/contentviewers/artifactviewers/ContactArtifactViewer.java index 734a7ec180af09b5b82765175f60ba01295aace7..95da68ca10430d1a906f2e4b0106664e1a1edbb9 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/artifactviewers/ContactArtifactViewer.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/artifactviewers/ContactArtifactViewer.java @@ -633,21 +633,18 @@ protected Map<Persona, ArrayList<CentralRepoAccount>> doInBackground() throws Ex return new HashMap<>(); } - Collection<PersonaAccount> personaAccounts = PersonaAccount.getPersonaAccountsForAccount(account); - if (personaAccounts != null && !personaAccounts.isEmpty()) { + // make a list of all unique accounts for this contact + if (!account.getAccountType().equals(Account.Type.DEVICE)) { + CentralRepoAccount.CentralRepoAccountType crAccountType = CentralRepository.getInstance().getAccountTypeByName(account.getAccountType().getTypeName()); + CentralRepoAccount crAccount = CentralRepository.getInstance().getAccount(crAccountType, account.getTypeSpecificID()); - // look for unique accounts - Collection<CentralRepoAccount> accountCandidates - = personaAccounts - .stream() - .map(PersonaAccount::getAccount) - .collect(Collectors.toList()); - for (CentralRepoAccount crAccount : accountCandidates) { - if (uniqueAccountsList.contains(crAccount) == false) { - uniqueAccountsList.add(crAccount); - } + if (crAccount != null && uniqueAccountsList.contains(crAccount) == false) { + uniqueAccountsList.add(crAccount); } - + } + + Collection<PersonaAccount> personaAccounts = PersonaAccount.getPersonaAccountsForAccount(account); + if (personaAccounts != null && !personaAccounts.isEmpty()) { // get personas for the account Collection<Persona> personas = personaAccounts