Author: chetanm
Date: Fri Nov 11 12:12:53 2016
New Revision: 1769276

URL: http://svn.apache.org/viewvc?rev=1769276&view=rev
Log:
OAK-5079 - Diff would not work for bundled nodes when done without journal 
support

Add methods to determine bundling state of any NodeState

Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtils.java
    
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtils.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtils.java?rev=1769276&r1=1769275&r2=1769276&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtils.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtils.java
 Fri Nov 11 12:12:53 2016
@@ -32,6 +32,7 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 import static 
org.apache.jackrabbit.oak.plugins.document.bundlor.DocumentBundlor.META_PROP_BUNDLING_PATH;
 
@@ -104,4 +105,16 @@ public final class BundlorUtils {
         }
         return childNodeNames;
     }
+
+    static boolean isBundlingRoot(NodeState state){
+        return state.hasProperty(DocumentBundlor.META_PROP_PATTERN);
+    }
+
+    static boolean isBundledChild(NodeState state){
+        return state.hasProperty(DocumentBundlor.META_PROP_BUNDLING_PATH);
+    }
+
+    static boolean isBundledNode(NodeState state){
+        return isBundlingRoot(state) || isBundledChild(state);
+    }
 }

Modified: 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java?rev=1769276&r1=1769275&r2=1769276&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
 Fri Nov 11 12:12:53 2016
@@ -152,6 +152,25 @@ public class DocumentBundlingTest {
     }
 
     @Test
+    public void bundlorUtilsIsBundledMethods() throws Exception{
+        NodeBuilder builder = store.getRoot().builder();
+        NodeBuilder fileNode = newNode("nt:file");
+        fileNode.child("jcr:content").setProperty("jcr:data", "foo");
+        builder.child("test").setChildNode("book.jpg", 
fileNode.getNodeState());
+
+        merge(builder);
+        NodeState fileNodeState =  NodeStateUtils.getNode(store.getRoot(), 
"/test/book.jpg");
+        assertTrue(BundlorUtils.isBundledNode(fileNodeState));
+        assertFalse(BundlorUtils.isBundledChild(fileNodeState));
+        assertTrue(BundlorUtils.isBundlingRoot(fileNodeState));
+
+        NodeState contentNode =  NodeStateUtils.getNode(store.getRoot(), 
"/test/book.jpg/jcr:content");
+        assertTrue(BundlorUtils.isBundledNode(contentNode));
+        assertTrue(BundlorUtils.isBundledChild(contentNode));
+        assertFalse(BundlorUtils.isBundlingRoot(contentNode));
+    }
+
+    @Test
     public void bundledParent() throws Exception{
         NodeBuilder builder = store.getRoot().builder();
         NodeBuilder appNB = newNode("app:Asset");


Reply via email to