Author: chetanm
Date: Wed Oct 19 15:07:04 2016
New Revision: 1765621

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

Add a marker property for any realive bundled node which gets added

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

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingHandler.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingHandler.java?rev=1765621&r1=1765620&r2=1765621&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingHandler.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingHandler.java
 Wed Oct 19 15:07:04 2016
@@ -24,11 +24,18 @@ import java.util.Set;
 
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 import static org.apache.jackrabbit.oak.commons.PathUtils.ROOT_PATH;
 
 public class BundlingHandler {
+    /**
+     * True property which is used to mark the presence of relative node
+     * This needs to be set when a bundled relative node is added
+     */
+    private static final PropertyState NODE_PRESENCE_MARKER =
+            PropertyStates.createProperty(DocumentBundlor.META_PROP_NODE, 
Boolean.TRUE);
     private final BundledTypesRegistry registry;
     private final String path;
     private final BundlingContext ctx;
@@ -67,7 +74,7 @@ public class BundlingHandler {
         Set<PropertyState> metaProps = Collections.emptySet();
         Matcher childMatcher = ctx.matcher.next(name);
         if (childMatcher.isMatch()) {
-            //TODO Add meta prop for bundled child node
+            metaProps = Collections.singleton(NODE_PRESENCE_MARKER);
             childContext = createChildContext(childMatcher);
         } else {
             DocumentBundlor bundlor = registry.getBundlor(state);

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=1765621&r1=1765620&r2=1765621&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:07:04 2016
@@ -39,11 +39,18 @@ public class DocumentBundlor {
      */
     public static final String META_PROP_PATTERN = ":pattern";
 
+    /**
+     * Hidden property name used as suffix for relative node path
+     * to indicate presence of that node. So for a relative node 'jcr:content'
+     * the parent node must have a property 'jcr:content/:self
+     */
+    public static final String META_PROP_NODE = ":self";
+
     public static final String PROP_PATTERN = "pattern";
     private final List<Include> includes;
 
     public static DocumentBundlor from(NodeState nodeState){
-        Preconditions.checkArgument(nodeState.hasProperty(PROP_PATTERN), 
"NodeStated [%s] does not have required " +
+        Preconditions.checkArgument(nodeState.hasProperty(PROP_PATTERN), 
"NodeState [%s] does not have required " +
                 "property [%s]", nodeState, PROP_PATTERN);
        return DocumentBundlor.from(nodeState.getStrings(PROP_PATTERN));
     }


Reply via email to