Skip to content

Commit

Permalink
[BUG] 🐛 Fix search OR and AND reversed
Browse files Browse the repository at this point in the history
Signed-off-by: Cécile Chemin <[email protected]>
  • Loading branch information
CChemin authored and clement-dufaure committed Aug 28, 2024
1 parent 87ab8b6 commit e05fd79
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,15 @@ private <M extends SugoiObject> Filter getFilterFromObject(
private <M extends SugoiObject> Filter getFilterFromObject(
M object, LdapMapper<M> mapper, String searchType, boolean encodeCommonNameWildcard) {
Assert.isTrue(
searchType.equals("AND") || searchType.equals("OR"), "Search type should be AND or OR.");
searchType.equalsIgnoreCase("AND") || searchType.equalsIgnoreCase("OR"),
"Search type should be AND or OR.");
List<Attribute> attributes = mapper.createAttributesForFilter(object);
List<Filter> attributeListFilter = getAttributesFilters(attributes, encodeCommonNameWildcard);
List<Filter> objectClassListFilter = getObjectClassFilters(attributes);
if (!objectClassListFilter.isEmpty() && attributeListFilter.isEmpty()) {
return LdapFilter.and(objectClassListFilter);
} else if (objectClassListFilter.isEmpty() && !attributeListFilter.isEmpty()) {
return searchType.equals("AND")
return searchType.equalsIgnoreCase("OR")
? LdapFilter.or(attributeListFilter)
: LdapFilter.and(attributeListFilter);
} else {
Expand Down

0 comments on commit e05fd79

Please sign in to comment.