jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r585507 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
Date Wed, 17 Oct 2007 13:48:59 GMT
Author: jukka
Date: Wed Oct 17 06:48:58 2007
New Revision: 585507

URL: http://svn.apache.org/viewvc?rev=585507&view=rev
Log:
JCR-1176: MemoryFileSystem is different from other FileSystems
    - Moving a folder should move the entire subtree

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java?rev=585507&r1=585506&r2=585507&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
Wed Oct 17 06:48:58 2007
@@ -237,9 +237,33 @@
         return (String[]) result.toArray(new String[0]);
     }
 
-    public void move(String srcPath, String destPath) {
-        Object src = entries.remove(srcPath);
-        entries.put(destPath, src);
+    public void move(String srcPath, String destPath)
+            throws FileSystemException {
+        assertExistence(srcPath);
+        if (exists(destPath)) {
+            throw new FileSystemException("Destination exists: " + destPath);
+        }
+
+        Map moves = new HashMap();
+        moves.put(srcPath, destPath);
+        if (getEntry(srcPath).isFolder()) {
+            srcPath = srcPath + "/";
+            Iterator iterator= entries.keySet().iterator();
+            while (iterator.hasNext()) {
+                String name = (String) iterator.next();
+                if (name.startsWith(srcPath)) {
+                    moves.put(
+                            name,
+                            destPath + "/" + name.substring(srcPath.length()));
+                }
+            }
+        }
+
+        Iterator iterator = moves.entrySet().iterator();
+        while (iterator.hasNext()) {
+            Map.Entry entry = (Map.Entry) iterator.next();
+            entries.put(entry.getValue(), entries.remove(entry.getKey()));
+        }
     }
 
     public void touch(String filePath) throws FileSystemException {



Mime
View raw message