If no current Sone exists, return an error.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / DeletePostPage.java
index 6ef86f0..5cb4b44 100644 (file)
 
 package net.pterodactylus.sone.web;
 
-import com.google.common.base.Optional;
-
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.web.Method;
 
+import com.google.common.base.Optional;
+
 /**
  * Lets the user delete a post they made.
  *
@@ -48,16 +48,13 @@ public class DeletePostPage extends SoneTemplatePage {
        // TEMPLATEPAGE METHODS
        //
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                if (request.getMethod() == Method.GET) {
                        String postId = request.getHttpRequest().getParam("post");
                        String returnPage = request.getHttpRequest().getParam("returnPage");
-                       Optional<Post> post = webInterface.getCore().getPost(postId);
+                       Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
                        if (!post.isPresent()) {
                                throw new RedirectException("noPermission.html");
                        }
@@ -67,7 +64,7 @@ public class DeletePostPage extends SoneTemplatePage {
                } else if (request.getMethod() == Method.POST) {
                        String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
                        String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
-                       Optional<Post> post = webInterface.getCore().getPost(postId);
+                       Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
                        if (!post.isPresent() || !post.get().getSone().isLocal()) {
                                throw new RedirectException("noPermission.html");
                        }