From ee9da6382633b1927ecb17a9bfe8b72e965fddec Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 15 Sep 2011 16:37:56 +0200 Subject: [PATCH] Add method to parse an identity from a request. --- .../java/net/pterodactylus/wotns/ui/web/BasicPage.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/net/pterodactylus/wotns/ui/web/BasicPage.java b/src/main/java/net/pterodactylus/wotns/ui/web/BasicPage.java index f8ba131..fa8c06f 100644 --- a/src/main/java/net/pterodactylus/wotns/ui/web/BasicPage.java +++ b/src/main/java/net/pterodactylus/wotns/ui/web/BasicPage.java @@ -19,6 +19,7 @@ package net.pterodactylus.wotns.ui.web; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; +import net.pterodactylus.util.web.Method; import net.pterodactylus.wotns.freenet.wot.IdentityManager; import net.pterodactylus.wotns.freenet.wot.OwnIdentity; import net.pterodactylus.wotns.web.FreenetRequest; @@ -32,6 +33,7 @@ import net.pterodactylus.wotns.web.FreenetTemplatePage; public class BasicPage extends FreenetTemplatePage { protected final WebInterface webInterface; + protected final IdentityManager identityManager; public BasicPage(WebInterface webInterface, String path, Template template) { @@ -44,6 +46,21 @@ public class BasicPage extends FreenetTemplatePage { // PROTECTED METHODS // + protected OwnIdentity getIdentity(FreenetRequest request) { + if (request.getMethod() == Method.POST) { + String ownIdentityId = request.getHttpRequest().getPartAsStringFailsafe("ownIdentity", 43); + return identityManager.getOwnIdentity(ownIdentityId); + } else if (request.getMethod() == Method.GET) { + String ownIdentityId = request.getHttpRequest().getParam("ownIdentity"); + return identityManager.getOwnIdentity(ownIdentityId); + } + return null; + } + + // + // FREENETTEMPLATEPAGE METHODS + // + /** * {@inheritDoc} */ -- 2.7.4