jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1574189 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ oak-jcr/src/main/java/org/apache/...
Date Tue, 04 Mar 2014 20:35:04 GMT
Author: jukka
Date: Tue Mar  4 20:35:03 2014
New Revision: 1574189

URL: http://svn.apache.org/r1574189
Log:
OAK-1495: Unify Root.commit(String) and Root.commit(Map)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableRoot.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableRoot.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/CommitInfo.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/session/SessionImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java?rev=1574189&r1=1574188&r2=1574189&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Root.java Tue
Mar  4 20:35:03 2014
@@ -24,7 +24,6 @@ import java.util.Map;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 
 /**
  * A {@code Root} instance serves as a container for a {@link Tree}. It is
@@ -111,37 +110,21 @@ public interface Root {
      * After a successful operation the root is automatically
      * {@link #refresh() refreshed}, such that trees previously obtained
      * through {@link #getTree(String)} may become non existing.
-     */
-    void commit(Map<String, Object> info) throws CommitFailedException;
-
-    /**
-     * Atomically persists all changes made to the tree attached to this root
-     * at the given {@code path}. An implementation may throw a
-     * {@code CommitFailedException} if there are changes outside of the subtree
-     * designated by {@code path} and the implementation does not support
-     * such partial commits. However all implementation must handler the
-     * case where a {@code path} designates a subtree that contains all
-     * unpersisted changes.
-     * <p>
-     * After a successful operation the root is automatically
-     * {@link #refresh() refreshed}, such that trees previously obtained
-     * through {@link #getTree(String)} may become non existing.
      *
-     * @param path of the subtree to commit
+     * @param info commit information
      * @throws CommitFailedException if the commit failed
      */
-    void commit(@Nullable String path) throws CommitFailedException;
+    void commit(@Nonnull Map<String, Object> info) throws CommitFailedException;
 
     /**
      * Atomically persists all changes made to the tree attached to this root.
      * Calling this method is equivalent to calling the
-     * {@link #commit(String)} method with a {@code null} argument {@code path}.
+     * {@link #commit(Map<String, Object> info)} method with an empty info map.
      *
      * @throws CommitFailedException if the commit failed
      */
     void commit() throws CommitFailedException;
 
-
     /**
      * Determine whether there are changes on this tree
      * @return  {@code true} iff this tree was modified

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableRoot.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableRoot.java?rev=1574189&r1=1574188&r2=1574189&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableRoot.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableRoot.java
Tue Mar  4 20:35:03 2014
@@ -100,11 +100,6 @@ public final class ImmutableRoot impleme
     }
 
     @Override
-    public void commit(String path) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
     public void commit() {
         throw new UnsupportedOperationException();
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableRoot.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableRoot.java?rev=1574189&r1=1574188&r2=1574189&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableRoot.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableRoot.java
Tue Mar  4 20:35:03 2014
@@ -27,14 +27,13 @@ import static org.apache.jackrabbit.oak.
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 import javax.security.auth.Subject;
 
-import com.google.common.collect.Maps;
 import org.apache.jackrabbit.oak.api.Blob;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.ContentSession;
@@ -250,15 +249,8 @@ class MutableRoot implements Root {
     }
 
     @Override
-    public void commit(@Nullable String path) throws CommitFailedException {
-        Map<String, Object> info = Maps.newHashMap();
-        info.put(COMMIT_PATH, path);
-        commit(info);
-    }
-
-    @Override
     public void commit() throws CommitFailedException {
-        commit((String) null);
+        commit(Collections.<String, Object>emptyMap());
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/CommitInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/CommitInfo.java?rev=1574189&r1=1574188&r2=1574189&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/CommitInfo.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/CommitInfo.java
Tue Mar  4 20:35:03 2014
@@ -21,13 +21,14 @@ package org.apache.jackrabbit.oak.spi.co
 import static com.google.common.base.Objects.toStringHelper;
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import java.util.Collections;
 import java.util.Map;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableMap;
+
 import org.apache.jackrabbit.oak.api.Root;
 
 /**
@@ -60,9 +61,7 @@ public final class CommitInfo {
      */
     public CommitInfo(
             @Nonnull String sessionId, @Nullable String userId) {
-        this(sessionId, userId, ImmutableMap.<String, Object>of(
-            Root.COMMIT_PATH, "/"
-        ));
+        this(sessionId, userId, Collections.<String, Object>emptyMap());
     }
 
     /**

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=1574189&r1=1574188&r2=1574189&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 Mar  4 20:35:03 2014
@@ -24,6 +24,7 @@ import static org.apache.jackrabbit.api.
 import static org.apache.jackrabbit.oak.commons.PathUtils.denotesRoot;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicLong;
@@ -36,6 +37,7 @@ import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.ConstraintViolationException;
 
 import com.google.common.collect.Maps;
+
 import org.apache.jackrabbit.oak.api.AuthInfo;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.ContentSession;
@@ -361,39 +363,32 @@ public class SessionDelegate {
         return root.hasPendingChanges();
     }
 
-    public void save() throws RepositoryException {
-        sessionStats.save();
-        try {
-            commit();
-        } catch (CommitFailedException e) {
-            RepositoryException repositoryException = newRepositoryException(e);
-            sessionStats.failedSave(repositoryException);
-            throw repositoryException;
-        }
-    }
-
     /**
-     * Save the subtree rooted at the given {@code path}.
+     * Save the subtree rooted at the given {@code path}, or the entire
+     * transient space if given the root path or {@code null}.
      * <p>
-     * This implementation only performs the save if the subtree rooted at {@code path} contains
-     * all transient changes and will throw an
+     * This implementation only performs the save if the subtree rooted
+     * at {@code path} contains all transient changes and will throw an
      * {@link javax.jcr.UnsupportedRepositoryOperationException} otherwise.
      *
      * @param path
      * @throws RepositoryException
      */
-    public void save(final String path) throws RepositoryException {
-        sessionStats.save();
-        if (denotesRoot(path)) {
-            save();
+    public void save(String path) throws RepositoryException {
+        Map<String, Object> info;
+        if (path == null || denotesRoot(path)) {
+            info = Collections.emptyMap();
         } else {
-            try {
-                root.commit(path);
-            } catch (CommitFailedException e) {
-                RepositoryException repositoryException = newRepositoryException(e);
-                sessionStats.failedSave(repositoryException);
-                throw repositoryException;
-            }
+            info = Collections.singletonMap(Root.COMMIT_PATH, (Object) path);
+        }
+
+        sessionStats.save();
+        try {
+            root.commit(info);
+        } catch (CommitFailedException e) {
+            RepositoryException repositoryException = newRepositoryException(e);
+            sessionStats.failedSave(repositoryException);
+            throw repositoryException;
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionImpl.java?rev=1574189&r1=1574188&r2=1574189&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionImpl.java
Tue Mar  4 20:35:03 2014
@@ -411,7 +411,7 @@ public class SessionImpl implements Jack
         perform(new WriteOperation<Void>() {
             @Override
             public Void perform() throws RepositoryException {
-                sd.save();
+                sd.save(null);
                 return null;
             }
 



Mime
View raw message