@Override
public QueryResult<PermissionRule> getPermissionRules(long studyId, Study.Entity entry) throws CatalogDBException {
Query query = new Query(QueryParams.UID.key(), studyId);
QueryOptions options = new QueryOptions(QueryOptions.INCLUDE, QueryParams.PERMISSION_RULES.key());
QueryResult<Study> studyQueryResult = get(query, options);
if (studyQueryResult.getNumResults() == 0) {
throw new CatalogDBException("Unexpected error: Study " + studyId + " not found");
}
List<PermissionRule> permissionRules = studyQueryResult.first().getPermissionRules().get(entry);
if (permissionRules == null) {
permissionRules = Collections.emptyList();
}
permissionRules.removeIf(permissionRule ->
StringUtils.splitByWholeSeparatorPreserveAllTokens(permissionRule.getId(), INTERNAL_DELIMITER, 2).length == 2);
return new QueryResult<>(String.valueOf(studyId), studyQueryResult.getDbTime(), permissionRules.size(), permissionRules.size(),
"", "", permissionRules);
}