X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FGetPostsCommand.java;h=bd579ca7ad70e1e9a7a2067e1b3d6f90d8aeb79e;hb=959c51e271d7da6566ecd13b912ede0d5e627b3d;hp=6a3b07eb6544037eeb21764f121206a186ee9ac1;hpb=47ed7eaf00c35889781831d33d04e9f91c9ad266;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.")); } }