use of com.epam.ta.reportportal.ws.converter.builders.UserPreferenceBuilder in project service-api by reportportal.
the class UpdatePreferenceHandlerImpl method addPreference.
@Override
public OperationCompletionRS addPreference(ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user, Long filterId) {
if (userPreferenceRepository.findByProjectIdAndUserIdAndFilterId(projectDetails.getProjectId(), user.getUserId(), filterId).isPresent()) {
throw new ReportPortalException(ErrorType.RESOURCE_ALREADY_EXISTS, "User Preference");
}
UserFilter filter = getShareableEntityHandler.getPermitted(filterId, projectDetails);
UserPreference userPreference = new UserPreferenceBuilder().withUser(user.getUserId()).withProject(projectDetails.getProjectId()).withFilter(filter).get();
userPreferenceRepository.save(userPreference);
return new OperationCompletionRS("Filter with id = " + filterId + " successfully added to launches tab.");
}
Aggregations