use of com.mercedesbenz.sechub.sharedkernel.usecases.admin.project.UseCaseAdminDeleteProject 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.usecases.admin.project.UseCaseAdminDeleteProject in project sechub by mercedes-benz.
the class InformAdminsThatProjectHasBeenDeletedNotificationService method notify.
@UseCaseAdminDeleteProject(@Step(number = 3, name = "Inform sechub admins that project has been deleted"))
public void notify(ProjectMessage projectMessage, String baseUrl) {
requireNonNull(projectMessage);
SimpleMailMessage message = factory.createMessage("SecHub Project " + projectMessage.getProjectId() + " has been deleted");
message.setTo(notificationConfiguration.getEmailAdministrators());
message.setText(createEmailContent(projectMessage, baseUrl));
emailService.send(message);
}
use of com.mercedesbenz.sechub.sharedkernel.usecases.admin.project.UseCaseAdminDeleteProject in project sechub by mercedes-benz.
the class InformUsersThatProjectHasBeenDeletedNotificationService method notify.
@UseCaseAdminDeleteProject(@Step(number = 5, name = "Inform users that the project has been deleted"))
public void notify(ProjectMessage projectMessage, String baseUrl) {
requireNonNull(projectMessage);
Set<String> mailAdresses = projectMessage.getUserEmailAdresses();
if (mailAdresses == null || mailAdresses.isEmpty()) {
LOG.info("No users found for project {} so ignore sending info mail about delete", projectMessage.getProjectId());
return;
}
SimpleMailMessage message = factory.createMessage("A SecHub project where you have been a user was deleted: " + projectMessage.getProjectId());
StringBuilder emailContent = new StringBuilder();
emailContent.append("Project '" + projectMessage.getProjectId() + "' in environment " + baseUrl + "\n");
emailContent.append("has been deleted.\n\n");
emailContent.append("This means that all report data has been deleted, and thus sechub scans for this project are no longer accessible.\n");
String[] userAdresses = projectMessage.getUserEmailAdresses().toArray(new String[mailAdresses.size()]);
// we do send per BCC so users do not get other email addresses. Maybe necessary
message.setBcc(userAdresses);
// because of data protection
message.setText(emailContent.toString());
emailService.send(message);
}
use of com.mercedesbenz.sechub.sharedkernel.usecases.admin.project.UseCaseAdminDeleteProject in project sechub by mercedes-benz.
the class InformOwnerThatProjectHasBeenDeletedNotificationService method notify.
@UseCaseAdminDeleteProject(@Step(number = 4, name = "Inform project owner that the project has been deleted"))
public void notify(ProjectMessage projectMessage, String baseUrl) {
requireNonNull(projectMessage);
String projectOwnerEmailAddress = projectMessage.getProjectOwnerEmailAddress();
if (projectOwnerEmailAddress == null) {
LOG.warn("No project owner email message set - can not inform owner about delete of project {}", projectMessage.getProjectId());
return;
}
SimpleMailMessage message = factory.createMessage("A SecHub project you were the owner was deleted: " + projectMessage.getProjectId());
StringBuilder emailContent = new StringBuilder();
emailContent.append("Your project '");
emailContent.append(projectMessage.getProjectId());
emailContent.append("' in environment ");
emailContent.append(baseUrl);
emailContent.append("\n");
emailContent.append("has been deleted.\n\n");
emailContent.append("This means that all report data has been deleted, and thus sechub scans for this project are no longer accessible.\n");
message.setTo(projectOwnerEmailAddress);
message.setText(emailContent.toString());
emailService.send(message);
}
Aggregations