X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FUnlockSonePage.java;h=56ee2b7c46accfb238d7c538e3cbbfc43f0a5acd;hb=fd88107b013522d7620f5297386472206f320e10;hp=84911632464a65edf83fc5674c09acfe52502759;hpb=d063d7366c883a8f130de67af67a84eb6d725361;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/UnlockSonePage.java b/src/main/java/net/pterodactylus/sone/web/UnlockSonePage.java index 8491163..56ee2b7 100644 --- a/src/main/java/net/pterodactylus/sone/web/UnlockSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/UnlockSonePage.java @@ -17,11 +17,14 @@ package net.pterodactylus.sone.web; +import net.pterodactylus.sone.data.LocalSone; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; +import com.google.common.base.Optional; + /** * This page lets the user unlock a {@link Sone} to allow its insertion. * @@ -52,9 +55,9 @@ public class UnlockSonePage extends SoneTemplatePage { protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 44); - Sone sone = webInterface.getCore().getLocalSone(soneId); - if (sone != null) { - webInterface.getCore().unlockSone(sone); + Optional localSone = webInterface.getCore().getLocalSone(soneId); + if (localSone.isPresent()) { + webInterface.getCore().unlockSone(localSone.get()); } String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); throw new RedirectException(returnPage);