1 25 26 package com.j2biz.blogunity.web.actions.my; 27 28 import javax.servlet.http.HttpServletRequest ; 29 import javax.servlet.http.HttpServletResponse ; 30 31 import com.j2biz.blogunity.dao.CommentDAO; 32 import com.j2biz.blogunity.exception.BlogunityException; 33 import com.j2biz.blogunity.i18n.I18N; 34 import com.j2biz.blogunity.i18n.I18NStatusFactory; 35 import com.j2biz.blogunity.pojo.Comment; 36 import com.j2biz.blogunity.pojo.Entry; 37 import com.j2biz.blogunity.web.IActionResult; 38 39 46 public class DeleteCommentExecAction extends MyAbstractAction { 47 48 54 public IActionResult execute(HttpServletRequest request, HttpServletResponse response) 55 throws BlogunityException { 56 57 String id = request.getParameter("id"); 58 CommentDAO dao = new CommentDAO(); 59 Comment comment = dao.getCommentByID(Long.parseLong(id)); 60 Entry entry = comment.getCommentedEntry(); 61 62 69 70 if (!(user.isAdministrator() || comment.getAuthor().getId().longValue() == user.getId().longValue() || comment.getCommentedEntry().getAuthor().getId().longValue() == user.getId() 73 .longValue() || comment.getCommentedEntry().getBlog().getFounder().getId().longValue() == user.getId() 75 .longValue() 77 )) { throw new BlogunityException(I18NStatusFactory 78 .create(I18N.ERRORS.USER_NOT_AUTHORIZED_FOR_EXECUTION)); } 79 80 82 dao.deleteCommentWithAllSubComments(comment); 83 84 navigationStack.pop(); 85 return navigationStack.peek(); 86 } 87 88 } | Popular Tags |