Search in sources :

Example 1 with FilterUpdatedEvent

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

the class UpdateUserFilterHandlerImpl method updateUserFilter.

@Override
public OperationCompletionRS updateUserFilter(Long userFilterId, UpdateUserFilterRQ updateRQ, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user) {
    validateFilterRq(updateRQ);
    UserFilter userFilter = getShareableEntityHandler.getAdministrated(userFilterId, projectDetails);
    expect(userFilter.getProject().getId(), Predicate.isEqual(projectDetails.getProjectId())).verify(USER_FILTER_NOT_FOUND, userFilterId, projectDetails.getProjectId(), user.getUserId());
    if (!userFilter.getName().equals(updateRQ.getName())) {
        BusinessRule.expect(userFilterRepository.existsByNameAndOwnerAndProjectId(updateRQ.getName(), userFilter.getOwner(), projectDetails.getProjectId()), BooleanUtils::isFalse).verify(ErrorType.USER_FILTER_ALREADY_EXISTS, updateRQ.getName(), userFilter.getOwner(), projectDetails.getProjectName());
    }
    UserFilterActivityResource before = TO_ACTIVITY_RESOURCE.apply(userFilter);
    UserFilter updated = new UserFilterBuilder(userFilter).addFilterRq(updateRQ).get();
    if (before.isShared() != updated.isShared()) {
        aclHandler.updateAcl(updated, projectDetails.getProjectId(), updated.isShared());
    }
    messageBus.publishActivity(new FilterUpdatedEvent(before, TO_ACTIVITY_RESOURCE.apply(updated), user.getUserId(), user.getUsername()));
    return new OperationCompletionRS("User filter with ID = '" + updated.getId() + "' successfully updated.");
}
Also used : UserFilterActivityResource(com.epam.ta.reportportal.ws.model.activity.UserFilterActivityResource) UserFilter(com.epam.ta.reportportal.entity.filter.UserFilter) FilterUpdatedEvent(com.epam.ta.reportportal.core.events.activity.FilterUpdatedEvent) UserFilterBuilder(com.epam.ta.reportportal.ws.converter.builders.UserFilterBuilder) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Aggregations

FilterUpdatedEvent (com.epam.ta.reportportal.core.events.activity.FilterUpdatedEvent)1 UserFilter (com.epam.ta.reportportal.entity.filter.UserFilter)1 UserFilterBuilder (com.epam.ta.reportportal.ws.converter.builders.UserFilterBuilder)1 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)1 UserFilterActivityResource (com.epam.ta.reportportal.ws.model.activity.UserFilterActivityResource)1