svn commit: r602869 - in /lenya/trunk/src: impl/java/org/apache/lenya/cms/publication/ modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/ modules-core/sitemanagement/java/test/org/apache/lenya/cms/site/usecases/ modules-core/sitem...

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Mon Dec 10 03:41:12 2007
New Revision: 602869

URL: http://svn.apache.org/viewvc?rev=602869&view=rev
Log:
Use iteration instead of recursion for deep copies. This fixes bug 44005.

Added:
    lenya/trunk/src/modules-core/sitemanagement/java/test/org/apache/lenya/cms/site/usecases/CopyPasteTest.java
Modified:
    lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
    lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Paste.java
    lenya/trunk/src/modules-core/sitemanagement/usecases/site/copy.jx

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=602869&r1=602868&r2=602869&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 Mon Dec 10 03:41:12 2007
@@ -577,14 +577,14 @@
             throws PublicationException {
 
         SiteStructure site = sourceArea.getSite();
-
-        copyAllLanguageVersions(sourceArea, sourcePath, targetArea, targetPath);
+        SiteNode root = site.getNode(sourcePath);
         
-        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);
+        List preOrder = preOrder(root);
+        for (Iterator i = preOrder.iterator(); i.hasNext(); ) {
+            SiteNode node = (SiteNode) i.next();
+            String nodeSourcePath = node.getPath();
+            String nodeTargetPath = targetPath + nodeSourcePath.substring(sourcePath.length());
+            copyAllLanguageVersions(sourceArea, nodeSourcePath, targetArea, nodeTargetPath);
         }
     }
 

Modified: lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Paste.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Paste.java?rev=602869&r1=602868&r2=602869&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Paste.java (original)
+++ lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Paste.java Mon Dec 10 03:41:12 2007
@@ -77,11 +77,6 @@
                         addErrorMessage("will-paste-in-own-subtree");
                     }
                 }
-                else if(clipboard.getMethod() == Clipboard.METHOD_COPY) {
-                    if(uuid.equals(node.getUuid())) {
-                        addErrorMessage("will-copy-to-self");
-                    }
-                }
             }
         }
     }

Added: lenya/trunk/src/modules-core/sitemanagement/java/test/org/apache/lenya/cms/site/usecases/CopyPasteTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/sitemanagement/java/test/org/apache/lenya/cms/site/usecases/CopyPasteTest.java?rev=602869&view=auto
==============================================================================
--- lenya/trunk/src/modules-core/sitemanagement/java/test/org/apache/lenya/cms/site/usecases/CopyPasteTest.java (added)
+++ lenya/trunk/src/modules-core/sitemanagement/java/test/org/apache/lenya/cms/site/usecases/CopyPasteTest.java Mon Dec 10 03:41:12 2007
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.site.usecases;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.site.SiteStructure;
+import org.apache.lenya.cms.usecase.AbstractUsecaseTest;
+
+public class CopyPasteTest extends AbstractUsecaseTest {
+
+    String PARENT_PATH = "/doctypes";
+    String CHILD_URL = "/test/authoring/doctypes/cforms.html";
+    String VERIFICATION_PATH = "/doctypes/cforms/doctypes/cforms";
+
+    protected String getUsecaseName() {
+        return "sitemanagement.paste";
+    }
+
+    protected Map getParameters() {
+        return Collections.singletonMap("private.sourceUrl", CHILD_URL);
+    }
+
+    protected void prepareUsecase() throws Exception {
+        super.prepareUsecase();
+
+        Publication pub = getPublication("test");
+        SiteStructure site = pub.getArea(Publication.AUTHORING_AREA).getSite();
+        Document parent = site.getNode(PARENT_PATH).getLink(pub.getDefaultLanguage()).getDocument();
+
+        Clipboard clipboard = new Clipboard(parent, Clipboard.METHOD_COPY);
+        ClipboardHelper helper = new ClipboardHelper();
+        helper.saveClipboard(this.context, clipboard);
+    }
+
+    protected void checkPostconditions() throws Exception {
+        super.checkPostconditions();
+        
+        Publication pub = getPublication("test");
+        SiteStructure site = pub.getArea(Publication.AUTHORING_AREA).getSite();
+        assertTrue(site.contains(VERIFICATION_PATH));
+    }
+}

Modified: lenya/trunk/src/modules-core/sitemanagement/usecases/site/copy.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/sitemanagement/usecases/site/copy.jx?rev=602869&r1=602868&r2=602869&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/sitemanagement/usecases/site/copy.jx (original)
+++ lenya/trunk/src/modules-core/sitemanagement/usecases/site/copy.jx Mon Dec 10 03:41:12 2007
@@ -54,9 +54,7 @@
                 <i18n:translate>
                   <i18n:text key="copy-doc-to-clip?"/>
                   <i18n:param>
-                    <strong>
-                      <jx:out value="${usecase.getParameter('document').getLink().getLabel()}"/>
-                    </strong>
+                    <jx:out value="${usecase.getParameter('document').getLink().getLabel()}"/>
                   </i18n:param>
                 </i18n:translate>
               </td>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.