projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use a unique ID for posts
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
web
/
BookmarkPage.java
diff --git
a/src/main/java/net/pterodactylus/sone/web/BookmarkPage.java
b/src/main/java/net/pterodactylus/sone/web/BookmarkPage.java
index
12a0934
..
b053b5e
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/BookmarkPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/BookmarkPage.java
@@
-1,5
+1,5
@@
/*
/*
- * Sone - BookmarkPage.java - Copyright © 2011 David Roden
+ * Sone - BookmarkPage.java - Copyright © 2011
–2013
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
*
* 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
@@
-17,9
+17,14
@@
package net.pterodactylus.sone.web;
package net.pterodactylus.sone.web;
-import net.pterodactylus.sone.web.page.Page.Request.Method;
+import net.pterodactylus.sone.data.IdBuilder;
+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.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.
/**
* Page that lets the user bookmark a post.
@@
-46,12
+51,15
@@
public class BookmarkPage extends SoneTemplatePage {
* {@inheritDoc}
*/
@Override
* {@inheritDoc}
*/
@Override
- protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+ protected void processTemplate(
Freenet
Request request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
if (request.getMethod() == Method.POST) {
super.processTemplate(request, templateContext);
if (request.getMethod() == Method.POST) {
- String id = request.getHttpRequest().getPartAsStringFailsafe("post",
36
);
+ String id = request.getHttpRequest().getPartAsStringFailsafe("post",
IdBuilder.ID_STRING_LENGTH
);
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
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);
}
}
throw new RedirectException(returnPage);
}
}