jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1325998 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk: simple/SimpleKernelImpl.java wrapper/MicroKernelWrapperBase.java wrapper/SecurityWrapper.java
Date Fri, 13 Apr 2012 22:39:19 GMT
Author: jukka
Date: Fri Apr 13 22:39:19 2012
New Revision: 1325998

URL: http://svn.apache.org/viewvc?rev=1325998&view=rev
Log:
OAK-48: MicroKernel.getNodes() should return null for not existing nodes instead of throwing
an exception

Adjust the MK wrapper layer. This fixes the failing integration test.

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/SimpleKernelImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/MicroKernelWrapperBase.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/SecurityWrapper.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/SimpleKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/SimpleKernelImpl.java?rev=1325998&r1=1325997&r2=1325998&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/SimpleKernelImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/simple/SimpleKernelImpl.java
Fri Apr 13 22:39:19 2012
@@ -482,7 +482,7 @@ public class SimpleKernelImpl extends Mi
             n = getRevisionDataRoot(revisionId).getNode(path.substring(1));
         }
         if (n == null) {
-            throw ExceptionFactory.get("Path not found: " + path);
+            return null;
         }
         JsopStream json = new JsopStream();
         n.append(json, depth, offset, count, true);
@@ -509,7 +509,12 @@ public class SimpleKernelImpl extends Mi
             return head;
         } else {
             long rev = Revision.parseId(revisionId);
-            return getRevisionNode(node, rev, rev).getNode("head");
+            NodeImpl rnode = getRevisionNode(node, rev, rev);
+            if (rnode != null) {
+                return rnode.getNode("head");
+            } else {
+                return null;
+            }
         }
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/MicroKernelWrapperBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/MicroKernelWrapperBase.java?rev=1325998&r1=1325997&r2=1325998&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/MicroKernelWrapperBase.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/MicroKernelWrapperBase.java
Fri Apr 13 22:39:19 2012
@@ -37,11 +37,22 @@ public abstract class MicroKernelWrapper
     }
 
     public final String getNodes(String path, String revisionId) {
-        return getNodesStream(path, revisionId).toString();
+        JsopReader reader = getNodesStream(path, revisionId);
+        if (reader != null) {
+            return reader.toString();
+        } else {
+            return null;
+        }
     }
 
     public final String getNodes(String path, String revisionId, int depth, long offset,
int count, String filter) {
-        return getNodesStream(path, revisionId, depth, offset, count, filter).toString();
+        JsopReader reader =
+                getNodesStream(path, revisionId, depth, offset, count, filter);
+        if (reader != null) {
+            return reader.toString();
+        } else {
+            return null;
+        }
     }
 
     public final String diff(String fromRevisionId, String toRevisionId, String filter) {
@@ -76,11 +87,22 @@ public abstract class MicroKernelWrapper
             }
 
             public JsopReader getNodesStream(String path, String revisionId) {
-                return new JsopTokenizer(wrapped.getNodes(path, revisionId));
+                String json = wrapped.getNodes(path, revisionId);
+                if (json != null) {
+                    return new JsopTokenizer(json);
+                } else {
+                    return null;
+                }
             }
 
             public JsopReader getNodesStream(String path, String revisionId, int depth, long
offset, int count, String filter) {
-                return new JsopTokenizer(wrapped.getNodes(path, revisionId, depth, offset,
count, filter));
+                String json = wrapped.getNodes(
+                        path, revisionId, depth, offset, count, filter);
+                if (json != null) {
+                    return new JsopTokenizer(json);
+                } else {
+                    return null;
+                }
             }
 
             public JsopReader getRevisionsStream(long since, int maxEntries) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/SecurityWrapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/SecurityWrapper.java?rev=1325998&r1=1325997&r2=1325998&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/SecurityWrapper.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/mk/wrapper/SecurityWrapper.java
Fri Apr 13 22:39:19 2012
@@ -283,7 +283,7 @@ public class SecurityWrapper extends Mic
             throw ExceptionFactory.get("Node not found: " + path);
         }
         JsopReader t = mk.getNodesStream(path, revisionId, depth, offset, count, filter);
-        if (admin) {
+        if (admin || t == null) {
             return t;
         }
         t.read('{');



Mime
View raw message