Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import jakarta.validation.constraints.Min;
import java.beans.PropertyDescriptor;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -31,6 +33,7 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ClassUtils;
import org.apache.syncope.common.lib.SyncopeConstants;
import org.apache.syncope.common.lib.types.AnyTypeKind;
import org.apache.syncope.common.lib.types.AttrSchemaType;
Expand Down Expand Up @@ -59,6 +62,7 @@
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
import org.apache.syncope.core.persistence.api.entity.Realm;
import org.apache.syncope.core.persistence.api.entity.Relatable;
import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
import org.apache.syncope.core.persistence.api.entity.group.Group;
Expand Down Expand Up @@ -439,6 +443,32 @@ protected boolean matches(final Any any, final AnyCond cond, final boolean not)

// Deal with any fields representing relationships to other entities
relationshipFieldMatches(pd, cond, schema);
if (!(anyAttrValue instanceof String)) {

try {
Method relMethod = null;
if (!SyncopeConstants.UUID_PATTERN.matcher(cond.getExpression()).matches()) {
Class<?> type = pd.getPropertyType();

if (Realm.class.isAssignableFrom(type)) {
relMethod = ClassUtils.getPublicMethod(pd.getPropertyType(), "getFullPath");
} else if (User.class.isAssignableFrom(type)) {
relMethod = ClassUtils.getPublicMethod(pd.getPropertyType(), "getUsername");
} else if (Group.class.isAssignableFrom(type)) {
relMethod = ClassUtils.getPublicMethod(pd.getPropertyType(), "getName");
}
} else {
relMethod = ClassUtils.getPublicMethod(pd.getPropertyType(), "getKey");
}

if (relMethod != null && String.class.isAssignableFrom(relMethod.getReturnType())) {
anyAttrValue = relMethod.invoke(anyAttrValue);
}
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
LOG.error("Could not find getter method for relationshipField of type [{}]",
pd.getPropertyType().getSimpleName(), e);
}
}

PlainAttrValue attrValue = new PlainAttrValue();
if (cond.getType() != AttrCond.Type.LIKE
Expand Down
Loading