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 org.apache.commons.lang.StringUtils; 32 33 import com.j2biz.blogunity.dao.CommentDAO; 34 import com.j2biz.blogunity.exception.BlogunityException; 35 import com.j2biz.blogunity.i18n.I18N; 36 import com.j2biz.blogunity.i18n.I18NStatusFactory; 37 import com.j2biz.blogunity.pojo.Comment; 38 import com.j2biz.blogunity.web.ActionResultFactory; 39 import com.j2biz.blogunity.web.IActionResult; 40 41 48 public class EditCommentFormAction extends MyAbstractAction { 49 50 private static final IActionResult COMMENT_FORM_FORWARD = ActionResultFactory 51 .buildForward("/jsp/my/editCommentForm.jsp"); 52 53 59 public IActionResult execute(HttpServletRequest request, HttpServletResponse response) 60 throws BlogunityException { 61 62 String id = request.getParameter("id"); 63 if (StringUtils.isEmpty(id)) { 64 id = (String ) request.getAttribute("id"); 66 if (StringUtils.isEmpty(id)) { throw new BlogunityException(I18NStatusFactory.create( 67 I18N.ERRORS.ID_NOT_SETTED, "Comment")); } 68 69 } 70 71 CommentDAO dao = new CommentDAO(); 72 Comment comment = dao.getCommentByID(Long.parseLong(id)); 73 74 81 82 if (!(user.isAdministrator() || comment.getAuthor().getId().longValue() == user.getId().longValue() || comment.getCommentedEntry().getAuthor().getId().longValue() == user.getId() 85 .longValue() || comment.getCommentedEntry().getBlog().getFounder().getId().longValue() == user.getId() 87 .longValue() 89 )) { throw new BlogunityException(I18NStatusFactory 90 .create(I18N.ERRORS.USER_NOT_AUTHORIZED_FOR_EXECUTION)); } 91 92 request.setAttribute("requestedComment", comment); 93 94 navigationStack.push(ActionResultFactory.buildRedirect(I18N.MESSAGES.NAVI_EDIT_COMMENT, 95 currentActionPath)); 96 97 return COMMENT_FORM_FORWARD; 98 } 99 100 } | Popular Tags |