@Override public String intercept(ActionInvocation actionInvocation) throws Exception { Map<String, Object> session = actionInvocation.getInvocationContext().getSession(); User user = (User) session.get(GlobalNames.USER); if (user == null) { return Action.LOGIN; } else { if (rol != null) { if (!user.getLevel().toString().equals("GOD")) { if (rol.equals("GOD")) { return Action.ERROR; } if (rol.equals("ADMIN") && !(user.getLevel().toString().equals("ADMIN"))) { return Action.ERROR; } } } Action action = (Action) actionInvocation.getAction(); if (action instanceof UserAware) { ((UserAware) action).setUser(user); } } return actionInvocation.invoke(); }
public String execute() throws InstanceNotFoundException { user = panService.findUser(id); if (user.getLevel() != Level.GOD) { user.setLevel(Level.DISABLED); } panService.updateUser(user); return SUCCESS; }