jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1515750 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: delegate/VersionManagerDelegate.java version/VersionHistoryImpl.java version/VersionStorage.java
Date Tue, 20 Aug 2013 09:24:28 GMT
Author: mreutegg
Date: Tue Aug 20 09:24:28 2013
New Revision: 1515750

URL: http://svn.apache.org/r1515750
Log:
OAK-958: Session related entities do not honour session refresh settings
- Version methods that modify must use 'write' operations
- Rearranged some code

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/VersionManagerDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionStorage.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/VersionManagerDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/VersionManagerDelegate.java?rev=1515750&r1=1515749&r2=1515750&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/VersionManagerDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/VersionManagerDelegate.java
Tue Aug 20 09:24:28 2013
@@ -34,7 +34,6 @@ import javax.jcr.UnsupportedRepositoryOp
 import javax.jcr.version.LabelExistsVersionException;
 import javax.jcr.version.VersionException;
 
-import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
@@ -42,31 +41,24 @@ import org.apache.jackrabbit.oak.api.Typ
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.jcr.version.ReadWriteVersionManager;
 import org.apache.jackrabbit.oak.jcr.version.VersionStorage;
-import org.apache.jackrabbit.oak.plugins.version.VersionConstants;
 
 /**
  * {@code VersionManagerDelegate}...
  */
 public class VersionManagerDelegate {
 
-    private static final String VERSION_STORAGE_PATH
-            = '/' + JcrConstants.JCR_SYSTEM + '/' + JcrConstants.JCR_VERSIONSTORAGE;
-
     private final SessionDelegate sessionDelegate;
 
     private final ReadWriteVersionManager versionManager;
 
     public static VersionManagerDelegate create(SessionDelegate sessionDelegate) {
-        Tree vsTree = getVersionStorageTree(sessionDelegate.getRoot());
-        return new VersionManagerDelegate(sessionDelegate,
-                new VersionStorage(sessionDelegate.getRoot(), vsTree));
+        return new VersionManagerDelegate(sessionDelegate);
     }
 
-    private VersionManagerDelegate(SessionDelegate sessionDelegate,
-                                   VersionStorage versionStorage) {
+    private VersionManagerDelegate(SessionDelegate sessionDelegate) {
         this.sessionDelegate = sessionDelegate;
         this.versionManager = new ReadWriteVersionManager(
-                versionStorage,
+                new VersionStorage(sessionDelegate.getRoot()),
                 sessionDelegate.getRoot()) {
             @Override
             protected void refresh() {
@@ -192,9 +184,8 @@ public class VersionManagerDelegate {
         // perform operation on fresh storage to not interfere
         // with pending changes in the workspace.
         Root fresh = sessionDelegate.getContentSession().getLatestRoot();
-        VersionStorage storage = new VersionStorage(
-                fresh, getVersionStorageTree(fresh));
-        String vhRelPath = PathUtils.relativize(VERSION_STORAGE_PATH,
+        VersionStorage storage = new VersionStorage(fresh);
+        String vhRelPath = PathUtils.relativize(VersionStorage.VERSION_STORAGE_PATH,
                 checkNotNull(versionHistory).getPath());
         versionManager.addVersionLabel(storage, vhRelPath,
                 checkNotNull(version).getName(), checkNotNull(oakVersionLabel),
@@ -216,9 +207,8 @@ public class VersionManagerDelegate {
         // perform operation on fresh storage to not interfere
         // with pending changes in the workspace.
         Root fresh = sessionDelegate.getContentSession().getLatestRoot();
-        VersionStorage storage = new VersionStorage(
-                fresh, getVersionStorageTree(fresh));
-        String vhRelPath = PathUtils.relativize(VERSION_STORAGE_PATH,
+        VersionStorage storage = new VersionStorage(fresh);
+        String vhRelPath = PathUtils.relativize(VersionStorage.VERSION_STORAGE_PATH,
                 checkNotNull(versionHistory).getPath());
         versionManager.removeVersionLabel(storage, vhRelPath,
                 checkNotNull(oakVersionLabel));
@@ -239,13 +229,4 @@ public class VersionManagerDelegate {
         return checkNotNull(nodeDelegate).getTree();
     }
 
-    /**
-     * Returns the version storage tree for the given workspace.
-     * @param workspaceRoot the root of the workspace.
-     * @return the version storage tree.
-     */
-    private static Tree getVersionStorageTree(@Nonnull Root workspaceRoot) {
-        // TODO: this assumes the version store is in the same workspace.
-        return checkNotNull(workspaceRoot).getTree(VERSION_STORAGE_PATH);
-    }
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java?rev=1515750&r1=1515749&r2=1515750&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java
Tue Aug 20 09:24:28 2013
@@ -149,7 +149,7 @@ public class VersionHistoryImpl extends 
                                 final boolean moveLabel)
             throws LabelExistsVersionException, VersionException,
             RepositoryException {
-        perform(new SessionOperation<Void>() {
+        perform(new SessionOperation<Void>(true) {
             @Override
             public Void perform() throws RepositoryException {
                 String oakLabel = sessionContext.getOakName(label);
@@ -164,7 +164,7 @@ public class VersionHistoryImpl extends 
     @Override
     public void removeVersionLabel(final String label)
             throws VersionException, RepositoryException {
-        perform(new SessionOperation<Void>() {
+        perform(new SessionOperation<Void>(true) {
             @Override
             public Void perform() throws RepositoryException {
                 String oakLabel = sessionContext.getOakName(label);

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionStorage.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionStorage.java?rev=1515750&r1=1515749&r2=1515750&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionStorage.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionStorage.java
Tue Aug 20 09:24:28 2013
@@ -18,22 +18,25 @@ package org.apache.jackrabbit.oak.jcr.ve
 
 import javax.annotation.Nonnull;
 
+import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 /**
  * Simple abstraction of the version storage.
  */
 public class VersionStorage {
 
+    public static final String VERSION_STORAGE_PATH
+            = '/' + JcrConstants.JCR_SYSTEM + '/' + JcrConstants.JCR_VERSIONSTORAGE;
+
     private final Root root;
-    private final Tree versionStorage;
 
-    public VersionStorage(@Nonnull Root versionStorageRoot,
-                   @Nonnull Tree versionStorageTree) {
+    public VersionStorage(@Nonnull Root versionStorageRoot) {
         this.root = versionStorageRoot;
-        this.versionStorage = versionStorageTree;
     }
 
     /**
@@ -45,7 +48,7 @@ public class VersionStorage {
      * @return the version storage tree.
      */
     Tree getTree() {
-        return versionStorage;
+        return getVersionStorageTree(root);
     }
 
     /**
@@ -63,4 +66,14 @@ public class VersionStorage {
     void refresh() {
         root.refresh();
     }
+
+    /**
+     * Returns the version storage tree for the given workspace.
+     * @param workspaceRoot the root of the workspace.
+     * @return the version storage tree.
+     */
+    private static Tree getVersionStorageTree(@Nonnull Root workspaceRoot) {
+        // TODO: this assumes the version store is in the same workspace.
+        return checkNotNull(workspaceRoot).getTree(VERSION_STORAGE_PATH);
+    }
 }



Mime
View raw message