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.BlogDAO; 32 import com.j2biz.blogunity.dao.UserDAO; 33 import com.j2biz.blogunity.exception.BlogunityException; 34 import com.j2biz.blogunity.i18n.I18N; 35 import com.j2biz.blogunity.i18n.I18NStatusFactory; 36 import com.j2biz.blogunity.pojo.Blog; 37 import com.j2biz.blogunity.web.IActionResult; 38 39 47 public class FavoriteBlogDeleteExecAction extends MyAbstractAction { 48 49 53 59 public IActionResult execute(HttpServletRequest request, HttpServletResponse response) 60 throws BlogunityException { 61 62 String blogId = request.getParameter("id"); 63 64 Blog b = (new BlogDAO()).getBlogByID(Long.parseLong(blogId)); 65 66 if (!user.getFavoriteBlogs().contains(b)) 67 throw new BlogunityException(I18NStatusFactory 68 .create(I18N.ERRORS.USER_NOT_AUTHORIZED_FOR_EXECUTION)); 69 70 user.getFavoriteBlogs().remove(b); 71 (new UserDAO()).updateUser(user); 72 73 navigationStack.pop(); 74 return navigationStack.peek(); 75 76 } 77 78 } | Popular Tags |