Package cn.edu.zju.acm.onlinejudge.form

Examples of cn.edu.zju.acm.onlinejudge.form.RoleForm


        ActionForward forward = this.checkAdmin(mapping, context);
        if (forward != null) {
            return forward;
        }

        RoleForm roleForm = (RoleForm) form;
        AuthorizationPersistence authorizationPersistence =
                PersistenceManager.getInstance().getAuthorizationPersistence();

        if (roleForm.getId() == null || roleForm.getId().trim().length() == 0) {
            long roleId = Utility.parseLong(context.getRequest().getParameter("roleId"));
            RoleSecurity role = authorizationPersistence.getRole(roleId);
            if (role == null) {
                return this.handleSuccess(mapping, context, "success");
            }

            // add contest names
            Map<Long, String> contestNames = new TreeMap<Long, String>();
            for (AbstractContest contest : ContestManager.getInstance().getAllContests()) {
                contestNames.put(contest.getId(), contest.getTitle());
            }
            for (AbstractContest contest : ContestManager.getInstance().getAllProblemsets()) {
                contestNames.put(contest.getId(), contest.getTitle());
            }
            for (AbstractContest contest : ContestManager.getInstance().getAllCourses()) {
                contestNames.put(contest.getId(), contest.getTitle());
            }
            context.setAttribute("ContestNames", contestNames);

            // TODO add forums
            Map<Long, String> forumNames = new TreeMap<Long, String>();
            forumNames.put(1L, "ZOJ Forum");
            context.setAttribute("ForumNames", forumNames);

            roleForm.populate(role);
            return this.handleSuccess(mapping, context, "failure");
        }

        RoleSecurity role = roleForm.toRole();
        authorizationPersistence.updateRole(role, context.getUserProfile().getId());

        if (role.getId() == 1) {
            ContextAdapter.resetDefaultUserSecurity();
        }
View Full Code Here

TOP

Related Classes of cn.edu.zju.acm.onlinejudge.form.RoleForm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.