Add method to parse an identity from an arbitrary parameter.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 16 Sep 2011 11:27:39 +0000 (13:27 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 16 Sep 2011 11:27:39 +0000 (13:27 +0200)
src/main/java/net/pterodactylus/wotns/ui/web/BasicPage.java

index 85ad8b1..2921c7e 100644 (file)
@@ -53,11 +53,15 @@ public class BasicPage extends FreenetTemplatePage {
        //
 
        protected OwnIdentity getOwnIdentity(FreenetRequest request) {
+               return getOwnIdentity(request, "ownIdentity");
+       }
+
+       protected OwnIdentity getOwnIdentity(FreenetRequest request, String parameterName) {
                if (request.getMethod() == Method.POST) {
-                       String ownIdentityId = request.getHttpRequest().getPartAsStringFailsafe("ownIdentity", 43);
+                       String ownIdentityId = request.getHttpRequest().getPartAsStringFailsafe(parameterName, 43);
                        return identityManager.getOwnIdentity(ownIdentityId);
                } else if (request.getMethod() == Method.GET) {
-                       String ownIdentityId = request.getHttpRequest().getParam("ownIdentity");
+                       String ownIdentityId = request.getHttpRequest().getParam(parameterName);
                        return identityManager.getOwnIdentity(ownIdentityId);
                }
                return null;