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:
1127a71
)
Store the originating Sone in the post.
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Thu, 14 Oct 2010 08:02:21 +0000
(10:02 +0200)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Thu, 14 Oct 2010 08:02:21 +0000
(10:02 +0200)
src/main/java/net/pterodactylus/sone/data/Post.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/data/Sone.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/web/CreatePostPage.java
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/sone/data/Post.java
b/src/main/java/net/pterodactylus/sone/data/Post.java
index
3c02a1c
..
456b205
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/Post.java
+++ b/
src/main/java/net/pterodactylus/sone/data/Post.java
@@
-25,6
+25,9
@@
package net.pterodactylus.sone.data;
*/
public class Post {
*/
public class Post {
+ /** The Sone this post belongs to. */
+ private final Sone sone;
+
/** The time of the post (in milliseconds since Jan 1, 1970 UTC). */
private final long time;
/** The time of the post (in milliseconds since Jan 1, 1970 UTC). */
private final long time;
@@
-34,17
+37,29
@@
public class Post {
/**
* Creates a new post.
*
/**
* Creates a new post.
*
+ * @param sone
+ * The Sone this post belongs to
* @param time
* The time of the post (in milliseconds since Jan 1, 1970 UTC)
* @param text
* The text of the post
*/
* @param time
* The time of the post (in milliseconds since Jan 1, 1970 UTC)
* @param text
* The text of the post
*/
- public Post(long time, String text) {
+ public Post(Sone sone, long time, String text) {
+ this.sone = sone;
this.time = time;
this.text = text;
}
/**
this.time = time;
this.text = text;
}
/**
+ * Returns the Sone this post belongs to.
+ *
+ * @return The Sone of this post
+ */
+ public Sone getSone() {
+ return sone;
+ }
+
+ /**
* Returns the time of the post.
*
* @return The time of the post (in milliseconds since Jan 1, 1970 UTC)
* Returns the time of the post.
*
* @return The time of the post (in milliseconds since Jan 1, 1970 UTC)
diff --git
a/src/main/java/net/pterodactylus/sone/data/Sone.java
b/src/main/java/net/pterodactylus/sone/data/Sone.java
index
33b97a0
..
27c7852
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/Sone.java
+++ b/
src/main/java/net/pterodactylus/sone/data/Sone.java
@@
-217,12
+217,13
@@
public class Sone {
}
/**
}
/**
- * Adds
the given pos
t to this Sone.
+ * Adds
a post with the given tex
t to this Sone.
*
*
- * @param
pos
t
- * The
post to add
+ * @param
tex
t
+ * The
text to post
*/
*/
- public synchronized void addPost(Post post) {
+ public synchronized void addPost(String text) {
+ Post post = new Post(this, System.currentTimeMillis(), text);
if (posts.add(post)) {
modificationCounter++;
}
if (posts.add(post)) {
modificationCounter++;
}
diff --git
a/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java
b/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java
index
b6b291e
..
44e0d21
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/CreatePostPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/CreatePostPage.java
@@
-51,8
+51,7
@@
public class CreatePostPage extends SoneTemplatePage {
super.processTemplate(request, template);
String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim();
if (text.length() != 0) {
super.processTemplate(request, template);
String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim();
if (text.length() != 0) {
- Post post = new Post(System.currentTimeMillis(), text);
- getCurrentSone(request.getToadletContext()).addPost(post);
+ getCurrentSone(request.getToadletContext()).addPost(text);
throw new RedirectException("index.html");
}
template.set("errorTextEmpty", true);
throw new RedirectException("index.html");
}
template.set("errorTextEmpty", true);