use of org.ambraproject.wombat.service.remote.UserApi in project wombat by PLOS.
the class ArticleController method renderArticleCommentTree.
/**
* Serves a request for an expanded view of a single comment and any replies.
*
* @param model data to pass to the view
* @param site current site
* @param commentDoi specifies the comment
* @return path to the template
* @throws IOException
*/
@RequestMapping(name = "articleCommentTree", value = "/article/comment")
public String renderArticleCommentTree(HttpServletRequest request, Model model, @SiteParam Site site, @RequestParam("id") String commentDoi) throws IOException {
requireNonemptyParameter(commentDoi);
Map<String, Object> comment;
try {
comment = commentService.getComment(commentDoi, site);
} catch (CommentService.CommentNotFoundException e) {
throw new NotFoundException(e);
} catch (UserApi.UserApiException e) {
log.error(e.getMessage(), e);
model.addAttribute("userApiError", e);
// Get a copy of the comment that is not populated with userApi data.
// This articleApi call is redundant to one that commentService.getComment would have made before throwing.
// TODO: Prevent extra articleApi call
comment = getComment(commentDoi);
}
RequestedDoiVersion doi = RequestedDoiVersion.of(getParentArticleDoiFromComment(comment));
articleMetadataFactory.get(site, doi).validateVisibility("articleCommentTree").populate(request, model);
model.addAttribute("comment", comment);
addCommentAvailability(model);
return site + "/ftl/article/comment/comment";
}
use of org.ambraproject.wombat.service.remote.UserApi in project wombat by PLOS.
the class CommentController method renderArticleCommentTree.
/**
* Serves a request for an expanded view of a single comment and any replies.
*
* @param model data to pass to the view
* @param site current site
* @param commentDoi specifies the comment
* @return path to the template
* @throws IOException
*/
@RequestMapping(name = "articleCommentTree", value = "/article/comment")
public String renderArticleCommentTree(HttpServletRequest request, Model model, @SiteParam Site site, @RequestParam("id") String commentDoi) throws IOException {
requireNonemptyParameter(commentDoi);
Map<String, Object> comment;
try {
comment = commentService.getComment(commentDoi, site);
} catch (CommentService.CommentNotFoundException e) {
throw new NotFoundException(e);
} catch (UserApi.UserApiException e) {
log.error(e.getMessage(), e);
model.addAttribute("userApiError", e);
// Get a copy of the comment that is not populated with userApi data.
// This articleApi call is redundant to one that commentService.getComment would have made before throwing.
// TODO: Prevent extra articleApi call
comment = getComment(commentDoi);
}
RequestedDoiVersion doi = RequestedDoiVersion.of(getParentArticleDoiFromComment(comment));
articleMetadataFactory.get(site, doi).validateVisibility("articleCommentTree").populate(request, model);
model.addAttribute("comment", comment);
addCommentAvailability(model);
return site + "/ftl/article/comment/comment";
}
Aggregations