Index: oak-jcr/pom.xml IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-jcr/pom.xml (date 1362603615000) +++ oak-jcr/pom.xml (date 1362606184000) @@ -223,7 +223,6 @@ org.apache.jackrabbit.oak.jcr.version.VersionHistoryTest#testGetVersionHistoryFromNode org.apache.jackrabbit.oak.jcr.version.VersionHistoryTest#testGetVersionHistory org.apache.jackrabbit.oak.jcr.version.VersionHistoryTest#testGetVersionHistoryAfterMove - org.apache.jackrabbit.oak.jcr.MoveTest Index: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java (date 1362603615000) +++ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemDelegate.java (date 1362606184000) @@ -24,6 +24,7 @@ import org.apache.jackrabbit.oak.api.Tree.Status; import org.apache.jackrabbit.oak.api.TreeLocation; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.plugins.identifier.IdentifierManager; import static com.google.common.base.Preconditions.checkNotNull; @@ -128,6 +129,12 @@ return getClass().getSimpleName() + '[' + location.getPath() + ']'; } + //------------------------------------------------------------< internal >--- + + protected final IdentifierManager getIdManager() { + return getSessionDelegate().getIdManager(); + } + //------------------------------------------------------------< private >--- /** @@ -139,10 +146,12 @@ @Nonnull private synchronized TreeLocation getLocationInternal() { if (sessionDelegate.getRevision() != revision || !location.exists()) { - location = sessionDelegate.getLocation(location.getPath()); + location = sessionDelegate.getLocation(resolvePath()); revision = sessionDelegate.getRevision(); } return location; } + + protected abstract String resolvePath(); } Index: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java (date 1362603615000) +++ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java (date 1362606184000) @@ -44,6 +44,8 @@ */ public class NodeDelegate extends ItemDelegate { + private final String id; + /** * Create a new {@code NodeDelegate} instance for a valid {@code TreeLocation}. That * is for one where {@code getTree() != null}. @@ -60,15 +62,17 @@ protected NodeDelegate(SessionDelegate sessionDelegate, Tree tree) { super(sessionDelegate, tree.getLocation()); + id = getIdManager().getIdentifier(tree); } private NodeDelegate(SessionDelegate sessionDelegate, TreeLocation location) { super(sessionDelegate, location); + id = getIdManager().getIdentifier(location.getTree()); } @Nonnull public String getIdentifier() throws InvalidItemStateException { - return sessionDelegate.getIdManager().getIdentifier(getTree()); + return getIdManager().getIdentifier(getTree()); } /** @@ -254,6 +258,11 @@ throw new InvalidItemStateException(); } return tree; + } + + @Override + protected String resolvePath() { + return getIdManager().getLocation(id).getPath(); } // -----------------------------------------------------------< private >--- Index: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java (date 1362603615000) +++ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/PropertyDelegate.java (date 1362606184000) @@ -25,7 +25,9 @@ import javax.jcr.ValueFormatException; import org.apache.jackrabbit.oak.api.PropertyState; +import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.TreeLocation; +import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; import org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl; @@ -36,10 +38,21 @@ * items does not exist anymore. */ public class PropertyDelegate extends ItemDelegate { + private final String parentId; + private final String name; PropertyDelegate(SessionDelegate sessionDelegate, TreeLocation location) { super(sessionDelegate, location); + Tree parent = location.getParent().getTree(); + PropertyState property = location.getProperty(); + if (parent == null || property == null) { + parentId = PathUtils.getParentPath(location.getPath()); + name = PathUtils.getName(location.getPath()); + } else { + parentId = getIdManager().getIdentifier(parent); + name = property.getName(); - } + } + } /** * Get the value of the property @@ -109,6 +122,13 @@ */ public void remove() throws InvalidItemStateException { getLocation().remove(); + } + + //------------------------------------------------------------< internal >--- + + @Override + protected String resolvePath() { + return PathUtils.concat(getIdManager().getLocation(parentId).getPath(), name); } //------------------------------------------------------------< private >--- Index: oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveTest.java (date 1362603615000) +++ oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/MoveTest.java (date 1362606184000) @@ -21,7 +21,6 @@ import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.test.AbstractJCRTest; -import org.junit.Ignore; import org.junit.Test; /** @@ -88,7 +87,6 @@ assertEquals(sourcePath, node1.getPath()); } - @Ignore("OAK-606") @Test public void testMoveReferenceable() throws Exception { Node node1 = testRootNode.addNode(nodeName1); @@ -96,10 +94,16 @@ Node node2 = testRootNode.addNode(nodeName2); superuser.save(); + Node node1Again = testRootNode.getNode(nodeName1); String destPath = node2.getPath() + '/' + nodeName1; - move(node1.getPath(), destPath, true); + move(node1Again.getPath(), destPath, true); - assertEquals(destPath, node1.getPath()); + assertEquals(destPath, node1Again.getPath()); + + try { + node1.getPath(); + fail(); + } catch (InvalidItemStateException expected) {} } @Test @@ -120,7 +124,6 @@ assertEquals(sourcePath, node1.getPath()); } - @Ignore("OAK-607") @Test public void testMoveNewReferenceable() throws Exception { Node node1 = testRootNode.addNode(nodeName1); @@ -131,9 +134,15 @@ String destPath = node2.getPath() + '/' + nodeName1; move(node1.getPath(), destPath, false); + try { - assertEquals(destPath, node1.getPath()); + assertEquals(destPath, node1.getPath()); + fail(); + } catch (InvalidItemStateException expected) {} superuser.save(); + try { - assertEquals(destPath, node1.getPath()); + assertEquals(destPath, node1.getPath()); + fail(); + } catch (InvalidItemStateException expected) {} } } \ No newline at end of file