X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FWebOfTrustConnector.java;h=7ce1ede788d7f56a72732c512e56933f4d60b1d5;hb=e01ceeed92f226bf74c9f516bce882b5cd816a62;hp=d3e8747fe521807c5dbfea8f5718f2a3010531e1;hpb=d5efb086bee8f103cbe90c7a953ffbb7ff27b689;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java index d3e8747..7ce1ede 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java @@ -29,11 +29,10 @@ import net.pterodactylus.sone.freenet.plugin.PluginConnector; import net.pterodactylus.sone.freenet.plugin.PluginException; import net.pterodactylus.sone.freenet.plugin.event.ReceivedReplyEvent; import net.pterodactylus.util.logging.Logging; +import net.pterodactylus.util.number.Numbers; -import com.google.common.base.Optional; import com.google.common.collect.MapMaker; import com.google.common.eventbus.Subscribe; -import com.google.common.primitives.Ints; import com.google.inject.Inject; import freenet.support.SimpleFieldSet; @@ -78,13 +77,6 @@ public class WebOfTrustConnector { // /** - * Stops the web of trust connector. - */ - public void stop() { - /* does nothing. */ - } - - /** * Loads all own identities from the Web of Trust plugin. * * @return All own identity @@ -114,20 +106,6 @@ public class WebOfTrustConnector { /** * Loads all identities that the given identities trusts with a score of - * more than 0. - * - * @param ownIdentity - * The own identity - * @return All trusted identities - * @throws PluginException - * if an error occured talking to the Web of Trust plugin - */ - public Set loadTrustedIdentities(OwnIdentity ownIdentity) throws PluginException { - return loadTrustedIdentities(ownIdentity, null); - } - - /** - * Loads all identities that the given identities trusts with a score of * more than 0 and the (optional) given context. * * @param ownIdentity @@ -153,9 +131,9 @@ public class WebOfTrustConnector { DefaultIdentity identity = new DefaultIdentity(id, nickname, requestUri); identity.setContexts(parseContexts("Contexts" + identityCounter + ".", fields)); identity.setProperties(parseProperties("Properties" + identityCounter + ".", fields)); - Integer trust = Ints.tryParse(fields.get("Trust" + identityCounter)); - int score = Optional.fromNullable(Ints.tryParse(fields.get("Score" + identityCounter))).or(0); - int rank = Optional.fromNullable(Ints.tryParse(fields.get("Rank" + identityCounter))).or(0); + Integer trust = Numbers.safeParseInteger(fields.get("Trust" + identityCounter), null); + int score = Numbers.safeParseInteger(fields.get("Score" + identityCounter), 0); + int rank = Numbers.safeParseInteger(fields.get("Rank" + identityCounter), 0); identity.setTrust(ownIdentity, new Trust(trust, score, rank)); identities.add(identity); } @@ -433,7 +411,6 @@ public class WebOfTrustConnector { logger.log(Level.FINEST, String.format("Received Reply from Plugin: %s", receivedReplyEvent.fieldSet().get("Message"))); synchronized (reply) { reply.setFields(receivedReplyEvent.fieldSet()); - reply.setData(receivedReplyEvent.data()); reply.notify(); } } @@ -448,9 +425,6 @@ public class WebOfTrustConnector { /** The fields of the reply. */ private SimpleFieldSet fields; - /** The payload of the reply. */ - private Bucket data; - /** Empty constructor. */ public Reply() { /* do nothing. */ @@ -475,26 +449,6 @@ public class WebOfTrustConnector { this.fields = fields; } - /** - * Returns the payload of the reply. - * - * @return The payload of the reply (may be {@code null}) - */ - @SuppressWarnings("unused") - public Bucket getData() { - return data; - } - - /** - * Sets the payload of the reply. - * - * @param data - * The payload of the reply (may be {@code null}) - */ - public void setData(Bucket data) { - this.data = data; - } - } /**