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.logging.Log; 32 import org.apache.commons.logging.LogFactory; 33 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.Entry; 38 import com.j2biz.blogunity.web.ActionResultFactory; 39 import com.j2biz.blogunity.web.IActionResult; 40 41 48 public class SaveBlogEntrySuccessAction extends MyAbstractAction { 49 52 private static final Log log = LogFactory.getLog(SaveBlogEntrySuccessAction.class); 53 54 private static final IActionResult SUCCESS_FORWARD = ActionResultFactory 55 .buildForward("/jsp/my/saveBlogEntrySuccess.jsp"); 56 57 63 public IActionResult execute(HttpServletRequest request, HttpServletResponse response) 64 throws BlogunityException { 65 if (log.isDebugEnabled()) { 66 log.debug("execute(HttpServletRequest, HttpServletResponse) - start"); 67 } 68 69 Entry e = (Entry) request.getSession().getAttribute("savedEntry"); 71 if (e == null) { throw new BlogunityException(I18NStatusFactory.create( 72 I18N.ERRORS.NOT_FOUND, "Entry")); } 73 74 if (user.getId().longValue() != e.getAuthor().getId().longValue() 75 && !user.isAdministrator()) 76 throw new BlogunityException(I18NStatusFactory 77 .create(I18N.ERRORS.USER_NOT_AUTHORIZED_FOR_EXECUTION)); 78 79 request.getSession().removeAttribute("savedEntry"); 80 request.setAttribute("savedEntry", e); 81 82 return SUCCESS_FORWARD; 83 } 84 85 } | Popular Tags |