Search in sources :

Example 41 with ActionForward

use of org.apache.struts.action.ActionForward in project zoj by licheng.

the class ContestInfoAction method execute.

/**
 * Show Contest Info.
 *
 * <pre>
 * </pre>
 *
 * @param mapping
 *            action mapping
 * @param form
 *            action form
 * @param request
 *            http servlet request
 * @param response
 *            http servlet response
 *
 * @return action forward instance
 *
 * @throws Exception
 *             any errors happened
 */
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, ContextAdapter context) throws Exception {
    // check contest
    boolean isProblemset = context.getRequest().getRequestURI().endsWith("problemsetInfo.do");
    ActionForward forward = this.checkContestViewPermission(mapping, context, isProblemset, false);
    if (forward != null) {
        return forward;
    }
    return this.handleSuccess(mapping, context, "success");
}
Also used : ActionForward(org.apache.struts.action.ActionForward)

Example 42 with ActionForward

use of org.apache.struts.action.ActionForward in project zoj by licheng.

the class CreateContestAction method execute.

/**
 * Register.
 *
 * @param mapping
 *            action mapping
 * @param form
 *            action form
 * @param request
 *            http servlet request
 * @param response
 *            http servlet response
 *
 * @return action forward instance
 *
 * @throws Exception
 *             any errors happened
 */
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, ContextAdapter context) throws Exception {
    ActionForward forward = this.checkAdmin(mapping, context);
    if (forward != null) {
        return forward;
    }
    ContestPersistence contestPersistence = PersistenceManager.getInstance().getContestPersistence();
    ContestForm contestForm = (ContestForm) form;
    if (contestForm == null || contestForm.getId() == null) {
        return this.handleSuccess(mapping, context, "failure");
    }
    context.setAttribute("ContestForm", contestForm);
    // create user profile
    AbstractContest contest = contestForm.toContest();
    contestPersistence.createContest(contest, context.getUserProfile().getId());
    ContestManager.getInstance().refreshContest(contest.getId());
    ActionMessages messages = new ActionMessages();
    messages.add("message", new ActionMessage("onlinejudge.createContest.success"));
    this.saveErrors(context.getRequest(), messages);
    context.setAttribute("back", "manageContests.do");
    return this.handleSuccess(mapping, context, "success");
}
Also used : AbstractContest(cn.edu.zju.acm.onlinejudge.bean.AbstractContest) ContestPersistence(cn.edu.zju.acm.onlinejudge.persistence.ContestPersistence) ContestForm(cn.edu.zju.acm.onlinejudge.form.ContestForm) ActionMessages(org.apache.struts.action.ActionMessages) ActionMessage(org.apache.struts.action.ActionMessage) ActionForward(org.apache.struts.action.ActionForward)

Example 43 with ActionForward

use of org.apache.struts.action.ActionForward in project zoj by licheng.

the class DeleteContestAction method execute.

/**
 * Register.
 *
 * @param mapping
 *            action mapping
 * @param form
 *            action form
 * @param request
 *            http servlet request
 * @param response
 *            http servlet response
 *
 * @return action forward instance
 *
 * @throws Exception
 *             any errors happened
 */
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, ContextAdapter context) throws Exception {
    // check contest
    boolean isProblemset = context.getRequest().getRequestURI().endsWith("deleteProblemset.do");
    ActionForward forward = this.checkContestAdminPermission(mapping, context, isProblemset, false);
    if (forward != null) {
        return forward;
    }
    AbstractContest contest = context.getContest();
    ContestPersistence contestPersistence = PersistenceManager.getInstance().getContestPersistence();
    contestPersistence.deleteContest(contest.getId(), context.getUserSecurity().getId());
    ContestManager.getInstance().refreshContest(contest.getId());
    ActionMessages messages = new ActionMessages();
    if (isProblemset) {
        messages.add("message", new ActionMessage("onlinejudge.deleteProblemset.success"));
    } else {
        messages.add("message", new ActionMessage("onlinejudge.deleteContest.success"));
    }
    this.saveErrors(context.getRequest(), messages);
    context.setAttribute("back", isProblemset ? "showProblemsets.do" : "showContests.do");
    return this.handleSuccess(mapping, context, "success");
}
Also used : AbstractContest(cn.edu.zju.acm.onlinejudge.bean.AbstractContest) ContestPersistence(cn.edu.zju.acm.onlinejudge.persistence.ContestPersistence) ActionMessages(org.apache.struts.action.ActionMessages) ActionMessage(org.apache.struts.action.ActionMessage) ActionForward(org.apache.struts.action.ActionForward)

