use of org.sonar.server.permission.index.FooIndexDefinition.FOO_INDEX in project sonarqube by SonarSource.
the class FooIndex method hasAccessToProject.
public boolean hasAccessToProject(String projectUuid) {
SearchHits hits = esClient.prepareSearch(FOO_INDEX).setTypes(FOO_TYPE).setQuery(QueryBuilders.boolQuery().must(QueryBuilders.termQuery(FooIndexDefinition.FIELD_PROJECT_UUID, projectUuid)).filter(authorizationTypeSupport.createQueryFilter())).get().getHits();
List<String> names = Arrays.stream(hits.hits()).map(h -> h.getSource().get(FooIndexDefinition.FIELD_NAME).toString()).collect(Collectors.toList());
return names.size() == 2 && names.contains("bar") && names.contains("baz");
}
Aggregations