Update years in copyright line
[Sone.git] / src / main / java / net / pterodactylus / sone / web / BookmarkPage.java
index 12a0934..afb6a29 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - BookmarkPage.java - Copyright © 2011 David Roden
+ * Sone - BookmarkPage.java - Copyright © 2011–2015 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.web.page.Page.Request.Method;
+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;
 
 /**
  * Page that lets the user bookmark a post.
@@ -46,12 +50,15 @@ public class BookmarkPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                if (request.getMethod() == Method.POST) {
                        String id = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
                        String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
-                       webInterface.getCore().bookmarkPost(id);
+                       Optional<Post> post = webInterface.getCore().getPost(id);
+                       if (post.isPresent()) {
+                               webInterface.getCore().bookmarkPost(post.get());
+                       }
                        throw new RedirectException(returnPage);
                }
        }