class PDSCancelJobService {

    @UseCaseUserCancelsJob(@PDSStep(name="service call",description = "trigger change to execution service and marks job status as cancel requested",number=2))
    public void cancelJob(UUID jobUUID) {
        notNull(jobUUID, "job uuid may not be null!");

        PDSJob job = assertJobFound(jobUUID, repository);
        if (PDSJobStatusState.CANCEL_REQUESTED.equals(job.getState()) || PDSJobStatusState.CANCELED.equals(job.getState())) {
            LOG.info("Cancel ignored because in state:{}", job.getState());
            return;
        }
        assertJobIsInState(job, PDSJobStatusState.RUNNING);

        executionService.cancel(jobUUID);

        job.setState(PDSJobStatusState.CANCEL_REQUESTED);

        repository.save(job);

    }

}