X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FGetPostsCommand.java;h=bd579ca7ad70e1e9a7a2067e1b3d6f90d8aeb79e;hb=f10d40f746f6c7c716f783da11791d28c1117447;hp=6a3b07eb6544037eeb21764f121206a186ee9ac1;hpb=58ba9d9a5ac37dc2e08d3d0bce762b3f93bc8de8;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java b/src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java index 6a3b07e..bd579ca 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java @@ -1,5 +1,5 @@ /* - * Sone - GetPostsCommand.java - Copyright © 2011 David Roden + * Sone - GetPostsCommand.java - Copyright © 2011–2013 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,19 +45,16 @@ public class GetPostsCommand extends AbstractSoneCommand { super(core); } - /** - * {@inheritDoc} - */ @Override public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException { - Sone sone = getSone(parameters, "Sone", false); + Sone sone = getMandatorySone(parameters, "Sone"); int startPost = getInt(parameters, "StartPost", 0); int maxPosts = getInt(parameters, "MaxPosts", -1); List posts = sone.getPosts(); if (posts.size() < startPost) { - return new Response("Posts", encodePosts(Collections. emptyList(), "Posts.", false)); + return new Response("Posts", encodePosts(Collections. emptyList(), "Posts.")); } - return new Response("Posts", encodePosts(sone.getPosts().subList(startPost, (maxPosts == -1) ? posts.size() : Math.min(startPost + maxPosts, posts.size())), "Posts.", true)); + return new Response("Posts", encodePostsWithReplies(sone.getPosts().subList(startPost, (maxPosts == -1) ? posts.size() : Math.min(startPost + maxPosts, posts.size())), "Posts.")); } }