use of com.mercedesbenz.sechub.sharedkernel.usecases.user.execute.UseCaseUserApprovesJob in project sechub by mercedes-benz.
the class SchedulerApproveJobService method approveJob.
@UseCaseUserApprovesJob(@Step(number = 2, name = "Try to find job annd update execution state", description = "When job is found and user has access job will be marked as ready for execution"))
public void approveJob(String projectId, UUID jobUUID) {
assertion.assertIsValidProjectId(projectId);
assertion.assertIsValidJobUUID(jobUUID);
assertService.assertUserHasAccessToProject(projectId);
assertService.assertProjectAllowsWriteAccess(projectId);
ScheduleSecHubJob secHubJob = assertService.assertJob(projectId, jobUUID);
ExecutionState state = secHubJob.getExecutionState();
if (!ExecutionState.INITIALIZING.equals(state)) {
throw new NotAcceptableException("Not in correct state");
}
secHubJob.setExecutionState(ExecutionState.READY_TO_START);
jobRepository.save(secHubJob);
LOG.info("job {} now approved", jobUUID);
}
Aggregations