KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nemesis > forum > webapp > admin > action > DelForumAction


1 package org.nemesis.forum.webapp.admin.action;
2
3 import javax.servlet.http.HttpServletRequest JavaDoc;
4 import javax.servlet.http.HttpServletResponse JavaDoc;
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.ProfileManager;
16 import org.nemesis.forum.exception.NotFoundException;
17 import org.nemesis.forum.exception.UnauthorizedException;
18
19 public class DelForumAction extends BaseAction {
20     
21     static protected Log log =LogFactory.getLog(DelForumAction.class);
22     
23     public ActionForward execute(ActionMapping mapping,
24                  ActionForm form,
25                  HttpServletRequest JavaDoc request,
26                  HttpServletResponse JavaDoc response)
27     throws Exception JavaDoc {
28         
29         //check logon
30
checkUser(request);
31         //check permission
32
checkPermission(request,OperationConstants.DELETE_FORUM);
33         
34         ActionErrors errors = new ActionErrors();
35         
36         try {
37                 try {
38                     
39                     ForumFactory forumFactory = ForumFactory.getInstance(getAuthToken(request));
40                     ProfileManager manager = forumFactory.getProfileManager();
41                     Forum f = forumFactory.getForum(Integer.parseInt(request.getParameter("id")));
42                     forumFactory.deleteForum(f);
43                     
44                     errors.add("general", new ActionError("delForum.confirm"));
45                     
46                 }
47                 catch( NotFoundException fnfe ) {
48                     errors.add("general", new ActionError("delForum.notFound"));
49                 }
50                 catch( UnauthorizedException ue ) {
51                     errors.add("general", new ActionError("delForum.unauthorized"));
52                 }
53                 
54         } catch (Exception JavaDoc e) {
55             String JavaDoc eid=this.getClass().getName()+"_"+System.currentTimeMillis();
56             log.error("eid:"+eid +"\nsessionID" +request.getSession().getId(),e) ;
57             errors.add("general", new ActionError("error.general","error id:"+eid));
58         }
59         
60         saveErrors(request, errors);
61
62         return mapping.findForward("success");
63     
64     }
65 }
Popular Tags