Example 44 with ActionForward

use of org.apache.struts.action.ActionForward in project zoj by licheng.

the class DeleteRoleAction method execute.

/**
 * Register.
 *
 * @param mapping
 *            action mapping
 * @param form
 *            action form
 * @param request
 *            http servlet request
 * @param response
 *            http servlet response
 *
 * @return action forward instance
 *
 * @throws Exception
 *             any errors happened
 */
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, ContextAdapter context) throws Exception {
    // check admin
    ActionForward forward = this.checkAdmin(mapping, context);
    if (forward != null) {
        return forward;
    }
    long roleId = Utility.parseLong(context.getRequest().getParameter("roleId"));
    AuthorizationPersistence ap = PersistenceManager.getInstance().getAuthorizationPersistence();
    ap.deleteRole(roleId, context.getUserProfile().getId());
    return this.handleSuccess(mapping, context, "success");
}
Also used : AuthorizationPersistence(cn.edu.zju.acm.onlinejudge.persistence.AuthorizationPersistence) ActionForward(org.apache.struts.action.ActionForward)

Example 45 with ActionForward

use of org.apache.struts.action.ActionForward in project zoj by licheng.

the class EditContestAction method execute.

/**
 * Edit Contest.
 *
 * <pre>
 * </pre>
 *
 * @param mapping
 *            action mapping
 * @param form
 *            action form
 * @param request
 *            http servlet request
 * @param response
 *            http servlet response
 *
 * @return action forward instance
 *
 * @throws Exception
 *             any errors happened
 */
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, ContextAdapter context) throws Exception {
    boolean isProblemset = context.getRequest().getRequestURI().endsWith("editProblemset.do");
    ActionForward forward = this.checkContestAdminPermission(mapping, context, isProblemset, false);
    if (forward != null) {
        return forward;
    }
    ContestForm contestForm = (ContestForm) form;
    if (contestForm.getId() == null) {
        AbstractContest contest = context.getContest();
        contestForm.populate(contest);
        return this.handleSuccess(mapping, context);
    } else {
        ContestPersistence persistence = PersistenceManager.getInstance().getContestPersistence();
        AbstractContest contest = contestForm.toContest();
        persistence.updateContest(contest, context.getUserSecurity().getId());
        ContestManager.getInstance().refreshContest(contest.getId());
        ActionMessages messages = new ActionMessages();
        messages.add("message", new ActionMessage("onlinejudge.editContest.success"));
        this.saveErrors(context.getRequest(), messages);
        context.setAttribute("back", (isProblemset ? "problemsetInfo.do" : "contestInfo.do") + "?contestId=" + contest.getId());
        return this.handleSuccess(mapping, context, "success");
    }
}
Also used : AbstractContest(cn.edu.zju.acm.onlinejudge.bean.AbstractContest) ContestForm(cn.edu.zju.acm.onlinejudge.form.ContestForm) ContestPersistence(cn.edu.zju.acm.onlinejudge.persistence.ContestPersistence) ActionMessages(org.apache.struts.action.ActionMessages) ActionMessage(org.apache.struts.action.ActionMessage) ActionForward(org.apache.struts.action.ActionForward)

Aggregations

ActionForward (org.apache.struts.action.ActionForward)117 AbstractContest (cn.edu.zju.acm.onlinejudge.bean.AbstractContest)16 ActionMessages (org.apache.struts.action.ActionMessages)14 Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)11 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)11 UserProfile (cn.edu.zju.acm.onlinejudge.bean.UserProfile)9 ActionMessage (org.apache.struts.action.ActionMessage)9 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)8 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)7 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)7 UserContext (org.mifos.security.util.UserContext)7 IOException (java.io.IOException)6 Date (java.util.Date)6 AuthorizationPersistence (cn.edu.zju.acm.onlinejudge.persistence.AuthorizationPersistence)5 ArrayList (java.util.ArrayList)5 Cookie (javax.servlet.http.Cookie)5 ActionMapping (org.apache.struts.action.ActionMapping)5 CloseSession (org.mifos.framework.util.helpers.CloseSession)5 Submission (cn.edu.zju.acm.onlinejudge.bean.Submission)4 IWantDocumentService (edu.cornell.kfs.module.purap.document.service.IWantDocumentService)4