X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FSoneImpl.java;h=5678824e9ed794763cd55d14f4b7eaa6b9651a67;hb=43740d6a1dfc686ab54d0aebd4a5b1bce75b9ed6;hp=08c104fc83a7687a2294ada1e68bc9b4e6a2f169;hpb=210684b4bc499e298a0d0abeddd4008cdeb406bc;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/data/SoneImpl.java b/src/main/java/net/pterodactylus/sone/data/SoneImpl.java index 08c104f..5678824 100644 --- a/src/main/java/net/pterodactylus/sone/data/SoneImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/SoneImpl.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.data; import static com.google.common.base.Preconditions.checkNotNull; import static java.lang.String.format; +import static java.util.logging.Logger.getLogger; import java.net.MalformedURLException; import java.util.ArrayList; @@ -33,7 +34,6 @@ import java.util.logging.Logger; import net.pterodactylus.sone.data.SoneOptions.DefaultSoneOptions; import net.pterodactylus.sone.freenet.wot.Identity; import net.pterodactylus.sone.freenet.wot.OwnIdentity; -import net.pterodactylus.util.logging.Logging; import freenet.keys.FreenetURI; @@ -50,7 +50,7 @@ import com.google.common.hash.Hashing; public class SoneImpl implements Sone { /** The logger. */ - private static final Logger logger = Logging.getLogger(SoneImpl.class); + private static final Logger logger = getLogger("Sone.Data"); /** The ID of this Sone. */ private final String id; @@ -167,26 +167,17 @@ public class SoneImpl implements Sone { * @return The request URI of this Sone */ public FreenetURI getRequestUri() { - return (requestUri != null) ? requestUri.setSuggestedEdition(latestEdition) : null; - } - - /** - * Sets the request URI of this Sone. - * - * @param requestUri - * The request URI of this Sone - * @return This Sone (for method chaining) - */ - public Sone setRequestUri(FreenetURI requestUri) { - if (this.requestUri == null) { - this.requestUri = requestUri.setKeyType("USK").setDocName("Sone").setMetaString(new String[0]); - return this; - } - if (!this.requestUri.equalsKeypair(requestUri)) { - logger.log(Level.WARNING, String.format("Request URI %s tried to overwrite %s!", requestUri, this.requestUri)); - return this; + try { + return new FreenetURI(getIdentity().getRequestUri()) + .setKeyType("USK") + .setDocName("Sone") + .setMetaString(new String[0]) + .setSuggestedEdition(latestEdition); + } catch (MalformedURLException e) { + throw new IllegalStateException( + format("Identity %s's request URI is incorrect.", + getIdentity()), e); } - return this; } /** @@ -199,7 +190,10 @@ public class SoneImpl implements Sone { return null; } try { - return new FreenetURI(((OwnIdentity) getIdentity()).getInsertUri()).setDocName("Sone").setMetaString(new String[0]); + return new FreenetURI(((OwnIdentity) getIdentity()).getInsertUri()) + .setDocName("Sone") + .setMetaString(new String[0]) + .setSuggestedEdition(latestEdition); } catch (MalformedURLException e) { throw new IllegalStateException(format("Own identity %s's insert URI is incorrect.", getIdentity()), e); }