jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1513522 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: RepositoryImpl.java SessionContext.java SessionImpl.java delegate/SessionDelegate.java xml/ImportHandler.java
Date Tue, 13 Aug 2013 14:53:45 GMT
Author: mduerig
Date: Tue Aug 13 14:53:45 2013
New Revision: 1513522

URL: http://svn.apache.org/r1513522
Log:
OAK-958: Session related entities do not honour session refresh settings
push permission provider refresh logic down to SessionDelegate

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImportHandler.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java?rev=1513522&r1=1513521&r2=1513522&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
Tue Aug 13 14:53:45 2013
@@ -57,7 +57,7 @@ public class RepositoryImpl implements J
      * Name of the session attribute value determining the session refresh
      * behaviour.
      *
-     * @see SessionDelegate#SessionDelegate(ContentSession, long)
+     * @see SessionDelegate#SessionDelegate(ContentSession, SecurityProvider, long)
      */
     public static final String REFRESH_INTERVAL = "oak.refresh-interval";
 
@@ -205,7 +205,7 @@ public class RepositoryImpl implements J
             ContentSession contentSession = contentRepository.login(credentials, workspaceName);
             SessionContext context = createSessionContext(
                     Collections.<String, Object>singletonMap(REFRESH_INTERVAL, refreshInterval),
-                    new SessionDelegate(contentSession, refreshInterval));
+                    new SessionDelegate(contentSession, securityProvider, refreshInterval));
             return context.getSession();
         } catch (LoginException e) {
             throw new javax.jcr.LoginException(e.getMessage(), e);

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java?rev=1513522&r1=1513521&r2=1513522&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
Tue Aug 13 14:53:45 2013
@@ -52,7 +52,6 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.spi.security.SecurityConfiguration;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
 import org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration;
-import org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider;
 import org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration;
 import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConfiguration;
 import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration;
@@ -80,7 +79,6 @@ public class SessionContext implements N
     private WorkspaceImpl workspace = null;
 
     private AccessControlManager accessControlManager;
-    private PermissionProvider permissionProvider;
     private PrincipalManager principalManager;
     private UserManager userManager;
     private PrivilegeManager privilegeManager;
@@ -309,18 +307,9 @@ public class SessionContext implements N
         }
     }
 
-    public void refresh(boolean includeRoot) {
-        if (includeRoot) {
-            getSessionDelegate().getRoot().refresh();
-        }
-        if (permissionProvider != null) {
-            permissionProvider.refresh();
-        }
-    }
-
     @Nonnull
     public AccessManager getAccessManager() throws RepositoryException {
-        return new AccessManager(getPermissionProvider());
+        return new AccessManager(delegate.getPermissionProvider());
     }
 
     @Nonnull
@@ -337,15 +326,6 @@ public class SessionContext implements N
         namespaces.clear();
     }
 
-    //------------------------------------------------------------< private >---
-    @Nonnull
-    private PermissionProvider getPermissionProvider() {
-        if (permissionProvider == null) {
-            permissionProvider = getConfig(AuthorizationConfiguration.class).getPermissionProvider(delegate.getRoot(),
delegate.getAuthInfo().getPrincipals());
-        }
-        return permissionProvider;
-    }
-
     @Nonnull
     private <T> T getConfig(Class<T> clss) {
         return repository.getSecurityProvider().getConfiguration(clss);

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java?rev=1513522&r1=1513521&r2=1513522&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionImpl.java
Tue Aug 13 14:53:45 2013
@@ -392,7 +392,6 @@ public class SessionImpl implements Jack
             @Override
             public Void perform() throws RepositoryException {
                 sd.save();
-                sessionContext.refresh(false);
                 return null;
             }
         });
@@ -404,7 +403,6 @@ public class SessionImpl implements Jack
             @Override
             public Void perform() throws RepositoryException {
                 sd.refresh(keepChanges);
-                sessionContext.refresh(false);
                 return null;
             }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java?rev=1513522&r1=1513521&r2=1513522&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java
Tue Aug 13 14:53:45 2013
@@ -40,6 +40,9 @@ import org.apache.jackrabbit.oak.commons
 import org.apache.jackrabbit.oak.core.IdentifierManager;
 import org.apache.jackrabbit.oak.jcr.operation.SessionOperation;
 import org.apache.jackrabbit.oak.jcr.security.AccessManager;
+import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
+import org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration;
+import org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider;
 import org.apache.jackrabbit.oak.spi.security.authorization.permission.Permissions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -55,6 +58,7 @@ public class SessionDelegate {
     private final Root root;
     private final IdentifierManager idManager;
     private final Exception initStackTrace;
+    private final PermissionProvider permissionProvider;
 
     private boolean isAlive = true;
     private int sessionOpCount;
@@ -73,14 +77,18 @@ public class SessionDelegate {
      * dispatcher in order.
      *
      * @param contentSession  the content session
+     * @param securityProvider the security provider
      * @param refreshInterval  refresh interval in seconds.
      */
-    public SessionDelegate(@Nonnull ContentSession contentSession, long refreshInterval)
{
+    public SessionDelegate(@Nonnull ContentSession contentSession, SecurityProvider securityProvider,
long refreshInterval) {
         this.contentSession = checkNotNull(contentSession);
         this.refreshInterval = MILLISECONDS.convert(refreshInterval, SECONDS);
         this.root = contentSession.getLatestRoot();
         this.idManager = new IdentifierManager(root);
         this.initStackTrace = new Exception("The session was created here:");
+        this.permissionProvider = securityProvider.getConfiguration(AuthorizationConfiguration.class)
+                .getPermissionProvider(root, contentSession.getAuthInfo().getPrincipals());
+
     }
 
     public synchronized void refreshAtNextAccess() {
@@ -296,6 +304,7 @@ public class SessionDelegate {
         } catch (CommitFailedException e) {
             throw newRepositoryException(e);
         }
+        permissionProvider.refresh();
     }
 
     public void refresh(boolean keepChanges) {
@@ -304,6 +313,7 @@ public class SessionDelegate {
         } else {
             root.refresh();
         }
+        permissionProvider.refresh();
     }
 
     //----------------------------------------------------------< Workspace >---
@@ -404,6 +414,11 @@ public class SessionDelegate {
         return root.getQueryEngine();
     }
 
+    @Nonnull
+    public PermissionProvider getPermissionProvider() {
+        return permissionProvider;
+    }
+
     /**
      * The current {@code Root} instance this session delegate instance operates on.
      * To ensure the returned root reflects the correct repository revision access

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImportHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImportHandler.java?rev=1513522&r1=1513521&r2=1513522&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImportHandler.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/xml/ImportHandler.java
Tue Aug 13 14:53:45 2013
@@ -115,9 +115,11 @@ public class ImportHandler extends Defau
         if (isWorkspaceImport) {
             try {
                 root.commit();
-                sessionContext.refresh(true);
+                sessionContext.getSession().refresh(false);
             } catch (CommitFailedException e) {
                 throw new SAXException(e);
+            } catch (RepositoryException e) {
+                throw new SAXException(e);
             }
         }
     }



Mime
View raw message