From: David ‘Bombe’ Roden Date: Tue, 19 Oct 2010 06:34:08 +0000 (+0200) Subject: Make it possible for the user to specify the document name of the SSK. X-Git-Tag: 0.1-RC1~207 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=f17746700b861bb3485b839397a6fc073ab0bd93;p=Sone.git Make it possible for the user to specify the document name of the SSK. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 4197067..a6cbc82 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -274,7 +274,7 @@ public class Core extends AbstractService { * if a Sone error occurs */ public Sone createSone(String name) throws SoneException { - return createSone(name, null, null); + return createSone(name, "Sone-" + name, null, null); } /** @@ -284,6 +284,8 @@ public class Core extends AbstractService { * * @param name * The name of the Sone + * @param documentName + * The document name in the SSK * @param requestUri * The request URI of the Sone, or {@link NullPointerException} * to create a Sone at a random location @@ -294,7 +296,7 @@ public class Core extends AbstractService { * @throws SoneException * if a Sone error occurs */ - public Sone createSone(String name, String requestUri, String insertUri) throws SoneException { + public Sone createSone(String name, String documentName, String requestUri, String insertUri) throws SoneException { if ((name == null) || (name.trim().length() == 0)) { throw new SoneException(Type.INVALID_SONE_NAME); } @@ -311,7 +313,7 @@ public class Core extends AbstractService { Sone sone; try { logger.log(Level.FINEST, "Creating new Sone “%s” at %s (%s)…", new Object[] { name, finalRequestUri, finalInsertUri }); - sone = getSone(UUID.randomUUID().toString()).setName(name).setRequestUri(new FreenetURI(finalRequestUri).setKeyType("USK").setDocName("Sone-" + name)).setInsertUri(new FreenetURI(finalInsertUri).setKeyType("USK").setDocName("Sone-" + name)); + sone = getSone(UUID.randomUUID().toString()).setName(name).setRequestUri(new FreenetURI(finalRequestUri).setKeyType("USK").setDocName(documentName)).setInsertUri(new FreenetURI(finalInsertUri).setKeyType("USK").setDocName(documentName)); sone.setProfile(new Profile()); /* set modification counter to 1 so it is inserted immediately. */ sone.setModificationCounter(1); diff --git a/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java b/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java index 0174b76..901874c 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java @@ -61,17 +61,22 @@ public class CreateSonePage extends SoneTemplatePage { protected void processTemplate(Request request, Template template) throws RedirectException { super.processTemplate(request, template); String name = ""; + String documentName = null; String requestUri = null; String insertUri = null; if (request.getMethod() == Method.POST) { name = request.getHttpRequest().getPartAsStringFailsafe("name", 100); + documentName = request.getHttpRequest().getPartAsStringFailsafe("document-name", 96); + if (documentName.trim().length() == 0) { + documentName = "Sone-" + name; + } if (request.getHttpRequest().getParam("create-from-uri").length() > 0) { requestUri = request.getHttpRequest().getPartAsStringFailsafe("request-uri", 256); insertUri = request.getHttpRequest().getPartAsStringFailsafe("insert-uri", 256); } try { /* create Sone. */ - Sone sone = webInterface.core().createSone(name, requestUri, insertUri); + Sone sone = webInterface.core().createSone(name, documentName, requestUri, insertUri); /* log in the new Sone. */ setCurrentSone(request.getToadletContext(), sone); diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index 76d0a06..06ad735 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -33,6 +33,7 @@ Page.Login.CreateSone.Description=Use this function if you want to create a comp Page.Login.CreateSone.Label.RequestURI=Sone Request URI: Page.Login.CreateSone.Label.InsertURI=Sone Insert URI: Page.Login.CreateSone.Label.Name=Sone name: +Page.Login.CreateSone.Label.DocumentName=Name in key: Page.Login.CreateSone.Button.CreateFromURI=Create at given URI Page.Login.CreateSone.Button.CreateRandom=Create new Sone diff --git a/src/main/resources/templates/createSone.html b/src/main/resources/templates/createSone.html index d95415f..71d7366 100644 --- a/src/main/resources/templates/createSone.html +++ b/src/main/resources/templates/createSone.html @@ -9,6 +9,10 @@ +
+ + +
class="error"<%/if>> diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html index 7356fbb..3bb860f 100644 --- a/src/main/resources/templates/login.html +++ b/src/main/resources/templates/login.html @@ -38,6 +38,10 @@
+ + +
+