use of com.mercedesbenz.sechub.sharedkernel.usecases.job.UseCaseAdminCancelsJob in project sechub by mercedes-benz.
the class SchedulerCancelJobService method cancelJob.
/**
* This service will cancel given JOB. There is NO check if current user has
* access - this must be done before.
*
* @param jobUUID
* @param ownerEmailAddress
*/
@UseCaseAdminCancelsJob(@Step(number = 3, name = "Try to find job and mark as being canceled", description = "When job is found and user has access the state will be updated and marked as canceled"))
public void cancelJob(UUID jobUUID, String ownerEmailAddress) {
assertion.assertIsValidJobUUID(jobUUID);
Optional<ScheduleSecHubJob> optJob = jobRepository.findById(jobUUID);
if (!optJob.isPresent()) {
LOG.warn("Job {} not present, so not able to cancel!", jobUUID);
return;
}
ScheduleSecHubJob secHubJob = optJob.get();
cancelBatchJobService.stopAllRunningBatchJobsForSechubJobUUID(jobUUID);
markJobAsCanceled(secHubJob);
LOG.info("job {} has been canceled", jobUUID);
sendJobCanceled(secHubJob, ownerEmailAddress);
}
use of com.mercedesbenz.sechub.sharedkernel.usecases.job.UseCaseAdminCancelsJob in project sechub by mercedes-benz.
the class JobCancelService method cancelJob.
@Validated
@UseCaseAdminCancelsJob(@Step(number = 2, name = "Cancel job", description = "Will trigger event that job cancel requested"))
public void cancelJob(UUID jobUUID) {
assertion.assertIsValidJobUUID(jobUUID);
auditLogService.log("Requested cancelation of job {}", jobUUID);
JobMessage message = buildMessage(jobUUID);
/* trigger event */
informCancelJobRequested(message);
}
use of com.mercedesbenz.sechub.sharedkernel.usecases.job.UseCaseAdminCancelsJob in project sechub by mercedes-benz.
the class InformUserThatJobHasBeenCanceledService method notify.
@UseCaseAdminCancelsJob(@Step(number = 4, name = "Inform user that her/his job has been canceled"))
public void notify(JobMessage jobMessage) {
String ownerEmailAddress = jobMessage.getOwnerEmailAddress();
if (ownerEmailAddress == null || ownerEmailAddress.isEmpty()) {
LOG.warn("Event did not contain user email address of canceled job {}, so cannot inform!", jobMessage.getJobUUID());
return;
}
SimpleMailMessage message = factory.createMessage("Your SecHub Job has been canceled");
message.setTo(ownerEmailAddress);
message.setText(createEmailContent(jobMessage));
emailService.send(message);
}
Aggregations