if (!userQueryService.isLoggedIn(request, response)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
final JSONRenderer renderer = new JSONRenderer();
context.setRenderer(renderer);
try {
String path = request.getRequestURI().substring((Latkes.getContextPath() + "/console/articles/status/").length());
final String status = StringUtils.substringBefore(path, "/");
path = path.substring((status + "/").length());
final boolean published = "published".equals(status) ? true : false;
final JSONObject requestJSONObject = Requests.buildPaginationRequest(path);
requestJSONObject.put(Article.ARTICLE_IS_PUBLISHED, published);
final JSONArray excludes = new JSONArray();
excludes.put(Article.ARTICLE_CONTENT);
excludes.put(Article.ARTICLE_UPDATE_DATE);
excludes.put(Article.ARTICLE_CREATE_DATE);
excludes.put(Article.ARTICLE_AUTHOR_EMAIL);
excludes.put(Article.ARTICLE_HAD_BEEN_PUBLISHED);
excludes.put(Article.ARTICLE_IS_PUBLISHED);
excludes.put(Article.ARTICLE_RANDOM_DOUBLE);
requestJSONObject.put(Keys.EXCLUDES, excludes);
final JSONObject result = articleQueryService.getArticles(requestJSONObject);
result.put(Keys.STATUS_CODE, true);
renderer.setJSONObject(result);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
final JSONObject jsonObject = QueryResults.defaultResult();
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("getFailLabel"));
}
}