Search in sources :

Example 1 with ActionLog

use of cn.edu.zju.acm.onlinejudge.util.ActionLog in project zoj by licheng.

the class ShowActionDashboardAction method execute.

/**
     * ShowRolesAction.
     *
     * @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
     */
public ActionForward execute(ActionMapping mapping, ActionForm form, ContextAdapter context) throws Exception {
    ActionForward forward = checkAdmin(mapping, context);
    if (forward != null) {
        return forward;
    }
    LogSearchForm searchForm = (LogSearchForm) form;
    if (searchForm.getTimeStart() == null) {
        searchForm.setTimeStart(Utility.toTimestamp(new Date(System.currentTimeMillis() - 24 * 3600 * 1000)));
    }
    ActionMessages errors = searchForm.check();
    if (errors.size() > 0) {
        context.setAttribute("logs", new ArrayList<AccessLog>());
        return handleFailure(mapping, context, errors);
    }
    LogCriteria criteria = searchForm.toLogCriteria();
    if (criteria.getTimeStart() == null) {
        criteria.setTimeStart(new Date(System.currentTimeMillis() - 24 * 3600 * 1000));
    }
    List<ActionLog> logs = PerformanceManager.getInstance().getActionDashboard(criteria, searchForm.getOrderBy());
    context.setAttribute("parameters", searchForm.toParameterMap());
    context.setAttribute("logs", logs);
    return handleSuccess(mapping, context, "success");
}
Also used : AccessLog(cn.edu.zju.acm.onlinejudge.util.AccessLog) LogSearchForm(cn.edu.zju.acm.onlinejudge.form.LogSearchForm) ActionMessages(org.apache.struts.action.ActionMessages) LogCriteria(cn.edu.zju.acm.onlinejudge.bean.request.LogCriteria) ActionLog(cn.edu.zju.acm.onlinejudge.util.ActionLog) ActionForward(org.apache.struts.action.ActionForward) Date(java.util.Date)

Aggregations

LogCriteria (cn.edu.zju.acm.onlinejudge.bean.request.LogCriteria)1 LogSearchForm (cn.edu.zju.acm.onlinejudge.form.LogSearchForm)1 AccessLog (cn.edu.zju.acm.onlinejudge.util.AccessLog)1 ActionLog (cn.edu.zju.acm.onlinejudge.util.ActionLog)1 Date (java.util.Date)1 ActionForward (org.apache.struts.action.ActionForward)1 ActionMessages (org.apache.struts.action.ActionMessages)1