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.ProfileManager; 15 import org.nemesis.forum.User; 16 import org.nemesis.forum.exception.NotFoundException; 17 import org.nemesis.forum.exception.UnauthorizedException; 18 19 public class DelUserAction extends BaseAction { 20 21 static protected Log log =LogFactory.getLog(DelUserAction.class); 22 23 public ActionForward execute(ActionMapping mapping, 24 ActionForm form, 25 HttpServletRequest request, 26 HttpServletResponse response) 27 throws Exception { 28 29 checkUser(request); 31 checkPermission(request,OperationConstants.DELETE_USER); 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 User u = manager.getUser(Integer.parseInt(request.getParameter("id"))); 42 manager.deleteUser(u); 43 errors.add("general", new ActionError("delUser.confirm")); 44 45 } 46 catch( NotFoundException fnfe ) { 47 errors.add("general", new ActionError("delUser.notFound")); 48 } 49 catch( UnauthorizedException ue ) { 50 errors.add("general", new ActionError("delUser.unauthorized")); 51 } 52 53 } catch (Exception e) { 54 String eid=this.getClass().getName()+"_"+System.currentTimeMillis(); 55 log.error("eid:"+eid +"\nsessionID" +request.getSession().getId(),e) ; 56 errors.add("general", new ActionError("error.general","error id:"+eid)); 57 } 58 59 saveErrors(request, errors); 60 61 return mapping.findForward("success"); 62 63 } 64 } | Popular Tags |