You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by md...@apache.org on 2015/02/18 14:57:47 UTC

syncope git commit: [SYNCOPE-644] Fix Role Sync with RoleSchema as accountId

Repository: syncope
Updated Branches:
  refs/heads/1_2_X 742b4eca7 -> 2f7fc8993


[SYNCOPE-644] Fix Role Sync with RoleSchema as accountId


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/2f7fc899
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/2f7fc899
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/2f7fc899

Branch: refs/heads/1_2_X
Commit: 2f7fc8993042ee816eb5d24fbb29d7ab7de7091a
Parents: 742b4ec
Author: Marco Di Sabatino Di Diodoro <md...@apache.org>
Authored: Wed Feb 18 14:09:48 2015 +0100
Committer: Marco Di Sabatino Di Diodoro <md...@apache.org>
Committed: Wed Feb 18 14:09:48 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/syncope/core/sync/SyncUtilities.java | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/2f7fc899/core/src/main/java/org/apache/syncope/core/sync/SyncUtilities.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/sync/SyncUtilities.java b/core/src/main/java/org/apache/syncope/core/sync/SyncUtilities.java
index 0c3f146..94dea9a 100644
--- a/core/src/main/java/org/apache/syncope/core/sync/SyncUtilities.java
+++ b/core/src/main/java/org/apache/syncope/core/sync/SyncUtilities.java
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.types.MappingPurpose;
 import org.apache.syncope.common.types.SubjectType;
 import org.apache.syncope.common.types.SyncPolicySpec;
@@ -39,6 +40,7 @@ import org.apache.syncope.core.persistence.dao.EntitlementDAO;
 import org.apache.syncope.core.persistence.dao.PolicyDAO;
 import org.apache.syncope.core.persistence.dao.RoleDAO;
 import org.apache.syncope.core.persistence.dao.SchemaDAO;
+import org.apache.syncope.core.persistence.dao.SubjectDAO;
 import org.apache.syncope.core.persistence.dao.SubjectSearchDAO;
 import org.apache.syncope.core.persistence.dao.UserDAO;
 import org.apache.syncope.core.persistence.dao.search.AttributeCond;
@@ -168,7 +170,7 @@ public class SyncUtilities {
                 }
 
                 List<AbstractSubject> subjects =
-                        userDAO.findByAttrValue(accountIdItem.getIntAttrName(), value, attrUtil);
+                        getSubjectDAO(accountIdItem).findByAttrValue(accountIdItem.getIntAttrName(), value, attrUtil);
                 for (AbstractSubject subject : subjects) {
                     result.add(subject.getId());
                 }
@@ -176,7 +178,8 @@ public class SyncUtilities {
 
             case UserDerivedSchema:
             case RoleDerivedSchema:
-                subjects = userDAO.findByDerAttrValue(accountIdItem.getIntAttrName(), uid, attrUtil);
+                subjects = getSubjectDAO(accountIdItem).
+                        findByDerAttrValue(accountIdItem.getIntAttrName(), uid, attrUtil);
                 for (AbstractSubject subject : subjects) {
                     result.add(subject.getId());
                 }
@@ -352,4 +355,8 @@ public class SyncUtilities {
 
         return enabled;
     }
+
+    private SubjectDAO getSubjectDAO(final AbstractMappingItem accountIdItem) {
+        return AttributableType.USER == accountIdItem.getIntMappingType().getAttributableType() ? userDAO : roleDAO;
+    }
 }