Search in sources :

Example 1 with ProjectUpdatedEvent

use of com.epam.ta.reportportal.core.events.activity.ProjectUpdatedEvent in project service-api by reportportal.

the class UpdateProjectHandlerImpl method updateProject.

@Override
public OperationCompletionRS updateProject(String projectName, UpdateProjectRQ updateProjectRQ, ReportPortalUser user) {
    Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(ErrorType.PROJECT_NOT_FOUND, projectName));
    ProjectAttributesActivityResource before = TO_ACTIVITY_RESOURCE.apply(project);
    updateProjectConfiguration(updateProjectRQ.getConfiguration(), project);
    ofNullable(updateProjectRQ.getUserRoles()).ifPresent(roles -> updateProjectUserRoles(roles, project, user));
    projectRepository.save(project);
    ProjectAttributesActivityResource after = TO_ACTIVITY_RESOURCE.apply(project);
    applicationEventPublisher.publishEvent(new ProjectEvent(project.getId(), UPDATE_EVENT));
    messageBus.publishActivity(new ProjectUpdatedEvent(before, after, user.getUserId(), user.getUsername()));
    messageBus.publishActivity(new ProjectAnalyzerConfigEvent(before, after, user.getUserId(), user.getUsername()));
    return new OperationCompletionRS("Project with name = '" + project.getName() + "' is successfully updated.");
}
Also used : ProjectAttributesActivityResource(com.epam.ta.reportportal.ws.model.activity.ProjectAttributesActivityResource) Project(com.epam.ta.reportportal.entity.project.Project) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ProjectAnalyzerConfigEvent(com.epam.ta.reportportal.core.events.activity.ProjectAnalyzerConfigEvent) ProjectUpdatedEvent(com.epam.ta.reportportal.core.events.activity.ProjectUpdatedEvent) ProjectEvent(com.epam.reportportal.extension.event.ProjectEvent) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Aggregations

ProjectEvent (com.epam.reportportal.extension.event.ProjectEvent)1 ProjectAnalyzerConfigEvent (com.epam.ta.reportportal.core.events.activity.ProjectAnalyzerConfigEvent)1 ProjectUpdatedEvent (com.epam.ta.reportportal.core.events.activity.ProjectUpdatedEvent)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 ProjectAttributesActivityResource (com.epam.ta.reportportal.ws.model.activity.ProjectAttributesActivityResource)1