Author: chetanm
Date: Fri Nov 11 12:13:08 2016
New Revision: 1769277
URL: http://svn.apache.org/viewvc?rev=1769277&view=rev
Log:
OAK-5079 - Diff would not work for bundled nodes when done without journal
support
Add methods to determine bundling state of DocumentNodeState
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
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/BundlorUtilsTest.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/DocumentNodeState.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java?rev=1769277&r1=1769276&r2=1769277&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeState.java
Fri Nov 11 12:13:08 2016
@@ -343,6 +343,17 @@ public class DocumentNodeState extends A
}
}
+ public Set<String> getBundledChildNodeNames(){
+ return bundlingContext.getBundledChildNodeNames();
+ }
+
+ public boolean hasOnlyBundledChildren(){
+ if (bundlingContext.isBundled()){
+ return bundlingContext.hasOnlyBundledChildren();
+ }
+ return false;
+ }
+
String getPropertyAsString(String propertyName) {
return asString(properties.get(propertyName));
}
@@ -815,11 +826,11 @@ public class DocumentNodeState extends A
return !hasNonBundledChildren;
}
- public List<String> getBundledChildNodeNames(){
+ public Set<String> getBundledChildNodeNames(){
if (isBundled()) {
return BundlorUtils.getChildNodeNames(rootProperties.keySet(),
matcher);
}
- return Collections.emptyList();
+ return Collections.emptySet();
}
private boolean hasBundledChildren(Matcher matcher){
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=1769277&r1=1769276&r2=1769277&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:13:08 2016
@@ -23,6 +23,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.annotation.Nonnull;
@@ -30,6 +31,7 @@ import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.spi.state.NodeState;
@@ -85,8 +87,8 @@ public final class BundlorUtils {
return result;
}
- public static List<String> getChildNodeNames(Collection<String> keys,
Matcher matcher){
- List<String> childNodeNames = Lists.newArrayList();
+ public static Set<String> getChildNodeNames(Collection<String> keys,
Matcher matcher){
+ Set<String> childNodeNames = Sets.newHashSet();
//Immediate child should have depth 1 more than matcher depth
int expectedDepth = matcher.depth() + 1;
Modified:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtilsTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtilsTest.java?rev=1769277&r1=1769276&r2=1769277&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtilsTest.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlorUtilsTest.java
Fri Nov 11 12:13:08 2016
@@ -22,6 +22,7 @@ package org.apache.jackrabbit.oak.plugin
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
@@ -89,7 +90,7 @@ public class BundlorUtilsTest {
);
Matcher m = new Include("jcr:content/*").createMatcher();
- List<String> names = BundlorUtils.getChildNodeNames(testData, m);
+ Set<String> names = BundlorUtils.getChildNodeNames(testData, m);
assertThat(names, hasItem("jcr:content"));
names = BundlorUtils.getChildNodeNames(testData,
m.next("jcr:content"));
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=1769277&r1=1769276&r2=1769277&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:13:08 2016
@@ -528,6 +528,36 @@ public class DocumentBundlingTest {
}
@Test
+ public void documentNodeStateBundledMethods() throws Exception{
+ NodeBuilder builder = store.getRoot().builder();
+ NodeBuilder appNB = newNode("app:Asset");
+ createChild(appNB,
+ "jcr:content",
+ "jcr:content/comments", //not bundled
+ "jcr:content/metadata",
+ "jcr:content/metadata/xmp", //not bundled
+ "jcr:content/renditions", //includes all
+ "jcr:content/renditions/original",
+ "jcr:content/renditions/original/jcr:content"
+ );
+ builder.child("test").setChildNode("book.jpg", appNB.getNodeState());
+
+ merge(builder);
+ DocumentNodeState appNode = (DocumentNodeState)
getNode(store.getRoot(), "test/book.jpg");
+ assertTrue(appNode.hasOnlyBundledChildren());
+ assertEquals(ImmutableSet.of("jcr:content"),
appNode.getBundledChildNodeNames());
+ assertEquals(ImmutableSet.of("metadata", "renditions"),
+
asDocumentState(appNode.getChildNode("jcr:content")).getBundledChildNodeNames());
+
+ builder = store.getRoot().builder();
+ childBuilder(builder, "/test/book.jpg/foo");
+ merge(builder);
+
+ DocumentNodeState appNode2 = (DocumentNodeState)
getNode(store.getRoot(), "test/book.jpg");
+ assertFalse(appNode2.hasOnlyBundledChildren());
+ }
+
+ @Test
public void bundledDocsShouldNotBePartOfBackgroundUpdate() throws
Exception{
NodeBuilder builder = store.getRoot().builder();
NodeBuilder fileNode = newNode("nt:file");
@@ -788,7 +818,7 @@ public class DocumentBundlingTest {
return store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
}
- private static DocumentNodeState asDocumentState(NodeState state){
+ static DocumentNodeState asDocumentState(NodeState state){
if (state instanceof DocumentNodeState){
return (DocumentNodeState) state;
}
@@ -809,7 +839,7 @@ public class DocumentBundlingTest {
return copyOf(getNode(state, path).getChildNodeNames());
}
- private static NodeBuilder newNode(String typeName){
+ static NodeBuilder newNode(String typeName){
NodeBuilder builder = EMPTY_NODE.builder();
builder.setProperty(JCR_PRIMARYTYPE, typeName);
return builder;