From: David ‘Bombe’ Roden Date: Thu, 15 Sep 2011 14:37:56 +0000 (+0200) Subject: Add method to parse an identity from a request. X-Git-Tag: 0.0.1~10 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ee9da6382633b1927ecb17a9bfe8b72e965fddec;p=WoTNS.git Add method to parse an identity from a request. --- 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} */