Search in sources :

Example 1 with UseCaseUserApprovesJob

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);
}
Also used : NotAcceptableException(com.mercedesbenz.sechub.sharedkernel.error.NotAcceptableException) ScheduleSecHubJob(com.mercedesbenz.sechub.domain.schedule.job.ScheduleSecHubJob) UseCaseUserApprovesJob(com.mercedesbenz.sechub.sharedkernel.usecases.user.execute.UseCaseUserApprovesJob)

Aggregations

ScheduleSecHubJob (com.mercedesbenz.sechub.domain.schedule.job.ScheduleSecHubJob)1 NotAcceptableException (com.mercedesbenz.sechub.sharedkernel.error.NotAcceptableException)1 UseCaseUserApprovesJob (com.mercedesbenz.sechub.sharedkernel.usecases.user.execute.UseCaseUserApprovesJob)1