All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.n3r.quartz.glass.web.controller.JsServiceController Maven / Gradle / Ivy

There is a newer version: 0.0.9
Show newest version
package org.n3r.quartz.glass.web.controller;

import org.apache.commons.lang3.StringUtils;
import org.n3r.quartz.glass.job.annotation.JobBean;
import org.n3r.quartz.glass.log.joblog.JobLog;
import org.n3r.quartz.glass.log.joblog.JobLogs;
import org.n3r.quartz.glass.util.Page;
import org.n3r.quartz.glass.util.Query;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class JsServiceController {
    /**
     * Gets job description for a job class.
     * Used as a js service from pages.
     */
    @RequestMapping("/jsapi/jobs/description")
    @ResponseBody
    public JobBean description(String className) {
        if (StringUtils.isEmpty(className)) return null;

        try {
            return JobBean.fromClass(Class.forName(className));
        } catch (ClassNotFoundException e) {
            return null;
        }
    }

    @RequestMapping("/jsapi/logs")
    @ResponseBody
    public Page logs(@RequestParam Long executionId, @RequestParam(defaultValue = "1") Integer page) {
        return JobLogs.getLogs(executionId, Query.oneBasedIndex(page).withSize(LogsController.PAGE_SIZE));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy