* if a Sone error occurs
*/
public Sone createSone(String name) throws SoneException {
- return createSone(name, null, null);
+ return createSone(name, "Sone-" + name, null, null);
}
/**
*
* @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
* @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);
}
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);
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);
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
<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>" />
<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>