1 package org.nemesis.forum.webapp.admin.action; 2 3 import javax.servlet.http.HttpServletRequest ; 4 import javax.servlet.http.HttpServletResponse ; 5 6 import org.apache.commons.logging.Log; 7 import org.apache.commons.logging.LogFactory; 8 import org.apache.struts.action.ActionError; 9 import org.apache.struts.action.ActionErrors; 10 import org.apache.struts.action.ActionForm; 11 import org.apache.struts.action.ActionForward; 12 import org.apache.struts.action.ActionMapping; 13 import org.nemesis.forum.Forum; 14 import org.nemesis.forum.ForumFactory; 15 import org.nemesis.forum.exception.ForumNotFoundException; 16 import org.nemesis.forum.exception.ForumThreadNotFoundException; 17 import org.nemesis.forum.exception.UnauthorizedException; 18 19 public class DelThreadAction extends BaseAction { 20 21 static protected Log log = LogFactory.getLog(DelThreadAction.class); 22 23 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 24 25 checkUser(request); 27 28 ActionErrors errors = new ActionErrors(); 29 30 try { 31 32 ForumFactory forumFactory = ForumFactory.getInstance(getAuthToken(request)); 33 Forum forum = forumFactory.getForum(Integer.parseInt(request.getParameter("id"))); 34 request.setAttribute("id", request.getParameter("id")); 35 checkPermission(request, OperationConstants.DELETE_THREAD, forum); 37 38 forum.deleteThread(forum.getThread( Integer.parseInt(request.getParameter("threadID")))); 39 40 } catch (ForumNotFoundException e) { 41 errors.add("general", new ActionError("content.forumNotFound")); 42 } catch (ForumThreadNotFoundException e) { 43 errors.add("general", new ActionError("content.threadNotFound")); 44 } catch (UnauthorizedException ue) { 45 errors.add("general", new ActionError("content.Unauthorized")); 46 } catch (Exception e) { 47 String eid = this.getClass().getName() + "_" + System.currentTimeMillis(); 48 log.error("eid:" + eid + "\nsessionID" + request.getSession().getId(), e); 49 errors.add("general", new ActionError("error.general", "erreur id:" + eid)); 50 } 51 52 if (!errors.isEmpty()) { 53 saveErrors(request, errors); 54 return mapping.findForward("cancel"); 55 } 56 57 return mapping.findForward("success"); 58 59 } 60 } | Popular Tags |