Remove PostProvider methods from Core.
[Sone.git] / src / main / java / net / pterodactylus / sone / fcp / AbstractSoneCommand.java
index 108a80f..19c1979 100644 (file)
@@ -33,12 +33,12 @@ import net.pterodactylus.sone.freenet.fcp.Command;
 import net.pterodactylus.sone.freenet.fcp.FcpException;
 import net.pterodactylus.sone.template.SoneAccessor;
 
-import com.google.common.base.Optional;
-import com.google.common.collect.Collections2;
-
 import freenet.node.FSParseException;
 import freenet.support.SimpleFieldSet;
 
+import com.google.common.base.Optional;
+import com.google.common.collect.Collections2;
+
 /**
  * Abstract base implementation of a {@link Command} with Sone-related helper
  * methods.
@@ -186,7 +186,7 @@ public abstract class AbstractSoneCommand extends AbstractCommand {
        protected Post getPost(SimpleFieldSet simpleFieldSet, String parameterName) throws FcpException {
                try {
                        String postId = simpleFieldSet.getString(parameterName);
-                       Optional<Post> post = core.getPost(postId);
+                       Optional<Post> post = core.getDatabase().getPost(postId);
                        if (!post.isPresent()) {
                                throw new FcpException("Could not load post from “" + postId + "”.");
                        }
@@ -301,7 +301,7 @@ public abstract class AbstractSoneCommand extends AbstractCommand {
 
                postBuilder.put(prefix + "ID", post.getId());
                postBuilder.put(prefix + "Sone", post.getSone().getId());
-               if (post.hasRecipient()) {
+               if (post.getRecipientId().isPresent()) {
                        postBuilder.put(prefix + "Recipient", post.getRecipientId().get());
                }
                postBuilder.put(prefix + "Time", post.getTime());
@@ -309,7 +309,7 @@ public abstract class AbstractSoneCommand extends AbstractCommand {
                postBuilder.put(encodeLikes(core.getLikes(post), prefix + "Likes."));
 
                if (includeReplies) {
-                       List<PostReply> replies = core.getReplies(post);
+                       List<PostReply> replies = core.getReplies(post.getId());
                        postBuilder.put(encodeReplies(replies, prefix));
                }
 
@@ -338,7 +338,7 @@ public abstract class AbstractSoneCommand extends AbstractCommand {
                        String postPrefix = prefix + postIndex++;
                        postBuilder.put(encodePost(post, postPrefix + ".", includeReplies));
                        if (includeReplies) {
-                               postBuilder.put(encodeReplies(Collections2.filter(core.getReplies(post), Reply.FUTURE_REPLY_FILTER), postPrefix + "."));
+                               postBuilder.put(encodeReplies(Collections2.filter(core.getReplies(post.getId()), Reply.FUTURE_REPLY_FILTER), postPrefix + "."));
                        }
                }
 
@@ -399,9 +399,6 @@ public abstract class AbstractSoneCommand extends AbstractCommand {
        // OBJECT METHODS
        //
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public String toString() {
                return getClass().getName() + "[writeAccess=" + writeAccess + "]";