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);
}
}
Aggregations