You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by sm...@apache.org on 2015/05/22 16:09:23 UTC
directory-fortress-core git commit: FC-105 - [fortress-core] -
assignment of entity not allowed, reduce complexity of validate
Repository: directory-fortress-core
Updated Branches:
refs/heads/master 7eb023cbe -> f7e48b2d7
FC-105 - [fortress-core] - assignment of entity not allowed, reduce complexity of validate
Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/f7e48b2d
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/f7e48b2d
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/f7e48b2d
Branch: refs/heads/master
Commit: f7e48b2d7159c3dcf9b971fe4cf83e0097e45db7
Parents: 7eb023c
Author: Shawn McKinney <sm...@apache.org>
Authored: Fri May 22 09:09:20 2015 -0500
Committer: Shawn McKinney <sm...@apache.org>
Committed: Fri May 22 09:09:20 2015 -0500
----------------------------------------------------------------------
.../fortress/core/rbac/AdminRoleP.java | 43 +++++++++++---------
1 file changed, 24 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/f7e48b2d/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleP.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleP.java b/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleP.java
index 4bde7ee..d9bc1bd 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleP.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/AdminRoleP.java
@@ -21,6 +21,7 @@ package org.apache.directory.fortress.core.rbac;
import java.util.List;
+import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -151,8 +152,8 @@ public final class AdminRoleP
AdminRole update( AdminRole entity ) throws SecurityException
{
validate( entity );
- entity = rDao.update( entity );
- return read( entity );
+ AdminRole updateEntity = rDao.update( entity );
+ return read( updateEntity );
}
@@ -292,8 +293,7 @@ public final class AdminRoleP
throw new SecurityException( GlobalErrIds.ARLE_DELETE_FAILED, error, re );
}
}
-
-
+
/**
* Method will perform simple validations to ensure the integrity of the Admin Role entity targeted for insertion
* or updating in directory. For example the Admin Role temporal constraints will be validated. Data reasonability
@@ -323,7 +323,6 @@ public final class AdminRoleP
}
else if ( !RoleUtil.isParent( entity.getBeginRange(), entity.getEndRange(), entity.getContextId() )
&& !entity.getBeginRange().equalsIgnoreCase( entity.getEndRange() ) )
- //public static boolean isParent(String child, String parent)
{
String error = "validate invalid range detected for role name [" + entity.getName()
+ "] begin range [" + entity.getBeginRange() + "] end range [" + entity.getEndRange() + "]";
@@ -391,24 +390,30 @@ public final class AdminRoleP
if ( VUtil.isNotNullOrEmpty( entity.getOsU() ) )
{
- for ( String ou : entity.getOsU() )
- {
- OrgUnit inOe = new OrgUnit( ou );
- inOe.setType( OrgUnit.Type.USER );
- inOe.setContextId( entity.getContextId() );
- op.read( inOe );
- }
+ validateOrgs( entity.getOsU(), entity.getContextId() );
}
if ( VUtil.isNotNullOrEmpty( entity.getOsP() ) )
{
- for ( String ou : entity.getOsP() )
- {
- OrgUnit inOe = new OrgUnit( ou );
- inOe.setType( OrgUnit.Type.PERM );
- inOe.setContextId( entity.getContextId() );
- op.read( inOe );
- }
+ validateOrgs( entity.getOsP(), entity.getContextId() );
+ }
+ }
+
+ /**
+ * Called by validate()
+ *
+ * @param orgs
+ * @param contextId
+ * @throws SecurityException
+ */
+ private void validateOrgs( Set<String> orgs, String contextId ) throws SecurityException
+ {
+ for ( String ou : orgs )
+ {
+ OrgUnit inOe = new OrgUnit( ou );
+ inOe.setType( OrgUnit.Type.USER );
+ inOe.setContextId( contextId );
+ op.read( inOe );
}
}
}
\ No newline at end of file