import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
/* parse local Sones. */
logger.log(Level.INFO, "Loading %d Sones…", allSoneNames.size());
for (String soneName : allSoneNames) {
+ String id = configuration.getStringValue("Sone/Name." + soneName + "/ID").getValue(null);
String insertUri = configuration.getStringValue("Sone/Name." + soneName + "/InsertURI").getValue(null);
String requestUri = configuration.getStringValue("Sone/Name." + soneName + "/RequestURI").getValue(null);
try {
- localSones.add(new Sone(soneName, new FreenetURI(requestUri), new FreenetURI(insertUri)));
+ localSones.add(new Sone(UUID.fromString(id), soneName, new FreenetURI(requestUri), new FreenetURI(insertUri)));
} catch (MalformedURLException mue1) {
logger.log(Level.WARNING, "Could not create Sone from requestUri (“" + requestUri + "”) and insertUri (“" + insertUri + "”)!", mue1);
}
/* store all Sones. */
for (Sone sone : localSones) {
+ configuration.getStringValue("Sone/Name." + sone.getName() + "/ID").setValue(sone.getId());
configuration.getStringValue("Sone/Name." + sone.getName() + "/RequestURI").setValue(sone.getRequestUri().toString());
configuration.getStringValue("Sone/Name." + sone.getName() + "/InsertURI").setValue(sone.getInsertUri().toString());
}
public class Sone {
/** A GUID for this Sone. */
- private final UUID id = UUID.randomUUID();
+ private final UUID id;
/** The name of this Sone. */
private final String name;
/**
* Creates a new Sone.
*
+ * @param id
+ * The ID of this Sone
* @param name
* The name of the Sone
* @param requestUri
* The request URI of the Sone
*/
- public Sone(String name, FreenetURI requestUri) {
- this(name, requestUri, null);
+ public Sone(UUID id, String name, FreenetURI requestUri) {
+ this(id, name, requestUri, null);
}
/**
* Creates a new Sone.
*
+ * @param id
+ * The ID of this Sone
* @param name
* The name of the Sone
* @param requestUri
* @param insertUri
* The insert URI of the Sone
*/
- public Sone(String name, FreenetURI requestUri, FreenetURI insertUri) {
+ public Sone(UUID id, String name, FreenetURI requestUri, FreenetURI insertUri) {
+ this.id = id;
this.name = name;
this.requestUri = requestUri;
this.insertUri = insertUri;
if (session == null) {
return null;
}
- return (Sone) session.getAttribute("Sone.CurrentSone");
+ String soneId = (String) session.getAttribute("Sone.CurrentSone");
+ for (Sone sone : webInterface.core().localSones()) {
+ if (sone.getId().equals(soneId)) {
+ return sone;
+ }
+ }
+ return null;
}
/**
*/
protected void setCurrentSone(ToadletContext toadletContext, Sone sone) {
Session session = getCurrentSession(toadletContext);
- session.setAttribute("Sone.CurrentSone", sone);
+ session.setAttribute("Sone.CurrentSone", sone.getId());
}
//