use of com.mercedesbenz.sechub.sharedkernel.messaging.ProjectMessage in project sechub by mercedes-benz.
the class ProjectChangeAccessLevelService method sendProjectAccessLevelChangedEvent.
@IsSendingAsyncMessage(MessageID.PROJECT_ACCESS_LEVEL_CHANGED)
private void sendProjectAccessLevelChangedEvent(Project project, ProjectAccessLevel formerAccessLevel) {
DomainMessage request = new DomainMessage(MessageID.PROJECT_ACCESS_LEVEL_CHANGED);
ProjectMessage projectData = new ProjectMessage();
projectData.setProjectId(project.id);
projectData.setFormerAccessLevel(formerAccessLevel);
projectData.setNewAccessLevel(project.getAccessLevel());
request.set(MessageDataKeys.PROJECT_ACCESS_LEVEL_CHANGE_DATA, projectData);
eventBus.sendAsynchron(request);
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.ProjectMessage in project sechub by mercedes-benz.
the class ProjectChangeOwnerService method sendOwnerChangedForProjectEvent.
@IsSendingAsyncMessage(MessageID.PROJECT_OWNER_CHANGED)
private void sendOwnerChangedForProjectEvent(Project project, User previousOwner, User newOwner) {
DomainMessage request = new DomainMessage(MessageID.PROJECT_OWNER_CHANGED);
ProjectMessage projectData = new ProjectMessage();
projectData.setProjectId(project.id);
projectData.setPreviousProjectOwnerEmailAddress(previousOwner.getEmailAdress());
projectData.setProjectOwnerEmailAddress(newOwner.getEmailAdress());
project.users.forEach(user -> {
projectData.addUserEmailAddress(user.getEmailAdress());
});
request.set(MessageDataKeys.PROJECT_OWNER_CHANGE_DATA, projectData);
eventBus.sendAsynchron(request);
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.ProjectMessage in project sechub by mercedes-benz.
the class ProjectDeleteService method deleteProject.
@UseCaseAdminDeleteProject(@Step(number = 2, name = "Service deletes projects.", next = { 3, 4, 5, 6, 7 }, description = "The service will delete the project with dependencies and triggers asynchronous events"))
public void deleteProject(String projectId) {
auditLogService.log("triggers delete of project {}", logSanitizer.sanitize(projectId, 30));
assertion.assertIsValidProjectId(projectId);
Project project = projectRepository.findOrFailProject(projectId);
/* create message containing data before project is deleted */
ProjectMessage message = new ProjectMessage();
message.setProjectId(project.getId());
message.setProjectActionTriggeredBy(userContext.getUserId());
User owner = project.getOwner();
if (owner == null) {
LOG.warn("No owner found for project {} while deleting", project.getId());
} else {
message.setProjectOwnerEmailAddress(owner.getEmailAdress());
// handle ORM mapping. Avoid cache conflicts
owner.getOwnedProjects().remove(project);
}
for (User user : project.getUsers()) {
message.addUserEmailAddress(user.getEmailAdress());
// handle ORM mapping. Avoid cache conflicts
user.getProjects().remove(project);
}
transactionService.deleteWithAssociationsInOwnTransaction(projectId);
informProjectDeleted(message);
if (owner != null) {
sendRefreshUserAuth(owner);
}
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.ProjectMessage in project sechub by mercedes-benz.
the class ProjectChangeAccessLevelServiceTest method a_change_from_full_access_to_read_only_does_trigger_one_async_event_containing_old_and_new_access_level.
@Test
void a_change_from_full_access_to_read_only_does_trigger_one_async_event_containing_old_and_new_access_level() {
/* prepare */
Project project = new Project();
when(repository.findOrFailProject(PROJECT1_ID)).thenReturn(project);
/* execute */
serviceToTest.changeProjectAccessLevel(PROJECT1_ID, ProjectAccessLevel.READ_ONLY);
/* test */
ArgumentCaptor<DomainMessage> eventCaptor = ArgumentCaptor.forClass(DomainMessage.class);
verify(eventBus).sendAsynchron(eventCaptor.capture());
DomainMessage sentEvent = eventCaptor.getValue();
assertEquals(MessageID.PROJECT_ACCESS_LEVEL_CHANGED, sentEvent.getMessageId());
ProjectMessage eventProjectMessage = sentEvent.get(MessageDataKeys.PROJECT_ACCESS_LEVEL_CHANGE_DATA);
assertNotNull(eventProjectMessage);
assertEquals(ProjectAccessLevel.FULL, eventProjectMessage.getFormerAccessLevel());
assertEquals(ProjectAccessLevel.READ_ONLY, eventProjectMessage.getNewAccessLevel());
}
use of com.mercedesbenz.sechub.sharedkernel.messaging.ProjectMessage in project sechub by mercedes-benz.
the class ProjectUpdateWhitelistService method sendProjectCreatedEvent.
@IsSendingAsyncMessage(MessageID.PROJECT_WHITELIST_UPDATED)
private void sendProjectCreatedEvent(String projectId, Set<URI> whitelist) {
DomainMessage request = new DomainMessage(MessageID.PROJECT_WHITELIST_UPDATED);
ProjectMessage message = new ProjectMessage();
message.setProjectId(projectId);
message.setWhitelist(whitelist);
request.set(MessageDataKeys.PROJECT_WHITELIST_UPDATE_DATA, message);
eventBus.sendAsynchron(request);
}
Aggregations