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 2006/02/20 12:26:27 UTC

svn commit: r379093 - /lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java

Author: andreas
Date: Mon Feb 20 03:26:10 2006
New Revision: 379093

URL: http://svn.apache.org/viewcvs?rev=379093&view=rev
Log:
Update last modification date when source node content is changed

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java

Modified: lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java?rev=379093&r1=379092&r2=379093&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/repository/SourceNode.java Mon Feb 20 03:26:10 2006
@@ -23,6 +23,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Collection;
+import java.util.Date;
 
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.logger.Logger;
@@ -255,7 +256,7 @@
                     out.write(buf, 0, read);
                     read = in.read(buf);
                 }
-
+                
             } catch (Exception e) {
                 throw new RepositoryException(e);
             } finally {
@@ -492,6 +493,7 @@
          */
         public synchronized void close() throws IOException {
             SourceNode.this.data = super.toByteArray();
+            SourceNode.this.lastModified = new Date().getTime();
             super.close();
         }
     }
@@ -522,6 +524,8 @@
             }
         }
     }
+    
+    private long lastModified = -1;
 
     /**
      * @see org.apache.lenya.cms.repository.Node#getLastModified()
@@ -532,12 +536,22 @@
         try {
             resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
             source = resolver.resolveURI(getRealSourceURI());
+            
+            long sourceLastModified;
+            
             if (source.exists()) {
-                return source.getLastModified();
-            } else {
+                sourceLastModified = source.getLastModified();
+                if (sourceLastModified > this.lastModified) {
+                    this.lastModified = sourceLastModified;
+                }
+            }
+            else if (this.lastModified == -1) {
                 throw new RepositoryException("The source [" + getRealSourceURI()
                         + "] does not exist!");
             }
+            
+            return this.lastModified;
+            
         } catch (Exception e) {
             throw new RuntimeException(e);
         } finally {



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