projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
a95d49d
)
Make it possible for the user to specify the document name of the SSK.
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Tue, 19 Oct 2010 06:34:08 +0000
(08:34 +0200)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Tue, 19 Oct 2010 06:34:08 +0000
(08:34 +0200)
src/main/java/net/pterodactylus/sone/core/Core.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/CreateSonePage.java
patch
|
blob
|
history
src/main/resources/i18n/sone.en.properties
patch
|
blob
|
history
src/main/resources/templates/createSone.html
patch
|
blob
|
history
src/main/resources/templates/login.html
patch
|
blob
|
history
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
(file)
--- 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 {
* 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 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
* @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
*/
* @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);
}
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 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-" + n
ame));
+ sone = getSone(UUID.randomUUID().toString()).setName(name).setRequestUri(new FreenetURI(finalRequestUri).setKeyType("USK").setDocName(
documentName)).setInsertUri(new FreenetURI(finalInsertUri).setKeyType("USK").setDocName(documentN
ame));
sone.setProfile(new Profile());
/* set modification counter to 1 so it is inserted immediately. */
sone.setModificationCounter(1);
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
(file)
--- 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 = "";
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);
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. */
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);
/* 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
(file)
--- 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.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
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
(file)
--- a/
src/main/resources/templates/createSone.html
+++ b/
src/main/resources/templates/createSone.html
@@
-9,6
+9,10
@@
<label for="name"><%= Page.Login.CreateSone.Label.Name|l10n|html></label>
<input type="text" name="name" value="<% name|html>"/>
</div>
<label for="name"><%= Page.Login.CreateSone.Label.Name|l10n|html></label>
<input type="text" name="name" value="<% name|html>"/>
</div>
+ <div>
+ <label for="document-name"><%= Page.Login.CreateSone.Label.DocumentName|l10n|html></label>
+ <input type="text" name="document-name" value="<% documentName|html>" />
+ </div>
<div<%if errorUri> class="error"<%/if>>
<label for="insert-uri"><%= Page.Login.CreateSone.Label.RequestURI|l10n|html></label>
<input type="text" name="insert-uri" value="<% insertUri|html>" />
<div<%if errorUri> class="error"<%/if>>
<label for="insert-uri"><%= Page.Login.CreateSone.Label.RequestURI|l10n|html></label>
<input type="text" name="insert-uri" value="<% insertUri|html>" />
diff --git
a/src/main/resources/templates/login.html
b/src/main/resources/templates/login.html
index
7356fbb
..
3bb860f
100644
(file)
--- a/
src/main/resources/templates/login.html
+++ b/
src/main/resources/templates/login.html
@@
-38,6
+38,10
@@
<input type="text" name="name" />
</div>
<div>
<input type="text" name="name" />
</div>
<div>
+ <label for="document-name"><%= Page.Login.CreateSone.Label.DocumentName|l10n|html></label>
+ <input type="text" name="document-name" value="<% documentName|html>" />
+ </div>
+ <div>
<label for="insert-uri"><%= Page.Login.CreateSone.Label.RequestURI|l10n|html></label>
<input type="text" name="insert-uri" value="" />
</div>
<label for="insert-uri"><%= Page.Login.CreateSone.Label.RequestURI|l10n|html></label>
<input type="text" name="insert-uri" value="" />
</div>