throw new org.springframework.xd.dirt.job.JobExecutionAlreadyRunningException(
"Job Execution for this job is already running: " + jobExecution.getJobInstance());
}
final JobInstance lastInstance = jobExecution.getJobInstance();
final ExpandedJobParametersConverter expandedJobParametersConverter = new ExpandedJobParametersConverter();
final JobParameters jobParameters = jobExecution.getJobParameters();
final Job job;
try {
job = jobLocator.getJob(lastInstance.getJobName());
}
catch (NoSuchJobException e1) {
throw new org.springframework.xd.dirt.job.NoSuchBatchJobException("The job '" + lastInstance.getJobName()
+ "' does not exist.");
}
try {
job.getJobParametersValidator().validate(jobParameters);
}
catch (JobParametersInvalidException e) {
throw new org.springframework.xd.dirt.job.JobParametersInvalidException(
"The Job Parameters for Job Execution " + jobExecution.getId()
+ " are invalid.");
}
final BatchStatus status = jobExecution.getStatus();
if (status == BatchStatus.COMPLETED || status == BatchStatus.ABANDONED) {
throw new org.springframework.xd.dirt.job.JobInstanceAlreadyCompleteException(
"Job Execution " + jobExecution.getId() + " is already complete.");
}
if (!job.isRestartable()) {
throw new org.springframework.xd.dirt.job.JobRestartException(
"The job '" + lastInstance.getJobName() + "' is not restartable.");
}
final String jobParametersAsString = expandedJobParametersConverter
.getJobParametersAsString(jobParameters, true);
jobDeployer.launch(lastInstance.getJobName(), jobParametersAsString);
}