Use web package from utils.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 13 Sep 2011 08:21:12 +0000 (10:21 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 13 Sep 2011 08:32:55 +0000 (10:32 +0200)
75 files changed:
src/main/java/net/pterodactylus/sone/template/GetPagePlugin.java
src/main/java/net/pterodactylus/sone/template/ParserFilter.java
src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java
src/main/java/net/pterodactylus/sone/text/SoneTextParserContext.java
src/main/java/net/pterodactylus/sone/web/AboutPage.java
src/main/java/net/pterodactylus/sone/web/BookmarkPage.java
src/main/java/net/pterodactylus/sone/web/BookmarksPage.java
src/main/java/net/pterodactylus/sone/web/CreatePostPage.java
src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java
src/main/java/net/pterodactylus/sone/web/CreateSonePage.java
src/main/java/net/pterodactylus/sone/web/DeletePostPage.java
src/main/java/net/pterodactylus/sone/web/DeleteProfileFieldPage.java
src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java
src/main/java/net/pterodactylus/sone/web/DeleteSonePage.java
src/main/java/net/pterodactylus/sone/web/DismissNotificationPage.java
src/main/java/net/pterodactylus/sone/web/DistrustPage.java
src/main/java/net/pterodactylus/sone/web/EditProfileFieldPage.java
src/main/java/net/pterodactylus/sone/web/EditProfilePage.java
src/main/java/net/pterodactylus/sone/web/FollowSonePage.java
src/main/java/net/pterodactylus/sone/web/IndexPage.java
src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java
src/main/java/net/pterodactylus/sone/web/LikePage.java
src/main/java/net/pterodactylus/sone/web/LockSonePage.java
src/main/java/net/pterodactylus/sone/web/LoginPage.java
src/main/java/net/pterodactylus/sone/web/LogoutPage.java
src/main/java/net/pterodactylus/sone/web/MarkAsKnownPage.java
src/main/java/net/pterodactylus/sone/web/OptionsPage.java
src/main/java/net/pterodactylus/sone/web/RescuePage.java
src/main/java/net/pterodactylus/sone/web/SearchPage.java
src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java
src/main/java/net/pterodactylus/sone/web/TrustPage.java
src/main/java/net/pterodactylus/sone/web/UnbookmarkPage.java
src/main/java/net/pterodactylus/sone/web/UnfollowSonePage.java
src/main/java/net/pterodactylus/sone/web/UnlikePage.java
src/main/java/net/pterodactylus/sone/web/UnlockSonePage.java
src/main/java/net/pterodactylus/sone/web/UntrustPage.java
src/main/java/net/pterodactylus/sone/web/ViewPostPage.java
src/main/java/net/pterodactylus/sone/web/ViewSonePage.java
src/main/java/net/pterodactylus/sone/web/WebInterface.java
src/main/java/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/DeleteProfileFieldAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/DismissNotificationAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/GetTranslationPage.java
src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java
src/main/java/net/pterodactylus/sone/web/ajax/LikeAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/MoveProfileFieldAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.java
src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java
src/main/java/net/pterodactylus/sone/web/page/FreenetRequest.java [new file with mode: 0644]
src/main/java/net/pterodactylus/sone/web/page/FreenetTemplatePage.java
src/main/java/net/pterodactylus/sone/web/page/Page.java [deleted file]
src/main/java/net/pterodactylus/sone/web/page/PageToadlet.java
src/main/java/net/pterodactylus/sone/web/page/PageToadletFactory.java
src/main/java/net/pterodactylus/sone/web/page/RedirectPage.java [deleted file]
src/main/java/net/pterodactylus/sone/web/page/StaticPage.java [deleted file]
src/main/java/net/pterodactylus/sone/web/page/TemplatePage.java [deleted file]

index a25d619..b2a4962 100644 (file)
@@ -19,9 +19,10 @@ package net.pterodactylus.sone.template;
 
 import java.util.Map;
 
 
 import java.util.Map;
 
-import net.pterodactylus.sone.web.page.Page.Request;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.template.Plugin;
 import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.template.Plugin;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Request;
 
 /**
  * Extracts a page number from a {@link Request}’s parameters and stores it in
 
 /**
  * Extracts a page number from a {@link Request}’s parameters and stores it in
@@ -50,7 +51,7 @@ public class GetPagePlugin implements Plugin {
                        pageKey = "page";
                }
 
                        pageKey = "page";
                }
 
-               Request request = (Request) templateContext.get(requestKey);
+               FreenetRequest request = (FreenetRequest) templateContext.get(requestKey);
                String pageString = request.getHttpRequest().getParam(parameter);
                int page = 0;
                try {
                String pageString = request.getHttpRequest().getParam(parameter);
                int page = 0;
                try {
index 332f504..3494c21 100644 (file)
@@ -35,7 +35,7 @@ import net.pterodactylus.sone.text.PostPart;
 import net.pterodactylus.sone.text.SonePart;
 import net.pterodactylus.sone.text.SoneTextParser;
 import net.pterodactylus.sone.text.SoneTextParserContext;
 import net.pterodactylus.sone.text.SonePart;
 import net.pterodactylus.sone.text.SoneTextParser;
 import net.pterodactylus.sone.text.SoneTextParserContext;
-import net.pterodactylus.sone.web.page.Page.Request;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.template.Filter;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.template.Filter;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
@@ -108,7 +108,7 @@ public class ParserFilter implements Filter {
                if (sone == null) {
                        sone = core.getSone(soneKey, false);
                }
                if (sone == null) {
                        sone = core.getSone(soneKey, false);
                }
-               Request request = (Request) templateContext.get("request");
+               FreenetRequest request = (FreenetRequest) templateContext.get("request");
                SoneTextParserContext context = new SoneTextParserContext(request, sone);
                StringWriter parsedTextWriter = new StringWriter();
                try {
                SoneTextParserContext context = new SoneTextParserContext(request, sone);
                StringWriter parsedTextWriter = new StringWriter();
                try {
index fb31719..a0d80af 100644 (file)
@@ -26,15 +26,15 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 
 import java.util.Map;
 import java.util.Map.Entry;
 
-import net.pterodactylus.sone.web.page.Page.Request;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.template.Filter;
 import net.pterodactylus.util.template.TemplateContext;
 
 /**
 import net.pterodactylus.util.template.Filter;
 import net.pterodactylus.util.template.TemplateContext;
 
 /**
- * This filter expects a {@link Request} as input and outputs a {@link URI} that
- * is modified by the parameters. The name of the parameter is handed in as
- * “name”, the value may either be stored in “value”, or in a template variable
- * whose key is stored in “key”.
+ * This filter expects a {@link FreenetRequest} as input and outputs a
+ * {@link URI} that is modified by the parameters. The name of the parameter is
+ * handed in as “name”, the value may either be stored in “value”, or in a
+ * template variable whose key is stored in “key”.
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
@@ -45,7 +45,7 @@ public class RequestChangeFilter implements Filter {
         */
        @Override
        public Object format(TemplateContext templateContext, Object data, Map<String, String> parameters) {
         */
        @Override
        public Object format(TemplateContext templateContext, Object data, Map<String, String> parameters) {
-               Request request = (Request) data;
+               FreenetRequest request = (FreenetRequest) data;
                String name = parameters.get("name");
                String nameKey = parameters.get("nameKey");
                if (nameKey != null) {
                String name = parameters.get("name");
                String nameKey = parameters.get("nameKey");
                if (nameKey != null) {
index 4a89016..35b190b 100644 (file)
@@ -18,7 +18,7 @@
 package net.pterodactylus.sone.text;
 
 import net.pterodactylus.sone.data.Sone;
 package net.pterodactylus.sone.text;
 
 import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.web.page.Page.Request;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 
 /**
  * {@link ParserContext} implementation for the {@link SoneTextParser}. It
 
 /**
  * {@link ParserContext} implementation for the {@link SoneTextParser}. It
@@ -30,7 +30,7 @@ import net.pterodactylus.sone.web.page.Page.Request;
 public class SoneTextParserContext implements ParserContext {
 
        /** The request being processed. */
 public class SoneTextParserContext implements ParserContext {
 
        /** The request being processed. */
-       private final Request request;
+       private final FreenetRequest request;
 
        /** The posting Sone. */
        private final Sone postingSone;
 
        /** The posting Sone. */
        private final Sone postingSone;
@@ -43,7 +43,7 @@ public class SoneTextParserContext implements ParserContext {
         * @param postingSone
         *            The posting Sone
         */
         * @param postingSone
         *            The posting Sone
         */
-       public SoneTextParserContext(Request request, Sone postingSone) {
+       public SoneTextParserContext(FreenetRequest request, Sone postingSone) {
                this.request = request;
                this.postingSone = postingSone;
        }
                this.request = request;
                this.postingSone = postingSone;
        }
@@ -53,7 +53,7 @@ public class SoneTextParserContext implements ParserContext {
         *
         * @return The request being processed
         */
         *
         * @return The request being processed
         */
-       public Request getRequest() {
+       public FreenetRequest getRequest() {
                return request;
        }
 
                return request;
        }
 
index 4c14457..a9698e4 100644 (file)
@@ -17,6 +17,7 @@
 
 package net.pterodactylus.sone.web;
 
 
 package net.pterodactylus.sone.web;
 
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.version.Version;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.version.Version;
@@ -54,7 +55,7 @@ public class AboutPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                templateContext.set("version", version);
        }
                super.processTemplate(request, templateContext);
                templateContext.set("version", version);
        }
index 12a0934..0ebf9d5 100644 (file)
 
 package net.pterodactylus.sone.web;
 
 
 package net.pterodactylus.sone.web;
 
-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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * Page that lets the user bookmark a post.
 
 /**
  * Page that lets the user bookmark a post.
@@ -46,7 +47,7 @@ public class BookmarkPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@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);
                super.processTemplate(request, templateContext);
                if (request.getMethod() == Method.POST) {
                        String id = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
index d6f63aa..ad1717b 100644 (file)
@@ -23,6 +23,7 @@ import java.util.List;
 import java.util.Set;
 
 import net.pterodactylus.sone.data.Post;
 import java.util.Set;
 
 import net.pterodactylus.sone.data.Post;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.collection.Pagination;
 import net.pterodactylus.util.filter.Filter;
 import net.pterodactylus.util.filter.Filters;
 import net.pterodactylus.util.collection.Pagination;
 import net.pterodactylus.util.filter.Filter;
 import net.pterodactylus.util.filter.Filters;
@@ -57,7 +58,7 @@ public class BookmarksPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                Set<Post> allPosts = webInterface.getCore().getBookmarkedPosts();
                Set<Post> loadedPosts = Filters.filteredSet(allPosts, new Filter<Post>() {
                super.processTemplate(request, templateContext);
                Set<Post> allPosts = webInterface.getCore().getBookmarkedPosts();
                Set<Post> loadedPosts = Filters.filteredSet(allPosts, new Filter<Post>() {
index 147e4ae..22f6efa 100644 (file)
@@ -20,9 +20,10 @@ package net.pterodactylus.sone.web;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.text.TextFilter;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.text.TextFilter;
-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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * This page lets the user create a new {@link Post}.
 
 /**
  * This page lets the user create a new {@link Post}.
@@ -51,7 +52,7 @@ public class CreatePostPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
                if (request.getMethod() == Method.POST) {
                super.processTemplate(request, templateContext);
                String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
                if (request.getMethod() == Method.POST) {
index 2b12352..f28be35 100644 (file)
@@ -20,9 +20,10 @@ package net.pterodactylus.sone.web;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.text.TextFilter;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.text.TextFilter;
-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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * This page lets the user post a reply to a post.
 
 /**
  * This page lets the user post a reply to a post.
@@ -51,7 +52,7 @@ public class CreateReplyPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
                String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim();
                super.processTemplate(request, templateContext);
                String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
                String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim();
index 3f940a3..9878358 100644 (file)
@@ -28,10 +28,11 @@ import java.util.logging.Logger;
 import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.wot.OwnIdentity;
 import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.wot.OwnIdentity;
-import net.pterodactylus.sone.web.page.Page.Request.Method;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 import freenet.clients.http.ToadletContext;
 
 /**
 import freenet.clients.http.ToadletContext;
 
 /**
@@ -94,7 +95,7 @@ public class CreateSonePage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                List<OwnIdentity> ownIdentitiesWithoutSone = getOwnIdentitiesWithoutSone(webInterface.getCore());
                templateContext.set("identitiesWithoutSone", ownIdentitiesWithoutSone);
                super.processTemplate(request, templateContext);
                List<OwnIdentity> ownIdentitiesWithoutSone = getOwnIdentitiesWithoutSone(webInterface.getCore());
                templateContext.set("identitiesWithoutSone", ownIdentitiesWithoutSone);
index 7a36d02..c8fd20f 100644 (file)
 package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Post;
 package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Post;
-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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * Lets the user delete a post they made.
 
 /**
  * Lets the user delete a post they made.
@@ -49,7 +50,7 @@ public class DeletePostPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@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.GET) {
                        String postId = request.getHttpRequest().getParam("post");
                super.processTemplate(request, templateContext);
                if (request.getMethod() == Method.GET) {
                        String postId = request.getHttpRequest().getParam("post");
index 82f2ace..030279b 100644 (file)
@@ -20,9 +20,10 @@ package net.pterodactylus.sone.web;
 import net.pterodactylus.sone.data.Profile;
 import net.pterodactylus.sone.data.Profile.Field;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.data.Profile;
 import net.pterodactylus.sone.data.Profile.Field;
 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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * Page that lets the user confirm the deletion of a profile field.
 
 /**
  * Page that lets the user confirm the deletion of a profile field.
@@ -51,7 +52,7 @@ public class DeleteProfileFieldPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                Sone currentSone = getCurrentSone(request.getToadletContext());
                Profile profile = currentSone.getProfile();
                super.processTemplate(request, templateContext);
                Sone currentSone = getCurrentSone(request.getToadletContext());
                Profile profile = currentSone.getProfile();
index 782589f..226e0d3 100644 (file)
 package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Reply;
 package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Reply;
-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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * This page lets the user delete a reply.
 
 /**
  * This page lets the user delete a reply.
@@ -49,7 +50,7 @@ public class DeleteReplyPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                String replyId = request.getHttpRequest().getPartAsStringFailsafe("reply", 36);
                Reply reply = webInterface.getCore().getReply(replyId);
                super.processTemplate(request, templateContext);
                String replyId = request.getHttpRequest().getPartAsStringFailsafe("reply", 36);
                Reply reply = webInterface.getCore().getReply(replyId);
index 21979b8..bbf533f 100644 (file)
 package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Sone;
 package net.pterodactylus.sone.web;
 
 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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * Lets the user delete a Sone. Of course the Sone is not really deleted from
 
 /**
  * Lets the user delete a Sone. Of course the Sone is not really deleted from
@@ -51,7 +52,7 @@ public class DeleteSonePage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@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) {
                        if (request.getHttpRequest().isPartSet("deleteSone")) {
                super.processTemplate(request, templateContext);
                if (request.getMethod() == Method.POST) {
                        if (request.getHttpRequest().isPartSet("deleteSone")) {
index 15c5675..9d79195 100644 (file)
@@ -17,6 +17,7 @@
 
 package net.pterodactylus.sone.web;
 
 
 package net.pterodactylus.sone.web;
 
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.notify.Notification;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.notify.Notification;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
@@ -48,7 +49,7 @@ public class DismissNotificationPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                String notificationId = request.getHttpRequest().getPartAsStringFailsafe("notification", 36);
                Notification notification = webInterface.getNotifications().getNotification(notificationId);
                super.processTemplate(request, templateContext);
                String notificationId = request.getHttpRequest().getPartAsStringFailsafe("notification", 36);
                Notification notification = webInterface.getNotifications().getNotification(notificationId);
index 37a792c..473bf1c 100644 (file)
@@ -19,9 +19,10 @@ package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Sone;
 
 import net.pterodactylus.sone.core.Core;
 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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * Page that lets the user distrust another Sone. This will assign a
 
 /**
  * Page that lets the user distrust another Sone. This will assign a
@@ -52,7 +53,7 @@ public class DistrustPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@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 returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
                super.processTemplate(request, templateContext);
                if (request.getMethod() == Method.POST) {
                        String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
index 219bdc5..a06592a 100644 (file)
@@ -20,9 +20,10 @@ package net.pterodactylus.sone.web;
 import net.pterodactylus.sone.data.Profile;
 import net.pterodactylus.sone.data.Profile.Field;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.data.Profile;
 import net.pterodactylus.sone.data.Profile.Field;
 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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * Page that lets the user edit the name of a profile field.
 
 /**
  * Page that lets the user edit the name of a profile field.
@@ -51,7 +52,7 @@ public class EditProfileFieldPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                Sone currentSone = getCurrentSone(request.getToadletContext());
                Profile profile = currentSone.getProfile();
                super.processTemplate(request, templateContext);
                Sone currentSone = getCurrentSone(request.getToadletContext());
                Profile profile = currentSone.getProfile();
index 43dd15b..59c7e3e 100644 (file)
@@ -22,10 +22,11 @@ import java.util.List;
 import net.pterodactylus.sone.data.Profile;
 import net.pterodactylus.sone.data.Profile.Field;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.data.Profile;
 import net.pterodactylus.sone.data.Profile.Field;
 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.number.Numbers;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.number.Numbers;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 import freenet.clients.http.ToadletContext;
 
 /**
 import freenet.clients.http.ToadletContext;
 
 /**
@@ -55,7 +56,7 @@ public class EditProfilePage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                ToadletContext toadletContenxt = request.getToadletContext();
                Sone currentSone = getCurrentSone(toadletContenxt);
                super.processTemplate(request, templateContext);
                ToadletContext toadletContenxt = request.getToadletContext();
                Sone currentSone = getCurrentSone(toadletContenxt);
@@ -153,7 +154,7 @@ public class EditProfilePage extends SoneTemplatePage {
         * @return The parsed ID, or {@code null} if there was no part matching the
         *         given string
         */
         * @return The parsed ID, or {@code null} if there was no part matching the
         *         given string
         */
-       private String getFieldId(Request request, String partNameStart) {
+       private String getFieldId(FreenetRequest request, String partNameStart) {
                for (String partName : request.getHttpRequest().getParts()) {
                        if (partName.startsWith(partNameStart)) {
                                return partName.substring(partNameStart.length());
                for (String partName : request.getHttpRequest().getParts()) {
                        if (partName.startsWith(partNameStart)) {
                                return partName.substring(partNameStart.length());
index 81225e9..143e0ba 100644 (file)
 package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Sone;
 package net.pterodactylus.sone.web;
 
 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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * This page lets the user follow another Sone.
 
 /**
  * This page lets the user follow another Sone.
@@ -47,7 +48,7 @@ public class FollowSonePage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@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 returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
                super.processTemplate(request, templateContext);
                if (request.getMethod() == Method.POST) {
                        String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
index 35b88a9..356b4ab 100644 (file)
@@ -24,6 +24,7 @@ import java.util.List;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.notify.ListNotificationFilters;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.notify.ListNotificationFilters;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.collection.Pagination;
 import net.pterodactylus.util.filter.Filter;
 import net.pterodactylus.util.filter.Filters;
 import net.pterodactylus.util.collection.Pagination;
 import net.pterodactylus.util.filter.Filter;
 import net.pterodactylus.util.filter.Filters;
@@ -57,7 +58,7 @@ public class IndexPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                final Sone currentSone = getCurrentSone(request.getToadletContext());
                List<Post> allPosts = new ArrayList<Post>();
                super.processTemplate(request, templateContext);
                final Sone currentSone = getCurrentSone(request.getToadletContext());
                List<Post> allPosts = new ArrayList<Post>();
index ad63791..52e4239 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Collections;
 import java.util.List;
 
 import net.pterodactylus.sone.data.Sone;
 import java.util.List;
 
 import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.collection.Pagination;
 import net.pterodactylus.util.collection.ReverseComparator;
 import net.pterodactylus.util.filter.Filter;
 import net.pterodactylus.util.collection.Pagination;
 import net.pterodactylus.util.collection.ReverseComparator;
 import net.pterodactylus.util.filter.Filter;
@@ -57,7 +58,7 @@ public class KnownSonesPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                String sortField = request.getHttpRequest().getParam("sort");
                String sortOrder = request.getHttpRequest().getParam("order");
                super.processTemplate(request, templateContext);
                String sortField = request.getHttpRequest().getParam("sort");
                String sortOrder = request.getHttpRequest().getParam("order");
index 56f55ef..c5174c6 100644 (file)
@@ -19,9 +19,10 @@ package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 
 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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * Page that lets the user like a {@link Post}.
 
 /**
  * Page that lets the user like a {@link Post}.
@@ -50,7 +51,7 @@ public class LikePage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@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 type = request.getHttpRequest().getPartAsStringFailsafe("type", 16);
                super.processTemplate(request, templateContext);
                if (request.getMethod() == Method.POST) {
                        String type = request.getHttpRequest().getPartAsStringFailsafe("type", 16);
index d09de66..a56d263 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Sone;
 package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Sone;
+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;
 
@@ -49,7 +50,7 @@ public class LockSonePage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
                Sone sone = webInterface.getCore().getLocalSone(soneId, false);
                super.processTemplate(request, templateContext);
                String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
                Sone sone = webInterface.getCore().getLocalSone(soneId, false);
index 8e612ea..6f43b6f 100644 (file)
@@ -24,10 +24,11 @@ import java.util.logging.Logger;
 
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.wot.OwnIdentity;
 
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.wot.OwnIdentity;
-import net.pterodactylus.sone.web.page.Page.Request.Method;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 import freenet.clients.http.ToadletContext;
 
 /**
 import freenet.clients.http.ToadletContext;
 
 /**
@@ -61,7 +62,7 @@ public class LoginPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                /* get all own identities. */
                List<Sone> localSones = new ArrayList<Sone>(webInterface.getCore().getLocalSones());
                super.processTemplate(request, templateContext);
                /* get all own identities. */
                List<Sone> localSones = new ArrayList<Sone>(webInterface.getCore().getLocalSones());
@@ -87,7 +88,7 @@ public class LoginPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected String getRedirectTarget(Request request) {
+       protected String getRedirectTarget(FreenetRequest request) {
                if (getCurrentSone(request.getToadletContext(), false) != null) {
                        return "index.html";
                }
                if (getCurrentSone(request.getToadletContext(), false) != null) {
                        return "index.html";
                }
index 7cd0587..a7f769f 100644 (file)
@@ -17,6 +17,7 @@
 
 package net.pterodactylus.sone.web;
 
 
 package net.pterodactylus.sone.web;
 
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 import freenet.clients.http.ToadletContext;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 import freenet.clients.http.ToadletContext;
@@ -46,7 +47,7 @@ public class LogoutPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                setCurrentSone(request.getToadletContext(), null);
                super.processTemplate(request, templateContext);
                throw new RedirectException("index.html");
                setCurrentSone(request.getToadletContext(), null);
                super.processTemplate(request, templateContext);
                throw new RedirectException("index.html");
index 9f91c84..987fa1f 100644 (file)
@@ -22,6 +22,7 @@ import java.util.StringTokenizer;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
+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;
 
@@ -53,7 +54,7 @@ public class MarkAsKnownPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                String type = request.getHttpRequest().getPartAsStringFailsafe("type", 5);
                if (!type.equals("sone") && !type.equals("post") && !type.equals("reply")) {
                super.processTemplate(request, templateContext);
                String type = request.getHttpRequest().getPartAsStringFailsafe("type", 5);
                if (!type.equals("sone") && !type.equals("post") && !type.equals("reply")) {
index fda6afd..75e73a0 100644 (file)
@@ -23,10 +23,11 @@ import java.util.List;
 import net.pterodactylus.sone.core.Core.Preferences;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired;
 import net.pterodactylus.sone.core.Core.Preferences;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired;
-import net.pterodactylus.sone.web.page.Page.Request.Method;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.number.Numbers;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.number.Numbers;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * This page lets the user edit the options of the Sone plugin.
 
 /**
  * This page lets the user edit the options of the Sone plugin.
@@ -55,7 +56,7 @@ public class OptionsPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                Preferences preferences = webInterface.getCore().getPreferences();
                Sone currentSone = webInterface.getCurrentSone(request.getToadletContext(), false);
                super.processTemplate(request, templateContext);
                Preferences preferences = webInterface.getCore().getPreferences();
                Sone currentSone = webInterface.getCurrentSone(request.getToadletContext(), false);
index 40b03f1..f653615 100644 (file)
@@ -19,10 +19,11 @@ package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.core.SoneRescuer;
 import net.pterodactylus.sone.data.Sone;
 
 import net.pterodactylus.sone.core.SoneRescuer;
 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.number.Numbers;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.number.Numbers;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * Page that lets the user control the rescue mode for a Sone.
 
 /**
  * Page that lets the user control the rescue mode for a Sone.
@@ -52,7 +53,7 @@ public class RescuePage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                Sone currentSone = getCurrentSone(request.getToadletContext(), false);
                SoneRescuer soneRescuer = webInterface.getCore().getSoneRescuer(currentSone);
                super.processTemplate(request, templateContext);
                Sone currentSone = getCurrentSone(request.getToadletContext(), false);
                SoneRescuer soneRescuer = webInterface.getCore().getSoneRescuer(currentSone);
index fab7a57..91e2a08 100644 (file)
@@ -32,6 +32,7 @@ import net.pterodactylus.sone.data.Profile;
 import net.pterodactylus.sone.data.Profile.Field;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.data.Profile.Field;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.cache.Cache;
 import net.pterodactylus.util.cache.CacheException;
 import net.pterodactylus.util.cache.CacheItem;
 import net.pterodactylus.util.cache.Cache;
 import net.pterodactylus.util.cache.CacheException;
 import net.pterodactylus.util.cache.CacheItem;
@@ -96,7 +97,7 @@ public class SearchPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                String query = request.getHttpRequest().getParam("query").trim();
                if (query.length() == 0) {
                super.processTemplate(request, templateContext);
                String query = request.getHttpRequest().getParam("query").trim();
                if (query.length() == 0) {
index b7e36f4..095db9e 100644 (file)
@@ -27,8 +27,8 @@ import java.util.Map;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.main.SonePlugin;
 import net.pterodactylus.sone.notify.ListNotificationFilters;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.main.SonePlugin;
 import net.pterodactylus.sone.notify.ListNotificationFilters;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.sone.web.page.FreenetTemplatePage;
 import net.pterodactylus.sone.web.page.FreenetTemplatePage;
-import net.pterodactylus.sone.web.page.Page;
 import net.pterodactylus.util.collection.ListBuilder;
 import net.pterodactylus.util.collection.MapBuilder;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.collection.ListBuilder;
 import net.pterodactylus.util.collection.MapBuilder;
 import net.pterodactylus.util.template.Template;
@@ -202,7 +202,7 @@ public class SoneTemplatePage extends FreenetTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected String getPageTitle(Request request) {
+       protected String getPageTitle(FreenetRequest request) {
                if (pageTitleKey != null) {
                        return webInterface.getL10n().getString(pageTitleKey);
                }
                if (pageTitleKey != null) {
                        return webInterface.getL10n().getString(pageTitleKey);
                }
@@ -213,7 +213,7 @@ public class SoneTemplatePage extends FreenetTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected List<Map<String, String>> getAdditionalLinkNodes(Request request) {
+       protected List<Map<String, String>> getAdditionalLinkNodes(FreenetRequest request) {
                return new ListBuilder<Map<String, String>>().add(new MapBuilder<String, String>().put("rel", "search").put("type", "application/opensearchdescription+xml").put("title", "Sone").put("href", "http://" + request.getHttpRequest().getHeader("host") + "/Sone/OpenSearch.xml").get()).get();
        }
 
                return new ListBuilder<Map<String, String>>().add(new MapBuilder<String, String>().put("rel", "search").put("type", "application/opensearchdescription+xml").put("title", "Sone").put("href", "http://" + request.getHttpRequest().getHeader("host") + "/Sone/OpenSearch.xml").get()).get();
        }
 
@@ -247,7 +247,7 @@ public class SoneTemplatePage extends FreenetTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                Sone currentSone = getCurrentSone(request.getToadletContext(), false);
                templateContext.set("core", webInterface.getCore());
                super.processTemplate(request, templateContext);
                Sone currentSone = getCurrentSone(request.getToadletContext(), false);
                templateContext.set("core", webInterface.getCore());
@@ -266,7 +266,7 @@ public class SoneTemplatePage extends FreenetTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected String getRedirectTarget(Page.Request request) {
+       protected String getRedirectTarget(FreenetRequest request) {
                if (requiresLogin() && (getCurrentSone(request.getToadletContext(), false) == null)) {
                        HTTPRequest httpRequest = request.getHttpRequest();
                        String originalUrl = httpRequest.getPath();
                if (requiresLogin() && (getCurrentSone(request.getToadletContext(), false) == null)) {
                        HTTPRequest httpRequest = request.getHttpRequest();
                        String originalUrl = httpRequest.getPath();
index b0dadef..f2cf92e 100644 (file)
@@ -19,9 +19,10 @@ package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Sone;
 
 import net.pterodactylus.sone.core.Core;
 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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * Page that lets the user trust another Sone. This will assign a configurable
 
 /**
  * Page that lets the user trust another Sone. This will assign a configurable
@@ -52,7 +53,7 @@ public class TrustPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@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 returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
                super.processTemplate(request, templateContext);
                if (request.getMethod() == Method.POST) {
                        String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
index 60165b2..def3bf4 100644 (file)
@@ -20,9 +20,10 @@ package net.pterodactylus.sone.web;
 import java.util.Set;
 
 import net.pterodactylus.sone.data.Post;
 import java.util.Set;
 
 import net.pterodactylus.sone.data.Post;
-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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * Page that lets the user unbookmark a post.
 
 /**
  * Page that lets the user unbookmark a post.
@@ -49,7 +50,7 @@ public class UnbookmarkPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@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);
                super.processTemplate(request, templateContext);
                if (request.getMethod() == Method.POST) {
                        String id = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
index 33b88a1..d8e53ce 100644 (file)
 package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Sone;
 package net.pterodactylus.sone.web;
 
 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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * This page lets the user unfollow another Sone.
 
 /**
  * This page lets the user unfollow another Sone.
@@ -47,7 +48,7 @@ public class UnfollowSonePage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@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 returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
                super.processTemplate(request, templateContext);
                if (request.getMethod() == Method.POST) {
                        String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
index 24ff3ca..f47c4f2 100644 (file)
@@ -19,9 +19,10 @@ package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 
 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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * Page that lets the user unlike a {@link Post}.
 
 /**
  * Page that lets the user unlike a {@link Post}.
@@ -50,7 +51,7 @@ public class UnlikePage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@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 type = request.getHttpRequest().getPartAsStringFailsafe("type", 16);
                super.processTemplate(request, templateContext);
                if (request.getMethod() == Method.POST) {
                        String type = request.getHttpRequest().getPartAsStringFailsafe("type", 16);
index ccb5959..f527558 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Sone;
 package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Sone;
+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;
 
@@ -48,7 +49,7 @@ public class UnlockSonePage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
                Sone sone = webInterface.getCore().getLocalSone(soneId, false);
                super.processTemplate(request, templateContext);
                String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
                Sone sone = webInterface.getCore().getLocalSone(soneId, false);
index c5e7dec..d711525 100644 (file)
@@ -19,9 +19,10 @@ package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Sone;
 
 import net.pterodactylus.sone.core.Core;
 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.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
+import net.pterodactylus.util.web.Method;
 
 /**
  * Page that lets the user untrust another Sone. This will remove all trust
 
 /**
  * Page that lets the user untrust another Sone. This will remove all trust
@@ -52,7 +53,7 @@ public class UntrustPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@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 returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
                super.processTemplate(request, templateContext);
                if (request.getMethod() == Method.POST) {
                        String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
index b62e19c..4cc9864 100644 (file)
@@ -19,6 +19,7 @@ package net.pterodactylus.sone.web;
 
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.template.SoneAccessor;
 
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.template.SoneAccessor;
+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;
 
@@ -49,7 +50,7 @@ public class ViewPostPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected String getPageTitle(Request request) {
+       protected String getPageTitle(FreenetRequest request) {
                String postId = request.getHttpRequest().getParam("post");
                Post post = webInterface.getCore().getPost(postId, false);
                String title = "";
                String postId = request.getHttpRequest().getParam("post");
                Post post = webInterface.getCore().getPost(postId, false);
                String title = "";
@@ -65,7 +66,7 @@ public class ViewPostPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                String postId = request.getHttpRequest().getParam("post");
                boolean raw = request.getHttpRequest().getParam("raw").equals("true");
                super.processTemplate(request, templateContext);
                String postId = request.getHttpRequest().getParam("post");
                boolean raw = request.getHttpRequest().getParam("raw").equals("true");
index 889c74c..5d463c0 100644 (file)
@@ -29,6 +29,7 @@ import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.template.SoneAccessor;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.template.SoneAccessor;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.collection.Pagination;
 import net.pterodactylus.util.number.Numbers;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.collection.Pagination;
 import net.pterodactylus.util.number.Numbers;
 import net.pterodactylus.util.template.Template;
@@ -61,7 +62,7 @@ public class ViewSonePage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected String getPageTitle(Request request) {
+       protected String getPageTitle(FreenetRequest request) {
                String soneId = request.getHttpRequest().getParam("sone");
                Sone sone = webInterface.getCore().getSone(soneId, false);
                if ((sone != null) && (sone.getTime() > 0)) {
                String soneId = request.getHttpRequest().getParam("sone");
                Sone sone = webInterface.getCore().getSone(soneId, false);
                if ((sone != null) && (sone.getTime() > 0)) {
@@ -75,7 +76,7 @@ public class ViewSonePage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                String soneId = request.getHttpRequest().getParam("sone");
                Sone sone = webInterface.getCore().getSone(soneId, false);
                super.processTemplate(request, templateContext);
                String soneId = request.getHttpRequest().getParam("sone");
                Sone sone = webInterface.getCore().getSone(soneId, false);
index 08202d4..3eb1ac3 100644 (file)
@@ -90,11 +90,9 @@ import net.pterodactylus.sone.web.ajax.UnfollowSoneAjaxPage;
 import net.pterodactylus.sone.web.ajax.UnlikeAjaxPage;
 import net.pterodactylus.sone.web.ajax.UnlockSoneAjaxPage;
 import net.pterodactylus.sone.web.ajax.UntrustAjaxPage;
 import net.pterodactylus.sone.web.ajax.UnlikeAjaxPage;
 import net.pterodactylus.sone.web.ajax.UnlockSoneAjaxPage;
 import net.pterodactylus.sone.web.ajax.UntrustAjaxPage;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.sone.web.page.PageToadlet;
 import net.pterodactylus.sone.web.page.PageToadletFactory;
 import net.pterodactylus.sone.web.page.PageToadlet;
 import net.pterodactylus.sone.web.page.PageToadletFactory;
-import net.pterodactylus.sone.web.page.RedirectPage;
-import net.pterodactylus.sone.web.page.StaticPage;
-import net.pterodactylus.sone.web.page.TemplatePage;
 import net.pterodactylus.util.cache.Cache;
 import net.pterodactylus.util.cache.CacheException;
 import net.pterodactylus.util.cache.CacheItem;
 import net.pterodactylus.util.cache.Cache;
 import net.pterodactylus.util.cache.CacheException;
 import net.pterodactylus.util.cache.CacheItem;
@@ -125,6 +123,9 @@ import net.pterodactylus.util.template.TemplateParser;
 import net.pterodactylus.util.template.XmlFilter;
 import net.pterodactylus.util.thread.Ticker;
 import net.pterodactylus.util.version.Version;
 import net.pterodactylus.util.template.XmlFilter;
 import net.pterodactylus.util.thread.Ticker;
 import net.pterodactylus.util.version.Version;
+import net.pterodactylus.util.web.RedirectPage;
+import net.pterodactylus.util.web.StaticPage;
+import net.pterodactylus.util.web.TemplatePage;
 import freenet.clients.http.SessionManager;
 import freenet.clients.http.SessionManager.Session;
 import freenet.clients.http.ToadletContainer;
 import freenet.clients.http.SessionManager;
 import freenet.clients.http.SessionManager.Session;
 import freenet.clients.http.ToadletContainer;
@@ -569,7 +570,7 @@ public class WebInterface implements CoreListener {
                Template openSearchTemplate = TemplateParser.parse(createReader("/templates/xml/OpenSearch.xml"));
 
                PageToadletFactory pageToadletFactory = new PageToadletFactory(sonePlugin.pluginRespirator().getHLSimpleClient(), "/Sone/");
                Template openSearchTemplate = TemplateParser.parse(createReader("/templates/xml/OpenSearch.xml"));
 
                PageToadletFactory pageToadletFactory = new PageToadletFactory(sonePlugin.pluginRespirator().getHLSimpleClient(), "/Sone/");
-               pageToadlets.add(pageToadletFactory.createPageToadlet(new RedirectPage("", "index.html")));
+               pageToadlets.add(pageToadletFactory.createPageToadlet(new RedirectPage<FreenetRequest>("", "index.html")));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new IndexPage(indexTemplate, this), "Index"));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateSonePage(createSoneTemplate, this), "CreateSone"));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new KnownSonesPage(knownSonesTemplate, this), "KnownSones"));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new IndexPage(indexTemplate, this), "Index"));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateSonePage(createSoneTemplate, this), "CreateSone"));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new KnownSonesPage(knownSonesTemplate, this), "KnownSones"));
@@ -605,10 +606,10 @@ public class WebInterface implements CoreListener {
                pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", noPermissionTemplate, "Page.NoPermission.Title", this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationPage(emptyTemplate, this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("invalid.html", invalidTemplate, "Page.Invalid.Title", this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", noPermissionTemplate, "Page.NoPermission.Title", this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationPage(emptyTemplate, this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("invalid.html", invalidTemplate, "Page.Invalid.Title", this)));
-               pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("css/", "/static/css/", "text/css")));
-               pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("javascript/", "/static/javascript/", "text/javascript")));
-               pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("images/", "/static/images/", "image/png")));
-               pageToadlets.add(pageToadletFactory.createPageToadlet(new TemplatePage("OpenSearch.xml", "application/opensearchdescription+xml", templateContextFactory, openSearchTemplate)));
+               pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage<FreenetRequest>("css/", "/static/css/", "text/css")));
+               pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage<FreenetRequest>("javascript/", "/static/javascript/", "text/javascript")));
+               pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage<FreenetRequest>("images/", "/static/images/", "image/png")));
+               pageToadlets.add(pageToadletFactory.createPageToadlet(new TemplatePage<FreenetRequest>("OpenSearch.xml", "application/opensearchdescription+xml", templateContextFactory, openSearchTemplate)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new GetTranslationPage(this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new GetStatusAjaxPage(this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new GetNotificationAjaxPage(this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new GetTranslationPage(this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new GetStatusAjaxPage(this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new GetNotificationAjaxPage(this)));
index 760bd34..0cf7b01 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.sone.web.ajax;
 
 import net.pterodactylus.sone.web.WebInterface;
 package net.pterodactylus.sone.web.ajax;
 
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -45,7 +46,7 @@ public class BookmarkAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String id = request.getHttpRequest().getParam("post", null);
                if ((id == null) || (id.length() == 0)) {
                        return createErrorJsonObject("invalid-post-id");
                String id = request.getHttpRequest().getParam("post", null);
                if ((id == null) || (id.length() == 0)) {
                        return createErrorJsonObject("invalid-post-id");
index 0fc1236..c6f4455 100644 (file)
@@ -21,6 +21,7 @@ import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.text.TextFilter;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.text.TextFilter;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -44,7 +45,7 @@ public class CreatePostAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                Sone sone = getCurrentSone(request.getToadletContext());
                if (sone == null) {
                        return createErrorJsonObject("auth-required");
                Sone sone = getCurrentSone(request.getToadletContext());
                if (sone == null) {
                        return createErrorJsonObject("auth-required");
index ce78f58..9f5c882 100644 (file)
@@ -22,6 +22,7 @@ import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.text.TextFilter;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.text.TextFilter;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -49,7 +50,7 @@ public class CreateReplyAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String postId = request.getHttpRequest().getParam("post");
                String text = request.getHttpRequest().getParam("text").trim();
                String senderId = request.getHttpRequest().getParam("sender");
                String postId = request.getHttpRequest().getParam("post");
                String text = request.getHttpRequest().getParam("text").trim();
                String senderId = request.getHttpRequest().getParam("sender");
index 8d3b414..37ab040 100644 (file)
@@ -19,6 +19,7 @@ package net.pterodactylus.sone.web.ajax;
 
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.web.WebInterface;
 
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -46,7 +47,7 @@ public class DeletePostAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String postId = request.getHttpRequest().getParam("post");
                Post post = webInterface.getCore().getPost(postId, false);
                if ((post == null) || (post.getSone() == null)) {
                String postId = request.getHttpRequest().getParam("post");
                Post post = webInterface.getCore().getPost(postId, false);
                if ((post == null) || (post.getSone() == null)) {
index 4625c13..205fb85 100644 (file)
@@ -21,6 +21,7 @@ import net.pterodactylus.sone.data.Profile;
 import net.pterodactylus.sone.data.Profile.Field;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Profile.Field;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -44,7 +45,7 @@ public class DeleteProfileFieldAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String fieldId = request.getHttpRequest().getParam("field");
                Sone currentSone = getCurrentSone(request.getToadletContext());
                Profile profile = currentSone.getProfile();
                String fieldId = request.getHttpRequest().getParam("field");
                Sone currentSone = getCurrentSone(request.getToadletContext());
                Profile profile = currentSone.getProfile();
index e12b2cf..7bea4cf 100644 (file)
@@ -19,6 +19,7 @@ package net.pterodactylus.sone.web.ajax;
 
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.web.WebInterface;
 
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -46,7 +47,7 @@ public class DeleteReplyAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String replyId = request.getHttpRequest().getParam("reply");
                Reply reply = webInterface.getCore().getReply(replyId);
                if (reply == null) {
                String replyId = request.getHttpRequest().getParam("reply");
                Reply reply = webInterface.getCore().getReply(replyId);
                if (reply == null) {
index 08e3ee5..232cab6 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.sone.web.ajax;
 
 import net.pterodactylus.sone.web.WebInterface;
 package net.pterodactylus.sone.web.ajax;
 
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.notify.Notification;
 
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.notify.Notification;
 
@@ -42,7 +43,7 @@ public class DismissNotificationAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String notificationId = request.getHttpRequest().getParam("notification");
                Notification notification = webInterface.getNotifications().getNotification(notificationId);
                if (notification == null) {
                String notificationId = request.getHttpRequest().getParam("notification");
                Notification notification = webInterface.getNotifications().getNotification(notificationId);
                if (notification == null) {
index ca770e4..4ba3dbb 100644 (file)
@@ -21,6 +21,7 @@ import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.wot.Trust;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.wot.Trust;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -45,7 +46,7 @@ public class DistrustAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                Sone currentSone = getCurrentSone(request.getToadletContext(), false);
                if (currentSone == null) {
                        return createErrorJsonObject("auth-required");
                Sone currentSone = getCurrentSone(request.getToadletContext(), false);
                if (currentSone == null) {
                        return createErrorJsonObject("auth-required");
index 0036545..5351281 100644 (file)
@@ -21,6 +21,7 @@ import net.pterodactylus.sone.data.Profile;
 import net.pterodactylus.sone.data.Profile.Field;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Profile.Field;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -48,7 +49,7 @@ public class EditProfileFieldAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String fieldId = request.getHttpRequest().getParam("field");
                Sone currentSone = getCurrentSone(request.getToadletContext());
                Profile profile = currentSone.getProfile();
                String fieldId = request.getHttpRequest().getParam("field");
                Sone currentSone = getCurrentSone(request.getToadletContext());
                Profile profile = currentSone.getProfile();
index d82ab1d..5c3e5f4 100644 (file)
@@ -19,6 +19,7 @@ package net.pterodactylus.sone.web.ajax;
 
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
 
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -42,7 +43,7 @@ public class FollowSoneAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String soneId = request.getHttpRequest().getParam("sone");
                if (!webInterface.getCore().hasSone(soneId)) {
                        return createErrorJsonObject("invalid-sone-id");
                String soneId = request.getHttpRequest().getParam("sone");
                if (!webInterface.getCore().hasSone(soneId)) {
                        return createErrorJsonObject("invalid-sone-id");
index a8b991d..539be3d 100644 (file)
@@ -27,6 +27,7 @@ import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.template.SoneAccessor;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.template.SoneAccessor;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonArray;
 import net.pterodactylus.util.json.JsonObject;
 
 import net.pterodactylus.util.json.JsonArray;
 import net.pterodactylus.util.json.JsonObject;
 
@@ -55,7 +56,7 @@ public class GetLikesAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String type = request.getHttpRequest().getParam("type", null);
                String id = request.getHttpRequest().getParam(type, null);
                if ((id == null) || (id.length() == 0)) {
                String type = request.getHttpRequest().getParam("type", null);
                String id = request.getHttpRequest().getParam(type, null);
                if ((id == null) || (id.length() == 0)) {
index 8bfe472..198a04f 100644 (file)
@@ -27,6 +27,7 @@ import net.pterodactylus.sone.main.SonePlugin;
 import net.pterodactylus.sone.notify.ListNotification;
 import net.pterodactylus.sone.notify.ListNotificationFilters;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.notify.ListNotification;
 import net.pterodactylus.sone.notify.ListNotificationFilters;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.notify.Notification;
 import net.pterodactylus.util.notify.TemplateNotification;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.notify.Notification;
 import net.pterodactylus.util.notify.TemplateNotification;
@@ -75,7 +76,7 @@ public class GetNotificationAjaxPage extends JsonPage {
         */
        @Override
        @SuppressWarnings("unchecked")
         */
        @Override
        @SuppressWarnings("unchecked")
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String[] notificationIds = request.getHttpRequest().getParam("notifications").split(",");
                JsonObject jsonNotifications = new JsonObject();
                Sone currentSone = getCurrentSone(request.getToadletContext(), false);
                String[] notificationIds = request.getHttpRequest().getParam("notifications").split(",");
                JsonObject jsonNotifications = new JsonObject();
                Sone currentSone = getCurrentSone(request.getToadletContext(), false);
@@ -110,7 +111,7 @@ public class GetNotificationAjaxPage extends JsonPage {
         *            The notification to create a JSON object
         * @return The JSON object
         */
         *            The notification to create a JSON object
         * @return The JSON object
         */
-       private JsonObject createJsonNotification(Request request, Notification notification) {
+       private JsonObject createJsonNotification(FreenetRequest request, Notification notification) {
                JsonObject jsonNotification = new JsonObject();
                jsonNotification.put("id", notification.getId());
                StringWriter notificationWriter = new StringWriter();
                JsonObject jsonNotification = new JsonObject();
                jsonNotification.put("id", notification.getId());
                StringWriter notificationWriter = new StringWriter();
index f56c5b7..8be816d 100644 (file)
@@ -22,6 +22,7 @@ import java.io.StringWriter;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.io.Closer;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.io.Closer;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.template.Template;
@@ -56,7 +57,7 @@ public class GetPostAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String postId = request.getHttpRequest().getParam("post");
                Post post = webInterface.getCore().getPost(postId, false);
                if (post == null) {
                String postId = request.getHttpRequest().getParam("post");
                Post post = webInterface.getCore().getPost(postId, false);
                if (post == null) {
@@ -89,7 +90,7 @@ public class GetPostAjaxPage extends JsonPage {
         *            The currently logged in Sone (to store in the template)
         * @return The JSON representation of the post
         */
         *            The currently logged in Sone (to store in the template)
         * @return The JSON representation of the post
         */
-       private JsonObject createJsonPost(Request request, Post post, Sone currentSone) {
+       private JsonObject createJsonPost(FreenetRequest request, Post post, Sone currentSone) {
                JsonObject jsonPost = new JsonObject();
                jsonPost.put("id", post.getId());
                jsonPost.put("sone", post.getSone().getId());
                JsonObject jsonPost = new JsonObject();
                jsonPost.put("id", post.getId());
                jsonPost.put("sone", post.getSone().getId());
index 6cc7d47..2eef58a 100644 (file)
@@ -22,6 +22,7 @@ import java.io.StringWriter;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.io.Closer;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.io.Closer;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.template.Template;
@@ -59,7 +60,7 @@ public class GetReplyAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String replyId = request.getHttpRequest().getParam("reply");
                Reply reply = webInterface.getCore().getReply(replyId);
                if ((reply == null) || (reply.getSone() == null)) {
                String replyId = request.getHttpRequest().getParam("reply");
                Reply reply = webInterface.getCore().getReply(replyId);
                if ((reply == null) || (reply.getSone() == null)) {
@@ -91,7 +92,7 @@ public class GetReplyAjaxPage extends JsonPage {
         *            The currently logged in Sone (to store in the template)
         * @return The JSON representation of the reply
         */
         *            The currently logged in Sone (to store in the template)
         * @return The JSON representation of the reply
         */
-       private JsonObject createJsonReply(Request request, Reply reply, Sone currentSone) {
+       private JsonObject createJsonReply(FreenetRequest request, Reply reply, Sone currentSone) {
                JsonObject jsonReply = new JsonObject();
                jsonReply.put("id", reply.getId());
                jsonReply.put("postId", reply.getPost().getId());
                JsonObject jsonReply = new JsonObject();
                jsonReply.put("id", reply.getId());
                jsonReply.put("postId", reply.getPost().getId());
index f704905..eaa6506 100644 (file)
@@ -31,6 +31,7 @@ import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.notify.ListNotificationFilters;
 import net.pterodactylus.sone.template.SoneAccessor;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.notify.ListNotificationFilters;
 import net.pterodactylus.sone.template.SoneAccessor;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.filter.Filter;
 import net.pterodactylus.util.filter.Filters;
 import net.pterodactylus.util.json.JsonArray;
 import net.pterodactylus.util.filter.Filter;
 import net.pterodactylus.util.filter.Filters;
 import net.pterodactylus.util.json.JsonArray;
@@ -62,7 +63,7 @@ public class GetStatusAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                final Sone currentSone = getCurrentSone(request.getToadletContext(), false);
                /* load Sones. */
                boolean loadAllSones = Boolean.parseBoolean(request.getHttpRequest().getParam("loadAllSones", "false"));
                final Sone currentSone = getCurrentSone(request.getToadletContext(), false);
                /* load Sones. */
                boolean loadAllSones = Boolean.parseBoolean(request.getHttpRequest().getParam("loadAllSones", "false"));
index f03e6e4..1711a5b 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Date;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.number.Digits;
 
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.number.Digits;
 
@@ -51,7 +52,7 @@ public class GetTimesAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String allIds = request.getHttpRequest().getParam("posts");
                JsonObject postTimes = new JsonObject();
                if (allIds.length() > 0) {
                String allIds = request.getHttpRequest().getParam("posts");
                JsonObject postTimes = new JsonObject();
                if (allIds.length() > 0) {
index 725b13a..e0909ca 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.sone.web.ajax;
 
 import net.pterodactylus.sone.web.WebInterface;
 package net.pterodactylus.sone.web.ajax;
 
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -45,7 +46,7 @@ public class GetTranslationPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String key = request.getHttpRequest().getParam("key");
                String translation = webInterface.getL10n().getString(key);
                return createSuccessJsonObject().put("value", translation);
                String key = request.getHttpRequest().getParam("key");
                String translation = webInterface.getL10n().getString(key);
                return createSuccessJsonObject().put("value", translation);
index b027ab8..1e5e8ed 100644 (file)
 
 package net.pterodactylus.sone.web.ajax;
 
 
 package net.pterodactylus.sone.web.ajax;
 
+import java.io.IOException;
+
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
-import net.pterodactylus.sone.web.page.Page;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.json.JsonUtils;
 import net.pterodactylus.util.json.JsonObject;
 import net.pterodactylus.util.json.JsonUtils;
+import net.pterodactylus.util.web.Page;
+import net.pterodactylus.util.web.Response;
 import freenet.clients.http.SessionManager.Session;
 import freenet.clients.http.ToadletContext;
 
 import freenet.clients.http.SessionManager.Session;
 import freenet.clients.http.ToadletContext;
 
@@ -31,7 +35,7 @@ import freenet.clients.http.ToadletContext;
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
-public abstract class JsonPage implements Page {
+public abstract class JsonPage implements Page<FreenetRequest> {
 
        /** The path of the page. */
        private final String path;
 
        /** The path of the page. */
        private final String path;
@@ -124,7 +128,7 @@ public abstract class JsonPage implements Page {
         *            The request to handle
         * @return The created JSON object
         */
         *            The request to handle
         * @return The created JSON object
         */
-       protected abstract JsonObject createJsonObject(Request request);
+       protected abstract JsonObject createJsonObject(FreenetRequest request);
 
        /**
         * Returns whether this command needs the form password for authentication
 
        /**
         * Returns whether this command needs the form password for authentication
@@ -187,23 +191,31 @@ public abstract class JsonPage implements Page {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       public Response handleRequest(Request request) {
+       public boolean isPrefixPage() {
+               return false;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public Response handleRequest(FreenetRequest request, Response response) throws IOException {
                if (webInterface.getCore().getPreferences().isRequireFullAccess() && !request.getToadletContext().isAllowedFullAccess()) {
                if (webInterface.getCore().getPreferences().isRequireFullAccess() && !request.getToadletContext().isAllowedFullAccess()) {
-                       return new Response(403, "Forbidden", "application/json", JsonUtils.format(new JsonObject().put("success", false).put("error", "auth-required")));
+                       return response.setStatusCode(403).setStatusText("Forbidden").setContentType("application/json").write(JsonUtils.format(new JsonObject().put("success", false).put("error", "auth-required")));
                }
                if (needsFormPassword()) {
                        String formPassword = request.getHttpRequest().getParam("formPassword");
                        if (!webInterface.getFormPassword().equals(formPassword)) {
                }
                if (needsFormPassword()) {
                        String formPassword = request.getHttpRequest().getParam("formPassword");
                        if (!webInterface.getFormPassword().equals(formPassword)) {
-                               return new Response(403, "Forbidden", "application/json", JsonUtils.format(new JsonObject().put("success", false).put("error", "auth-required")));
+                               return response.setStatusCode(403).setStatusText("Forbidden").setContentType("application/json").write(JsonUtils.format(new JsonObject().put("success", false).put("error", "auth-required")));
                        }
                }
                if (requiresLogin()) {
                        if (getCurrentSone(request.getToadletContext(), false) == null) {
                        }
                }
                if (requiresLogin()) {
                        if (getCurrentSone(request.getToadletContext(), false) == null) {
-                               return new Response(403, "Forbidden", "application/json", JsonUtils.format(createErrorJsonObject("auth-required")));
+                               return response.setStatusCode(403).setStatusText("Forbidden").setContentType("application/json").write(JsonUtils.format(new JsonObject().put("success", false).put("error", "auth-required")));
                        }
                }
                JsonObject jsonObject = createJsonObject(request);
                        }
                }
                JsonObject jsonObject = createJsonObject(request);
-               return new Response(200, "OK", "application/json", JsonUtils.format(jsonObject));
+               return response.setStatusCode(200).setStatusText("OK").setContentType("application/json").write(JsonUtils.format(jsonObject));
        }
 
 }
        }
 
 }
index bf87ead..e4d168f 100644 (file)
@@ -20,6 +20,7 @@ package net.pterodactylus.sone.web.ajax;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -43,7 +44,7 @@ public class LikeAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String type = request.getHttpRequest().getParam("type", null);
                String id = request.getHttpRequest().getParam(type, null);
                if ((id == null) || (id.length() == 0)) {
                String type = request.getHttpRequest().getParam("type", null);
                String id = request.getHttpRequest().getParam(type, null);
                if ((id == null) || (id.length() == 0)) {
index bca9a35..1d80905 100644 (file)
@@ -20,6 +20,7 @@ package net.pterodactylus.sone.web.ajax;
 import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -43,7 +44,7 @@ public class LockSoneAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String soneId = request.getHttpRequest().getParam("sone");
                Sone sone = webInterface.getCore().getLocalSone(soneId, false);
                if (sone == null) {
                String soneId = request.getHttpRequest().getParam("sone");
                Sone sone = webInterface.getCore().getLocalSone(soneId, false);
                if (sone == null) {
index b641ea0..42ee8b2 100644 (file)
@@ -22,6 +22,7 @@ import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -46,7 +47,7 @@ public class MarkAsKnownAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String type = request.getHttpRequest().getParam("type");
                if (!type.equals("sone") && !type.equals("post") && !type.equals("reply")) {
                        return createErrorJsonObject("invalid-type");
                String type = request.getHttpRequest().getParam("type");
                if (!type.equals("sone") && !type.equals("post") && !type.equals("reply")) {
                        return createErrorJsonObject("invalid-type");
index 092c1f7..b932a82 100644 (file)
@@ -21,6 +21,7 @@ import net.pterodactylus.sone.data.Profile;
 import net.pterodactylus.sone.data.Profile.Field;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Profile.Field;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -50,7 +51,7 @@ public class MoveProfileFieldAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                Sone currentSone = getCurrentSone(request.getToadletContext());
                Profile profile = currentSone.getProfile();
                String fieldId = request.getHttpRequest().getParam("field");
                Sone currentSone = getCurrentSone(request.getToadletContext());
                Profile profile = currentSone.getProfile();
                String fieldId = request.getHttpRequest().getParam("field");
index d6e2750..b27bedf 100644 (file)
@@ -21,6 +21,7 @@ import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.wot.Trust;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.wot.Trust;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -45,7 +46,7 @@ public class TrustAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                Sone currentSone = getCurrentSone(request.getToadletContext(), false);
                if (currentSone == null) {
                        return createErrorJsonObject("auth-required");
                Sone currentSone = getCurrentSone(request.getToadletContext(), false);
                if (currentSone == null) {
                        return createErrorJsonObject("auth-required");
index f07dcb0..6a9f8fe 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.sone.web.ajax;
 
 import net.pterodactylus.sone.web.WebInterface;
 package net.pterodactylus.sone.web.ajax;
 
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -45,7 +46,7 @@ public class UnbookmarkAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String id = request.getHttpRequest().getParam("post", null);
                if ((id == null) || (id.length() == 0)) {
                        return createErrorJsonObject("invalid-post-id");
                String id = request.getHttpRequest().getParam("post", null);
                if ((id == null) || (id.length() == 0)) {
                        return createErrorJsonObject("invalid-post-id");
index 7f719b7..26f1a11 100644 (file)
@@ -19,6 +19,7 @@ package net.pterodactylus.sone.web.ajax;
 
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
 
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -42,7 +43,7 @@ public class UnfollowSoneAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String soneId = request.getHttpRequest().getParam("sone");
                if (!webInterface.getCore().hasSone(soneId)) {
                        return createErrorJsonObject("invalid-sone-id");
                String soneId = request.getHttpRequest().getParam("sone");
                if (!webInterface.getCore().hasSone(soneId)) {
                        return createErrorJsonObject("invalid-sone-id");
index 84b0593..1841806 100644 (file)
@@ -20,6 +20,7 @@ package net.pterodactylus.sone.web.ajax;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -43,7 +44,7 @@ public class UnlikeAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String type = request.getHttpRequest().getParam("type", null);
                String id = request.getHttpRequest().getParam(type, null);
                if ((id == null) || (id.length() == 0)) {
                String type = request.getHttpRequest().getParam("type", null);
                String id = request.getHttpRequest().getParam(type, null);
                if ((id == null) || (id.length() == 0)) {
index 3160db0..d7430c1 100644 (file)
@@ -20,6 +20,7 @@ package net.pterodactylus.sone.web.ajax;
 import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -43,7 +44,7 @@ public class UnlockSoneAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                String soneId = request.getHttpRequest().getParam("sone");
                Sone sone = webInterface.getCore().getLocalSone(soneId, false);
                if (sone == null) {
                String soneId = request.getHttpRequest().getParam("sone");
                Sone sone = webInterface.getCore().getLocalSone(soneId, false);
                if (sone == null) {
index ad613ff..86222e0 100644 (file)
@@ -21,6 +21,7 @@ import net.pterodactylus.sone.core.Core;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.wot.Trust;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.wot.Trust;
 import net.pterodactylus.sone.web.WebInterface;
+import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
 
 /**
 import net.pterodactylus.util.json.JsonObject;
 
 /**
@@ -45,7 +46,7 @@ public class UntrustAjaxPage extends JsonPage {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       protected JsonObject createJsonObject(Request request) {
+       protected JsonObject createJsonObject(FreenetRequest request) {
                Sone currentSone = getCurrentSone(request.getToadletContext(), false);
                if (currentSone == null) {
                        return createErrorJsonObject("auth-required");
                Sone currentSone = getCurrentSone(request.getToadletContext(), false);
                if (currentSone == null) {
                        return createErrorJsonObject("auth-required");
diff --git a/src/main/java/net/pterodactylus/sone/web/page/FreenetRequest.java b/src/main/java/net/pterodactylus/sone/web/page/FreenetRequest.java
new file mode 100644 (file)
index 0000000..526f3ed
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Sone - FreenetRequest.java - Copyright © 2011 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.web.page;
+
+import java.net.URI;
+
+import net.pterodactylus.util.web.Method;
+import net.pterodactylus.util.web.Request;
+import freenet.clients.http.ToadletContext;
+import freenet.support.api.HTTPRequest;
+
+/**
+ * Encapsulates all Freenet-specific properties of a request.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class FreenetRequest extends Request {
+
+       /** The underlying HTTP request from Freenet. */
+       private final HTTPRequest httpRequest;
+
+       /** The toadlet context. */
+       private final ToadletContext toadletContext;
+
+       /**
+        * Creates a new freenet request.
+        *
+        * @param uri
+        *            The URI that is being accessed
+        * @param method
+        *            The method used to access this page
+        * @param httpRequest
+        *            The underlying HTTP request from Freenet
+        * @param toadletContext
+        *            The toadlet context
+        */
+       public FreenetRequest(URI uri, Method method, HTTPRequest httpRequest, ToadletContext toadletContext) {
+               super(uri, method);
+               this.httpRequest = httpRequest;
+               this.toadletContext = toadletContext;
+       }
+
+       //
+       // ACCESSORS
+       //
+
+       /**
+        * Returns the underlying HTTP request from Freenet.
+        *
+        * @return The underlying HTTP request from Freenet
+        */
+       public HTTPRequest getHttpRequest() {
+               return httpRequest;
+       }
+
+       /**
+        * Returns the toadlet context.
+        *
+        * @return The toadlet context
+        */
+       public ToadletContext getToadletContext() {
+               return toadletContext;
+       }
+
+}
index 5831a1b..8096a6a 100644 (file)
@@ -17,6 +17,7 @@
 
 package net.pterodactylus.sone.web.page;
 
 
 package net.pterodactylus.sone.web.page;
 
+import java.io.IOException;
 import java.io.StringWriter;
 import java.util.Collection;
 import java.util.Collections;
 import java.io.StringWriter;
 import java.util.Collection;
 import java.util.Collections;
@@ -26,11 +27,14 @@ import java.util.Map.Entry;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import net.pterodactylus.sone.web.page.Page.Request.Method;
 import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.template.TemplateContextFactory;
 import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.template.TemplateContextFactory;
+import net.pterodactylus.util.web.Method;
+import net.pterodactylus.util.web.Page;
+import net.pterodactylus.util.web.RedirectResponse;
+import net.pterodactylus.util.web.Response;
 import freenet.clients.http.LinkEnabledCallback;
 import freenet.clients.http.PageMaker;
 import freenet.clients.http.PageNode;
 import freenet.clients.http.LinkEnabledCallback;
 import freenet.clients.http.PageMaker;
 import freenet.clients.http.PageNode;
@@ -43,7 +47,7 @@ import freenet.support.HTMLNode;
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
-public class FreenetTemplatePage implements Page, LinkEnabledCallback {
+public class FreenetTemplatePage implements Page<FreenetRequest>, LinkEnabledCallback {
 
        /** The logger. */
        private static final Logger logger = Logging.getLogger(FreenetTemplatePage.class);
 
        /** The logger. */
        private static final Logger logger = Logging.getLogger(FreenetTemplatePage.class);
@@ -95,7 +99,7 @@ public class FreenetTemplatePage implements Page, LinkEnabledCallback {
         *            The request to serve
         * @return The title of the page
         */
         *            The request to serve
         * @return The title of the page
         */
-       protected String getPageTitle(Request request) {
+       protected String getPageTitle(FreenetRequest request) {
                return null;
        }
 
                return null;
        }
 
@@ -103,14 +107,22 @@ public class FreenetTemplatePage implements Page, LinkEnabledCallback {
         * {@inheritDoc}
         */
        @Override
         * {@inheritDoc}
         */
        @Override
-       public Response handleRequest(Request request) {
+       public boolean isPrefixPage() {
+               return false;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public Response handleRequest(FreenetRequest request, Response response) throws IOException {
                String redirectTarget = getRedirectTarget(request);
                if (redirectTarget != null) {
                        return new RedirectResponse(redirectTarget);
                }
 
                if (isFullAccessOnly() && !request.getToadletContext().isAllowedFullAccess()) {
                String redirectTarget = getRedirectTarget(request);
                if (redirectTarget != null) {
                        return new RedirectResponse(redirectTarget);
                }
 
                if (isFullAccessOnly() && !request.getToadletContext().isAllowedFullAccess()) {
-                       return new Response(401, "Not authorized", "text/html", "Not authorized");
+                       return response.setStatusCode(401).setStatusText("Not authorized").setContentType("text/html");
                }
                ToadletContext toadletContext = request.getToadletContext();
                if (request.getMethod() == Method.POST) {
                }
                ToadletContext toadletContext = request.getToadletContext();
                if (request.getMethod() == Method.POST) {
@@ -153,7 +165,7 @@ public class FreenetTemplatePage implements Page, LinkEnabledCallback {
 
                postProcess(request, templateContext);
 
 
                postProcess(request, templateContext);
 
-               return new Response(200, "OK", "text/html", pageNode.outer.generate());
+               return response.setStatusCode(200).setStatusText("OK").setContentType("text/html").write(pageNode.outer.generate());
        }
 
        /**
        }
 
        /**
@@ -186,7 +198,7 @@ public class FreenetTemplatePage implements Page, LinkEnabledCallback {
         * @throws RedirectException
         *             if the processing page wants to redirect after processing
         */
         * @throws RedirectException
         *             if the processing page wants to redirect after processing
         */
-       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+       protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
                /* do nothing. */
        }
 
                /* do nothing. */
        }
 
@@ -203,7 +215,7 @@ public class FreenetTemplatePage implements Page, LinkEnabledCallback {
         * @param templateContext
         *            The template context that supplied the rendered data
         */
         * @param templateContext
         *            The template context that supplied the rendered data
         */
-       protected void postProcess(Request request, TemplateContext templateContext) {
+       protected void postProcess(FreenetRequest request, TemplateContext templateContext) {
                /* do nothing. */
        }
 
                /* do nothing. */
        }
 
@@ -215,7 +227,7 @@ public class FreenetTemplatePage implements Page, LinkEnabledCallback {
         *            The request that is processed
         * @return The URL to redirect to, or {@code null} to not redirect
         */
         *            The request that is processed
         * @return The URL to redirect to, or {@code null} to not redirect
         */
-       protected String getRedirectTarget(Page.Request request) {
+       protected String getRedirectTarget(FreenetRequest request) {
                return null;
        }
 
                return null;
        }
 
@@ -226,7 +238,7 @@ public class FreenetTemplatePage implements Page, LinkEnabledCallback {
         *            The request for which to return the link nodes
         * @return All link nodes that should be added to the HTML head
         */
         *            The request for which to return the link nodes
         * @return All link nodes that should be added to the HTML head
         */
-       protected List<Map<String, String>> getAdditionalLinkNodes(Request request) {
+       protected List<Map<String, String>> getAdditionalLinkNodes(FreenetRequest request) {
                return Collections.emptyList();
        }
 
                return Collections.emptyList();
        }
 
diff --git a/src/main/java/net/pterodactylus/sone/web/page/Page.java b/src/main/java/net/pterodactylus/sone/web/page/Page.java
deleted file mode 100644 (file)
index 297081e..0000000
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * Sone - Page.java - Copyright © 2010 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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.web.page;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-
-import freenet.clients.http.ToadletContext;
-import freenet.support.api.HTTPRequest;
-
-/**
- * A page is responsible for handling HTTP requests and creating appropriate
- * responses.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public interface Page {
-
-       /**
-        * Returns the path of this toadlet.
-        *
-        * @return The path of this toadlet
-        */
-       public String getPath();
-
-       /**
-        * Handles a request.
-        *
-        * @param request
-        *            The request to handle
-        * @return The response
-        */
-       public Response handleRequest(Request request);
-
-       /**
-        * Container for request data.
-        *
-        * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
-        */
-       public class Request {
-
-               /**
-                * Enumeration for all possible HTTP request methods.
-                *
-                * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’
-                *         Roden</a>
-                */
-               public enum Method {
-
-                       /** GET. */
-                       GET,
-
-                       /** POST. */
-                       POST,
-
-                       /** PUT. */
-                       PUT,
-
-                       /** DELETE. */
-                       DELETE,
-
-                       /** HEAD. */
-                       HEAD,
-
-                       /** OPTIONS. */
-                       OPTIONS,
-
-                       /** TRACE. */
-                       TRACE,
-
-               }
-
-               /** The URI that was accessed. */
-               private final URI uri;
-
-               /** The HTTP method that was used. */
-               private final Method method;
-
-               /** The HTTP request. */
-               private final HTTPRequest httpRequest;
-
-               /** The toadlet context. */
-               private final ToadletContext toadletContext;
-
-               /**
-                * Creates a new request that holds the given data.
-                *
-                * @param uri
-                *            The URI of the request
-                * @param method
-                *            The HTTP method of the request
-                * @param httpRequest
-                *            The HTTP request
-                * @param toadletContext
-                *            The toadlet context of the request
-                */
-               public Request(URI uri, Method method, HTTPRequest httpRequest, ToadletContext toadletContext) {
-                       this.uri = uri;
-                       this.method = method;
-                       this.httpRequest = httpRequest;
-                       this.toadletContext = toadletContext;
-               }
-
-               /**
-                * Returns the URI that was accessed.
-                *
-                * @return The accessed URI
-                */
-               public URI getUri() {
-                       return uri;
-               }
-
-               /**
-                * Returns the HTTP method that was used to access the page.
-                *
-                * @return The HTTP method
-                */
-               public Method getMethod() {
-                       return method;
-               }
-
-               /**
-                * Returns the HTTP request.
-                *
-                * @return The HTTP request
-                */
-               public HTTPRequest getHttpRequest() {
-                       return httpRequest;
-               }
-
-               /**
-                * Returns the toadlet context.
-                *
-                * @return The toadlet context
-                */
-               public ToadletContext getToadletContext() {
-                       return toadletContext;
-               }
-
-       }
-
-       /**
-        * Container for the HTTP response of a {@link Page}.
-        *
-        * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
-        */
-       public class Response {
-
-               /** The HTTP status code of the response. */
-               private final int statusCode;
-
-               /** The HTTP status text of the response. */
-               private final String statusText;
-
-               /** The content type of the response. */
-               private final String contentType;
-
-               /** The headers of the response. */
-               private final Map<String, String> headers;
-
-               /** The content of the response body. */
-               private final InputStream content;
-
-               /**
-                * Creates a new response.
-                *
-                * @param statusCode
-                *            The HTTP status code of the response
-                * @param statusText
-                *            The HTTP status text of the response
-                * @param contentType
-                *            The content type of the response
-                * @param text
-                *            The text in the response body
-                */
-               public Response(int statusCode, String statusText, String contentType, String text) {
-                       this(statusCode, statusText, contentType, getBytes(text));
-               }
-
-               /**
-                * Creates a new response.
-                *
-                * @param statusCode
-                *            The HTTP status code of the response
-                * @param statusText
-                *            The HTTP status text of the response
-                * @param contentType
-                *            The content type of the response
-                * @param content
-                *            The content of the reponse body
-                */
-               public Response(int statusCode, String statusText, String contentType, byte[] content) {
-                       this(statusCode, statusText, contentType, new HashMap<String, String>(), content);
-               }
-
-               /**
-                * Creates a new response.
-                *
-                * @param statusCode
-                *            The HTTP status code of the response
-                * @param statusText
-                *            The HTTP status text of the response
-                * @param contentType
-                *            The content type of the response
-                * @param headers
-                *            The headers of the response
-                */
-               public Response(int statusCode, String statusText, String contentType, Map<String, String> headers) {
-                       this(statusCode, statusText, contentType, headers, (InputStream) null);
-               }
-
-               /**
-                * Creates a new response.
-                *
-                * @param statusCode
-                *            The HTTP status code of the response
-                * @param statusText
-                *            The HTTP status text of the response
-                * @param contentType
-                *            The content type of the response
-                * @param headers
-                *            The headers of the response
-                * @param content
-                *            The content of the reponse body
-                */
-               public Response(int statusCode, String statusText, String contentType, Map<String, String> headers, byte[] content) {
-                       this(statusCode, statusText, contentType, headers, new ByteArrayInputStream(content));
-               }
-
-               /**
-                * Creates a new response.
-                *
-                * @param statusCode
-                *            The HTTP status code of the response
-                * @param statusText
-                *            The HTTP status text of the response
-                * @param contentType
-                *            The content type of the response
-                * @param headers
-                *            The headers of the response
-                * @param content
-                *            The content of the reponse body
-                */
-               public Response(int statusCode, String statusText, String contentType, Map<String, String> headers, InputStream content) {
-                       this.statusCode = statusCode;
-                       this.statusText = statusText;
-                       this.contentType = contentType;
-                       this.headers = headers;
-                       this.content = content;
-               }
-
-               /**
-                * Returns the HTTP status code of the response.
-                *
-                * @return The HTTP status code
-                */
-               public int getStatusCode() {
-                       return statusCode;
-               }
-
-               /**
-                * Returns the HTTP status text.
-                *
-                * @return The HTTP status text
-                */
-               public String getStatusText() {
-                       return statusText;
-               }
-
-               /**
-                * Returns the content type of the response.
-                *
-                * @return The content type of the reponse
-                */
-               public String getContentType() {
-                       return contentType;
-               }
-
-               /**
-                * Returns HTTP headers of the response. May be {@code null} if no
-                * headers are returned.
-                *
-                * @return The response headers, or {@code null} if there are no
-                *         response headers
-                */
-               public Map<String, String> getHeaders() {
-                       return headers;
-               }
-
-               /**
-                * Sets the HTTP header with the given name to the given value. Multiple
-                * headers with the same name are not implemented so that latest call to
-                * {@link #setHeader(String, String)} determines what is sent to the
-                * browser.
-                *
-                * @param name
-                *            The name of the header
-                * @param value
-                *            The value of the header
-                */
-               public void setHeader(String name, String value) {
-                       headers.put(name, value);
-               }
-
-               /**
-                * Returns the content of the response body. May be {@code null} if the
-                * response does not have a body.
-                *
-                * @return The content of the response body
-                */
-               public InputStream getContent() {
-                       return content;
-               }
-
-               //
-               // PRIVATE METHODS
-               //
-
-               /**
-                * Returns the UTF-8 representation of the given text.
-                *
-                * @param text
-                *            The text to encode
-                * @return The encoded text
-                */
-               private static byte[] getBytes(String text) {
-                       try {
-                               return text.getBytes("UTF-8");
-                       } catch (UnsupportedEncodingException uee1) {
-                               /* every JVM needs to support UTF-8. */
-                       }
-                       return null;
-               }
-
-               /**
-                * Creates a header map containing a single header.
-                *
-                * @param name
-                *            The name of the header
-                * @param value
-                *            The value of the header
-                * @return The map containing the single header
-                */
-               protected static Map<String, String> createHeader(String name, String value) {
-                       Map<String, String> headers = new HashMap<String, String>();
-                       headers.put(name, value);
-                       return headers;
-               }
-
-       }
-
-       /**
-        * {@link Response} implementation that performs an HTTP redirect.
-        *
-        * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
-        */
-       public class RedirectResponse extends Response {
-
-               /**
-                * Creates a new redirect response to the new location.
-                *
-                * @param newLocation
-                *            The new location
-                */
-               public RedirectResponse(String newLocation) {
-                       this(newLocation, true);
-               }
-
-               /**
-                * Creates a new redirect response to the new location.
-                *
-                * @param newLocation
-                *            The new location
-                * @param permanent
-                *            Whether the redirect should be marked as permanent
-                */
-               public RedirectResponse(String newLocation, boolean permanent) {
-                       super(permanent ? 302 : 307, "Redirected", null, createHeader("Location", newLocation));
-               }
-
-       }
-
-}
index f594e58..ed01294 100644 (file)
@@ -19,9 +19,11 @@ package net.pterodactylus.sone.web.page;
 
 import java.io.IOException;
 import java.net.URI;
 
 import java.io.IOException;
 import java.net.URI;
-import java.util.Map.Entry;
 
 
-import net.pterodactylus.sone.web.page.Page.Request.Method;
+import net.pterodactylus.util.web.Header;
+import net.pterodactylus.util.web.Method;
+import net.pterodactylus.util.web.Page;
+import net.pterodactylus.util.web.Response;
 import freenet.client.HighLevelSimpleClient;
 import freenet.clients.http.LinkEnabledCallback;
 import freenet.clients.http.Toadlet;
 import freenet.client.HighLevelSimpleClient;
 import freenet.clients.http.LinkEnabledCallback;
 import freenet.clients.http.Toadlet;
@@ -30,7 +32,6 @@ import freenet.clients.http.ToadletContextClosedException;
 import freenet.support.MultiValueTable;
 import freenet.support.api.Bucket;
 import freenet.support.api.HTTPRequest;
 import freenet.support.MultiValueTable;
 import freenet.support.api.Bucket;
 import freenet.support.api.HTTPRequest;
-import freenet.support.io.BucketTools;
 import freenet.support.io.Closer;
 
 /**
 import freenet.support.io.Closer;
 
 /**
@@ -44,7 +45,7 @@ public class PageToadlet extends Toadlet implements LinkEnabledCallback {
        private final String menuName;
 
        /** The page that handles processing. */
        private final String menuName;
 
        /** The page that handles processing. */
-       private final Page page;
+       private final Page<FreenetRequest> page;
 
        /** The path prefix for the page. */
        private final String pathPrefix;
 
        /** The path prefix for the page. */
        private final String pathPrefix;
@@ -62,7 +63,7 @@ public class PageToadlet extends Toadlet implements LinkEnabledCallback {
         *            Prefix that is prepended to all {@link Page#getPath()} return
         *            values
         */
         *            Prefix that is prepended to all {@link Page#getPath()} return
         *            values
         */
-       protected PageToadlet(HighLevelSimpleClient highLevelSimpleClient, String menuName, Page page, String pathPrefix) {
+       protected PageToadlet(HighLevelSimpleClient highLevelSimpleClient, String menuName, Page<FreenetRequest> page, String pathPrefix) {
                super(highLevelSimpleClient);
                this.menuName = menuName;
                this.page = page;
                super(highLevelSimpleClient);
                this.menuName = menuName;
                this.page = page;
@@ -101,7 +102,7 @@ public class PageToadlet extends Toadlet implements LinkEnabledCallback {
         *             if the toadlet context is closed
         */
        public void handleMethodGET(URI uri, HTTPRequest httpRequest, ToadletContext toadletContext) throws IOException, ToadletContextClosedException {
         *             if the toadlet context is closed
         */
        public void handleMethodGET(URI uri, HTTPRequest httpRequest, ToadletContext toadletContext) throws IOException, ToadletContextClosedException {
-               handleRequest(new Page.Request(uri, Method.GET, httpRequest, toadletContext));
+               handleRequest(new FreenetRequest(uri, Method.GET, httpRequest, toadletContext));
        }
 
        /**
        }
 
        /**
@@ -119,7 +120,7 @@ public class PageToadlet extends Toadlet implements LinkEnabledCallback {
         *             if the toadlet context is closed
         */
        public void handleMethodPOST(URI uri, HTTPRequest httpRequest, ToadletContext toadletContext) throws IOException, ToadletContextClosedException {
         *             if the toadlet context is closed
         */
        public void handleMethodPOST(URI uri, HTTPRequest httpRequest, ToadletContext toadletContext) throws IOException, ToadletContextClosedException {
-               handleRequest(new Page.Request(uri, Method.POST, httpRequest, toadletContext));
+               handleRequest(new FreenetRequest(uri, Method.POST, httpRequest, toadletContext));
        }
 
        /**
        }
 
        /**
@@ -140,32 +141,25 @@ public class PageToadlet extends Toadlet implements LinkEnabledCallback {
         * @throws ToadletContextClosedException
         *             if the toadlet context is closed
         */
         * @throws ToadletContextClosedException
         *             if the toadlet context is closed
         */
-       private void handleRequest(Page.Request pageRequest) throws IOException, ToadletContextClosedException {
-               Bucket data = null;
+       private void handleRequest(FreenetRequest pageRequest) throws IOException, ToadletContextClosedException {
+               Bucket pageBucket = null;
                try {
                try {
-                       Page.Response pageResponse = page.handleRequest(pageRequest);
+                       pageBucket = pageRequest.getToadletContext().getBucketFactory().makeBucket(-1);
+                       Response pageResponse = new Response(pageBucket.getOutputStream());
+                       page.handleRequest(pageRequest, pageResponse);
                        MultiValueTable<String, String> headers = new MultiValueTable<String, String>();
                        if (pageResponse.getHeaders() != null) {
                        MultiValueTable<String, String> headers = new MultiValueTable<String, String>();
                        if (pageResponse.getHeaders() != null) {
-                               for (Entry<String, String> headerEntry : pageResponse.getHeaders().entrySet()) {
-                                       headers.put(headerEntry.getKey(), headerEntry.getValue());
+                               for (Header header : pageResponse.getHeaders()) {
+                                       for (String value : header) {
+                                               headers.put(header.getName(), value);
+                                       }
                                }
                        }
                                }
                        }
-                       data = pageRequest.getToadletContext().getBucketFactory().makeBucket(-1);
-                       if (pageResponse.getContent() != null) {
-                               try {
-                                       BucketTools.copyFrom(data, pageResponse.getContent(), -1);
-                               } finally {
-                                       Closer.close(pageResponse.getContent());
-                               }
-                       } else {
-                               /* get an OutputStream and close it immediately. */
-                               Closer.close(data.getOutputStream());
-                       }
-                       writeReply(pageRequest.getToadletContext(), pageResponse.getStatusCode(), pageResponse.getContentType(), pageResponse.getStatusText(), headers, data);
+                       writeReply(pageRequest.getToadletContext(), pageResponse.getStatusCode(), pageResponse.getContentType(), pageResponse.getStatusText(), headers, pageBucket);
                } catch (Throwable t1) {
                        writeInternalError(t1, pageRequest.getToadletContext());
                } finally {
                } catch (Throwable t1) {
                        writeInternalError(t1, pageRequest.getToadletContext());
                } finally {
-                       Closer.close(data);
+                       Closer.close(pageBucket);
                }
        }
 
                }
        }
 
index bd0adb9..e788039 100644 (file)
@@ -17,6 +17,7 @@
 
 package net.pterodactylus.sone.web.page;
 
 
 package net.pterodactylus.sone.web.page;
 
+import net.pterodactylus.util.web.Page;
 import freenet.client.HighLevelSimpleClient;
 
 /**
 import freenet.client.HighLevelSimpleClient;
 
 /**
@@ -54,7 +55,7 @@ public class PageToadletFactory {
         *            The page to wrap
         * @return The toadlet wrapped around the page
         */
         *            The page to wrap
         * @return The toadlet wrapped around the page
         */
-       public PageToadlet createPageToadlet(Page page) {
+       public PageToadlet createPageToadlet(Page<FreenetRequest> page) {
                return createPageToadlet(page, null);
        }
 
                return createPageToadlet(page, null);
        }
 
@@ -68,7 +69,7 @@ public class PageToadletFactory {
         *            The name of the menu item
         * @return The toadlet wrapped around the page
         */
         *            The name of the menu item
         * @return The toadlet wrapped around the page
         */
-       public PageToadlet createPageToadlet(Page page, String menuName) {
+       public PageToadlet createPageToadlet(Page<FreenetRequest> page, String menuName) {
                return new PageToadlet(highLevelSimpleClient, menuName, page, pathPrefix);
        }
 
                return new PageToadlet(highLevelSimpleClient, menuName, page, pathPrefix);
        }
 
diff --git a/src/main/java/net/pterodactylus/sone/web/page/RedirectPage.java b/src/main/java/net/pterodactylus/sone/web/page/RedirectPage.java
deleted file mode 100644 (file)
index 2ce34f9..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Sone - RedirectPage.java - Copyright © 2011 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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.web.page;
-
-/**
- * Page implementation that redirects the user to another URL.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class RedirectPage implements Page {
-
-       /** The original path. */
-       private String originalPath;
-
-       /** The path to redirect the browser to. */
-       private String newPath;
-
-       /**
-        * Creates a new redirect page.
-        *
-        * @param originalPath
-        *            The original path
-        * @param newPath
-        *            The path to redirect the browser to
-        */
-       public RedirectPage(String originalPath, String newPath) {
-               this.originalPath = originalPath;
-               this.newPath = newPath;
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       public String getPath() {
-               return originalPath;
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       public Response handleRequest(Request request) {
-               return new RedirectResponse(newPath);
-       }
-
-}
diff --git a/src/main/java/net/pterodactylus/sone/web/page/StaticPage.java b/src/main/java/net/pterodactylus/sone/web/page/StaticPage.java
deleted file mode 100644 (file)
index 3d24fdd..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Sone - StaticPage.java - Copyright © 2010 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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.web.page;
-
-import java.io.InputStream;
-
-/**
- * {@link Page} implementation that delivers static files from the class path.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class StaticPage implements Page {
-
-       /** The prefix for {@link #getPath()}. */
-       private final String pathPrefix;
-
-       /** The path used as prefix when loading resources. */
-       private final String resourcePathPrefix;
-
-       /** The MIME type for the files this path contains. */
-       private final String mimeType;
-
-       /**
-        * Creates a new CSS page.
-        *
-        * @param pathPrefix
-        *            The prefix for {@link #getPath()}
-        * @param resourcePathPrefix
-        *            The path prefix when loading resources
-        * @param mimeType
-        *            The MIME type of the files this path contains
-        */
-       public StaticPage(String pathPrefix, String resourcePathPrefix, String mimeType) {
-               this.pathPrefix = pathPrefix;
-               this.resourcePathPrefix = resourcePathPrefix;
-               this.mimeType = mimeType;
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       public String getPath() {
-               return pathPrefix;
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       public Response handleRequest(Request request) {
-               String path = request.getUri().getPath();
-               int lastSlash = path.lastIndexOf('/');
-               String filename = path.substring(lastSlash + 1);
-               InputStream fileInputStream = getClass().getResourceAsStream(resourcePathPrefix + filename);
-               if (fileInputStream == null) {
-                       return new Response(404, "Not found.", null, "");
-               }
-               return new Response(200, "OK", mimeType, null, fileInputStream);
-       }
-
-}
diff --git a/src/main/java/net/pterodactylus/sone/web/page/TemplatePage.java b/src/main/java/net/pterodactylus/sone/web/page/TemplatePage.java
deleted file mode 100644 (file)
index 06fc9fc..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Sone - StaticTemplatePage.java - Copyright © 2011 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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.web.page;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import net.pterodactylus.util.io.Closer;
-import net.pterodactylus.util.logging.Logging;
-import net.pterodactylus.util.template.Template;
-import net.pterodactylus.util.template.TemplateContext;
-import net.pterodactylus.util.template.TemplateContextFactory;
-
-/**
- * A template page is a single page that is created from a {@link Template} but
- * does not necessarily return HTML.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class TemplatePage implements Page {
-
-       /** The logger. */
-       private static final Logger logger = Logging.getLogger(TemplatePage.class);
-
-       /** The path of this page. */
-       private final String path;
-
-       /** The content type of this page. */
-       private final String contentType;
-
-       /** The template context factory. */
-       private final TemplateContextFactory templateContextFactory;
-
-       /** The template to render. */
-       private final Template template;
-
-       /**
-        * Creates a new template page.
-        *
-        * @param path
-        *            The path of the page
-        * @param contentType
-        *            The content type of the page
-        * @param templateContextFactory
-        *            The template context factory
-        * @param template
-        *            The template to render
-        */
-       public TemplatePage(String path, String contentType, TemplateContextFactory templateContextFactory, Template template) {
-               this.path = path;
-               this.contentType = contentType;
-               this.templateContextFactory = templateContextFactory;
-               this.template = template;
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       public String getPath() {
-               return path;
-       }
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       public Response handleRequest(Request request) {
-               ByteArrayOutputStream responseOutputStream = new ByteArrayOutputStream();
-               OutputStreamWriter responseWriter = null;
-               try {
-                       responseWriter = new OutputStreamWriter(responseOutputStream, "UTF-8");
-                       TemplateContext templateContext = templateContextFactory.createTemplateContext();
-                       templateContext.set("request", request);
-                       template.render(templateContext, responseWriter);
-               } catch (IOException ioe1) {
-                       logger.log(Level.WARNING, "Could not render template for path “" + path + "”!", ioe1);
-               } finally {
-                       Closer.close(responseWriter);
-                       Closer.close(responseOutputStream);
-               }
-               ByteArrayInputStream responseInputStream = new ByteArrayInputStream(responseOutputStream.toByteArray());
-               /* no need to close a ByteArrayInputStream. */
-               return new Response(200, "OK", contentType, null, responseInputStream);
-       }
-
-}