Fixed codacy issues and handled review comment

This commit is contained in:
Kelly Kelly 2020-06-04 10:14:56 -04:00
parent a5e5a3d5c5
commit 90c74d2aaa
2 changed files with 15 additions and 7 deletions

View File

@ -28,6 +28,7 @@ import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children; import org.openide.nodes.Children;
import org.openide.nodes.Sheet; import org.openide.nodes.Sheet;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
import org.openide.util.lookup.Lookups; import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.centralrepository.datamodel.PersonaAccount; import org.sleuthkit.autopsy.centralrepository.datamodel.PersonaAccount;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
@ -113,11 +114,18 @@ final class AccountDeviceInstanceNode extends AbstractNode {
return actions.toArray(new Action[actions.size()]); 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 @Override
public String getShortDescription() { public String getShortDescription() {
List<PersonaAccount> personaList; List<PersonaAccount> personaList;
try { try {
personaList = CVTPersonaCache.getInstance().getPersonaAccounts(getName()); personaList = CVTPersonaCache.getPersonaAccounts(getName());
} catch (ExecutionException ex) { } catch (ExecutionException ex) {
logger.log(Level.WARNING, "Failed to retrieve Persona details for node.", ex); logger.log(Level.WARNING, "Failed to retrieve Persona details for node.", ex);
return getDisplayName(); return getDisplayName();
@ -127,12 +135,12 @@ final class AccountDeviceInstanceNode extends AbstractNode {
if (!personaList.isEmpty()) { if (!personaList.isEmpty()) {
personaName = personaList.get(0).getPersona().getName(); personaName = personaList.get(0).getPersona().getName();
if (personaList.size() > 1) { if (personaList.size() > 1) {
personaName += String.format("(1 of %d)", personaList.size()); personaName += Bundle.AccountInstanceNode_Tooltip_suffix(Integer.toString(personaList.size()));
} }
} else { } else {
personaName = "None"; personaName = "None";
} }
return String.format(TOOLTIP_TEMPLATE, getDisplayName(), personaName); return Bundle.AccountInstanceNode_Tooltip_Template(getDisplayName(), personaName);
} }
} }

View File

@ -37,7 +37,7 @@ import org.sleuthkit.autopsy.coreutils.Logger;
* PersonaAccounts for a given Account typeSpecificID retrieved on first access * PersonaAccounts for a given Account typeSpecificID retrieved on first access
* and evicted from the cache after 5 minutes. * and evicted from the cache after 5 minutes.
*/ */
class CVTPersonaCache { final class CVTPersonaCache {
private static final Logger logger = Logger.getLogger(CVTPersonaCache.class.getName()); private static final Logger logger = Logger.getLogger(CVTPersonaCache.class.getName());
private final LoadingCache<String, List<PersonaAccount>> accountMap; private final LoadingCache<String, List<PersonaAccount>> accountMap;
@ -72,7 +72,7 @@ class CVTPersonaCache {
* *
* @return CVTPersonaCache instance. * @return CVTPersonaCache instance.
*/ */
static CVTPersonaCache getInstance() { private static CVTPersonaCache getInstance() {
if (instance == null) { if (instance == null) {
instance = new CVTPersonaCache(); instance = new CVTPersonaCache();
} }
@ -89,7 +89,7 @@ class CVTPersonaCache {
* *
* @throws ExecutionException * @throws ExecutionException
*/ */
List<PersonaAccount> getPersonaAccounts(String typeSpecificID) throws ExecutionException { static synchronized List<PersonaAccount> getPersonaAccounts(String typeSpecificID) throws ExecutionException {
return accountMap.get(typeSpecificID); return getInstance().accountMap.get(typeSpecificID);
} }
} }