X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FLockSonePage.java;h=cf33d0592f351728bf63cfcef976aee8aaca4a64;hb=fd88107b013522d7620f5297386472206f320e10;hp=604b1764d3486d2c9006c9465366ba21e8c8655e;hpb=99888ce13cc17d49f5e217ab6f2c9ad5ef168792;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/LockSonePage.java b/src/main/java/net/pterodactylus/sone/web/LockSonePage.java index 604b176..cf33d05 100644 --- a/src/main/java/net/pterodactylus/sone/web/LockSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/LockSonePage.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 lock a {@link Sone} to prevent it from being * inserted. @@ -53,9 +56,9 @@ public class LockSonePage 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, false); - if (sone != null) { - webInterface.getCore().lockSone(sone); + Optional sone = webInterface.getCore().getLocalSone(soneId); + if (sone.isPresent()) { + webInterface.getCore().lockSone(sone.get()); } String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); throw new RedirectException(returnPage);