jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1225539 - in /jackrabbit/sandbox/jackrabbit-microkernel/src: main/java/org/apache/jackrabbit/SessionImpl.java main/java/org/apache/jackrabbit/state/NodeState.java test/java/org/apache/jackrabbit/RepositoryTest.java
Date Thu, 29 Dec 2011 14:18:47 GMT
Author: mduerig
Date: Thu Dec 29 14:18:46 2011
New Revision: 1225539

URL: http://svn.apache.org/viewvc?rev=1225539&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
- implement transient move

Modified:
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/SessionImpl.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/SessionImpl.java?rev=1225539&r1=1225538&r2=1225539&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/SessionImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/SessionImpl.java
Thu Dec 29 14:18:46 2011
@@ -22,6 +22,7 @@ package org.apache.jackrabbit;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.security.Authenticator;
 import org.apache.jackrabbit.security.CredentialsInfo;
+import org.apache.jackrabbit.state.NodeState;
 import org.apache.jackrabbit.state.TransientSpace;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
@@ -243,8 +244,14 @@ public class SessionImpl implements Sess
     @Override
     public void move(String srcAbsPath, String destAbsPath) throws RepositoryException {
         checkLive();
-        // todo implement move
-        throw new UnsupportedRepositoryOperationException("move");
+        
+        Path sourcePath = Path.create(workspaceName, srcAbsPath);
+        NodeState sourceParent = NodeState.getNodeState(sessionContext, sourcePath.getParent());
+        if (sourceParent == null) {
+            throw new PathNotFoundException(srcAbsPath);
+        }
+        
+        sourceParent.move(sourcePath.getName(), Path.create(workspaceName, destAbsPath));
     }
 
     @Override

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java?rev=1225539&r1=1225538&r2=1225539&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/NodeState.java
Thu Dec 29 14:18:46 2011
@@ -33,6 +33,7 @@ import org.apache.jackrabbit.state.Chang
 
 import javax.jcr.ItemExistsException;
 import javax.jcr.ItemNotFoundException;
+import javax.jcr.PathNotFoundException;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -78,6 +79,12 @@ public class NodeState {
         nodeDelta.remove();
     }
 
+    public void move(String name, Path destination) throws ItemExistsException, PathNotFoundException,
+            ItemNotFoundException {
+
+        nodeDelta.moveNode(name, destination);
+    }
+
     public void setProperty(String name, JsonValue value) {
         nodeDelta.setValue(name, value);
     }

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java?rev=1225539&r1=1225538&r2=1225539&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/RepositoryTest.java
Thu Dec 29 14:18:46 2011
@@ -1194,6 +1194,28 @@ public class RepositoryTest {
     }
 
     @Test
+    public void move() throws RepositoryException {
+        Session session = getSession();
+
+        Node node = getNode(TEST_PATH);
+        node.addNode("source").addNode("node");
+        node.addNode("target");
+        session.save();
+
+        session.move(TEST_PATH + "/source/node", TEST_PATH + "/target/moved");
+
+        assertFalse(node.hasNode("source/node"));
+        assertTrue(node.hasNode("source"));
+        assertTrue(node.hasNode("target/moved"));
+
+        session.save();
+
+        assertFalse(node.hasNode("source/node"));
+        assertTrue(node.hasNode("source"));
+        assertTrue(node.hasNode("target/moved"));
+    }
+    
+    @Test
     @Ignore // todo implement node type support
     public void setPrimaryType() throws RepositoryException {
         Node testNode = getNode(TEST_PATH);



Mime
View raw message