Author: chetanm
Date: Thu Nov  3 07:58:47 2016
New Revision: 1767831

URL: http://svn.apache.org/viewvc?rev=1767831&view=rev
Log:
OAK-4981 - Config option to disable specific bundling config

Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledTypesRegistry.java
    
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/BundledTypesRegistryTest.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledTypesRegistry.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledTypesRegistry.java?rev=1767831&r1=1767830&r2=1767831&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledTypesRegistry.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledTypesRegistry.java
 Thu Nov  3 07:58:47 2016
@@ -51,7 +51,11 @@ public class BundledTypesRegistry {
     public static BundledTypesRegistry from(NodeState configParentState){
         Map<String, DocumentBundlor> bundlors = Maps.newHashMap();
         for (ChildNodeEntry e : configParentState.getChildNodeEntries()){
-            bundlors.put(e.getName(), DocumentBundlor.from(e.getNodeState()));
+            NodeState config = e.getNodeState();
+            if (config.getBoolean(DocumentBundlor.PROP_DISABLED)){
+                continue;
+            }
+            bundlors.put(e.getName(), DocumentBundlor.from(config));
         }
         return new BundledTypesRegistry(bundlors);
     }

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=1767831&r1=1767830&r2=1767831&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
 Thu Nov  3 07:58:47 2016
@@ -65,7 +65,11 @@ public class DocumentBundlor {
      */
     public static final String META_PROP_NON_BUNDLED_CHILD = 
HAS_CHILD_PROP_PREFIX + "non-bundled";
 
-
+    /**
+     * Boolean property. If set to true then that bundlor config would be 
considered as disabled
+     * and would not be used
+     */
+    public static final String PROP_DISABLED = "disabled";
 
     public static final String PROP_PATTERN = "pattern";
     private final List<Include> includes;

Modified: 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledTypesRegistryTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledTypesRegistryTest.java?rev=1767831&r1=1767830&r2=1767831&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledTypesRegistryTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundledTypesRegistryTest.java
 Thu Nov  3 07:58:47 2016
@@ -54,6 +54,14 @@ public class BundledTypesRegistryTest {
     }
 
     @Test
+    public void disabledIgnored() throws Exception{
+        builder.child("nt:file").setProperty(createProperty(PROP_PATTERN, 
asList("jcr:content"), STRINGS));
+        builder.child("nt:file").setProperty(DocumentBundlor.PROP_DISABLED, 
true);
+        BundledTypesRegistry registry = 
BundledTypesRegistry.from(builder.getNodeState());
+        assertTrue(registry.getBundlors().isEmpty());
+    }
+
+    @Test
     public void mixin() throws Exception{
         builder.child("mix:foo").setProperty(createProperty(PROP_PATTERN, 
asList("jcr:content"), STRINGS));
         BundledTypesRegistry registry = 
BundledTypesRegistry.from(builder.getNodeState());


Reply via email to