Search in sources :

Example 1 with JobMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage in project sechub by mercedes-benz.

the class JobRestartRequestService method buildMessage.

private JobMessage buildMessage(UUID jobUUID) {
    JobMessage message = new JobMessage();
    message.setJobUUID(jobUUID);
    JobInformation probe = new JobInformation();
    probe.setJobUUID(jobUUID);
    Example<JobInformation> example = Example.of(probe);
    Optional<JobInformation> optJobInfo = repository.findOne(example);
    if (!optJobInfo.isPresent()) {
        LOG.warn("Did not found job information, so not able to resolve owner email address");
        return message;
    }
    JobInformation jobInfo = optJobInfo.get();
    if (jobInfo.owner == null) {
        LOG.warn("Did not found owner inside job information, so not able to resolve owner email address");
        return message;
    }
    Optional<User> optUser = userRepository.findById(jobInfo.owner);
    if (!optUser.isPresent()) {
        LOG.warn("Did not found owner {} inside user repo, so not able to resolve owner email address", jobInfo.owner);
        return message;
    }
    message.setOwner(jobInfo.owner);
    message.setOwnerEmailAddress(optUser.get().getEmailAdress());
    return message;
}
Also used : User(com.mercedesbenz.sechub.domain.administration.user.User) JobMessage(com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage)

Example 2 with JobMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage in project sechub by mercedes-benz.

the class JobRestartRequestService method restartJobHard.

@Validated
@UseCaseAdminRestartsJobHard(@Step(number = 2, name = "Restart job", description = "Will trigger event that job restart (hard) requested"))
public void restartJobHard(UUID jobUUID) {
    assertion.assertIsValidJobUUID(jobUUID);
    auditLogService.log("Requested restart (hard) of job {}", jobUUID);
    JobMessage message = buildMessage(jobUUID);
    /* trigger event */
    triggerJobHardRestartRequest(message);
}
Also used : JobMessage(com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage) Validated(org.springframework.validation.annotation.Validated) UseCaseAdminRestartsJobHard(com.mercedesbenz.sechub.sharedkernel.usecases.job.UseCaseAdminRestartsJobHard)

Example 3 with JobMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage in project sechub by mercedes-benz.

the class JobAdministrationMessageHandler method handleJobFailed.

@IsReceivingAsyncMessage(MessageID.JOB_FAILED)
private void handleJobFailed(DomainMessage request) {
    JobMessage message = request.get(MessageDataKeys.JOB_FAILED_DATA);
    deleteService.delete(message.getJobUUID());
}
Also used : JobMessage(com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage) IsReceivingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)

Example 4 with JobMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage in project sechub by mercedes-benz.

the class JobAdministrationMessageHandler method handleJobDone.

@IsReceivingAsyncMessage(MessageID.JOB_DONE)
private void handleJobDone(DomainMessage request) {
    JobMessage message = request.get(MessageDataKeys.JOB_DONE_DATA);
    deleteService.delete(message.getJobUUID());
}
Also used : JobMessage(com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage) IsReceivingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)

Example 5 with JobMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage in project sechub by mercedes-benz.

the class JobAdministrationMessageHandler method handleJobCanceled.

@IsReceivingAsyncMessage(MessageID.JOB_CANCELED)
private void handleJobCanceled(DomainMessage request) {
    JobMessage message = request.get(MessageDataKeys.JOB_CANCEL_DATA);
    // we do drop job info - we only hold running and waiting jobs!
    deleteService.delete(message.getJobUUID());
}
Also used : JobMessage(com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage) IsReceivingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)

Aggregations

JobMessage (com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage)20 IsReceivingAsyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)7 DomainMessage (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage)6 IsSendingAsyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)4 Validated (org.springframework.validation.annotation.Validated)3 User (com.mercedesbenz.sechub.domain.administration.user.User)2 BatchJobMessage (com.mercedesbenz.sechub.sharedkernel.messaging.BatchJobMessage)2 UUID (java.util.UUID)2 UseCaseAdminCancelsJob (com.mercedesbenz.sechub.sharedkernel.usecases.job.UseCaseAdminCancelsJob)1 UseCaseAdminRestartsJob (com.mercedesbenz.sechub.sharedkernel.usecases.job.UseCaseAdminRestartsJob)1 UseCaseAdminRestartsJobHard (com.mercedesbenz.sechub.sharedkernel.usecases.job.UseCaseAdminRestartsJobHard)1