From b05aaf223c8c9a5199d6d557223d044bf6b335f1 Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Fri, 18 Dec 2020 17:08:10 -0500 Subject: [PATCH] Address bugs in CVT Summary Panel --- .../datamodel/CentralRepoAccount.java | 2 +- .../relationships/SummaryPanelWorker.java | 13 +++++- .../relationships/SummaryPersonaPane.java | 43 ++++++++++++++++--- .../relationships/SummaryViewer.java | 2 +- 4 files changed, 52 insertions(+), 8 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoAccount.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoAccount.java index 88c74a4fe8..8d62629363 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoAccount.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoAccount.java @@ -336,7 +336,7 @@ public final class CentralRepoAccount { normalizedAccountIdentifier = accountIdentifier.toLowerCase(); } } catch (CorrelationAttributeNormalizationException ex) { - throw new InvalidAccountIDException("Invalid account identifier", ex); + throw new InvalidAccountIDException(String.format("Account id normaization failed, invalid account identifier %s", accountIdentifier), ex); } return normalizedAccountIdentifier; diff --git a/Core/src/org/sleuthkit/autopsy/communications/relationships/SummaryPanelWorker.java b/Core/src/org/sleuthkit/autopsy/communications/relationships/SummaryPanelWorker.java index 2014f93bf2..bc6157f4cf 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/relationships/SummaryPanelWorker.java +++ b/Core/src/org/sleuthkit/autopsy/communications/relationships/SummaryPanelWorker.java @@ -21,20 +21,25 @@ package org.sleuthkit.autopsy.communications.relationships; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.logging.Level; import javax.swing.SwingWorker; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoAccount; import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; import org.sleuthkit.autopsy.centralrepository.datamodel.Persona; import org.sleuthkit.autopsy.centralrepository.datamodel.PersonaAccount; +import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.Account; import org.sleuthkit.datamodel.AccountFileInstance; +import org.sleuthkit.datamodel.InvalidAccountIDException; /** * Runnable SwingWorker for gather the data that the Summary panel needs. */ class SummaryPanelWorker extends SwingWorker { + private final static Logger logger = Logger.getLogger(SummaryPanelWorker.class.getName()); + private final Account account; // Construct a instance @@ -69,7 +74,13 @@ class SummaryPanelWorker extends SwingWorker personaMap; private final ViewButtonHandler viewButtonHandler = new ViewButtonHandler(); - private CentralRepoAccount currentAccount = null; + private CentralRepoAccount currentCRAccount = null; + private Account currentAccount = null; /** * Creates new form SummaryPersonaPane @@ -87,14 +98,16 @@ public final class SummaryPersonaPane extends javax.swing.JPanel { * * @param personaList New list of personas to show */ - void updatePersonaList(CentralRepoAccount account, List personaList) { + void updatePersonaList(Account account, CentralRepoAccount crAccount, List personaList) { JPanel panel = new JPanel(); + currentCRAccount = crAccount; currentAccount = account; + CardLayout layout = (CardLayout) getLayout(); if (personaList.isEmpty()) { layout.show(this, "create"); } else { - panel.setLayout(new GridLayout(personaList.size(), 1)); + panel.setLayout(new GridLayout(personaList.size() + 1, 1)); int maxWidth = 0; List panelList = new ArrayList<>(); for (Persona persona : personaList) { @@ -116,6 +129,7 @@ public final class SummaryPersonaPane extends javax.swing.JPanel { } } + panel.add(Box.createVerticalGlue()); personaScrollPane.setViewportView(panel); layout.show(this, "persona"); } @@ -158,7 +172,23 @@ public final class SummaryPersonaPane extends javax.swing.JPanel { if (persona != null) { List list = new ArrayList<>(); list.add(persona); - updatePersonaList(null, list); + + CentralRepoAccount crAccount = null; + Collection personaAccounts = null; + try { + personaAccounts = persona.getPersonaAccounts(); + } catch (CentralRepoException ex) { + logger.log(Level.WARNING, String.format("Failed to get cr account from person %s (%d)", persona.getName(), persona.getId()), ex); + } + + if (personaAccounts != null) { + Iterator iterator = personaAccounts.iterator(); + if (iterator.hasNext()) { + crAccount = iterator.next().getAccount(); + } + } + + updatePersonaList(currentAccount, crAccount, list); } } } @@ -236,8 +266,11 @@ public final class SummaryPersonaPane extends javax.swing.JPanel { // Pre populate the persona name and accounts if we have them. PersonaDetailsPanel personaPanel = createPersonaDialog.getDetailsPanel(); - personaPanel.addAccount(currentAccount, "", Persona.Confidence.HIGH); + if (currentCRAccount != null) { + personaPanel.addAccount(currentCRAccount, "", Persona.Confidence.HIGH); + } + personaPanel.setPersonaName(currentAccount.getTypeSpecificID()); // display the dialog now createPersonaDialog.display(); }//GEN-LAST:event_createButtonActionPerformed diff --git a/Core/src/org/sleuthkit/autopsy/communications/relationships/SummaryViewer.java b/Core/src/org/sleuthkit/autopsy/communications/relationships/SummaryViewer.java index 61be1f1307..4cf917eac1 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/relationships/SummaryViewer.java +++ b/Core/src/org/sleuthkit/autopsy/communications/relationships/SummaryViewer.java @@ -226,7 +226,7 @@ public class SummaryViewer extends javax.swing.JPanel implements RelationshipsVi List personaList = results.getPersonaList(); if (CentralRepository.isEnabled()) { - ((SummaryPersonaPane) personaPanel).updatePersonaList(results.getCRAccount(), personaList); + ((SummaryPersonaPane) personaPanel).updatePersonaList(account, results.getCRAccount(), personaList); } else { ((SummaryPersonaPane) personaPanel).setMessage("Bundle.SummaryViewer_Persona_Message()"); ((SummaryPersonaPane) personaPanel).showMessagePanel();