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.Group; 16 import org.nemesis.forum.ProfileManager; 17 import org.nemesis.forum.config.Constants; 18 import org.nemesis.forum.exception.NotFoundException; 19 import org.nemesis.forum.exception.UnauthorizedException; 20 import org.nemesis.forum.util.SecurityTools; 21 22 23 28 public class DelGroupPermissionAction extends BaseAction { 29 30 static protected Log log =LogFactory.getLog(DelGroupPermissionAction.class); 31 32 33 public ActionForward execute(ActionMapping mapping, 34 ActionForm form, 35 HttpServletRequest request, 36 HttpServletResponse response) 37 throws Exception { 38 39 checkUser(request); 41 42 ActionErrors errors = new ActionErrors(); 43 44 45 try { 46 47 ForumFactory forumFactory = ForumFactory.getInstance(getAuthToken(request)); 48 Forum forum = forumFactory.getForum(Integer.parseInt(request.getParameter("id"))); 49 request.setAttribute("id", request.getParameter("id")); 50 checkPermission(request, OperationConstants.DELETE_GROUP_PERMISSION, forum); 52 53 ProfileManager manager = forumFactory.getProfileManager(); 54 Group group = manager.getGroup( Integer.parseInt(request.getParameter("actor"))); 55 56 int perm=Integer.parseInt(request.getParameter("type")); 57 if(perm==Constants.FORUM_ADMIN && ! SecurityTools.isSystemAdmin(getAuthToken(request))){ 58 throw new UnauthorizedException(); 59 } 60 forum.removeGroupPermission(group, perm); 61 62 } catch (NotFoundException e) { 63 errors.add("general", new ActionError("forumPermission.forumNotFound")); 64 } catch (UnauthorizedException ue) { 65 errors.add("general", new ActionError("forumPermission.Unauthorized")); 66 } catch (Exception e) { 67 String eid = this.getClass().getName() + "_" + System.currentTimeMillis(); 68 log.error("eid:" + eid + "\nsessionID" + request.getSession().getId(), e); 69 errors.add("general", new ActionError("error.general", "erreur id:" + eid)); 70 } 71 72 if (!errors.isEmpty()) { 73 saveErrors(request, errors); 74 return mapping.findForward("cancel"); 75 } 76 77 return mapping.findForward("success"); 78 } 79 80 } | Popular Tags |