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] - concatenates strings using + in a loop
Date Mon, 18 May 2015 19:36:18 GMT
Repository: directory-fortress-core
Updated Branches:
  refs/heads/master f5aa1a81e -> 63c93a809


FC-105 - [fortress-core] - concatenates strings using + in a loop


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

Branch: refs/heads/master
Commit: 63c93a8095d793d6e0b89086cb1615ce85c35040
Parents: f5aa1a8
Author: Shawn McKinney <smckinney@apache.org>
Authored: Mon May 18 14:36:04 2015 -0500
Committer: Shawn McKinney <smckinney@apache.org>
Committed: Mon May 18 14:36:04 2015 -0500

----------------------------------------------------------------------
 .../directory/fortress/core/rbac/SdDAO.java     | 56 +++++++++++++-------
 1 file changed, 38 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/63c93a80/src/main/java/org/apache/directory/fortress/core/rbac/SdDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/SdDAO.java b/src/main/java/org/apache/directory/fortress/core/rbac/SdDAO.java
index 85eab65..21fe30d 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/SdDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/SdDAO.java
@@ -314,13 +314,12 @@ final class SdDAO extends ApacheDsDataProvider
         {
             ld = getAdminConnection();
             Entry findEntry = read( ld, dn, SD_SET_ATRS );
-            entity = unloadLdapEntry( findEntry, 0 );
-
-            if ( entity == null )
+            if ( findEntry == null )
             {
                 String warning = "getSD no entry found dn [" + dn + "]";
                 throw new FinderException( GlobalErrIds.SSD_NOT_FOUND, warning );
             }
+            entity = unloadLdapEntry( findEntry, 0 );
         }
         catch ( LdapNoSuchObjectException e )
         {
@@ -437,42 +436,55 @@ final class SdDAO extends ApacheDsDataProvider
         LdapConnection ld = null;
         String ssdRoot = getSdRoot( role.getContextId() );
         String objectClass = SSD_OBJECT_CLASS_NM;
-
         if ( type == SDSet.SDType.DYNAMIC )
         {
             objectClass = DSD_OBJECT_CLASS_NM;
         }
-
         try
         {
             String roleVal = encodeSafeText( role.getName(), GlobalIds.ROLE_LEN );
-            //String filter = GlobalIds.FILTER_PREFIX + SSD_OBJECT_CLASS_NM + ")(" + ROLES
+ "=" + roleVal + "))";
-            String filter = GlobalIds.FILTER_PREFIX + objectClass + ")(";
+            StringBuffer filterbuf = new StringBuffer();
+            filterbuf.append( GlobalIds.FILTER_PREFIX );
+            filterbuf.append( objectClass );
+            filterbuf.append( ")(" );
+
             // Include any parents target role may have:
             Set<String> roles = RoleUtil.getAscendants( role.getName(), role.getContextId()
);
 
             if ( VUtil.isNotNullOrEmpty( roles ) )
             {
-                filter += "|(" + ROLES + "=" + roleVal + ")";
+                filterbuf.append( "|(" );
+                filterbuf.append( ROLES );
+                filterbuf.append( "=" );
+                filterbuf.append( roleVal );
+                filterbuf.append( ")" );
 
                 for ( String uRole : roles )
                 {
-                    filter += "(" + ROLES + "=" + uRole + ")";
+                    filterbuf.append( "(" );
+                    filterbuf.append( ROLES );
+                    filterbuf.append( "=" );
+                    filterbuf.append( uRole );
+                    filterbuf.append( ")" );
                 }
-                filter += ")";
+                filterbuf.append( ")" );
+
             }
             else
             {
-                filter += ROLES + "=" + roleVal + ")";
+                filterbuf.append( ROLES );
+                filterbuf.append( "=" );
+                filterbuf.append( roleVal );
+                filterbuf.append( ")" );
+
             }
 
-            filter += ")";
+            filterbuf.append( ")" );
             ld = getAdminConnection();
             SearchCursor searchResults = search( ld, ssdRoot,
-                SearchScope.SUBTREE, filter, SD_SET_ATRS, false, GlobalIds.BATCH_SIZE );
+                SearchScope.SUBTREE, filterbuf.toString(), SD_SET_ATRS, false, GlobalIds.BATCH_SIZE
);
 
             long sequence = 0;
-
             while ( searchResults.next() )
             {
                 sdList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
@@ -543,15 +555,23 @@ final class SdDAO extends ApacheDsDataProvider
         {
             if ( VUtil.isNotNullOrEmpty( roles ) )
             {
-                String filter = GlobalIds.FILTER_PREFIX + objectClass + ")(|";
+                StringBuffer filterbuf = new StringBuffer();
+                filterbuf.append( GlobalIds.FILTER_PREFIX );
+                filterbuf.append( objectClass );
+                filterbuf.append( ")(|" );
+
                 for ( String rle : roles )
                 {
-                    filter += "(" + ROLES + "=" + rle + ")";
+                    filterbuf.append( "(" );
+                    filterbuf.append( ROLES );
+                    filterbuf.append( "=" );
+                    filterbuf.append( rle );
+                    filterbuf.append( ")" );
                 }
-                filter += "))";
+                filterbuf.append( "))" );
                 ld = getAdminConnection();
                 SearchCursor searchResults = search( ld, ssdRoot,
-                    SearchScope.SUBTREE, filter, SD_SET_ATRS, false, GlobalIds.BATCH_SIZE
);
+                    SearchScope.SUBTREE, filterbuf.toString(), SD_SET_ATRS, false, GlobalIds.BATCH_SIZE
);
                 long sequence = 0;
 
                 while ( searchResults.next() )


Mime
View raw message