projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d883f0f
)
Store the Sone ID instead of the Sone itself in the session.
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Wed, 13 Oct 2010 12:54:37 +0000
(14:54 +0200)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Wed, 13 Oct 2010 12:54:37 +0000
(14:54 +0200)
src/main/java/net/pterodactylus/sone/core/Core.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/data/Sone.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java
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
7333d68
..
13f1589
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/core/Core.java
+++ b/
src/main/java/net/pterodactylus/sone/core/Core.java
@@
-22,6
+22,7
@@
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
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;
import java.util.logging.Level;
import java.util.logging.Logger;
@@
-147,10
+148,11
@@
public class Core extends AbstractService {
/* parse local Sones. */
logger.log(Level.INFO, "Loading %d Sones…", allSoneNames.size());
for (String soneName : allSoneNames) {
/* 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 {
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);
}
} catch (MalformedURLException mue1) {
logger.log(Level.WARNING, "Could not create Sone from requestUri (“" + requestUri + "”) and insertUri (“" + insertUri + "”)!", mue1);
}
@@
-178,6
+180,7
@@
public class Core extends AbstractService {
/* store all Sones. */
for (Sone sone : localSones) {
/* 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());
}
configuration.getStringValue("Sone/Name." + sone.getName() + "/RequestURI").setValue(sone.getRequestUri().toString());
configuration.getStringValue("Sone/Name." + sone.getName() + "/InsertURI").setValue(sone.getInsertUri().toString());
}
diff --git
a/src/main/java/net/pterodactylus/sone/data/Sone.java
b/src/main/java/net/pterodactylus/sone/data/Sone.java
index
ba5ef68
..
4a73470
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/Sone.java
+++ b/
src/main/java/net/pterodactylus/sone/data/Sone.java
@@
-33,7
+33,7
@@
import freenet.keys.FreenetURI;
public class Sone {
/** A GUID for this Sone. */
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;
/** The name of this Sone. */
private final String name;
@@
-51,18
+51,22
@@
public class Sone {
/**
* Creates a new Sone.
*
/**
* 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
*/
* @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.
*
}
/**
* Creates a new Sone.
*
+ * @param id
+ * The ID of this Sone
* @param name
* The name of the Sone
* @param requestUri
* @param name
* The name of the Sone
* @param requestUri
@@
-70,7
+74,8
@@
public class Sone {
* @param insertUri
* The insert URI of the Sone
*/
* @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;
this.name = name;
this.requestUri = requestUri;
this.insertUri = insertUri;
diff --git
a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java
b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java
index
d6f1eb7
..
4078585
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java
@@
-110,7
+110,13
@@
public class SoneTemplatePage extends TemplatePage {
if (session == null) {
return null;
}
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;
}
/**
}
/**
@@
-123,7
+129,7
@@
public class SoneTemplatePage extends TemplatePage {
*/
protected void setCurrentSone(ToadletContext toadletContext, Sone sone) {
Session session = getCurrentSession(toadletContext);
*/
protected void setCurrentSone(ToadletContext toadletContext, Sone sone) {
Session session = getCurrentSession(toadletContext);
- session.setAttribute("Sone.CurrentSone", sone);
+ session.setAttribute("Sone.CurrentSone", sone
.getId()
);
}
//
}
//