Add methods to create a new Reply.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index 3b23113..0091265 100644 (file)
@@ -164,7 +164,43 @@ public class Core extends AbstractService {
         * @return The created post
         */
        public Post createPost(Sone sone, long time, String text) {
-               return getPost(UUID.randomUUID().toString()).setSone(sone).setTime(time).setText(text);
+               Post post = getPost(UUID.randomUUID().toString()).setSone(sone).setTime(time).setText(text);
+               sone.addPost(post);
+               return post;
+       }
+
+       /**
+        * Creates a reply.
+        *
+        * @param sone
+        *            The Sone that posts the reply
+        * @param post
+        *            The post the reply refers to
+        * @param text
+        *            The text of the reply
+        * @return The created reply
+        */
+       public Reply createReply(Sone sone, Post post, String text) {
+               return createReply(sone, post, System.currentTimeMillis(), text);
+       }
+
+       /**
+        * Creates a reply.
+        *
+        * @param sone
+        *            The Sone that posts the reply
+        * @param post
+        *            The post the reply refers to
+        * @param time
+        *            The time of the post
+        * @param text
+        *            The text of the reply
+        * @return The created reply
+        */
+       public Reply createReply(Sone sone, Post post, long time, String text) {
+               Reply reply = getReply(UUID.randomUUID().toString()).setSone(sone).setPost(post).setTime(time).setText(text);
+               sone.addReply(reply);
+               return reply;
        }
 
        //
@@ -410,7 +446,7 @@ public class Core extends AbstractService {
                                        String friendName = configuration.getStringValue(friendPrefix + "/Name").getValue(null);
                                        friendSone.setRequestUri(new FreenetURI(friendKey)).setName(friendName);
                                        soneDownloader.addSone(friendSone);
-                                       sone.addFriend(sone);
+                                       sone.addFriend(friendSone);
                                }
 
                                sone.setModificationCounter(modificationCounter);