Change all copyright headers to include 2012.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / DeletePostPage.java
index 2aaa6c9..6689061 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - DeletePostPage.java - Copyright © 2010 David Roden
+ * Sone - DeletePostPage.java - Copyright © 2010–2012 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
 package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Post;
-import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.web.page.Page.Request.Method;
+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;
 
 /**
  * Lets the user delete a post they made.
@@ -49,31 +50,30 @@ public class DeletePostPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, Template template) throws RedirectException {
-               super.processTemplate(request, template);
+       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");
-                       Post post = webInterface.core().getPost(postId);
-                       template.set("post", post);
-                       template.set("returnPage", returnPage);
+                       Post post = webInterface.getCore().getPost(postId);
+                       templateContext.set("post", post);
+                       templateContext.set("returnPage", returnPage);
                        return;
                } else if (request.getMethod() == Method.POST) {
                        String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
-                       String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
-                       Post post = webInterface.core().getPost(postId);
-                       Sone currentSone = getCurrentSone(request.getToadletContext());
-                       if (!post.getSone().equals(currentSone)) {
+                       String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
+                       Post post = webInterface.getCore().getPost(postId);
+                       if (!webInterface.getCore().isLocalSone(post.getSone())) {
                                throw new RedirectException("noPermission.html");
                        }
                        if (request.getHttpRequest().isPartSet("confirmDelete")) {
-                               currentSone.removePost(post);
+                               webInterface.getCore().deletePost(post);
                                throw new RedirectException(returnPage);
                        } else if (request.getHttpRequest().isPartSet("abortDelete")) {
                                throw new RedirectException(returnPage);
                        }
-                       template.set("post", post);
-                       template.set("returnPage", returnPage);
+                       templateContext.set("post", post);
+                       templateContext.set("returnPage", returnPage);
                }
        }