use of com.epam.ta.reportportal.core.events.activity.NotificationsConfigUpdatedEvent in project service-api by reportportal.
the class UpdateProjectHandlerImpl method updateProjectNotificationConfig.
@Override
public OperationCompletionRS updateProjectNotificationConfig(String projectName, ReportPortalUser user, ProjectNotificationConfigDTO updateProjectNotificationConfigRQ) {
Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(ErrorType.PROJECT_NOT_FOUND, projectName));
ProjectResource before = projectConverter.TO_PROJECT_RESOURCE.apply(project);
updateSenderCases(project, updateProjectNotificationConfigRQ.getSenderCases());
project.getProjectAttributes().stream().filter(it -> it.getAttribute().getName().equalsIgnoreCase(ProjectAttributeEnum.NOTIFICATIONS_ENABLED.getAttribute())).findAny().ifPresent(pa -> pa.setValue(String.valueOf(updateProjectNotificationConfigRQ.isEnabled())));
messageBus.publishActivity(new NotificationsConfigUpdatedEvent(before, updateProjectNotificationConfigRQ, user.getUserId(), user.getUsername()));
return new OperationCompletionRS("Notification configuration of project - '" + projectName + "' is successfully updated.");
}
Aggregations