use of org.ambraproject.rhino.rest.response.ServiceResponse in project rhino by PLOS.
the class CommentCrudServiceImpl method serveComments.
@Override
public ServiceResponse<List<CommentOutputView>> serveComments(ArticleIdentifier articleId) throws IOException {
Article article = articleCrudService.readArticle(articleId);
Collection<Comment> comments = fetchAllComments(article);
CommentOutputView.Factory factory = new CommentOutputView.Factory(new CompetingInterestPolicy(runtimeConfiguration), comments, article);
List<CommentOutputView> views = comments.stream().filter(comment -> comment.getParent() == null).sorted(CommentOutputView.BY_DATE).map(factory::buildView).collect(Collectors.toList());
return ServiceResponse.serveView(views);
}
Aggregations