X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FJsonPage.java;h=22eeec8ec855eda36cca525a5aef137efbd25594;hp=1e5e8ed8e1fd26125508c69e006eff7684a40c95;hb=8fb7349579c0c82d7143601c2007cad6f4cfb000;hpb=45f92ec63dbf8134d92ceed67294faa38117b195 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java index 1e5e8ed..22eeec8 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java @@ -1,5 +1,5 @@ /* - * Sone - JsonPage.java - Copyright © 2010 David Roden + * Sone - JsonPage.java - Copyright © 2010–2012 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,9 +18,11 @@ package net.pterodactylus.sone.web.ajax; import java.io.IOException; +import java.net.URI; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.WebInterface; +import net.pterodactylus.sone.web.page.FreenetPage; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.json.JsonObject; import net.pterodactylus.util.json.JsonUtils; @@ -35,7 +37,7 @@ import freenet.clients.http.ToadletContext; * * @author David ‘Bombe’ Roden */ -public abstract class JsonPage implements Page { +public abstract class JsonPage implements FreenetPage { /** The path of the page. */ private final String path; @@ -137,6 +139,7 @@ public abstract class JsonPage implements Page { * @return {@code true} if the form password (given as “formPassword”) is * required, {@code false} otherwise */ + @SuppressWarnings("static-method") protected boolean needsFormPassword() { return true; } @@ -147,6 +150,7 @@ public abstract class JsonPage implements Page { * @return {@code true} if the user needs to be logged in to use this page, * {@code false} otherwise */ + @SuppressWarnings("static-method") protected boolean requiresLogin() { return true; } @@ -160,7 +164,7 @@ public abstract class JsonPage implements Page { * * @return A reply signaling success */ - protected JsonObject createSuccessJsonObject() { + protected static JsonObject createSuccessJsonObject() { return new JsonObject().put("success", true); } @@ -171,7 +175,7 @@ public abstract class JsonPage implements Page { * The error that has occured * @return The JSON object, signalling failure and the error code */ - protected JsonObject createErrorJsonObject(String error) { + protected static JsonObject createErrorJsonObject(String error) { return new JsonObject().put("success", false).put("error", error); } @@ -218,4 +222,12 @@ public abstract class JsonPage implements Page { return response.setStatusCode(200).setStatusText("OK").setContentType("application/json").write(JsonUtils.format(jsonObject)); } + /** + * {@inheritDoc} + */ + @Override + public boolean isLinkExcepted(URI link) { + return false; + } + }