Search in sources :

Example 1 with GroupsNotFoundException

use of io.gravitee.management.service.exceptions.GroupsNotFoundException in project gravitee-management-rest-api by gravitee-io.

the class GroupServiceImpl method findByIds.

@Override
public Set<GroupEntity> findByIds(Set<String> groupIds) {
    try {
        logger.debug("findByIds {}", groupIds);
        Set<Group> groups = groupRepository.findByIds(groupIds);
        if (groups == null || groups.size() != groupIds.size()) {
            List<String> groupsFound = groups == null ? Collections.emptyList() : groups.stream().map(Group::getId).collect(Collectors.toList());
            Set<String> groupIdsNotFound = new HashSet<>(groupIds);
            groupIdsNotFound.removeAll(groupsFound);
            throw new GroupsNotFoundException(groupIdsNotFound);
        }
        logger.debug("findByIds {} - DONE", groups);
        return groups.stream().map(this::map).collect(Collectors.toSet());
    } catch (TechnicalException ex) {
        logger.error("An error occurs while trying to find groups", ex);
        throw new TechnicalManagementException("An error occurs while trying to find groups", ex);
    }
}
Also used : TechnicalException(io.gravitee.repository.exceptions.TechnicalException) GroupsNotFoundException(io.gravitee.management.service.exceptions.GroupsNotFoundException) TechnicalManagementException(io.gravitee.management.service.exceptions.TechnicalManagementException)

Aggregations

GroupsNotFoundException (io.gravitee.management.service.exceptions.GroupsNotFoundException)1 TechnicalManagementException (io.gravitee.management.service.exceptions.TechnicalManagementException)1 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)1