Index: oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java (revision 6b581b300983ca81fa88d315a4ea9ac81aeb6842) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/core/MutableTree.java (revision ) @@ -26,6 +26,7 @@ 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; import java.util.Collections; import java.util.Set; @@ -42,10 +43,10 @@ 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; class MutableTree extends AbstractTree { @@ -191,6 +192,7 @@ @Override public Tree addChild(String name) { + checkArgument(!isHidden(name)); beforeWrite(); if (!super.hasChild(name)) { nodeBuilder.setChildNode(name); @@ -266,6 +268,7 @@ @Override public void setProperty(PropertyState property) { + checkArgument(!isHidden(property.getName())); beforeWrite(); nodeBuilder.setProperty(property); root.updated(); @@ -273,6 +276,7 @@ @Override public void setProperty(String name, T value) { + checkArgument(!isHidden(name)); beforeWrite(); nodeBuilder.setProperty(name, value); root.updated(); @@ -280,6 +284,7 @@ @Override public void setProperty(String name, T value, Type type) { + checkArgument(!isHidden(name)); beforeWrite(); nodeBuilder.setProperty(name, value, type); root.updated(); Index: oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenPropertyTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenPropertyTest.java (revision 6b581b300983ca81fa88d315a4ea9ac81aeb6842) +++ oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenPropertyTest.java (revision ) @@ -30,12 +30,9 @@ 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; /** @@ -43,16 +40,14 @@ */ 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 @@ } } - @Ignore("OAK-1424") // FIXME : OAK-1424 @Test public void testCreateHiddenProperty() { Tree a = root.getTree("/a"); @@ -110,7 +104,6 @@ } } - @Ignore("OAK-1424") // FIXME : OAK-1424 @Test public void testCreateHiddenProperty2() { Tree a = root.getTree("/a"); @@ -123,7 +116,6 @@ } } - @Ignore("OAK-1424") // FIXME : OAK-1424 @Test public void testCreateHiddenProperty3() { Tree a = root.getTree("/a"); \ No newline at end of file Index: oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java (revision 6b581b300983ca81fa88d315a4ea9ac81aeb6842) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/api/Tree.java (revision ) @@ -251,9 +251,10 @@ * 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 @@ * 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 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. */ void setProperty(@Nonnull String name, @Nonnull T value) throws IllegalArgumentException; @@ -323,11 +326,12 @@ /** * 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 The type of this property. - * @throws IllegalArgumentException if the given name is invalid + * @throws IllegalArgumentException if {@code name} is not valid. */ void setProperty(@Nonnull String name, @Nonnull T value, Type type) throws IllegalArgumentException; Index: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/WorkspaceDelegate.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/WorkspaceDelegate.java (revision 6b581b300983ca81fa88d315a4ea9ac81aeb6842) +++ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/WorkspaceDelegate.java (revision ) @@ -16,17 +16,24 @@ */ package org.apache.jackrabbit.oak.jcr.delegate; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES; +import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; +import static org.apache.jackrabbit.JcrConstants.JCR_UUID; +import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.NODE_TYPES_PATH; + import java.util.ArrayList; import java.util.List; import java.util.Map; + import javax.annotation.Nonnull; import javax.jcr.ItemExistsException; 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; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Root; @@ -43,12 +50,6 @@ import org.apache.jackrabbit.oak.util.TreeUtil; import org.apache.jackrabbit.util.Text; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES; -import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; -import static org.apache.jackrabbit.JcrConstants.JCR_UUID; -import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.NODE_TYPES_PATH; - /** * Delegate class for workspace operations. */ @@ -93,45 +94,40 @@ 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); + String userId = sessionDelegate.getAuthInfo().getUserID(); + new WorkspaceCopy(src, destParent, Text.getName(destPath)).perform(root, userId); - sessionDelegate.refresh(true); + sessionDelegate.refresh(true); - } catch (CommitFailedException e) { - throw e.asRepositoryException(); - } + } - } //---------------------------< internal >----------------------------------- private static final class WorkspaceCopy { - private final Map 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)); + root.commit(ImmutableMap.of( + "copy-source", source.getPath())); + } 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 +155,8 @@ 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); } } Index: oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenTreeTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenTreeTest.java (revision 6b581b300983ca81fa88d315a4ea9ac81aeb6842) +++ oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/HiddenTreeTest.java (revision ) @@ -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.Ignore; -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.Test; + /** * Test to make sure hidden trees are never exposed. */ @@ -99,7 +98,6 @@ assertEquals(0, parent.getChildrenCount(1)); } - @Ignore("OAK-1424") // FIXME : OAK-1424 @Test public void testCreateHiddenChild() { try { \ No newline at end of file Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java (revision 6b581b300983ca81fa88d315a4ea9ac81aeb6842) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ReadWriteVersionManager.java (revision ) @@ -18,6 +18,28 @@ */ package org.apache.jackrabbit.oak.plugins.version; +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 org.apache.jackrabbit.JcrConstants.JCR_BASEVERSION; +import static org.apache.jackrabbit.JcrConstants.JCR_CREATED; +import static org.apache.jackrabbit.JcrConstants.JCR_ISCHECKEDOUT; +import static org.apache.jackrabbit.JcrConstants.JCR_PREDECESSORS; +import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; +import static org.apache.jackrabbit.JcrConstants.JCR_ROOTVERSION; +import static org.apache.jackrabbit.JcrConstants.JCR_SUCCESSORS; +import static org.apache.jackrabbit.JcrConstants.JCR_UUID; +import static org.apache.jackrabbit.JcrConstants.JCR_VERSIONABLEUUID; +import static org.apache.jackrabbit.JcrConstants.JCR_VERSIONHISTORY; +import static org.apache.jackrabbit.JcrConstants.JCR_VERSIONLABELS; +import static org.apache.jackrabbit.JcrConstants.NT_VERSION; +import static org.apache.jackrabbit.JcrConstants.NT_VERSIONHISTORY; +import static org.apache.jackrabbit.JcrConstants.NT_VERSIONLABELS; +import static org.apache.jackrabbit.oak.plugins.version.Utils.uuidFromNode; +import static org.apache.jackrabbit.oak.plugins.version.VersionConstants.JCR_COPIED_FROM; +import static org.apache.jackrabbit.oak.plugins.version.VersionConstants.REP_VERSIONSTORAGE; +import static org.apache.jackrabbit.oak.plugins.version.VersionConstants.VERSION_STORE_PATH; + import java.util.Calendar; import java.util.Collections; import java.util.Iterator; @@ -30,7 +52,6 @@ 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,35 +59,13 @@ 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; -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 org.apache.jackrabbit.JcrConstants.JCR_BASEVERSION; -import static org.apache.jackrabbit.JcrConstants.JCR_CREATED; -import static org.apache.jackrabbit.JcrConstants.JCR_ISCHECKEDOUT; -import static org.apache.jackrabbit.JcrConstants.JCR_PREDECESSORS; -import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; -import static org.apache.jackrabbit.JcrConstants.JCR_ROOTVERSION; -import static org.apache.jackrabbit.JcrConstants.JCR_SUCCESSORS; -import static org.apache.jackrabbit.JcrConstants.JCR_UUID; -import static org.apache.jackrabbit.JcrConstants.JCR_VERSIONABLEUUID; -import static org.apache.jackrabbit.JcrConstants.JCR_VERSIONHISTORY; -import static org.apache.jackrabbit.JcrConstants.JCR_VERSIONLABELS; -import static org.apache.jackrabbit.JcrConstants.NT_VERSION; -import static org.apache.jackrabbit.JcrConstants.NT_VERSIONHISTORY; -import static org.apache.jackrabbit.JcrConstants.NT_VERSIONLABELS; -import static org.apache.jackrabbit.oak.plugins.version.Utils.uuidFromNode; -import static org.apache.jackrabbit.oak.plugins.version.VersionConstants.JCR_COPIED_FROM; -import static org.apache.jackrabbit.oak.plugins.version.VersionConstants.REP_VERSIONSTORAGE; -import static org.apache.jackrabbit.oak.plugins.version.VersionConstants.VERSION_STORE_PATH; - /** * TODO document */ @@ -134,9 +133,9 @@ node.setProperty(JCR_PRIMARYTYPE, nt, Type.NAME); } } - PropertyState copiedFrom = versionable.getProperty(VersionConstants.HIDDEN_COPY_SOURCE); + String copiedFrom = null; // FIXME get copiedFrom = CommitInfo.getInfo().get("copied-from") if (copiedFrom != null) { - node.setProperty(JCR_COPIED_FROM, copiedFrom.getValue(Type.STRING), Type.WEAKREFERENCE); + node.setProperty(JCR_COPIED_FROM, copiedFrom, Type.WEAKREFERENCE); } // use jcr:rootVersion node to detect if we need to initialize the Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionConstants.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionConstants.java (revision 6b581b300983ca81fa88d315a4ea9ac81aeb6842) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionConstants.java (revision ) @@ -160,10 +160,4 @@ 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