Search in sources :

Example 21 with IsSendingAsyncMessage

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

the class SchedulerStatusService method buildStatus.

@IsSendingAsyncMessage(MessageID.SCHEDULER_STATUS_UPDATE)
public void buildStatus() {
    DomainMessage message = DomainMessageFactory.createEmptyRequest(MessageID.SCHEDULER_STATUS_UPDATE);
    SchedulerMessage sm = new SchedulerMessage();
    long amountOfJobsAll = jobRepository.count();
    long amountOfRunningJobs = jobRepository.countRunningJobs();
    long amountOfWaitingJobs = jobRepository.countWaitingJobs();
    boolean processingEnabled = configService.isJobProcessingEnabled();
    sm.setAmountOfJobsAll(amountOfJobsAll);
    sm.setAmountOfRunningJobs(amountOfRunningJobs);
    sm.setAmountOfWaitingJobs(amountOfWaitingJobs);
    sm.setJobProcessingEnabled(processingEnabled);
    message.set(MessageDataKeys.SCHEDULER_STATUS_DATA, sm);
    eventBus.sendAsynchron(message);
}
Also used : SchedulerMessage(com.mercedesbenz.sechub.sharedkernel.messaging.SchedulerMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) IsSendingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)

Example 22 with IsSendingAsyncMessage

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

the class AuthUserCreationService method createUser.

@UseCaseAdminAcceptsSignup(@Step(number = 4, next = { Step.NO_NEXT_STEP }, name = "Give user access", description = "Authorization layer is informed about new user and gives access to sechub. But without any project information"))
@IsSendingAsyncMessage(MessageID.REQUEST_USER_ROLE_RECALCULATION)
public void createUser(String userId, String hashedApiToken) {
    assertion.assertIsValidUserId(userId);
    Optional<AuthUser> found = userRepo.findByUserId(userId);
    if (found.isPresent()) {
        LOG.warn("Will skip user create action because user already found with name:{}", userId);
        return;
    }
    AuthUser user = new AuthUser();
    user.setUserId(userId);
    userRepo.save(user);
    LOG.info("Created auth user:{}", userId);
    eventBus.sendAsynchron(DomainMessageFactory.createRequestRoleCalculation(userId));
}
Also used : AuthUser(com.mercedesbenz.sechub.domain.authorization.AuthUser) UseCaseAdminAcceptsSignup(com.mercedesbenz.sechub.sharedkernel.usecases.admin.signup.UseCaseAdminAcceptsSignup) IsSendingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)

Example 23 with IsSendingAsyncMessage

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

the class SchedulerCancelJobService method sendJobCanceled.

@IsSendingAsyncMessage(MessageID.JOB_CANCELED)
private void sendJobCanceled(ScheduleSecHubJob secHubJob, String ownerEmailAddress) {
    DomainMessage request = DomainMessageFactory.createEmptyRequest(MessageID.JOB_CANCELED);
    JobMessage message = new JobMessage();
    message.setJobUUID(secHubJob.getUUID());
    message.setProjectId(secHubJob.getProjectId());
    message.setOwner(secHubJob.getOwner());
    message.setOwnerEmailAddress(ownerEmailAddress);
    request.set(MessageDataKeys.JOB_CANCEL_DATA, message);
    eventBus.sendAsynchron(request);
}
Also used : JobMessage(com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) IsSendingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)

Example 24 with IsSendingAsyncMessage

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

the class ScheduleJobLauncherService method sendJobStarted.

@IsSendingAsyncMessage(MessageID.JOB_STARTED)
private void sendJobStarted(String projectId, UUID jobUUID, String configuration, String owner) {
    DomainMessage request = new DomainMessage(MessageID.JOB_STARTED);
    JobMessage message = new JobMessage();
    message.setProjectId(projectId);
    message.setJobUUID(jobUUID);
    message.setConfiguration(configuration);
    message.setOwner(owner);
    message.setSince(LocalDateTime.now());
    request.set(MessageDataKeys.JOB_STARTED_DATA, message);
    eventBus.sendAsynchron(request);
}
Also used : JobMessage(com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) IsSendingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)

Example 25 with IsSendingAsyncMessage

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

the class ProjectCreationService method sendProjectCreatedEvent.

@IsSendingAsyncMessage(MessageID.PROJECT_CREATED)
private void sendProjectCreatedEvent(String projectId, Set<URI> whitelist) {
    DomainMessage request = new DomainMessage(MessageID.PROJECT_CREATED);
    ProjectMessage message = new ProjectMessage();
    message.setProjectId(projectId);
    message.setWhitelist(whitelist);
    request.set(MessageDataKeys.PROJECT_CREATION_DATA, message);
    eventBus.sendAsynchron(request);
}
Also used : ProjectMessage(com.mercedesbenz.sechub.sharedkernel.messaging.ProjectMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) IsSendingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)

Aggregations

IsSendingAsyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)32 DomainMessage (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage)31 UserMessage (com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage)10 JobMessage (com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage)4 ProjectMessage (com.mercedesbenz.sechub.sharedkernel.messaging.ProjectMessage)4 AuthUser (com.mercedesbenz.sechub.domain.authorization.AuthUser)1 AdministrationConfigMessage (com.mercedesbenz.sechub.sharedkernel.messaging.AdministrationConfigMessage)1 MappingMessage (com.mercedesbenz.sechub.sharedkernel.messaging.MappingMessage)1 SchedulerMessage (com.mercedesbenz.sechub.sharedkernel.messaging.SchedulerMessage)1 UseCaseAdminAcceptsSignup (com.mercedesbenz.sechub.sharedkernel.usecases.admin.signup.UseCaseAdminAcceptsSignup)1