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.ForumFactory; 14 import org.nemesis.forum.Group; 15 import org.nemesis.forum.ProfileManager; 16 import org.nemesis.forum.exception.NotFoundException; 17 import org.nemesis.forum.exception.UnauthorizedException; 18 19 20 public class DelGroupAction extends BaseAction { 21 22 static protected Log log =LogFactory.getLog(DelGroupAction.class); 23 24 public ActionForward execute(ActionMapping mapping, 25 ActionForm form, 26 HttpServletRequest request, 27 HttpServletResponse response) 28 throws Exception { 29 30 checkUser(request); 32 checkPermission(request,OperationConstants.DELETE_GROUP); 34 35 ActionErrors errors = new ActionErrors(); 36 37 try { 38 try { 39 40 ForumFactory forumFactory = ForumFactory.getInstance(getAuthToken(request)); 41 ProfileManager manager = forumFactory.getProfileManager(); 42 Group group = manager.getGroup(Integer.parseInt(request.getParameter("id"))); 43 manager.deleteGroup(group); 44 errors.add("general", new ActionError("delGroup.confirm")); 45 46 } 47 catch( NotFoundException fnfe ) { 48 errors.add("general", new ActionError("delGroup.notFound")); 49 } 50 catch( UnauthorizedException ue ) { 51 errors.add("general", new ActionError("delGroup.unauthorized")); 52 } 53 54 } catch (Exception e) { 55 String 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 } | Popular Tags |