You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by st...@apache.org on 2012/04/20 15:28:25 UTC

svn commit: r1328367 - in /jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk: api/MicroKernel.java core/MicroKernelImpl.java

Author: stefan
Date: Fri Apr 20 13:28:24 2012
New Revision: 1328367

URL: http://svn.apache.org/viewvc?rev=1328367&view=rev
Log:
OAK-11: Document and tighten contract of Microkernel API

clarified semantics of getJournal WRT branches

Modified:
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java?rev=1328367&r1=1328366&r2=1328367&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java (original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/api/MicroKernel.java Fri Apr 20 13:28:24 2012
@@ -112,9 +112,6 @@ public interface MicroKernel {
      * Returns a revision journal, starting with {@code fromRevisionId}
      * and ending with {@code toRevisionId} in chronological order.
      * <p/>
-     * The revision denoted by {@code fromRevisionId} is expected to be older
-     * i.e. than the one denoted by {@code toRevisionId});
-     * <p/>
      * Format:
      * <pre>
      * [
@@ -127,6 +124,12 @@ public interface MicroKernel {
      *   ...
      * ]
      * </pre>
+     * If {@code fromRevisionId} and {@code toRevisionId} are not in chronological
+     * order the returned journal will be empty (i.e. {@code []})
+     * <p/>
+     * A {@code MicroKernelException} is thrown if either {@code fromRevisionId}
+     * or {@code toRevisionId}  doesn't exist, denotes a <i>private</i> branch
+     * revision or if another error occurs.
      *
      * @param fromRevisionId id of first revision to be returned in journal
      * @param toRevisionId   id of last revision to be returned in journal,

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java?rev=1328367&r1=1328366&r2=1328367&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java (original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java Fri Apr 20 13:28:24 2012
@@ -158,6 +158,9 @@ public class MicroKernelImpl implements 
         List<StoredCommit> commits = new ArrayList<StoredCommit>();
         try {
             StoredCommit toCommit = rep.getCommit(toRevisionId);
+            if (toCommit.getBranchRootId() != null) {
+                throw new MicroKernelException("branch revisions are not supported: " + toRevisionId);
+            }
 
             Commit fromCommit;
             if (toRevisionId.equals(fromRevisionId)) {
@@ -165,10 +168,13 @@ public class MicroKernelImpl implements 
             } else {
                 fromCommit = rep.getCommit(fromRevisionId);
                 if (fromCommit.getCommitTS() > toCommit.getCommitTS()) {
-                    // negative range, return empty array
+                    // negative range, return empty journal
                     return "[]";
                 }
             }
+            if (fromCommit.getBranchRootId() != null) {
+                throw new MicroKernelException("branch revisions are not supported: " + fromRevisionId);
+            }
 
             // collect commits, starting with toRevisionId
             // and traversing parent commit links until we've reached
@@ -181,9 +187,14 @@ public class MicroKernelImpl implements 
                 }
                 Id commitId = commit.getParentId();
                 if (commitId == null) {
+                    // shouldn't get here, ignore
                     break;
                 }
                 commit = rep.getCommit(commitId);
+                if (commit.getCommitTS() < fromCommit.getCommitTS()) {
+                    // shouldn't get here, ignore
+                    break;
+                }
             }
         } catch (Exception e) {
             throw new MicroKernelException(e);