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 ch...@apache.org on 2016/10/19 15:11:54 UTC

svn commit: r1765646 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/ test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/

Author: chetanm
Date: Wed Oct 19 15:11:54 2016
New Revision: 1765646

URL: http://svn.apache.org/viewvc?rev=1765646&view=rev
Log:
OAK-1312 -  [bundling] Bundle nodes into a document

Handle case where pattern is somehow empty

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlor.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingConfigHandlerTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlorTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlor.java?rev=1765646&r1=1765645&r2=1765646&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlor.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlor.java Wed Oct 19 15:11:54 2016
@@ -22,7 +22,6 @@ package org.apache.jackrabbit.oak.plugin
 import java.util.ArrayList;
 import java.util.List;
 
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 import org.apache.jackrabbit.oak.api.PropertyState;
@@ -30,6 +29,7 @@ import org.apache.jackrabbit.oak.api.Typ
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.apache.jackrabbit.oak.api.Type.STRINGS;
 import static org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty;
 
@@ -67,7 +67,7 @@ public class DocumentBundlor {
     private final List<Include> includes;
 
     public static DocumentBundlor from(NodeState nodeState){
-        Preconditions.checkArgument(nodeState.hasProperty(PROP_PATTERN), "NodeState [%s] does not have required " +
+        checkArgument(nodeState.hasProperty(PROP_PATTERN), "NodeState [%s] does not have required " +
                 "property [%s]", nodeState, PROP_PATTERN);
        return DocumentBundlor.from(nodeState.getStrings(PROP_PATTERN));
     }
@@ -81,11 +81,12 @@ public class DocumentBundlor {
     }
 
     public static DocumentBundlor from(PropertyState prop){
-        Preconditions.checkArgument(META_PROP_PATTERN.equals(prop.getName()));
+        checkArgument(META_PROP_PATTERN.equals(prop.getName()));
         return from(prop.getValue(Type.STRINGS));
     }
 
     private DocumentBundlor(List<Include> includes) {
+        checkArgument(!includes.isEmpty(), "Include list cannot be empty");
         this.includes = ImmutableList.copyOf(includes);
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingConfigHandlerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingConfigHandlerTest.java?rev=1765646&r1=1765645&r2=1765646&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingConfigHandlerTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingConfigHandlerTest.java Wed Oct 19 15:11:54 2016
@@ -19,7 +19,9 @@
 
 package org.apache.jackrabbit.oak.plugins.document.bundlor;
 
+
 import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
 import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
@@ -27,6 +29,7 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.junit.Test;
 
 import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
+import static java.util.Collections.singletonList;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
@@ -57,7 +60,8 @@ public class BundlingConfigHandlerTest {
     private void addBundlorConfigForAsset() throws CommitFailedException {
         NodeBuilder builder = nodeStore.getRoot().builder();
         NodeBuilder bundlor = builder.child("jcr:system").child("documentstore").child("bundlor");
-        bundlor.child("app:Asset").setProperty(DocumentBundlor.PROP_PATTERN, "metadata");
+        bundlor.child("app:Asset").setProperty(DocumentBundlor.PROP_PATTERN,
+                singletonList("metadata"), Type.STRINGS);
         nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlorTest.java?rev=1765646&r1=1765645&r2=1765646&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlorTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlorTest.java Wed Oct 19 15:11:54 2016
@@ -19,8 +19,9 @@
 
 package org.apache.jackrabbit.oak.plugins.document.bundlor;
 
+import java.util.Collections;
+
 import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.junit.Test;
 
@@ -53,6 +54,11 @@ public class DocumentBundlorTest {
         DocumentBundlor.from(builder.getNodeState());
     }
 
+    @Test(expected = IllegalArgumentException.class)
+    public void invalid2() throws Exception{
+        DocumentBundlor.from(Collections.<String>emptyList());
+    }
+
     @Test
     public void asPropertyState() throws Exception{
         builder.setProperty(createProperty(PROP_PATTERN, asList("x", "x/y", "z"), STRINGS));