Search in sources :

Example 1 with NotificationsConfigUpdatedEvent

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.");
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ProjectResource(com.epam.ta.reportportal.ws.model.project.ProjectResource) NotificationsConfigUpdatedEvent(com.epam.ta.reportportal.core.events.activity.NotificationsConfigUpdatedEvent) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Aggregations

NotificationsConfigUpdatedEvent (com.epam.ta.reportportal.core.events.activity.NotificationsConfigUpdatedEvent)1 Project (com.epam.ta.reportportal.entity.project.Project)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)1 ProjectResource (com.epam.ta.reportportal.ws.model.project.ProjectResource)1