You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2011/09/02 11:20:52 UTC

svn commit: r1164427 - in /camel/branches/camel-2.8.x: ./ camel-core/src/main/java/org/apache/camel/component/file/ components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/ components/camel-ftp/src/test/java/org/apache/camel/component...

Author: davsclaus
Date: Fri Sep  2 09:20:52 2011
New Revision: 1164427

URL: http://svn.apache.org/viewvc?rev=1164427&view=rev
Log:
Merged revisions 1159326 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk


Added:
    camel/branches/camel-2.8.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameFixedStepwiseTest.java
      - copied unchanged from r1159326, camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameFixedStepwiseTest.java
    camel/branches/camel-2.8.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameFixedTest.java
      - copied unchanged from r1159326, camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameFixedTest.java
    camel/branches/camel-2.8.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameStepwiseTest.java
      - copied unchanged from r1159326, camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameStepwiseTest.java
Modified:
    camel/branches/camel-2.8.x/   (props changed)
    camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
    camel/branches/camel-2.8.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
    camel/branches/camel-2.8.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameTest.java

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep  2 09:20:52 2011
@@ -1 +1 @@
-/camel/trunk:1150651,1151054,1152170,1155230,1156108,1156260,1156524,1157348,1157798,1157831,1157878,1158153,1159171,1159174,1159457,1159460,1159606,1159682-1159683,1159867,1160547,1160637,1161010,1161082,1161524,1162309,1162395
+/camel/trunk:1150651,1151054,1152170,1155230,1156108,1156260,1156524,1157348,1157798,1157831,1157878,1158153,1159171,1159174,1159326,1159457,1159460,1159606,1159682-1159683,1159867,1160547,1160637,1161010,1161082,1161524,1162309,1162395

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

Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java?rev=1164427&r1=1164426&r2=1164427&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java (original)
+++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java Fri Sep  2 09:20:52 2011
@@ -363,7 +363,7 @@ public abstract class GenericFileConsume
      *
      * @param file        the file
      * @param isDirectory whether the file is a directory or a file
-     * @return <tt>true</tt> if the remote file is matched, <tt>false</tt> if not
+     * @return <tt>true</tt> if the file is matched, <tt>false</tt> if not
      */
     protected boolean isMatched(GenericFile<T> file, boolean isDirectory) {
         String name = file.getFileNameOnly();
@@ -423,9 +423,7 @@ public abstract class GenericFileConsume
                 return false;
             }
 
-            // the file is only valid if the done file exist
-            if (!operations.existsFile(doneFileName)) {
-                log.trace("Done file: {} does not exist", doneFileName);
+            if (!isMatched(file, doneFileName)) {
                 return false;
             }
         }
@@ -434,6 +432,24 @@ public abstract class GenericFileConsume
     }
 
     /**
+     * Strategy to perform file matching based on endpoint configuration in terms of done file name.
+     *
+     * @param file         the file
+     * @param doneFileName the done file name
+     * @return <tt>true</tt> if the file is matched, <tt>false</tt> if not
+     */
+    protected boolean isMatched(GenericFile<T> file, String doneFileName) {
+        // the file is only valid if the done file exist
+        if (!operations.existsFile(doneFileName)) {
+            log.trace("Done file: {} does not exist", doneFileName);
+            return false;
+        }
+
+        // assume matched
+        return true;
+    }
+
+    /**
      * Is the given file already in progress.
      *
      * @param file the file

Modified: camel/branches/camel-2.8.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java?rev=1164427&r1=1164426&r2=1164427&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java (original)
+++ camel/branches/camel-2.8.x/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java Fri Sep  2 09:20:52 2011
@@ -19,8 +19,10 @@ package org.apache.camel.component.file.
 import java.io.IOException;
 
 import org.apache.camel.Processor;
+import org.apache.camel.component.file.GenericFile;
 import org.apache.camel.component.file.GenericFileConsumer;
 import org.apache.camel.component.file.GenericFileOperationFailedException;
+import org.apache.camel.util.FileUtil;
 
 /**
  * Base class for remote file consumers.
@@ -141,4 +143,15 @@ public abstract class RemoteFileConsumer
     protected String remoteServer() {
         return ((RemoteFileEndpoint) endpoint).remoteServerInformation();
     }
+
+    @Override
+    protected boolean isMatched(GenericFile<T> file, String doneFileName) {
+        // ftp specific as we need to cater for stepwise
+        if (getEndpoint().getConfiguration().isStepwise()) {
+            // stepwise enabled, so done file should always be without path
+            doneFileName = FileUtil.stripPath(doneFileName);
+        }
+
+        return super.isMatched(file, doneFileName);
+    }
 }

Modified: camel/branches/camel-2.8.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameTest.java?rev=1164427&r1=1164426&r2=1164427&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDoneFileNameTest.java Fri Sep  2 09:20:52 2011
@@ -47,7 +47,7 @@ public class FtpConsumerDoneFileNameTest
         getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
 
         // write the done file
-        template.sendBodyAndHeader(getFtpUrl(), "", Exchange.FILE_NAME, "done");
+        template.sendBodyAndHeader(getFtpUrl(), "", Exchange.FILE_NAME, "hello.dat");
 
         assertMockEndpointsSatisfied();
 
@@ -55,7 +55,7 @@ public class FtpConsumerDoneFileNameTest
         Thread.sleep(1000);
 
         // done file should be deleted now
-        File file = new File(FTP_ROOT_DIR + "done/done").getAbsoluteFile();
+        File file = new File(FTP_ROOT_DIR + "done/hello.dat").getAbsoluteFile();
         assertFalse("Done file should be deleted: " + file, file.exists());
     }
 
@@ -64,7 +64,7 @@ public class FtpConsumerDoneFileNameTest
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from(getFtpUrl() + "&doneFileName=done")
+                from(getFtpUrl() + "&doneFileName=${file:name.noext}.dat")
                     .convertBodyTo(String.class)
                     .to("mock:result");
             }