Skip to content

Commit b2ff0b1

Browse files
fxprunayrecmangeat
authored andcommitted
CSW / Fix query when user is authenticated and not admin
* Fix java.util.MissingFormatArgumentException: Format specifier '%d' * Fix operation filter `-1` was excluding public record ie. not 1 * Fix combination OR/AND with isTemplate criteria
1 parent ebbc3e6 commit b2ff0b1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/src/main/java/org/fao/geonet/kernel/search/EsFilterBuilder.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,21 @@ private String buildPermissionsFilter(ServiceContext context) throws Exception {
3737
} else {
3838
// op0 (ie. view operation) contains one of the ids of your groups
3939
Set<Integer> groups = accessManager.getUserGroups(userSession, context.getIpAddress(), false);
40-
final String ids = groups.stream().map(Object::toString)
40+
final String ids = groups.stream()
41+
.map(Object::toString)
42+
.map(e -> e.replace("-", "\\\\-"))
4143
.collect(Collectors.joining(" OR "));
4244
String operationFilter = String.format("op%d:(%s)", ReservedOperation.view.getId(), ids);
4345

4446

4547
String ownerFilter = "";
4648
if (userSession.getUserIdAsInt() > 0) {
4749
// OR you are owner
48-
ownerFilter = String.format("owner:%d");
50+
ownerFilter = String.format("owner:%d", userSession.getUserIdAsInt());
4951
// OR member of groupOwner
5052
// TODOES
5153
}
52-
return String.format("%s %s", operationFilter, ownerFilter).trim();
54+
return String.format("(%s %s)", operationFilter, ownerFilter).trim();
5355
}
5456
}
5557
/**

0 commit comments

Comments
 (0)