syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [2/2] syncope git commit: [SYNCOPE-726] Aligning RoleDataBinder#update to UserDataBinder#update
Date Mon, 09 Nov 2015 08:31:11 GMT
[SYNCOPE-726] Aligning RoleDataBinder#update to UserDataBinder#update


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

Branch: refs/heads/1_1_X
Commit: b04d1e549506eb0b137572e4460b5fb08f8217d6
Parents: 080abc1
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Mon Nov 9 09:30:39 2015 +0100
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Mon Nov 9 09:30:39 2015 +0100

----------------------------------------------------------------------
 .../syncope/core/rest/data/RoleDataBinder.java    | 18 ++++++++++++------
 .../syncope/core/rest/data/UserDataBinder.java    |  9 ++++-----
 2 files changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/b04d1e54/core/src/main/java/org/apache/syncope/core/rest/data/RoleDataBinder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/rest/data/RoleDataBinder.java b/core/src/main/java/org/apache/syncope/core/rest/data/RoleDataBinder.java
index de21d4d..8c03c58 100644
--- a/core/src/main/java/org/apache/syncope/core/rest/data/RoleDataBinder.java
+++ b/core/src/main/java/org/apache/syncope/core/rest/data/RoleDataBinder.java
@@ -25,11 +25,13 @@ import java.util.Set;
 import org.apache.syncope.common.mod.RoleMod;
 import org.apache.syncope.common.to.RoleTO;
 import org.apache.syncope.common.types.AttributableType;
+import org.apache.syncope.common.types.IntMappingType;
 import org.apache.syncope.common.types.ResourceOperation;
 import org.apache.syncope.common.types.SyncopeClientExceptionType;
 import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
 import org.apache.syncope.common.validation.SyncopeClientException;
 import org.apache.syncope.core.connid.ConnObjectUtil;
+import org.apache.syncope.core.persistence.beans.AbstractMappingItem;
 import org.apache.syncope.core.persistence.beans.AccountPolicy;
 import org.apache.syncope.core.persistence.beans.Entitlement;
 import org.apache.syncope.core.persistence.beans.ExternalResource;
@@ -194,8 +196,6 @@ public class RoleDataBinder extends AbstractAttributableDataBinder {
 
         SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
 
-        Set<String> currentResources = role.getResourceNames();
-
         // name
         SyncopeClientException invalidRoles = new SyncopeClientException(SyncopeClientExceptionType.InvalidRoles);
         if (roleMod.getName() != null) {
@@ -203,9 +203,15 @@ public class RoleDataBinder extends AbstractAttributableDataBinder {
                     role.getParent() == null ? null : role.getParent().getId());
             if (otherRole == null || role.equals(otherRole)) {
                 if (!roleMod.getName().equals(role.getName())) {
-                    propByRes.addAll(ResourceOperation.UPDATE, currentResources);
-                    for (String resource : currentResources) {
-                        propByRes.addOldAccountId(resource, role.getName());
+                    propByRes.addAll(ResourceOperation.UPDATE, role.getResourceNames());
+
+                    for (ExternalResource resource : role.getResources()) {
+                        if (resource.getRmapping() != null) {
+                            AbstractMappingItem accountIdItem = resource.getRmapping().getAccountIdItem();
+                            if (accountIdItem != null && accountIdItem.getIntMappingType()
== IntMappingType.RoleName) {
+                                propByRes.addOldAccountId(resource.getName(), role.getName());
+                            }
+                        }
                     }
 
                     role.setName(roleMod.getName());
@@ -313,7 +319,7 @@ public class RoleDataBinder extends AbstractAttributableDataBinder {
 
         // -------------------------
         // Retrieve all [derived/virtual] attributes (inherited and not)
-        // -------------------------        
+        // -------------------------
         final List<RAttr> allAttributes = role.findLastInheritedAncestorAttributes();
 
         final List<RDerAttr> allDerAttributes = role.findLastInheritedAncestorDerivedAttributes();

http://git-wip-us.apache.org/repos/asf/syncope/blob/b04d1e54/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java b/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
index 94eb68a..27c4f9e 100644
--- a/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
+++ b/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
@@ -255,15 +255,14 @@ public class UserDataBinder extends AbstractAttributableDataBinder {
 
         // username
         if (userMod.getUsername() != null && !userMod.getUsername().equals(user.getUsername()))
{
-            String oldUsername = user.getUsername();
-
             user.setUsername(userMod.getUsername());
             propByRes.addAll(ResourceOperation.UPDATE, currentResources);
 
             for (ExternalResource resource : user.getResources()) {
-                for (AbstractMappingItem mapItem : resource.getUmapping().getItems()) {
-                    if (mapItem.isAccountid() && mapItem.getIntMappingType() == IntMappingType.Username)
{
-                        propByRes.addOldAccountId(resource.getName(), oldUsername);
+                if (resource.getRmapping() != null) {
+                    AbstractMappingItem accountIdItem = resource.getRmapping().getAccountIdItem();
+                    if (accountIdItem != null && accountIdItem.getIntMappingType()
== IntMappingType.RoleName) {
+                        propByRes.addOldAccountId(resource.getName(), user.getUsername());
                     }
                 }
             }


Mime
View raw message