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

com.jiuxian.mossrose.ui.MossroseRequestHandler Maven / Gradle / Ivy

There is a newer version: 1.1.5-RELEASE
Show newest version
package com.jiuxian.mossrose.ui;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import com.jiuxian.mossrose.JobOperation;
import com.jiuxian.mossrose.ui.vo.JobVo;
import com.jiuxian.mossrose.ui.vo.JobVoHelper;

@Path("")
public class MossroseRequestHandler {

	private JobOperation jobOperation;

	protected MossroseRequestHandler(JobOperation jobOperation) {
		super();
		this.jobOperation = jobOperation;
	}

	@GET
	@Path("all")
	@Produces("application/json")
	public Response> allJobInfo() {
		return new Response>(0, JobVoHelper.toVos(jobOperation.allJobs()));
	}

	@POST
	@Path("/all/pause")
	@Produces("application/json")
	public Response pauseAllJob() {
		jobOperation.pauseAllJob();
		return new Response(0, null);
	}

	@POST
	@Path("/all/resume")
	@Produces("application/json")
	public Response resumeAllJob() {
		jobOperation.resumeAllJob();
		return new Response(0, null);
	}

	@GET
	@Path("/{group}/{jobId}")
	@Produces("application/json")
	public Response jobInfo(@PathParam(value = "group") String group, @PathParam("jobId") String jobId) {
		return new Response(0, JobVoHelper.toVo(jobOperation.jobInfo(group, jobId)));
	}

	@POST
	@Path("/{group}/{jobId}/pause")
	@Produces("application/json")
	public Response pauseJob(@PathParam(value = "group") String group, @PathParam("jobId") String jobId) {
		jobOperation.pauseJob(group, jobId);
		return new Response(0, null);
	}

	@POST
	@Path("/{group}/{jobId}/resume")
	@Produces("application/json")
	public Response resumeJob(@PathParam(value = "group") String group, @PathParam("jobId") String jobId) {
		jobOperation.resumeJob(group, jobId);
		return new Response(0, null);
	}

	@POST
	@Path("/{group}/{jobId}/run")
	@Produces("application/json")
	public Response runJob(@PathParam(value = "group") String group, @PathParam("jobId") String jobId) {
		jobOperation.runJobNow(group, jobId);
		return new Response(0, null);
	}

}