jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1504509 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImpl.java
Date Thu, 18 Jul 2013 16:22:15 GMT
Author: angela
Date: Thu Jul 18 16:22:15 2013
New Revision: 1504509

URL: http://svn.apache.org/r1504509
Log:
OAK-920: revert unrelated changes

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImpl.java?rev=1504509&r1=1504508&r2=1504509&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImpl.java
Thu Jul 18 16:22:15 2013
@@ -31,9 +31,6 @@ import javax.annotation.Nullable;
 
 import com.google.common.base.Predicate;
 import com.google.common.base.Strings;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
 import com.google.common.collect.ImmutableSortedSet;
 import com.google.common.collect.Iterators;
 import com.google.common.primitives.Longs;
@@ -67,9 +64,6 @@ class CompiledPermissionImpl implements 
 
     private final Set<String> readPaths;
 
-    private final Cache<String, Collection<PermissionEntry>> userEntryCache;
-    private final Cache<String, Collection<PermissionEntry>> groupEntryCache;
-
     private PrivilegeBitsProvider bitsProvider;
 
     CompiledPermissionImpl(@Nonnull Set<Principal> principals,
@@ -94,13 +88,6 @@ class CompiledPermissionImpl implements 
                 }
             }
         }
-
-        userEntryCache = CacheBuilder.newBuilder().maximumSize(10000).recordStats()
-                .build();
-                //.build(new EntriesLoader(userTrees));
-        groupEntryCache = CacheBuilder.newBuilder().maximumSize(10000).recordStats()
-                .build();
-                //.build(new EntriesLoader(groupTrees));
     }
 
     //------------------------------------------------< CompiledPermissions >---
@@ -108,39 +95,19 @@ class CompiledPermissionImpl implements 
     public void refresh(@Nonnull ImmutableTree permissionsTree,
                  @Nonnull PrivilegeBitsProvider bitsProvider) {
         this.bitsProvider = bitsProvider;
-        boolean refreshU = false;
-        boolean refreshG = false;
         // test if a permission has been added for those principals that didn't have one
before
         for (Principal principal : principals) {
             Map<String, Tree> target = getTargetMap(principal);
             Tree principalRoot = getPrincipalRoot(permissionsTree, principal);
             String pName = principal.getName();
-            boolean isGroup = (principal instanceof Group);
             if (principalRoot.exists()) {
                 if (!target.containsKey(pName) || !principalRoot.equals(target.get(pName)))
{
                     target.put(pName, principalRoot);
-                    if (isGroup) {
-                        refreshG = true;
-                    } else {
-                        refreshU = true;
-                    }
                 }
             } else {
-                if (target.remove(pName) != null) {
-                    if (isGroup) {
-                        refreshG = true;
-                    } else {
-                        refreshU = true;
-                    }
-                }
+                target.remove(pName);
             }
         }
-        if (refreshG) {
-            groupEntryCache.invalidateAll();
-        }
-        if (refreshU) {
-            userEntryCache.invalidateAll();
-        }
     }
 
     @Override
@@ -297,10 +264,10 @@ class CompiledPermissionImpl implements 
     private Iterator<PermissionEntry> getEntryIterator(@Nonnull EntryPredicate predicate)
{
         Iterator<PermissionEntry> userEntries = (userTrees.isEmpty()) ?
                 Iterators.<PermissionEntry>emptyIterator() :
-                new EntryIterator(userEntryCache, userTrees, predicate);
+                new EntryIterator(userTrees, predicate);
         Iterator<PermissionEntry> groupEntries = (groupTrees.isEmpty()) ?
                 Iterators.<PermissionEntry>emptyIterator():
-                new EntryIterator(groupEntryCache, groupTrees, predicate);
+                new EntryIterator(groupTrees, predicate);
         return Iterators.concat(userEntries, groupEntries);
     }
 
@@ -360,7 +327,6 @@ class CompiledPermissionImpl implements 
     private class EntryIterator implements Iterator<PermissionEntry> {
 
         private final Collection<Tree> principalTrees;
-        private final Cache<String, Collection<PermissionEntry>> cache;
         private final EntryPredicate predicate;
 
         // the next oak path for which to retrieve permission entries
@@ -370,10 +336,8 @@ class CompiledPermissionImpl implements 
         // the next permission entry
         private PermissionEntry next;
 
-        private EntryIterator(@Nonnull Cache<String, Collection<PermissionEntry>>
cache,
-                              @Nonnull Map<String, Tree> principalTrees,
+        private EntryIterator(@Nonnull Map<String, Tree> principalTrees,
                               @Nonnull EntryPredicate predicate) {
-            this.cache = cache;
             this.principalTrees = principalTrees.values();
             this.predicate = predicate;
             this.path = Strings.nullToEmpty(predicate.path);
@@ -418,49 +382,19 @@ class CompiledPermissionImpl implements 
 
         @Nonnull
         private Iterator<PermissionEntry> getNextEntries() {
-            Collection entries = cache.getIfPresent(path);
-            if (entries == null) {
-                ImmutableSortedSet.Builder<PermissionEntry> es = new ImmutableSortedSet.Builder(new
EntryComparator());
-                for (Tree principalRoot : principalTrees) {
-                    String name = PermissionUtil.getEntryName(path);
-                    Tree parent = principalRoot;
-                    while (parent.hasChild(name)) {
-                        parent = parent.getChild(name);
-                        PermissionEntry pe = new PermissionEntry(parent, restrictionProvider);
-                        es.add(pe);
-//                        if (predicate.apply(pe)) {
-//                            es.add(pe);
-//                        }
-                    }
-                }
-                entries = es.build();
-                cache.put(path, entries);
-            }
-            return (entries == null) ? Iterators.<PermissionEntry>emptyIterator() :
Iterators.filter(entries.iterator(), predicate);
-        }
-    }
-
-    private final class EntriesLoader extends CacheLoader<String, Collection<PermissionEntry>>
{
-
-        private final Map<String, Tree> principalTrees;
-
-        private EntriesLoader(Map<String, Tree> principalTrees) {
-            this.principalTrees = principalTrees;
-        }
-
-        @Override
-        public Collection<PermissionEntry> load(String path) throws Exception {
-            ImmutableSortedSet.Builder<PermissionEntry> es = new ImmutableSortedSet.Builder(new
EntryComparator());
-            for (Tree principalRoot : principalTrees.values()) {
+            ImmutableSortedSet.Builder<PermissionEntry> entries = new ImmutableSortedSet.Builder(new
EntryComparator());
+            for (Tree principalRoot : principalTrees) {
                 String name = PermissionUtil.getEntryName(path);
                 Tree parent = principalRoot;
                 while (parent.hasChild(name)) {
                     parent = parent.getChild(name);
                     PermissionEntry pe = new PermissionEntry(parent, restrictionProvider);
-                    es.add(pe);
+                    if (predicate.apply(pe)) {
+                        entries.add(pe);
+                    }
                 }
             }
-            return es.build();
+            return entries.build().iterator();
         }
     }
 



Mime
View raw message