From 90c74d2aaa32e77de374fa13df072c3ac9285d0e Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Thu, 4 Jun 2020 10:14:56 -0400 Subject: [PATCH] Fixed codacy issues and handled review comment --- .../communications/AccountDeviceInstanceNode.java | 14 +++++++++++--- .../autopsy/communications/CVTPersonaCache.java | 8 ++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/communications/AccountDeviceInstanceNode.java b/Core/src/org/sleuthkit/autopsy/communications/AccountDeviceInstanceNode.java index 96386c0e59..c977cb81fc 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/AccountDeviceInstanceNode.java +++ b/Core/src/org/sleuthkit/autopsy/communications/AccountDeviceInstanceNode.java @@ -28,6 +28,7 @@ import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Sheet; import org.openide.util.NbBundle; +import org.openide.util.NbBundle.Messages; import org.openide.util.lookup.Lookups; import org.sleuthkit.autopsy.centralrepository.datamodel.PersonaAccount; import org.sleuthkit.autopsy.coreutils.Logger; @@ -113,11 +114,18 @@ final class AccountDeviceInstanceNode extends AbstractNode { return actions.toArray(new Action[actions.size()]); } + @Messages({ + "# {0} - Contact Name", + "# {1} - Persona Name", + "AccountInstanceNode_Tooltip_Template=Contact: {0} - Persona: {1}", + "# {0} - PersonaAccount count", + "AccountInstanceNode_Tooltip_suffix=(1 of {0})" + }) @Override public String getShortDescription() { List personaList; try { - personaList = CVTPersonaCache.getInstance().getPersonaAccounts(getName()); + personaList = CVTPersonaCache.getPersonaAccounts(getName()); } catch (ExecutionException ex) { logger.log(Level.WARNING, "Failed to retrieve Persona details for node.", ex); return getDisplayName(); @@ -127,12 +135,12 @@ final class AccountDeviceInstanceNode extends AbstractNode { if (!personaList.isEmpty()) { personaName = personaList.get(0).getPersona().getName(); if (personaList.size() > 1) { - personaName += String.format("(1 of %d)", personaList.size()); + personaName += Bundle.AccountInstanceNode_Tooltip_suffix(Integer.toString(personaList.size())); } } else { personaName = "None"; } - return String.format(TOOLTIP_TEMPLATE, getDisplayName(), personaName); + return Bundle.AccountInstanceNode_Tooltip_Template(getDisplayName(), personaName); } } diff --git a/Core/src/org/sleuthkit/autopsy/communications/CVTPersonaCache.java b/Core/src/org/sleuthkit/autopsy/communications/CVTPersonaCache.java index d4d36fa64d..f4bface5fb 100755 --- a/Core/src/org/sleuthkit/autopsy/communications/CVTPersonaCache.java +++ b/Core/src/org/sleuthkit/autopsy/communications/CVTPersonaCache.java @@ -37,7 +37,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; * PersonaAccounts for a given Account typeSpecificID retrieved on first access * and evicted from the cache after 5 minutes. */ -class CVTPersonaCache { +final class CVTPersonaCache { private static final Logger logger = Logger.getLogger(CVTPersonaCache.class.getName()); private final LoadingCache> accountMap; @@ -72,7 +72,7 @@ class CVTPersonaCache { * * @return CVTPersonaCache instance. */ - static CVTPersonaCache getInstance() { + private static CVTPersonaCache getInstance() { if (instance == null) { instance = new CVTPersonaCache(); } @@ -89,7 +89,7 @@ class CVTPersonaCache { * * @throws ExecutionException */ - List getPersonaAccounts(String typeSpecificID) throws ExecutionException { - return accountMap.get(typeSpecificID); + static synchronized List getPersonaAccounts(String typeSpecificID) throws ExecutionException { + return getInstance().accountMap.get(typeSpecificID); } }