jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1570187 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/api/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ oak-core/src/test/java/org/a...
Date Thu, 20 Feb 2014 13:45:56 GMT
Author: angela
Date: Thu Feb 20 13:45:56 2014
New Revision: 1570187

URL: http://svn.apache.org/r1570187
Log:
OAK-1424 : Oak API allows to create hidden tree and properties

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionConstants.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditor.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditorProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenPropertyTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenTreeTest.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/WorkspaceDelegate.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java?rev=1570187&r1=1570186&r2=1570187&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java Thu
Feb 20 13:45:56 2014
@@ -251,9 +251,10 @@ public interface Tree {
      * Add a child with the given {@code name}. Does nothing if such a child
      * already exists.
      *
-     * @param name name of the child
+     * @param name name of the child. A valid name does not start with a colon,
+     *             is not empty and does not contain a forward slash.
      * @return the {@code Tree} instance of the child with the given {@code name}.
-     * @throws IllegalArgumentException if the given name is invalid
+     * @throws IllegalArgumentException if {@code name} is not valid.
      */
     @Nonnull
     Tree addChild(@Nonnull String name) throws IllegalArgumentException;
@@ -304,18 +305,20 @@ public interface Tree {
      * Set a property state
      *
      * @param property The property state to set
-     * @throws IllegalArgumentException if the property name is invalid
+     * @throws IllegalArgumentException if {@code property} has a non valid name. A valid
name
+     *         does not start with a colon, is not empty and does not contain a forward slash.
      */
     void setProperty(@Nonnull PropertyState property);
 
     /**
      * Set a property state
      *
-     * @param name  The name of this property
+     * @param name  The name of this property. A valid name does not start with a colon,
+     *              is not empty and does not contain a forward slash.
      * @param value The value of this property
      * @param <T>   The type of this property. Must be one of {@code String, Blob,
byte[], Long, Integer, Double, Boolean, BigDecimal}
-     * @throws IllegalArgumentException if {@code T} is not one of the above types,
-     *                                  or if the given name is invalid
+     * @throws IllegalArgumentException if {@code T} is not one of the above types or
+     *         if {@code name} is not valid.
      */
     <T> void setProperty(@Nonnull String name, @Nonnull T value)
             throws IllegalArgumentException;
@@ -323,11 +326,12 @@ public interface Tree {
     /**
      * Set a property state
      *
-     * @param name  The name of this property
+     * @param name  The name of this property. A valid name does not start with a colon,
+     *              is not empty and does not contain a forward slash.
      * @param value The value of this property
      * @param type  The type of this property.
      * @param <T>   The type of this property.
-     * @throws IllegalArgumentException if the given name is invalid
+     * @throws IllegalArgumentException if {@code name} is not valid.
      */
     <T> void setProperty(@Nonnull String name, @Nonnull T value, Type<T> type)
             throws IllegalArgumentException;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java?rev=1570187&r1=1570186&r2=1570187&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java
Thu Feb 20 13:45:56 2014
@@ -18,34 +18,33 @@
  */
 package org.apache.jackrabbit.oak.core;
 
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.collect.Iterables.indexOf;
-import static org.apache.jackrabbit.oak.api.Type.NAME;
-import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
-import static org.apache.jackrabbit.oak.commons.PathUtils.isAbsolute;
-
 import java.util.Collections;
 import java.util.Set;
-
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Sets;
-
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.core.AbstractRoot.Move;
 import org.apache.jackrabbit.oak.plugins.memory.MultiGenericPropertyState;
+import org.apache.jackrabbit.oak.plugins.memory.PropertyBuilder;
 import org.apache.jackrabbit.oak.plugins.tree.AbstractTree;
 import org.apache.jackrabbit.oak.plugins.tree.TreeConstants;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.apache.jackrabbit.oak.plugins.memory.PropertyBuilder;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.indexOf;
+import static org.apache.jackrabbit.oak.api.Type.NAME;
+import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
+import static org.apache.jackrabbit.oak.commons.PathUtils.isAbsolute;
+import static org.apache.jackrabbit.oak.spi.state.NodeStateUtils.isHidden;
 
 class MutableTree extends AbstractTree {
 
@@ -194,6 +193,7 @@ class MutableTree extends AbstractTree {
 
     @Override
     public Tree addChild(String name) {
+        checkArgument(!isHidden(name));
         beforeWrite();
         if (!super.hasChild(name)) {
             nodeBuilder.setChildNode(name);
@@ -269,6 +269,7 @@ class MutableTree extends AbstractTree {
 
     @Override
     public void setProperty(PropertyState property) {
+        checkArgument(!isHidden(property.getName()));
         beforeWrite();
         nodeBuilder.setProperty(property);
         root.updated();
@@ -276,6 +277,7 @@ class MutableTree extends AbstractTree {
 
     @Override
     public <T> void setProperty(String name, T value) {
+        checkArgument(!isHidden(name));
         beforeWrite();
         nodeBuilder.setProperty(name, value);
         root.updated();
@@ -283,6 +285,7 @@ class MutableTree extends AbstractTree {
 
     @Override
     public <T> void setProperty(String name, T value, Type<T> type) {
+        checkArgument(!isHidden(name));
         beforeWrite();
         nodeBuilder.setProperty(name, value, type);
         root.updated();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java?rev=1570187&r1=1570186&r2=1570187&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java
Thu Feb 20 13:45:56 2014
@@ -22,15 +22,14 @@ import java.util.Calendar;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
-
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import javax.jcr.RepositoryException;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Sets;
-
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
@@ -38,10 +37,10 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.core.ImmutableRoot;
-import org.apache.jackrabbit.oak.plugins.tree.ImmutableTree;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.plugins.identifier.IdentifierManager;
 import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager;
+import org.apache.jackrabbit.oak.plugins.tree.ImmutableTree;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.util.ISO8601;
 
@@ -109,12 +108,13 @@ class ReadWriteVersionManager extends Re
      * {@code versionable} node.
      *
      * @param versionable the versionable node.
+     * @param infoMap The additional information as provided by {@link org.apache.jackrabbit.oak.spi.commit.CommitInfo#getInfo()}
      * @return the version history node.
      * @throws IllegalArgumentException if the given node does not have a
      *                                  {@code jcr:uuid} property.
      */
     @Nonnull
-    NodeBuilder getOrCreateVersionHistory(@Nonnull NodeBuilder versionable)
+    NodeBuilder getOrCreateVersionHistory(@Nonnull NodeBuilder versionable, @Nonnull Map<String,
Object> infoMap)
             throws CommitFailedException {
         checkNotNull(versionable);
         String vUUID = uuidFromNode(versionable);
@@ -134,9 +134,9 @@ class ReadWriteVersionManager extends Re
                 node.setProperty(JCR_PRIMARYTYPE, nt, Type.NAME);
             }
         }
-        PropertyState copiedFrom = versionable.getProperty(VersionConstants.HIDDEN_COPY_SOURCE);
+        Object copiedFrom = infoMap.get(JCR_COPIED_FROM);
         if (copiedFrom != null) {
-            node.setProperty(JCR_COPIED_FROM, copiedFrom.getValue(Type.STRING), Type.WEAKREFERENCE);
+            node.setProperty(JCR_COPIED_FROM, copiedFrom.toString(), Type.WEAKREFERENCE);
         }
 
         // use jcr:rootVersion node to detect if we need to initialize the
@@ -171,7 +171,7 @@ class ReadWriteVersionManager extends Re
 
     public void checkin(@Nonnull NodeBuilder versionable)
             throws CommitFailedException {
-        NodeBuilder history = getOrCreateVersionHistory(versionable);
+        NodeBuilder history = getOrCreateVersionHistory(versionable, Collections.EMPTY_MAP);
         createVersion(history, versionable);
     }
 
@@ -180,7 +180,7 @@ class ReadWriteVersionManager extends Re
                         @Nullable VersionSelector selector)
             throws CommitFailedException {
         String versionPath = getIdentifierManager().getPath(versionUUID);
-        NodeBuilder history = getOrCreateVersionHistory(versionable);
+        NodeBuilder history = getOrCreateVersionHistory(versionable, Collections.EMPTY_MAP);
         NodeBuilder version = null;
         if (versionPath != null) {
             String versionName = PathUtils.getName(versionPath);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionConstants.java?rev=1570187&r1=1570186&r2=1570187&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionConstants.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionConstants.java
Thu Feb 20 13:45:56 2014
@@ -160,10 +160,4 @@ public interface VersionConstants extend
             VersionConstants.REP_ACTIVITIES,
             VersionConstants.REP_CONFIGURATIONS
     );
-
-    /**
-     * Name of the hidden property that indicates the ID of the base version
-     * of a versionable node that has been copied.
-     */
-    String HIDDEN_COPY_SOURCE = ":copySource";
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditor.java?rev=1570187&r1=1570186&r2=1570187&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditor.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditor.java
Thu Feb 20 13:45:56 2014
@@ -26,8 +26,9 @@ import org.apache.jackrabbit.oak.api.Com
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.plugins.tree.ImmutableTree;
 import org.apache.jackrabbit.oak.plugins.lock.LockConstants;
+import org.apache.jackrabbit.oak.plugins.tree.ImmutableTree;
+import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
 import org.apache.jackrabbit.oak.spi.commit.Editor;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
@@ -52,21 +53,25 @@ class VersionEditor implements Editor {
     private NodeState before;
     private NodeState after;
     private boolean isReadOnly;
+    private CommitInfo commitInfo;
 
     public VersionEditor(@Nonnull NodeBuilder versionStore,
-                         @Nonnull NodeBuilder workspaceRoot) {
+                         @Nonnull NodeBuilder workspaceRoot,
+                         @Nonnull CommitInfo commitInfo) {
         this(null, new ReadWriteVersionManager(checkNotNull(versionStore),
-                checkNotNull(workspaceRoot)), workspaceRoot, "");
+                checkNotNull(workspaceRoot)), workspaceRoot, "", commitInfo);
     }
 
     VersionEditor(@Nullable VersionEditor parent,
                   @Nonnull ReadWriteVersionManager vMgr,
                   @Nonnull NodeBuilder node,
-                  @Nonnull String name) {
+                  @Nonnull String name,
+                  @Nonnull CommitInfo commitInfo) {
         this.parent = parent;
         this.vMgr = checkNotNull(vMgr);
         this.node = checkNotNull(node);
         this.name = checkNotNull(name);
+        this.commitInfo = commitInfo;
     }
 
     @Override
@@ -75,7 +80,7 @@ class VersionEditor implements Editor {
         this.before = before;
         this.after = after;
         if (isVersionable()) {
-            vMgr.getOrCreateVersionHistory(node);
+            vMgr.getOrCreateVersionHistory(node, commitInfo.getInfo());
         }
         // calculate isReadOnly state
         if (after.exists() || isVersionable()) {
@@ -167,12 +172,12 @@ class VersionEditor implements Editor {
     @Override
     public Editor childNodeChanged(String name, NodeState before,
             NodeState after) {
-        return new VersionEditor(this, vMgr, node.child(name), name);
+        return new VersionEditor(this, vMgr, node.child(name), name, commitInfo);
     }
 
     @Override
     public Editor childNodeDeleted(String name, NodeState before) {
-        return new VersionEditor(this, vMgr, MISSING_NODE.builder(), name);
+        return new VersionEditor(this, vMgr, MISSING_NODE.builder(), name, commitInfo);
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditorProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditorProvider.java?rev=1570187&r1=1570186&r2=1570187&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditorProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionEditorProvider.java
Thu Feb 20 13:45:56 2014
@@ -16,9 +16,6 @@
  */
 package org.apache.jackrabbit.oak.plugins.version;
 
-import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
-import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.JCR_VERSIONSTORAGE;
-
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
@@ -29,6 +26,9 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
+import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
+import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.JCR_VERSIONSTORAGE;
+
 @Component
 @Service(EditorProvider.class)
 public class VersionEditorProvider implements EditorProvider {
@@ -46,7 +46,7 @@ public class VersionEditorProvider imple
         }
         NodeBuilder versionStorage = system.child(JCR_VERSIONSTORAGE);
         return new VisibleEditor(new CompositeEditor(
-                new VersionEditor(versionStorage, builder),
+                new VersionEditor(versionStorage, builder, info),
                 new VersionStorageEditor(versionStorage, builder)));
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java?rev=1570187&r1=1570186&r2=1570187&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
Thu Feb 20 13:45:56 2014
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.oak.plugins.version;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import javax.annotation.Nonnull;
@@ -111,7 +112,7 @@ public class VersionablePathHook impleme
             if (JcrConstants.JCR_VERSIONHISTORY.equals(after.getName()) && nodeAfter.isVersionable(versionManager))
{
                 NodeBuilder vhBuilder;
                 try {
-                    vhBuilder = versionManager.getOrCreateVersionHistory(nodeAfter.builder);
+                    vhBuilder = versionManager.getOrCreateVersionHistory(nodeAfter.builder,
Collections.EMPTY_MAP);
                 } catch (CommitFailedException e) {
                     exceptions.add(e);
                     // stop further comparison

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenPropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenPropertyTest.java?rev=1570187&r1=1570186&r2=1570187&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenPropertyTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenPropertyTest.java
Thu Feb 20 13:45:56 2014
@@ -16,43 +16,38 @@
  */
 package org.apache.jackrabbit.oak.security.authorization.evaluation;
 
-import static org.apache.jackrabbit.oak.api.Type.NAME;
-import static org.apache.jackrabbit.oak.api.Type.STRING;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 import java.util.Set;
 
 import com.google.common.collect.Sets;
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.plugins.memory.PropertyBuilder;
-import org.apache.jackrabbit.oak.plugins.version.VersionConstants;
-import org.apache.jackrabbit.oak.spi.state.MoveDetector;
+import org.apache.jackrabbit.oak.plugins.tree.TreeConstants;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
+import static org.apache.jackrabbit.oak.api.Type.NAME;
+import static org.apache.jackrabbit.oak.api.Type.STRING;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 /**
  * Test for the hidden {@link org.apache.jackrabbit.oak.plugins.tree.TreeConstants#OAK_CHILD_ORDER}
property
  */
 public class HiddenPropertyTest extends AbstractOakCoreTest {
 
-    private String[] hiddenProps = new String[] {":hiddenProp", MoveDetector.SOURCE_PATH,
VersionConstants.HIDDEN_COPY_SOURCE};
+    private final String[] hiddenProps = new String[] {TreeConstants.OAK_CHILD_ORDER};
     @Override
     @Before
     public void before() throws Exception {
         super.before();
 
-        Tree a = root.getTree("/a");
-        a.setProperty(":hiddenProp", "val", STRING);
-        a.setProperty(MoveDetector.SOURCE_PATH, "/some/path", Type.PATH);
-        a.setProperty(VersionConstants.HIDDEN_COPY_SOURCE, "abc", STRING);
+        Tree b = root.getTree("/a/b");
+        b.orderBefore("bb");
         root.commit();
     }
 
@@ -97,7 +92,6 @@ public class HiddenPropertyTest extends 
         }
     }
 
-    @Ignore("OAK-1424") // FIXME : OAK-1424
     @Test
     public void testCreateHiddenProperty() {
         Tree a = root.getTree("/a");
@@ -110,7 +104,6 @@ public class HiddenPropertyTest extends 
         }
     }
 
-    @Ignore("OAK-1424") // FIXME : OAK-1424
     @Test
     public void testCreateHiddenProperty2() {
         Tree a = root.getTree("/a");
@@ -123,7 +116,6 @@ public class HiddenPropertyTest extends 
         }
     }
 
-    @Ignore("OAK-1424") // FIXME : OAK-1424
     @Test
     public void testCreateHiddenProperty3() {
         Tree a = root.getTree("/a");

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenTreeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenTreeTest.java?rev=1570187&r1=1570186&r2=1570187&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenTreeTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenTreeTest.java
Thu Feb 20 13:45:56 2014
@@ -16,17 +16,16 @@
  */
 package org.apache.jackrabbit.oak.security.authorization.evaluation;
 
+import org.apache.jackrabbit.oak.api.Tree;
+import org.junit.Before;
+import org.junit.Test;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import org.apache.jackrabbit.oak.api.Tree;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
 /**
  * Test to make sure hidden trees are never exposed.
  */
@@ -100,7 +99,6 @@ public class HiddenTreeTest extends Abst
         assertEquals(0, parent.getChildrenCount(1));
     }
 
-    @Ignore("OAK-1424") // FIXME : OAK-1424
     @Test
     public void testCreateHiddenChild() {
         try {

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/WorkspaceDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/WorkspaceDelegate.java?rev=1570187&r1=1570186&r2=1570187&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/WorkspaceDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/WorkspaceDelegate.java
Thu Feb 20 13:45:56 2014
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.oak.jcr.delegate;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import javax.annotation.Nonnull;
@@ -25,6 +26,7 @@ import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.ConstraintViolationException;
 
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Maps;
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
@@ -93,45 +95,46 @@ public class WorkspaceDelegate {
 
         accessManager.checkPermissions(destPath, Permissions.getString(Permissions.NODE_TYPE_MANAGEMENT));
 
-        try {
-            Tree typeRoot = root.getTree(NODE_TYPES_PATH);
-            new WorkspaceCopy(src, destParent, Text.getName(destPath), typeRoot, sessionDelegate.getAuthInfo().getUserID()).perform();
-            context.getSessionDelegate().commit(root);
-            sessionDelegate.refresh(true);
-        } catch (CommitFailedException e) {
-            throw e.asRepositoryException();
-        }
+        String userId = sessionDelegate.getAuthInfo().getUserID();
+        new WorkspaceCopy(src, destParent, Text.getName(destPath)).perform(root, userId);
+        sessionDelegate.refresh(true);
     }
 
     //---------------------------< internal >-----------------------------------
 
     private static final class WorkspaceCopy {
-
         private final Map<String, String> translated = Maps.newHashMap();
 
-        private final Tree src;
+        private final Tree source;
         private final Tree destParent;
         private final String destName;
 
-        private final Tree typeRoot;
-        private final String userId;
-
-        public WorkspaceCopy(@Nonnull Tree src, @Nonnull Tree destParent,
-                             @Nonnull String destName, @Nonnull Tree typeRoot,
-                             @Nonnull String userId) {
-            this.src = src;
+        public WorkspaceCopy(@Nonnull Tree source, @Nonnull Tree destParent, @Nonnull String
destName) {
+            this.source = source;
             this.destParent = destParent;
             this.destName = destName;
-            this.typeRoot = typeRoot;
-            this.userId = userId;
         }
 
-        public void perform() throws RepositoryException {
-            copy(src, destParent, destName);
-            updateReferences(src, destParent.getChild(destName));
+        public void perform(@Nonnull Root root, @Nonnull String userId) throws RepositoryException
{
+            try {
+                Tree typeRoot = root.getTree(NODE_TYPES_PATH);
+                copy(source, destParent, destName, typeRoot, userId);
+                updateReferences(source, destParent.getChild(destName));
+
+                Map<String, String> copyInfo = new HashMap<String, String>();
+                copyInfo.put("copy-source", source.getPath());
+                if (TreeUtil.isNodeType(source, JcrConstants.MIX_VERSIONABLE, typeRoot))
{
+                    String sourceBaseVersionId = source.getProperty(JcrConstants.JCR_BASEVERSION).getValue(Type.STRING);
+                    copyInfo.put(VersionConstants.JCR_COPIED_FROM, sourceBaseVersionId);
+                }
+                root.commit(ImmutableMap.<String, Object>copyOf(copyInfo));
+            } catch (CommitFailedException e) {
+                throw e.asRepositoryException();
+            }
         }
 
-        private void copy(@Nonnull Tree source, @Nonnull Tree destParent, @Nonnull String
destName) throws RepositoryException {
+        private void copy(Tree source, Tree destParent, String destName, Tree typeRoot, String
userId)
+                throws RepositoryException {
             String primaryType = TreeUtil.getPrimaryTypeName(source);
             if (primaryType == null) {
                 primaryType = TreeUtil.getDefaultChildType(typeRoot, destParent, destName);
@@ -159,12 +162,8 @@ public class WorkspaceDelegate {
                     dest.setProperty(property);
                 }
             }
-            if (TreeUtil.isNodeType(source, JcrConstants.MIX_VERSIONABLE, typeRoot)) {
-                String sourceBaseVersionId = source.getProperty(JcrConstants.JCR_BASEVERSION).getValue(Type.STRING);
-                dest.setProperty(VersionConstants.HIDDEN_COPY_SOURCE, sourceBaseVersionId,
Type.PATH);
-            }
             for (Tree child : source.getChildren()) {
-                copy(child, dest, child.getName());
+                copy(child, dest, child.getName(), typeRoot, userId);
             }
         }
 



Mime
View raw message