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.web.ActionResultFactory; 37 import com.j2biz.blogunity.web.IActionResult; 38 39 46 public class DeleteCommentConfirmAction extends MyAbstractAction { 47 private static final IActionResult DELETE_CONFIRM_FORWARD = ActionResultFactory 48 .buildForward("/jsp/my/deleteCommentConfirm.jsp"); 49 50 56 public IActionResult execute(HttpServletRequest request, HttpServletResponse response) 57 throws BlogunityException { 58 59 String id = request.getParameter("id"); 60 Comment comment = (new CommentDAO()).getCommentByID(Long.parseLong(id)); 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 request.setAttribute("requestedComment", comment); 81 82 navigationStack.push(ActionResultFactory.buildRedirect(I18N.MESSAGES.NAVI_DELETE_COMMENT, 83 currentActionPath)); 84 85 return DELETE_CONFIRM_FORWARD; 86 } 87 88 } | Popular Tags |