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 2005/04/01 17:58:35 UTC

svn commit: r159704 - lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java

Author: andreas
Date: Fri Apr  1 07:58:35 2005
New Revision: 159704

URL: http://svn.apache.org/viewcvs?view=rev&rev=159704
Log:
enabled transactions for workflow history

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

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java?view=diff&r1=159703&r2=159704
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java Fri Apr  1 07:58:35 2005
@@ -25,6 +25,7 @@
 import java.util.Date;
 import java.util.List;
 
+import org.apache.avalon.excalibur.io.FileUtil;
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.service.ServiceManager;
@@ -515,7 +516,14 @@
      * @return A string.
      */
     public File getHistoryFile() {
+        if (getIdentityMap().getUnitOfWork() == null) {
+            return getRealHistoryFile();
+        } else {
+            return getWorkHistoryFile();
+        }
+    }
 
+    protected File getRealHistoryFile() {
         DocumentIdToPathMapper pathMapper = getPublication().getPathMapper();
         String documentPath = pathMapper.getPath(getId(), getLanguage());
 
@@ -529,6 +537,21 @@
         return new File(getPublication().getDirectory(), path);
     }
 
+    protected File getWorkHistoryFile() {
+        DocumentIdToPathMapper pathMapper = getPublication().getPathMapper();
+        String documentPath = pathMapper.getPath(getId(), getLanguage());
+
+        String area = getArea();
+        if (!area.equals(Publication.ARCHIVE_AREA) && !area.equals(Publication.TRASH_AREA)) {
+            area = Publication.AUTHORING_AREA;
+        }
+
+        String path = "work/" + getUserId() + "/" + CMSHistory.HISTORY_PATH + "/" + area + "/"
+                + documentPath;
+        path = path.replace('/', File.separatorChar);
+        return new File(getPublication().getDirectory(), path);
+    }
+
     /**
      * @return The source URI of the history file.
      */
@@ -556,6 +579,11 @@
             getDublinCore().save();
             getHistory().save();
 
+            if (getWorkHistoryFile().exists()) {
+                FileUtil.copyFile(getWorkHistoryFile(), getRealHistoryFile());
+                getWorkHistoryFile().delete();
+            }
+
             sourceResolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
             realSource = (ModifiableSource) sourceResolver.resolveURI(getRealSourceURI());
             workSource = (ModifiableSource) sourceResolver.resolveURI(getWorkSourceURI());
@@ -588,7 +616,7 @@
     }
 
     private boolean isCheckedOut = false;
-    
+
     protected void checkin(boolean backup) throws TransactionException {
         try {
             String userName = getUserId();



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