use of org.springframework.http.ResponseEntity in project Saturn by vipshop.
the class JobOperationRestApiController method run.
@RequestMapping(value = "/{namespace}/jobs/{jobName}/run", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> run(@PathVariable("namespace") String namespace, @PathVariable("jobName") String jobName) throws SaturnJobConsoleException {
try {
checkMissingParameter("namespace", namespace);
checkMissingParameter("jobName", jobName);
restApiService.runJobAtOnce(namespace, jobName);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} catch (SaturnJobConsoleException e) {
throw e;
} catch (Exception e) {
throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
}
}
use of org.springframework.http.ResponseEntity in project Saturn by vipshop.
the class JobOperationRestApiController method create.
@RequestMapping(value = "/{namespace}/jobs", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> create(@PathVariable("namespace") String namespace, @RequestBody Map<String, Object> reqParams) throws SaturnJobConsoleException {
try {
JobConfig jobConfig = constructJobConfig(namespace, reqParams);
restApiService.createJob(namespace, jobConfig);
return new ResponseEntity<>(HttpStatus.CREATED);
} catch (SaturnJobConsoleException e) {
throw e;
} catch (Exception e) {
throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
}
}
use of org.springframework.http.ResponseEntity in project Saturn by vipshop.
the class JobOperationRestApiController method enable.
@RequestMapping(value = { "/{namespace}/{jobName}/enable", "/{namespace}/jobs/{jobName}/enable" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> enable(@PathVariable("namespace") String namespace, @PathVariable("jobName") String jobName) throws SaturnJobConsoleException {
HttpHeaders httpHeaders = new HttpHeaders();
try {
checkMissingParameter("namespace", namespace);
checkMissingParameter("jobName", jobName);
restApiService.enableJob(namespace, jobName);
return new ResponseEntity<>(httpHeaders, HttpStatus.OK);
} catch (SaturnJobConsoleException e) {
throw e;
} catch (Exception e) {
throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
}
}
use of org.springframework.http.ResponseEntity in project Saturn by vipshop.
the class JobOperationRestApiController method disable.
@RequestMapping(value = { "/{namespace}/{jobName}/disable", "/{namespace}/jobs/{jobName}/disable" }, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> disable(@PathVariable("namespace") String namespace, @PathVariable("jobName") String jobName) throws SaturnJobConsoleException {
HttpHeaders httpHeaders = new HttpHeaders();
try {
checkMissingParameter("namespace", namespace);
checkMissingParameter("jobName", jobName);
restApiService.disableJob(namespace, jobName);
return new ResponseEntity<>(httpHeaders, HttpStatus.OK);
} catch (SaturnJobConsoleException e) {
throw e;
} catch (Exception e) {
throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
}
}
use of org.springframework.http.ResponseEntity in project Saturn by vipshop.
the class JobOperationRestApiController method queryAll.
@RequestMapping(value = "/{namespace}/jobs", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> queryAll(@PathVariable("namespace") String namespace) throws SaturnJobConsoleException {
HttpHeaders httpHeaders = new HttpHeaders();
try {
checkMissingParameter("namespace", namespace);
List<RestApiJobInfo> restApiJobInfos = restApiService.getRestApiJobInfos(namespace);
return new ResponseEntity<Object>(restApiJobInfos, httpHeaders, HttpStatus.OK);
} catch (SaturnJobConsoleException e) {
throw e;
} catch (Exception e) {
throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
}
}
Aggregations