From fd15f829765e140002a66ae6b370bf2e778be151 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 16 Sep 2011 11:11:58 +0200 Subject: [PATCH] Get trusted identities from WoT, not from cache. --- .../wotns/freenet/wot/IdentityManager.java | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/pterodactylus/wotns/freenet/wot/IdentityManager.java b/src/main/java/net/pterodactylus/wotns/freenet/wot/IdentityManager.java index 3086f27..2958ca1 100644 --- a/src/main/java/net/pterodactylus/wotns/freenet/wot/IdentityManager.java +++ b/src/main/java/net/pterodactylus/wotns/freenet/wot/IdentityManager.java @@ -27,9 +27,7 @@ import java.util.Map.Entry; import java.util.logging.Level; import java.util.logging.Logger; -import net.pterodactylus.util.collection.SetBuilder; import net.pterodactylus.util.logging.Logging; -import net.pterodactylus.util.object.Default; import net.pterodactylus.util.service.AbstractService; import net.pterodactylus.wotns.freenet.plugin.PluginException; @@ -173,15 +171,31 @@ public class IdentityManager extends AbstractService { } } + /** + * Returns all identities that are trusted by the given own identity. In + * addition to all non-own identities the given own identity is also + * returned. + * + * @param ownIdentity + * The own identity to get the trusted identities for + * @return The identities trusted by the given own identity + */ public Set getTrustedIdentities(OwnIdentity ownIdentity) { - SetBuilder identities = new SetBuilder(); + Set identities = new HashSet(); if ((context == null) || ownIdentity.getContexts().contains(context)) { identities.add(ownIdentity); } - synchronized (syncObject) { - identities.addAll(Default.forNull(currentTrustedIdentities.get(ownIdentity), Collections. emptySet())); + try { + Set trustedIdentities = webOfTrustConnector.loadTrustedIdentities(ownIdentity, context); + Map newTrustedIdentities = new HashMap(); + for (Identity trustedIdentity : trustedIdentities) { + newTrustedIdentities.put(trustedIdentity.getId(), trustedIdentity); + } + checkTrustedIdentities(ownIdentity, newTrustedIdentities); + } catch (WebOfTrustException wote1) { + logger.log(Level.WARNING, String.format("Could not load all trusted identities for %s.", ownIdentity), wote1); } - return identities.get(); + return identities; } // -- 2.7.4