directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smckin...@apache.org
Subject directory-fortress-core git commit: FC-105 - [fortress-core] - cyclomatic complexity is 14
Date Fri, 22 May 2015 13:06:44 GMT
Repository: directory-fortress-core
Updated Branches:
  refs/heads/master 81d699c27 -> 33a145165


FC-105 - [fortress-core] - cyclomatic complexity is 14


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/33a14516
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/33a14516
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/33a14516

Branch: refs/heads/master
Commit: 33a14516510b0b1c5aaa4315dfbc31f7b38c4038
Parents: 81d699c
Author: Shawn McKinney <smckinney@apache.org>
Authored: Fri May 22 08:06:41 2015 -0500
Committer: Shawn McKinney <smckinney@apache.org>
Committed: Fri May 22 08:06:41 2015 -0500

----------------------------------------------------------------------
 .../fortress/core/ant/FortressAntTask.java      | 99 +++++++++++---------
 1 file changed, 53 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/33a14516/src/main/java/org/apache/directory/fortress/core/ant/FortressAntTask.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ant/FortressAntTask.java b/src/main/java/org/apache/directory/fortress/core/ant/FortressAntTask.java
index d7d44c1..4b3d12a 100755
--- a/src/main/java/org/apache/directory/fortress/core/ant/FortressAntTask.java
+++ b/src/main/java/org/apache/directory/fortress/core/ant/FortressAntTask.java
@@ -882,58 +882,13 @@ public class FortressAntTask extends Task implements InputHandler
         for ( Adduser adduser : addusers )
         {
             List<UserAnt> users = adduser.getUsers();
-
             for ( UserAnt user : users )
             {
                 LOG.info( "addUsers userid={} description={} orgUnit={}",
                     user.getUserId(), user.getDescription(), user.getOu() );
                 try
                 {
-                    try
-                    {
-                        adminMgr.addUser( user );
-                        if ( VUtil.isNotNullOrEmpty( user.getRoles() ) )
-                        {
-                            for ( UserRole uRole : user.getRoles() )
-                            {
-                                adminMgr.assignUser( uRole );
-                            }
-                        }
-                        if ( VUtil.isNotNullOrEmpty( user.getAdminRoles() ) )
-                        {
-                            for ( UserAdminRole uAdminRoleRole : user.getAdminRoles() )
-                            {
-                                dAdminMgr.assignUser( uAdminRoleRole );
-                            }
-                        }
-                    }
-                    catch ( SecurityException se )
-                    {
-                        // If User entity already there then call the udpate method.
-                        if ( se.getErrorId() == GlobalErrIds.USER_ID_DUPLICATE )
-                        {
-                            adminMgr.updateUser( user );
-                            if ( VUtil.isNotNullOrEmpty( user.getRoles() ) )
-                            {
-                                for ( UserRole uRole : user.getRoles() )
-                                {
-                                    adminMgr.assignUser( uRole );
-                                }
-                            }
-                            if ( VUtil.isNotNullOrEmpty( user.getAdminRoles() ) )
-                            {
-                                for ( UserAdminRole uAdminRoleRole : user.getAdminRoles()
)
-                                {
-                                    dAdminMgr.assignUser( uAdminRoleRole );
-                                }
-                            }
-                            LOG.info( "addUsers - Update entity - userId={}", user.getUserId()
);
-                        }
-                        else
-                        {
-                            throw se;
-                        }
-                    }
+                    addUser( user );
                 }
                 catch ( SecurityException se )
                 {
@@ -943,6 +898,58 @@ public class FortressAntTask extends Task implements InputHandler
         }
     }
 
+    /**
+     * Utility method called by addUsers()
+     *
+     * @param user
+     * @throws SecurityException
+     */
+    private void addUser(User user) throws SecurityException
+    {
+        try
+        {
+            adminMgr.addUser( user );
+            assignUser( user );
+        }
+        catch ( SecurityException se )
+        {
+            // If User entity already there then call the udpate method.
+            if ( se.getErrorId() == GlobalErrIds.USER_ID_DUPLICATE )
+            {
+                adminMgr.updateUser( user );
+                assignUser( user );
+                LOG.info( "addUsers - Update entity - userId={}", user.getUserId() );
+            }
+            else
+            {
+                throw se;
+            }
+        }
+    }
+
+    /**
+     * Utility method to assign roles to user.
+     *
+     * @param user
+     * @throws SecurityException
+     */
+    private void assignUser( User user ) throws SecurityException
+    {
+        if ( VUtil.isNotNullOrEmpty( user.getRoles() ) )
+        {
+            for ( UserRole uRole : user.getRoles() )
+            {
+                adminMgr.assignUser( uRole );
+            }
+        }
+        if ( VUtil.isNotNullOrEmpty( user.getAdminRoles() ) )
+        {
+            for ( UserAdminRole uAdminRoleRole : user.getAdminRoles() )
+            {
+                dAdminMgr.assignUser( uAdminRoleRole );
+            }
+        }
+    }
 
     /**
      * @throws BuildException


Mime
View raw message