directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smckin...@apache.org
Subject [1/2] directory-fortress-core git commit: FC-105 - [fortress-core] - use stringbuffer
Date Tue, 19 May 2015 18:34:39 GMT
Repository: directory-fortress-core
Updated Branches:
  refs/heads/master 99a6ab383 -> 8dc46aecd


FC-105 - [fortress-core] - use stringbuffer


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

Branch: refs/heads/master
Commit: 6aa9bd5a7cf32f1f34fbf1cb32d092dc73efe026
Parents: 9bebe57
Author: Shawn McKinney <smckinney@apache.org>
Authored: Tue May 19 13:28:40 2015 -0500
Committer: Shawn McKinney <smckinney@apache.org>
Committed: Tue May 19 13:28:40 2015 -0500

----------------------------------------------------------------------
 .../directory/fortress/core/rbac/PermDAO.java   | 63 +++++++++++++++-----
 1 file changed, 47 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/6aa9bd5a/src/main/java/org/apache/directory/fortress/core/rbac/PermDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/PermDAO.java b/src/main/java/org/apache/directory/fortress/core/rbac/PermDAO.java
index b2f23e3..6313f3a 100755
--- a/src/main/java/org/apache/directory/fortress/core/rbac/PermDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/rbac/PermDAO.java
@@ -1071,13 +1071,21 @@ final class PermDAO extends ApacheDsDataProvider
         {
             String permObjVal = encodeSafeText( permission.getObjName(), GlobalIds.PERM_LEN
);
             String permOpVal = encodeSafeText( permission.getOpName(), GlobalIds.PERM_LEN
);
-            String filter = GlobalIds.FILTER_PREFIX + PERM_OP_OBJECT_CLASS_NAME + ")("
-                + GlobalIds.POBJ_NAME + "=" + permObjVal + "*)("
-                + GlobalIds.POP_NAME + "=" + permOpVal + "*))";
-
+            StringBuffer filterbuf = new StringBuffer();
+            filterbuf.append( GlobalIds.FILTER_PREFIX );
+            filterbuf.append( PERM_OP_OBJECT_CLASS_NAME );
+            filterbuf.append( ")(" );
+            filterbuf.append( GlobalIds.POBJ_NAME );
+            filterbuf.append( "=" );
+            filterbuf.append( permObjVal );
+            filterbuf.append( "*)(" );
+            filterbuf.append( GlobalIds.POP_NAME );
+            filterbuf.append( "=" );
+            filterbuf.append( permOpVal );
+            filterbuf.append(  "*))" );
             ld = getAdminConnection();
             SearchCursor searchResults = search( ld, permRoot,
-                SearchScope.SUBTREE, filter, PERMISSION_OP_ATRS, false, GlobalIds.BATCH_SIZE
);
+                SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, GlobalIds.BATCH_SIZE
);
             long sequence = 0;
 
             while ( searchResults.next() )
@@ -1119,11 +1127,17 @@ final class PermDAO extends ApacheDsDataProvider
         try
         {
             String permObjVal = encodeSafeText( permObj.getObjName(), GlobalIds.PERM_LEN
);
-            String filter = GlobalIds.FILTER_PREFIX + PERM_OBJ_OBJECT_CLASS_NAME + ")("
-                + GlobalIds.POBJ_NAME + "=" + permObjVal + "*))";
+            StringBuffer filterbuf = new StringBuffer();
+            filterbuf.append( GlobalIds.FILTER_PREFIX );
+            filterbuf.append( PERM_OBJ_OBJECT_CLASS_NAME );
+            filterbuf.append( ")(" );
+            filterbuf.append( GlobalIds.POBJ_NAME );
+            filterbuf.append( "=" );
+            filterbuf.append( permObjVal );
+            filterbuf.append( "*))" );
             ld = getAdminConnection();
             SearchCursor searchResults = search( ld, permRoot,
-                SearchScope.SUBTREE, filter, PERMISION_OBJ_ATRS, false, GlobalIds.BATCH_SIZE
);
+                SearchScope.SUBTREE, filterbuf.toString(), PERMISION_OBJ_ATRS, false, GlobalIds.BATCH_SIZE
);
             long sequence = 0;
 
             while ( searchResults.next() )
@@ -1164,8 +1178,14 @@ final class PermDAO extends ApacheDsDataProvider
         try
         {
             String ouVal = encodeSafeText( ou.getName(), GlobalIds.OU_LEN );
-            String filter = GlobalIds.FILTER_PREFIX + PERM_OBJ_OBJECT_CLASS_NAME + ")("
-                + SchemaConstants.OU_AT + "=" + ouVal + "*))";
+            StringBuffer filterbuf = new StringBuffer();
+            filterbuf.append( GlobalIds.FILTER_PREFIX );
+            filterbuf.append( PERM_OBJ_OBJECT_CLASS_NAME );
+            filterbuf.append( ")(" );
+            filterbuf.append( SchemaConstants.OU_AT );
+            filterbuf.append( "=" );
+            filterbuf.append( ouVal );
+            filterbuf.append( "*))" );
             int maxLimit;
 
             if ( limitSize )
@@ -1179,7 +1199,7 @@ final class PermDAO extends ApacheDsDataProvider
 
             ld = getAdminConnection();
             SearchCursor searchResults = search( ld, permRoot,
-                SearchScope.SUBTREE, filter, PERMISION_OBJ_ATRS, false, GlobalIds.BATCH_SIZE,
maxLimit );
+                SearchScope.SUBTREE, filterbuf.toString(), PERMISION_OBJ_ATRS, false, GlobalIds.BATCH_SIZE,
maxLimit );
             long sequence = 0;
 
             while ( searchResults.next() )
@@ -1437,8 +1457,15 @@ final class PermDAO extends ApacheDsDataProvider
 
         try
         {
-            String filter = GlobalIds.FILTER_PREFIX + PERM_OP_OBJECT_CLASS_NAME + ")(|";
-            filter += "(" + USERS + "=" + session.getUserId() + ")";
+            StringBuffer filterbuf = new StringBuffer();
+            filterbuf.append( GlobalIds.FILTER_PREFIX );
+            filterbuf.append( PERM_OP_OBJECT_CLASS_NAME );
+            filterbuf.append( ")(|" );
+            filterbuf.append( "(" );
+            filterbuf.append( USERS );
+            filterbuf.append( "=" );
+            filterbuf.append( session.getUserId() );
+            filterbuf.append( ")" );
             Set<String> roles;
             if ( isAdmin )
             {
@@ -1452,14 +1479,18 @@ final class PermDAO extends ApacheDsDataProvider
             {
                 for ( String uRole : roles )
                 {
-                    filter += "(" + ROLES + "=" + uRole + ")";
+                    filterbuf.append( "(" );
+                    filterbuf.append( ROLES );
+                    filterbuf.append( "=" );
+                    filterbuf.append( uRole );
+                    filterbuf.append( ")" );
                 }
             }
 
-            filter += "))";
+            filterbuf.append( "))" );
             ld = getAdminConnection();
             SearchCursor searchResults = search( ld, permRoot,
-                SearchScope.SUBTREE, filter, PERMISSION_OP_ATRS, false, GlobalIds.BATCH_SIZE
);
+                SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, GlobalIds.BATCH_SIZE
);
             long sequence = 0;
 
             while ( searchResults.next() )


Mime
View raw message