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.BlogDAO; 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.Blog; 38 import com.j2biz.blogunity.web.ActionResultFactory; 39 import com.j2biz.blogunity.web.IActionResult; 40 41 48 public class CreateBlogEntryFormAction extends MyAbstractAction { 49 50 private static final IActionResult BLOG_ENTRY_FORM = ActionResultFactory 51 .buildForward("/jsp/my/createBlogEntryForm.jsp"); 52 53 59 public IActionResult execute(HttpServletRequest request, HttpServletResponse response) 60 throws BlogunityException { 61 String blogId = request.getParameter("id"); 62 if (StringUtils.isEmpty(blogId)) { throw new BlogunityException(I18NStatusFactory.create( 63 I18N.ERRORS.ID_NOT_SETTED, "Blog")); } 64 65 Blog b = (new BlogDAO()).getBlogByID(new Long (blogId)); 66 67 if (!user.canPostToBlog(b)) 68 throw new BlogunityException(I18NStatusFactory 69 .create(I18N.ERRORS.USER_CAN_NOT_POST_TO_BLOG)); 70 71 request.setAttribute("blog", b); 72 73 navigationStack.push(ActionResultFactory.buildRedirect(I18N.MESSAGES.NAVI_CREATE_ENTRY, 74 currentActionPath)); 75 76 return BLOG_ENTRY_FORM; 77 } 78 } | Popular Tags |