X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FDeleteReplyPage.java;h=7112b732791acd623e7fa506021087ec4b982ffc;hp=8c077166dddde240126f2e59633fb568c2323fe1;hb=7b55e0be6a3283e43a9bbab98f82aebdd948eb33;hpb=99888ce13cc17d49f5e217ab6f2c9ad5ef168792 diff --git a/src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java b/src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java index 8c07716..7112b73 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java @@ -1,5 +1,5 @@ /* - * Sone - DeleteReplyPage.java - Copyright © 2010–2013 David Roden + * Sone - DeleteReplyPage.java - Copyright © 2010–2016 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,8 @@ import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; import net.pterodactylus.util.web.Method; +import com.google.common.base.Optional; + /** * This page lets the user delete a reply. * @@ -50,17 +52,16 @@ public class DeleteReplyPage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { - super.processTemplate(request, templateContext); + protected void handleRequest(FreenetRequest request, TemplateContext templateContext) throws RedirectException { String replyId = request.getHttpRequest().getPartAsStringFailsafe("reply", 36); - PostReply reply = webInterface.getCore().getPostReply(replyId, false); + Optional reply = webInterface.getCore().getPostReply(replyId); String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); if (request.getMethod() == Method.POST) { - if (!reply.getSone().isLocal()) { + if (!reply.isPresent() || !reply.get().getSone().isLocal()) { throw new RedirectException("noPermission.html"); } if (request.getHttpRequest().isPartSet("confirmDelete")) { - webInterface.getCore().deleteReply(reply); + webInterface.getCore().deleteReply(reply.get()); throw new RedirectException(returnPage); } else if (request.getHttpRequest().isPartSet("abortDelete")) { throw new RedirectException(returnPage);