You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by rf...@apache.org on 2007/11/27 23:27:56 UTC

svn commit: r598789 - /lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Restore.java

Author: rfrovarp
Date: Tue Nov 27 14:27:56 2007
New Revision: 598789

URL: http://svn.apache.org/viewvc?rev=598789&view=rev
Log:
Don't allow restore to paths that don't exist. Prevents ghost nodes from bug 43861.

Modified:
    lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Restore.java

Modified: lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Restore.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Restore.java?rev=598789&r1=598788&r2=598789&view=diff
==============================================================================
--- lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Restore.java (original)
+++ lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Restore.java Tue Nov 27 14:27:56 2007
@@ -17,8 +17,11 @@
  */
 package org.apache.lenya.cms.site.usecases;
 
+import org.apache.lenya.cms.publication.Area;
 import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentLocator;
 import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.site.SiteUtil;
 import org.apache.lenya.cms.workflow.WorkflowUtil;
 import org.apache.lenya.workflow.Workflowable;
 
@@ -50,6 +53,25 @@
         return "restore";
     }
 
+    protected void doCheckPreconditions() throws Exception {
+        super.doCheckPreconditions();
+
+        String targetAreaName = getTargetArea(); 
+        Document doc = getSourceDocument();
+        if(doc == null) {
+            return;
+        }
+        // Check to see if parent node exists in target to prevent ghost nodes
+        Area targetArea = doc.getPublication().getArea(targetAreaName);
+        DocumentLocator targetLoc = doc.getLocator().getAreaVersion(targetAreaName);
+        targetLoc = SiteUtil.getAvailableLocator(this.manager, getDocumentFactory(), targetLoc);
+        String targetPath = targetLoc.getPath();
+        targetPath = targetPath.substring(0,targetPath.lastIndexOf('/'));
+        if(!targetArea.getSite().contains(targetPath)) {
+            addErrorMessage("The authoring path [" + targetPath + "] does not exist.");
+        }
+    }
+  
     protected void doCheckPostconditions() throws Exception {
         super.doCheckPostconditions();
 



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