HttpServletResponse response)
throws ServletException, IOException {
Weblogger roller = WebloggerFactory.getWeblogger();
try {
WeblogEntryManager wmgr = roller.getWeblogEntryManager();
WeblogEntryComment c = wmgr.getComment(request.getParameter("id"));
if (c == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
} else {
// need post permission to edit comments
RollerSession rses = RollerSession.getRollerSession(request);
Weblog weblog = c.getWeblogEntry().getWebsite();
if (weblog.hasUserPermission(rses.getAuthenticatedUser(), WeblogPermission.POST)) {
String content = Utilities.streamToString(request.getInputStream());
c.setContent(content);
// don't update the posttime when updating the comment
c.setPostTime(c.getPostTime());
wmgr.saveComment(c);
roller.flush();
c = wmgr.getComment(request.getParameter("id"));
content = Utilities.escapeHTML(c.getContent());
content = WordUtils.wrap(content, 72);
content = StringEscapeUtils.escapeJavaScript(content);
String json = "{ id: \"" + c.getId() + "\"," + "content: \"" + content + "\" }";
response.setStatus(HttpServletResponse.SC_OK);