private JobExecution findExecutionById(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("No JobExecution found for id: [" + executionId + "]"); } return jobExecution; } }
@ResponseBody @ExceptionHandler @ResponseStatus(HttpStatus.NOT_FOUND) public VndErrors onNoSuchJobExecutionException(NoSuchJobExecutionException e) { String logref = logDebug(e); return new VndErrors(logref, e.getMessage()); }
@Override public Exception getException(String msg) throws Exception { return new NoSuchJobExecutionException(msg); }
@Override public Exception getException(String msg, Throwable t) throws Exception { return new NoSuchJobExecutionException(msg, t); }
private JobExecution findExecutionById(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("No JobExecution found for id: [" + executionId + "]"); } return jobExecution; }
@RequestMapping(value = "/jobs/executions/{executionId}", method = RequestMethod.GET) public JobExecution findExecution(@PathVariable long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("JobExecution with id " + executionId + " not found."); } return jobExecution; }
@RequestMapping(value = "/jobs/executions/{executionId}", method = RequestMethod.GET) public JobExecution findExecution(@PathVariable long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("JobExecution with id " + executionId + " not found."); } return jobExecution; }
private JobExecution findExecutionById(Long jobExecutionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(jobExecutionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("No JobExecution found for id: [" + jobExecutionId + "]"); } return jobExecution; }
private JobExecution findExecutionById(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("No JobExecution found for id: [" + executionId + "]"); } return jobExecution; } }
private JobExecution findExecutionById(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("No JobExecution found for id: [" + executionId + "]"); } return jobExecution; } }
private JobExecution findExecutionById(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("No JobExecution found for id: [" + executionId + "]"); } return jobExecution; } }
/** * View the details of a single task execution, specified by id. * * @param id the id of the requested {@link JobExecution} * @return the {@link JobExecution} * @throws NoSuchJobExecutionException if the specified job execution for the id does * not exist. */ @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json") @ResponseStatus(HttpStatus.OK) public JobExecutionResource view(@PathVariable("id") long id) throws NoSuchJobExecutionException { TaskJobExecution jobExecution = taskJobService.getJobExecution(id); if (jobExecution == null) { throw new NoSuchJobExecutionException(String.format("No Job Execution with id of %d exits", id)); } return jobAssembler.toResource(jobExecution); }
@RequestMapping(value = "/jobs/executions/{executionId}", method = RequestMethod.GET) public String getStatus(@PathVariable long executionId) throws NoSuchJobExecutionException { if (LOG.isDebugEnabled()) { LOG.debug("Get ExitCode for JobExecution with id: {} ", executionId); } JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution != null) { return jobExecution.getExitStatus().getExitCode(); } else { throw new NoSuchJobExecutionException("JobExecution with id " + executionId + " not found."); } }
@RequestMapping(value = "/jobs/executions/{executionId}", method = RequestMethod.GET) public String getStatus(@PathVariable long executionId) throws NoSuchJobExecutionException { if (LOG.isDebugEnabled()) { LOG.debug("Get ExitCode for JobExecution with id: {} ", executionId); } JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution != null) { return jobExecution.getExitStatus().getExitCode(); } else { throw new NoSuchJobExecutionException("JobExecution with id " + executionId + " not found."); } }
/** * Stop Job Execution by the given executionId. * * @param jobExecutionId the executionId of the job execution to stop */ @RequestMapping(value = { "/{executionId}" }, method = RequestMethod.PUT, params = "stop=true") @ResponseStatus(HttpStatus.OK) public void stopJobExecution(@PathVariable("executionId") long jobExecutionId) throws JobExecutionNotRunningException, NoSuchJobExecutionException { try { jobService.stop(jobExecutionId); } catch (org.springframework.batch.core.launch.JobExecutionNotRunningException e) { throw new JobExecutionNotRunningException(String.format("Job execution with executionId %s is not running.", String.valueOf(jobExecutionId))); } catch (org.springframework.batch.core.launch.NoSuchJobExecutionException e) { throw new NoSuchJobExecutionException(String.format("Could not find jobExecution with id %s", String.valueOf(jobExecutionId))); } }
/** * View the details of a single task execution, specified by id. * * @param id the id of the requested {@link JobExecution} * @return the {@link JobExecution} * @throws NoSuchJobExecutionException if the specified job execution for the id does * not exist. */ @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json") @ResponseStatus(HttpStatus.OK) public JobExecutionResource view(@PathVariable("id") long id) throws NoSuchJobExecutionException { TaskJobExecution jobExecution = taskJobService.getJobExecution(id); if (jobExecution == null) { throw new NoSuchJobExecutionException(String.format("No Job Execution with id of %d exits", id)); } return jobAssembler.toResource(jobExecution); }
@RequestMapping(value = "/jobs/executions/{executionId}/log", method = RequestMethod.GET) public void getLogFile(HttpServletResponse response, @PathVariable long executionId) throws NoSuchJobExecutionException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("Get log file for job with executionId: {}", executionId); } String loggingPath = createLoggingPath(); JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("JobExecution with id " + executionId + " not found."); } File downloadFile = new File(loggingPath + jobLogFileNameCreator.getName(jobExecution)); InputStream is = new FileInputStream(downloadFile); FileCopyUtils.copy(is, response.getOutputStream()); response.flushBuffer(); }
@RequestMapping(value = "/jobs/executions/{executionId}/log", method = RequestMethod.GET) public void getLogFile(HttpServletResponse response, @PathVariable long executionId) throws NoSuchJobExecutionException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("Get log file for job with executionId: {}", executionId); } String loggingPath = createLoggingPath(); JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("JobExecution with id " + executionId + " not found."); } File downloadFile = new File(loggingPath + jobLogFileNameCreator.getName(jobExecution)); InputStream is = new FileInputStream(downloadFile); FileCopyUtils.copy(is, response.getOutputStream()); response.flushBuffer(); }
/** * Inspect the StepExecution with the provided Step Execution Id * * @param jobExecutionId Id of the {@link org.springframework.batch.core.JobExecution}, must not be null * @param stepExecutionId Id of the {@link org.springframework.batch.core.StepExecution}, must not be null * @return {@link StepExecutionInfoResource} that has the details on the given {@link org.springframework.batch.core.StepExecution}. * @throws NoSuchJobExecutionException Thrown if the respective {@link org.springframework.batch.core.JobExecution} does not exist * @throws org.springframework.batch.admin.service.NoSuchStepExecutionException Thrown if the respective {@link org.springframework.batch.core.StepExecution} does not exist */ @RequestMapping(value = "/{stepExecutionId}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public StepExecutionInfoResource details(@PathVariable long jobExecutionId, @PathVariable long stepExecutionId) throws NoSuchStepExecutionException, NoSuchJobExecutionException { try { StepExecution stepExecution = jobService.getStepExecution(jobExecutionId, stepExecutionId); return this.stepExecutionInfoResourceAssembler.toResource(new StepExecutionInfo(stepExecution, this.timeZone)); } catch (org.springframework.batch.admin.service.NoSuchStepExecutionException e) { throw new NoSuchStepExecutionException(String.format("Could not find step execution with id %s", String.valueOf(stepExecutionId))); } catch (org.springframework.batch.core.launch.NoSuchJobExecutionException e) { throw new NoSuchJobExecutionException(String.format("Could not find jobExecution with id %s", String.valueOf(jobExecutionId))); } }
/** * List all step executions. * * @param jobExecutionId Id of the {@link org.springframework.batch.core.JobExecution}, must not be null * @return Collection of {@link StepExecutionInfoResource} for the given jobExecutionId * @throws org.springframework.batch.core.launch.NoSuchJobExecutionException Thrown if the respective {@link org.springframework.batch.core.JobExecution} does not exist */ @RequestMapping(value = { "" }, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public Collection<StepExecutionInfoResource> list(@PathVariable("jobExecutionId") long jobExecutionId) throws NoSuchJobExecutionException { final Collection<StepExecution> stepExecutions; try { stepExecutions = jobService.getStepExecutions(jobExecutionId); } catch (NoSuchJobExecutionException e) { throw new NoSuchJobExecutionException(String.format("Could not find jobExecution with id %s", String.valueOf(jobExecutionId))); } final Collection<StepExecutionInfoResource> result = new ArrayList<StepExecutionInfoResource>(); for (StepExecution stepExecution : stepExecutions) { // Band-Aid to prevent Hateos crash - see XD-1206 if (stepExecution.getId() != null) { result.add(stepExecutionInfoResourceAssembler.toResource(new StepExecutionInfo(stepExecution, timeZone))); } } return result; }