final JobExecution jobExecution;
JobExecution lastExecution = jobRepository.getLastJobExecution(job.getName(), jobParameters);
if (lastExecution != null) {
if (!job.isRestartable()) {
throw new JobRestartException("JobInstance already exists and is not restartable");
}
/*
* validate here if it has stepExecutions that are UNKNOWN
* retrieve the previous execution and check
*/
for (StepExecution execution : lastExecution.getStepExecutions()) {
if (execution.getStatus() == BatchStatus.UNKNOWN) {
//throw
throw new JobRestartException("Step [" + execution.getStepName() + "] is of status UNKNOWN");
}//end if
}//end for
}
// Check the validity of the parameters before doing creating anything