You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2007/11/15 18:29:47 UTC

svn commit: r595371 - /lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java

Author: andreas
Date: Thu Nov 15 09:29:44 2007
New Revision: 595371

URL: http://svn.apache.org/viewvc?rev=595371&view=rev
Log:
Preserve child order in DocumentManagerImpl.copyAll() and moveAll(). This fixes bug 43858.

Modified:
    lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java

Modified: lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java?rev=595371&r1=595370&r2=595371&view=diff
==============================================================================
--- lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java (original)
+++ lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java Thu Nov 15 09:29:44 2007
@@ -20,9 +20,13 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -506,20 +510,31 @@
         SiteStructure site = sourceArea.getSite();
 
         SiteNode root = site.getNode(sourcePath);
-        NodeSet subsite = SiteUtil.getSubSite(this.manager, root);
+        List subsite = preOrder(root);
 
-        for (NodeIterator n = subsite.ascending(); n.hasNext();) {
-            SiteNode node = n.next();
+        for (Iterator n = subsite.iterator(); n.hasNext();) {
+            SiteNode node = (SiteNode) n.next();
             String subPath = node.getPath().substring(sourcePath.length());
             targetArea.getSite().add(targetPath + subPath);
         }
-        for (NodeIterator n = subsite.descending(); n.hasNext();) {
-            SiteNode node = n.next();
+        Collections.reverse(subsite);
+        for (Iterator n = subsite.iterator(); n.hasNext();) {
+            SiteNode node = (SiteNode) n.next();
             String subPath = node.getPath().substring(sourcePath.length());
             moveAllLanguageVersions(sourceArea, sourcePath + subPath, targetArea, targetPath
                     + subPath);
         }
     }
+    
+    protected List preOrder(SiteNode node) {
+    	List list = new ArrayList();
+    	list.add(node);
+    	SiteNode[] children = node.getChildren();
+    	for (int i = 0; i < children.length; i++) {
+    		list.addAll(preOrder(children[i]));
+    	}
+    	return list;
+    }
 
     public void moveAllLanguageVersions(Area sourceArea, String sourcePath, Area targetArea,
             String targetPath) throws PublicationException {
@@ -563,14 +578,13 @@
 
         SiteStructure site = sourceArea.getSite();
 
-        SiteNode root = site.getNode(sourcePath);
-        NodeSet subsite = SiteUtil.getSubSite(this.manager, root);
-
-        for (NodeIterator i = subsite.ascending(); i.hasNext();) {
-            SiteNode node = i.next();
-            String subPath = node.getPath().substring(sourcePath.length());
-            copyAllLanguageVersions(sourceArea, sourcePath + subPath, targetArea, targetPath
-                    + subPath);
+        copyAllLanguageVersions(sourceArea, sourcePath, targetArea, targetPath);
+        
+        SiteNode node = site.getNode(sourcePath);
+        SiteNode[] children = node.getChildren();
+        for (int i = 0; i < children.length; i++) {
+        	String childTargetPath = targetPath + "/" + children[i].getName();
+        	copyAll(sourceArea, children[i].getPath(), targetArea, childTargetPath);
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org