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

svn commit: r1293667 - /jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java

Author: stefan
Date: Sat Feb 25 19:16:31 2012
New Revision: 1293667

URL: http://svn.apache.org/viewvc?rev=1293667&view=rev
Log:
null revId => assume head

Modified:
    jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java

Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java?rev=1293667&r1=1293666&r2=1293667&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/MicroKernelImpl.java Sat Feb 25 19:16:31 2012
@@ -140,6 +140,8 @@ public class MicroKernelImpl implements 
             throw new IllegalStateException("this instance has already been disposed");
         }
 
+        toRevisionId = toRevisionId == null ? getHeadRevision() : toRevisionId;
+
         List<StoredCommit> commits = new ArrayList<StoredCommit>();
         try {
             StoredCommit toCommit = rep.getCommit(toRevisionId);
@@ -201,6 +203,8 @@ public class MicroKernelImpl implements 
             path = "/";
         }
 
+        toRevisionId = toRevisionId == null ? getHeadRevision() : toRevisionId;
+
         try {
             final JsopBuilder buff = new JsopBuilder();
             // maps (key: id of target node, value: path/to/target)
@@ -377,14 +381,37 @@ public class MicroKernelImpl implements 
         if (rep == null) {
             throw new IllegalStateException("this instance has already been disposed");
         }
+
+        revisionId = revisionId == null ? getHeadRevision() : revisionId;
+
         return rep.nodeExists(revisionId, path);
     }
 
+    public long getChildNodeCount(String path, String revisionId) throws MicroKernelException {
+        if (rep == null) {
+            throw new IllegalStateException("this instance has already been disposed");
+        }
+
+        revisionId = revisionId == null ? getHeadRevision() : revisionId;
+
+        try {
+            return rep.getNode(revisionId, path).getChildNodeCount();
+        } catch (Exception e) {
+            throw new MicroKernelException(e);
+        }
+    }
+
     public String getNodes(String path, String revisionId) throws MicroKernelException {
         return getNodes(path, revisionId, 1, 0, -1);
     }
 
     public String getNodes(String path, String revisionId, int depth, long offset, int count) throws MicroKernelException {
+        if (rep == null) {
+            throw new IllegalStateException("this instance has already been disposed");
+        }
+
+        revisionId = revisionId == null ? getHeadRevision() : revisionId;
+
         try {
             JsopBuilder buf = new JsopBuilder().object();
             toJson(buf, rep.getNode(revisionId, path), depth, (int) offset, count, true);
@@ -401,6 +428,9 @@ public class MicroKernelImpl implements 
         if (path.length() > 0 && !PathUtils.isAbsolute(path)) {
             throw new IllegalArgumentException("absolute path expected: " + path);
         }
+
+        revisionId = revisionId == null ? getHeadRevision() : revisionId;
+
         try {
             JsopTokenizer t = new JsopTokenizer(jsonDiff);
             CommitBuilder cb = rep.getCommitBuilder(revisionId, message);
@@ -584,7 +614,7 @@ public class MicroKernelImpl implements 
             }
         }
     }
-
+    
     static void addNode(LinkedList<AddNodeOperation> list, String path, String name, JsopTokenizer t) throws Exception {
         AddNodeOperation op = new AddNodeOperation();
         op.path = path;