camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1441519 - in /camel/branches/camel-2.10.x: ./ camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/component/file/ camel-core/src/test/java/org/apache/camel...
Date Fri, 01 Feb 2013 16:41:44 GMT
Author: davsclaus
Date: Fri Feb  1 16:41:44 2013
New Revision: 1441519

URL: http://svn.apache.org/viewvc?rev=1441519&view=rev
Log:
CAMEL-6025: Use long for file last modified header. Allows to transfer over JMS etc.

Added:
    camel/branches/camel-2.10.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteJmsKeepLastModifiedTest.java
      - copied unchanged from r1441518, camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteJmsKeepLastModifiedTest.java
Modified:
    camel/branches/camel-2.10.x/   (props changed)
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/Exchange.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
    camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/component/file/FileKeepLastModifiedTest.java
    camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java
    camel/branches/camel-2.10.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedTest.java

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1441518

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/Exchange.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/Exchange.java?rev=1441519&r1=1441518&r2=1441519&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/Exchange.java (original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/Exchange.java Fri
Feb  1 16:41:44 2013
@@ -120,6 +120,7 @@ public interface Exchange {
     String FILE_PATH            = "CamelFilePath";
     String FILE_PARENT          = "CamelFileParent";
     String FILE_LAST_MODIFIED   = "CamelFileLastModified";
+    String FILE_LENGTH          = "CamelFileLength";
     String FILTER_MATCHED       = "CamelFilterMatched";
     String FILE_LOCK_FILE_ACQUIRED   = "CamelFileLockFileAcquired"; 
 

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java?rev=1441519&r1=1441518&r2=1441519&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
Fri Feb  1 16:41:44 2013
@@ -1326,9 +1326,14 @@ public final class ExpressionBuilder {
                         throw new IllegalArgumentException("Cannot find java.util.Date object
at command: " + command);
                     }
                 } else if ("file".equals(command)) {
-                    date = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Date.class);
-                    if (date == null) {
-                        throw new IllegalArgumentException("Cannot find " + Exchange.FILE_LAST_MODIFIED
+ " header at command: " + command);
+                    Long num = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Long.class);
+                    if (num != null && num > 0) {
+                        date = new Date(num.longValue());
+                    } else {
+                        date = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Date.class);
+                        if (date == null) {
+                            throw new IllegalArgumentException("Cannot find " + Exchange.FILE_LAST_MODIFIED
+ " header at command: " + command);
+                        }
                     }
                 } else {
                     throw new IllegalArgumentException("Command not supported for dateExpression:
" + command);
@@ -1563,7 +1568,7 @@ public final class ExpressionBuilder {
     public static Expression fileSizeExpression() {
         return new ExpressionAdapter() {
             public Object evaluate(Exchange exchange) {
-                return exchange.getIn().getHeader("CamelFileLength", Long.class);
+                return exchange.getIn().getHeader(Exchange.FILE_LENGTH, Long.class);
             }
 
             @Override
@@ -1576,7 +1581,7 @@ public final class ExpressionBuilder {
     public static Expression fileLastModifiedExpression() {
         return new ExpressionAdapter() {
             public Object evaluate(Exchange exchange) {
-                return exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Date.class);
+                return exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Long.class);
             }
 
             @Override

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java?rev=1441519&r1=1441518&r2=1441519&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFile.java
Fri Feb  1 16:41:44 2013
@@ -144,10 +144,10 @@ public class GenericFile<T> implements W
             message.setHeader(Exchange.FILE_PARENT, getParent());
     
             if (getFileLength() >= 0) {
-                message.setHeader("CamelFileLength", getFileLength());
+                message.setHeader(Exchange.FILE_LENGTH, getFileLength());
             }
             if (getLastModified() > 0) {
-                message.setHeader(Exchange.FILE_LAST_MODIFIED, new Date(getLastModified()));
+                message.setHeader(Exchange.FILE_LAST_MODIFIED, getLastModified());
             }
         }
     }

Modified: camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/component/file/FileKeepLastModifiedTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/component/file/FileKeepLastModifiedTest.java?rev=1441519&r1=1441518&r2=1441519&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/component/file/FileKeepLastModifiedTest.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/component/file/FileKeepLastModifiedTest.java
Fri Feb  1 16:41:44 2013
@@ -53,7 +53,7 @@ public class FileKeepLastModifiedTest ex
 
         assertMockEndpointsSatisfied();
 
-        long t1 = mock.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_LAST_MODIFIED,
Date.class).getTime();
+        long t1 = mock.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_LAST_MODIFIED,
long.class);
         long t2 = new File("./target/keep/out/hello.txt").lastModified();
 
         assertEquals("Timestamp should have been kept", t1, t2);
@@ -76,7 +76,7 @@ public class FileKeepLastModifiedTest ex
 
         assertMockEndpointsSatisfied();
 
-        long t1 = mock.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_LAST_MODIFIED,
Date.class).getTime();
+        long t1 = mock.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_LAST_MODIFIED,
long.class);
         long t2 = new File("./target/keep/out/hello.txt").lastModified();
 
         assertNotSame("Timestamp should NOT have been kept", t1, t2);
