You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2026/10/12 09:26:55 UTC

(syncope) branch master updated: [SYNCOPE-2000] Add AnyAbout filtering by Realm, uManager, and gManager (#1566)

This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git


The following commit(s) were added to refs/heads/master by this push:
     new 0a5988401e [SYNCOPE-2000] Add AnyAbout filtering by Realm, uManager, and gManager (#1566)
0a5988401e is described below

commit 0a5988401e5836a9218800d724e8d3768df11dc8
Author: alberto bogi <35...@users.noreply.github.com>
AuthorDate: Mon Oct 12 11:25:01 2026 +0200

    [SYNCOPE-2000] Add AnyAbout filtering by Realm, uManager, and gManager (#1566)
---
 .../common/dao/AbstractAnyMatchDAO.java            | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/core/persistence-common/src/main/java/org/apache/syncope/core/persistence/common/dao/AbstractAnyMatchDAO.java b/core/persistence-common/src/main/java/org/apache/syncope/core/persistence/common/dao/AbstractAnyMatchDAO.java
index 7b19f5e6c4..aaa235f371 100644
--- a/core/persistence-common/src/main/java/org/apache/syncope/core/persistence/common/dao/AbstractAnyMatchDAO.java
+++ b/core/persistence-common/src/main/java/org/apache/syncope/core/persistence/common/dao/AbstractAnyMatchDAO.java
@@ -23,6 +23,8 @@ import jakarta.validation.constraints.Max;
 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;
@@ -31,6 +33,7 @@ import java.util.Set;
 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;
@@ -59,6 +62,7 @@ import org.apache.syncope.core.persistence.api.entity.Groupable;
 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;
@@ -439,6 +443,32 @@ public abstract class AbstractAnyMatchDAO implements AnyMatchDAO {
 
                 // 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