svn commit: r666685 - /lenya/trunk/src/java/org/apache/lenya/cms/workflow/DocumentWorkflowable.java

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Wed Jun 11 07:39:16 2008
New Revision: 666685

URL: http://svn.apache.org/viewvc?rev=666685&view=rev
Log:
Avoid RepositoryException in DocumentWorkflowable if node hasn't checked in yet.

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/workflow/DocumentWorkflowable.java

Modified: lenya/trunk/src/java/org/apache/lenya/cms/workflow/DocumentWorkflowable.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/workflow/DocumentWorkflowable.java?rev=666685&r1=666684&r2=666685&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/workflow/DocumentWorkflowable.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/workflow/DocumentWorkflowable.java Wed Jun 11 07:39:16 2008
@@ -107,7 +107,7 @@
 
     private Version[] versions = null;
 
-    private long lastModified = 0;
+    private int revision = 0;
 
     protected static final String METADATA_NAMESPACE = "http://apache.org/lenya/metadata/workflow/1.0";
     protected static final String METADATA_VERSION = "workflowVersion";
@@ -118,7 +118,10 @@
     public Version[] getVersions() {
         try {
             MetaData meta = this.document.getMetaData(METADATA_NAMESPACE);
-            if (this.versions == null || meta.getLastModified() > this.lastModified) {
+            
+            org.apache.lenya.cms.repository.History history = this.document.getRepositoryNode().getHistory();
+            boolean checkedIn = history.getRevisionNumbers().length > 0;
+            if (this.versions == null || (checkedIn && history.getLatestRevision().getNumber() > this.revision)) {
                 String[] versionStrings = meta.getValues(METADATA_VERSION);
                 this.versions = new Version[versionStrings.length];
                 
@@ -141,7 +144,9 @@
                     number++;
                 }
                 
-                this.lastModified = meta.getLastModified();
+                if (checkedIn) {
+                    this.revision = history.getLatestRevision().getNumber();
+                }
             }
         } catch (Exception e) {
             throw new RuntimeException(e);
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.