jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1513521 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: ItemImpl.java delegate/SessionDelegate.java delegate/UserManagerDelegator.java lock/LockImpl.java operation/SessionOperation.java
Date Tue, 13 Aug 2013 14:53:30 GMT
Author: mduerig
Date: Tue Aug 13 14:53:30 2013
New Revision: 1513521

URL: http://svn.apache.org/r1513521
Log:
OAK-938 UserManager does not honour session refresh settings
Add and use SessionDelegate.safePerform

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.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/delegate/UserManagerDelegator.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/SessionOperation.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java?rev=1513521&r1=1513520&r2=1513521&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
Tue Aug 13 14:53:30 2013
@@ -107,12 +107,7 @@ abstract class ItemImpl<T extends ItemDe
      */
     @CheckForNull
     protected final <U> U safePerform(@Nonnull SessionOperation<U> op) {
-        try {
-            return sessionDelegate.perform(op);
-        } catch (RepositoryException e) {
-            throw new RuntimeException(
-                    "Unexpected exception thrown by operation " + op, e);
-        }
+        return sessionDelegate.safePerform(op);
     }
 
     //---------------------------------------------------------------< Item >---

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=1513521&r1=1513520&r2=1513521&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:30 2013
@@ -97,6 +97,7 @@ public class SessionDelegate {
      * @param <T>  return type of {@code sessionOperation}
      * @return  the result of {@code sessionOperation.perform()}
      * @throws RepositoryException
+     * @see #getRoot()
      */
     public synchronized <T> T perform(SessionOperation<T> sessionOperation)
             throws RepositoryException {
@@ -136,6 +137,26 @@ public class SessionDelegate {
         }
     }
 
+    /**
+     * Same as {@link #perform(SessionOperation)} unless this method expects
+     * {@link SessionOperation#perform} <em>not</em> to throw a {@code RepositoryException}.
+     * Such exceptions will be wrapped into a {@code RuntimeException} and rethrown as they
+     * are considered an internal error.
+     *
+     * @param sessionOperation  the {@code SessionOperation} to perform
+     * @param <T>  return type of {@code sessionOperation}
+     * @return  the result of {@code sessionOperation.perform()}
+     * @see #getRoot()
+     */
+    public <T> T safePerform(SessionOperation<T> sessionOperation) {
+        try {
+            return perform(sessionOperation);
+        } catch (RepositoryException e) {
+            throw new RuntimeException("Unexpected exception thrown by operation " +
+                    sessionOperation, e);
+        }
+    }
+
     @Nonnull
     public ContentSession getContentSession() {
         return contentSession;
@@ -383,13 +404,21 @@ public class SessionDelegate {
         return root.getQueryEngine();
     }
 
-    //-----------------------------------------------------------< internal >---
-
-    @Nonnull  // FIXME this should be package private. OAK-672
+    /**
+     * The current {@code Root} instance this session delegate instance operates on.
+     * To ensure the returned root reflects the correct repository revision access
+     * should only be done from within a {@link SessionOperation} closure through
+     * {@link #perform(SessionOperation)}.
+     *
+     * @return  current root
+     */
+    @Nonnull
     public Root getRoot() {
         return root;
     }
 
+    //-----------------------------------------------------------< internal >---
+
     /**
      * Wraps the given {@link CommitFailedException} instance using the
      * appropriate {@link RepositoryException} subclass based on the
@@ -401,5 +430,4 @@ public class SessionDelegate {
     private static RepositoryException newRepositoryException(CommitFailedException exception)
{
         return exception.asRepositoryException();
     }
-
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserManagerDelegator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserManagerDelegator.java?rev=1513521&r1=1513520&r2=1513521&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserManagerDelegator.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserManagerDelegator.java
Tue Aug 13 14:53:30 2013
@@ -170,17 +170,12 @@ public class UserManagerDelegator implem
 
     @Override
     public boolean isAutoSave() {
-        try {
-            return sessionDelegate.perform(new UserManagerOperation<Boolean>(sessionDelegate)
{
-                @Override
-                public Boolean perform() {
-                    return userManagerDelegate.isAutoSave();
-                }
-            });
-        } catch (RepositoryException e) {
-            assert false : "Unexpected exception: " + e;
-            return false;
-        }
+        return sessionDelegate.safePerform(new UserManagerOperation<Boolean>(sessionDelegate)
{
+            @Override
+            public Boolean perform() {
+                return userManagerDelegate.isAutoSave();
+            }
+        });
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockImpl.java?rev=1513521&r1=1513520&r2=1513521&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockImpl.java
Tue Aug 13 14:53:30 2013
@@ -119,12 +119,7 @@ public final class LockImpl implements L
      */
     @CheckForNull
     private final <U> U safePerform(@Nonnull SessionOperation<U> op) {
-        try {
-            return context.getSessionDelegate().perform(op);
-        } catch (RepositoryException e) {
-            throw new RuntimeException(
-                    "Unexpected exception thrown by operation " + op, e);
-        }
+        return context.getSessionDelegate().safePerform(op);
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/SessionOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/SessionOperation.java?rev=1513521&r1=1513520&r2=1513521&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/SessionOperation.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/SessionOperation.java
Tue Aug 13 14:53:30 2013
@@ -22,6 +22,7 @@ import javax.jcr.RepositoryException;
 
 /**
  * A {@code SessionOperation} provides an execution context for executing session scoped
operations.
+ * @see org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate#perform(SessionOperation)
  */
 public abstract class SessionOperation<T> {
 



Mime
View raw message