if (!userUtils.isLoggedIn(request, response)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
final JSONRenderer renderer = new JSONRenderer();
context.setRenderer(renderer);
final JSONObject ret = new JSONObject();
try {
final JSONObject requestJSONObject = AbstractAction.parseRequestJSONObject(request, response);
final JSONObject article = requestJSONObject.getJSONObject(Article.ARTICLE);
final String articleId = article.getString(Keys.OBJECT_ID);
renderer.setJSONObject(ret);
if (!userUtils.canAccessArticle(articleId, request)) {
ret.put(Keys.MSG, langPropsService.get("forbiddenLabel"));
ret.put(Keys.STATUS_CODE, false);
return;
}
// The article to update has no sign
if (!article.has(Article.ARTICLE_SIGN_ID)) {
article.put(Article.ARTICLE_SIGN_ID, "0");
}
articleMgmtService.updateArticle(requestJSONObject);
ret.put(Keys.MSG, langPropsService.get("updateSuccLabel"));
ret.put(Keys.STATUS_CODE, true);
} catch (final ServiceException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
final JSONObject jsonObject = QueryResults.defaultResult();
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, e.getMessage());
}
}