@@ -99,7 +99,7 @@ public class FileKeepLastModifiedTest ex
 
         assertMockEndpointsSatisfied();
 
-        long t1 = mock.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_LAST_MODIFIED,
Date.class).getTime();
+        long t1 = mock.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_LAST_MODIFIED,
long.class);
         long t2 = new File("./target/keep/out/hello.txt").lastModified();
 
         assertNotSame("Timestamp should NOT have been kept", t1, t2);

Modified: camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java?rev=1441519&r1=1441518&r2=1441519&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java
Fri Feb  1 16:41:44 2013
@@ -83,9 +83,9 @@ public class FileLanguageTest extends La
         assertExpression("${file:length}", file.length());
         assertExpression("${file:size}", file.length());
 
-        // modified is a Date object
-        Date modified = SimpleLanguage.simple("${file:modified}").evaluate(exchange, Date.class);
-        assertEquals(new Date(file.lastModified()), modified);
+        // modified is a long object
+        Long modified = SimpleLanguage.simple("${file:modified}").evaluate(exchange, Long.class);
+        assertEquals(file.lastModified(), modified.longValue());
     }
 
     public void testFileUsingAlternativeStartToken() throws Exception {
@@ -102,9 +102,9 @@ public class FileLanguageTest extends La
         assertExpression("$simple{file:length}", file.length());
         assertExpression("$simple{file:size}", file.length());
 
-        // modified is a Date object
-        Date modified = SimpleLanguage.simple("${file:modified}").evaluate(exchange, Date.class);
-        assertEquals(new Date(file.lastModified()), modified);
+        // modified is a long object
+        long modified = SimpleLanguage.simple("${file:modified}").evaluate(exchange, long.class);
+        assertEquals(file.lastModified(), modified);
     }
 
     public void testDate() throws Exception {

Modified: camel/branches/camel-2.10.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedTest.java?rev=1441519&r1=1441518&r2=1441519&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedTest.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpKeepLastModifiedTest.java
Fri Feb  1 16:41:44 2013
@@ -59,7 +59,7 @@ public class FromFtpKeepLastModifiedTest
 
         assertMockEndpointsSatisfied();
 
-        long t1 = mock.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_LAST_MODIFIED,
Date.class).getTime();
+        long t1 = mock.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_LAST_MODIFIED,
long.class);
         long t2 = new File("./target/keep/out/hello.txt").lastModified();
 
         assertEquals("Timestamp should have been kept", t1, t2);
@@ -83,7 +83,7 @@ public class FromFtpKeepLastModifiedTest
 
         assertMockEndpointsSatisfied();
 
-        long t1 = mock.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_LAST_MODIFIED,
Date.class).getTime();
+        long t1 = mock.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_LAST_MODIFIED,
long.class);
         long t2 = new File("./target/keep/out/hello.txt").lastModified();
 
         assertNotSame("Timestamp should NOT have been kept", t1, t2);
@@ -107,7 +107,7 @@ public class FromFtpKeepLastModifiedTest
 
         assertMockEndpointsSatisfied();
 
-        long t1 = mock.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_LAST_MODIFIED,
Date.class).getTime();
+        long t1 = mock.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_LAST_MODIFIED,
long.class);
         long t2 = new File("./target/keep/out/hello.txt").lastModified();
 
         assertNotSame("Timestamp should NOT have been kept", t1, t2);



Mime
View raw message