X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FCreateSonePage.java;h=2e2fc410f4370da95c7d9392ed7616b682da6165;hb=25ca7aaaa3b481e1d22d907427d53c83387b1a55;hp=d55624f98bf2da40dbe8cf307e9ef0104c5158e4;hpb=2c5b76a2fbce16ef33f079a3de9ae9fc9a9d30b8;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java b/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java index d55624f..2e2fc41 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java @@ -1,5 +1,5 @@ /* - * FreenetSone - CreateSonePage.java - Copyright © 2010 David Roden + * Sone - CreateSonePage.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 @@ -31,6 +31,7 @@ import net.pterodactylus.sone.freenet.wot.OwnIdentity; 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 freenet.clients.http.ToadletContext; /** @@ -93,10 +94,10 @@ public class CreateSonePage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(Request request, Template template) throws RedirectException { - super.processTemplate(request, template); - List ownIdentitiesWithoutSone = getOwnIdentitiesWithoutSone(webInterface.core()); - template.set("identitiesWithoutSone", ownIdentitiesWithoutSone); + protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { + super.processTemplate(request, templateContext); + List ownIdentitiesWithoutSone = getOwnIdentitiesWithoutSone(webInterface.getCore()); + templateContext.set("identitiesWithoutSone", ownIdentitiesWithoutSone); if (request.getMethod() == Method.POST) { String id = request.getHttpRequest().getPartAsStringFailsafe("identity", 44); OwnIdentity selectedIdentity = null; @@ -107,12 +108,11 @@ public class CreateSonePage extends SoneTemplatePage { } } if (selectedIdentity == null) { - template.set("errorNoIdentity", true); + templateContext.set("errorNoIdentity", true); return; } /* create Sone. */ - webInterface.core().getIdentityManager().addContext(selectedIdentity, "Sone"); - Sone sone = webInterface.core().createSone(selectedIdentity); + Sone sone = webInterface.getCore().createSone(selectedIdentity); if (sone == null) { logger.log(Level.SEVERE, "Could not create Sone for OwnIdentity: %s", selectedIdentity); /* TODO - go somewhere else */ @@ -129,7 +129,7 @@ public class CreateSonePage extends SoneTemplatePage { */ @Override public boolean isEnabled(ToadletContext toadletContext) { - return getCurrentSone(toadletContext) == null; + return (getCurrentSone(toadletContext, false) == null) || (webInterface.getCore().getLocalSones().size() == 1); } }