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

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


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

commit 6423e98598705ca4a66a630f59b92017bf65e6c7
Author: alberto bogi <[email protected]>
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 c0471cd262..f753ab8598 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;
@@ -60,6 +63,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;
@@ -458,6 +462,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

Reply via email to