Author: sdumitriu
Date: 2008-02-08 14:12:16 +0100 (Fri, 08 Feb 2008)
New Revision: 7391

Modified:
   
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteVersionsAction.java
Log:
XWIKI-2085: Deleting all the revisions should move the whole document to the 
recycle bin
First step: prepare the code. The code in DeleteAction should be reusable, so 
that we don't duplicate code.


Modified: 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteVersionsAction.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteVersionsAction.java
      2008-02-08 13:07:44 UTC (rev 7390)
+++ 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/web/DeleteVersionsAction.java
      2008-02-08 13:12:16 UTC (rev 7391)
@@ -76,12 +76,19 @@
             archive.removeVersions(v1, v2, context);
             
context.getWiki().getVersioningStore().saveXWikiDocArchive(archive, true, 
context);
             tdoc.setDocumentArchive(archive);
-            // if we delete latest version then rollback to latest undeleted 
version
-            if (archive.getLatestVersion() != null
-                && !tdoc.getRCSVersion().equals(archive.getLatestVersion())) {
-                XWikiDocument newdoc = 
archive.loadDocument(archive.getLatestVersion(), context);
-                context.getWiki().getStore().saveXWikiDoc(newdoc, context);
-                context.setDoc(newdoc);
+            // Is this the last remaining version? If so, then recycle the 
document.
+            if (archive.getLatestVersion() == null) {
+                // TODO Make the code in DeleteAction reusable, then call it 
from here.
+            } else {
+                // There are still some versions left.
+                // If we delete the most recent (current) version, then 
rollback to latest undeleted
+                // version.
+                if (!tdoc.getRCSVersion().equals(archive.getLatestVersion())) {
+                    XWikiDocument newdoc =
+                        archive.loadDocument(archive.getLatestVersion(), 
context);
+                    context.getWiki().getStore().saveXWikiDoc(newdoc, context);
+                    context.setDoc(newdoc);
+                }
             }
         }
         sendRedirect(context);

_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to