Author: davsclaus
Date: Tue Dec 30 02:18:41 2008
New Revision: 730086

URL: http://svn.apache.org/viewvc?rev=730086&view=rev
Log:
CAMEL-1186: Get rid of consumer prefix for file component

Modified:
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
    
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAsyncRouteTest.java
    
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
    
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeFileOnlyTest.java
    
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMultipleDirectoriesTest.java
    
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSingleDirectoryOnlyTest.java
    
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryNotMatchedTest.java
    
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileDeleteRouteExceptionTest.java
    
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileDeleteRouteTest.java
    
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileNoOpRouteTest.java
    
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileRenameRouteTest.java
    
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileRouteTest.java

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java?rev=730086&r1=730085&r2=730086&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
 Tue Dec 30 02:18:41 2008
@@ -23,6 +23,7 @@
 
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.Processor;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.impl.ScheduledPollConsumer;
 import org.apache.camel.processor.DeadLetterChannel;
 import org.apache.commons.logging.Log;
@@ -37,8 +38,6 @@
     private static final transient Log LOG = 
LogFactory.getLog(FileConsumer.class);
 
     private FileEndpoint endpoint;
-    private boolean recursive;
-    private String regexPattern = "";
 
     public FileConsumer(final FileEndpoint endpoint, Processor processor) {
         super(endpoint, processor);
@@ -51,7 +50,7 @@
 
         boolean isDirectory = endpoint.getFile().isDirectory();
         if (isDirectory) {
-            pollDirectory(endpoint.getFile(), isRecursive(), files);
+            pollDirectory(endpoint.getFile(), files);
         } else {
             pollFile(endpoint.getFile(), files);
         }
@@ -92,10 +91,9 @@
      * Polls the given directory for files to process
      *
      * @param fileOrDirectory current directory or file
-     * @param processDir      recursive
      * @param fileList        current list of files gathered
      */
-    protected void pollDirectory(File fileOrDirectory, boolean processDir, 
List<File> fileList) {
+    protected void pollDirectory(File fileOrDirectory, List<File> fileList) {
         if (fileOrDirectory == null || !fileOrDirectory.exists()) {
             return;
         }
@@ -105,10 +103,10 @@
         }
         File[] files = fileOrDirectory.listFiles();
         for (File file : files) {
-            if (processDir && file.isDirectory()) {
+            if (endpoint.isRecursive() && file.isDirectory()) {
                 if (isValidFile(file)) {
                     // recursive scan and add the sub files and folders
-                    pollDirectory(file, isRecursive(), fileList);
+                    pollDirectory(file, fileList);
                 }
             } else if (file.isFile()) {
                 if (isValidFile(file)) {
@@ -299,18 +297,18 @@
             }
         }
 
-        if (regexPattern != null && regexPattern.length() > 0) {
-            if (!name.matches(regexPattern)) {
+        if (ObjectHelper.isNotEmpty(endpoint.getRegexPattern())) {
+            if (!name.matches(endpoint.getRegexPattern())) {
                 return false;
             }
         }
 
-        if (endpoint.getExcludedNamePrefix() != null) {
+        if (ObjectHelper.isNotEmpty(endpoint.getExcludedNamePrefix())) {
             if (name.startsWith(endpoint.getExcludedNamePrefix())) {
                 return false;
             }
         }
-        if (endpoint.getExcludedNamePostfix() != null) {
+        if (ObjectHelper.isNotEmpty(endpoint.getExcludedNamePostfix())) {
             if (name.endsWith(endpoint.getExcludedNamePostfix())) {
                 return false;
             }
@@ -319,20 +317,4 @@
         return true;
     }
 
-    public boolean isRecursive() {
-        return this.recursive;
-    }
-
-    public void setRecursive(boolean recursive) {
-        this.recursive = recursive;
-    }
-
-    public String getRegexPattern() {
-        return this.regexPattern;
-    }
-
-    public void setRegexPattern(String regexPattern) {
-        this.regexPattern = regexPattern;
-    }
-
 }

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java?rev=730086&r1=730085&r2=730086&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
 Tue Dec 30 02:18:41 2008
@@ -62,6 +62,8 @@
     private boolean delete;
     private boolean noop;
     private boolean append = true;
+    private boolean recursive;
+    private String regexPattern = "";
     private String moveNamePrefix;
     private String moveNamePostfix;
     private String preMoveNamePrefix;
@@ -301,6 +303,22 @@
         this.append = append;
     }
 
+    public boolean isRecursive() {
+        return this.recursive;
+    }
+
+    public void setRecursive(boolean recursive) {
+        this.recursive = recursive;
+    }
+
+    public String getRegexPattern() {
+        return this.regexPattern;
+    }
+
+    public void setRegexPattern(String regexPattern) {
+        this.regexPattern = regexPattern;
+    }
+
     public int getBufferSize() {
         return bufferSize;
     }

Modified: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAsyncRouteTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAsyncRouteTest.java?rev=730086&r1=730085&r2=730086&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAsyncRouteTest.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAsyncRouteTest.java
 Tue Dec 30 02:18:41 2008
@@ -32,7 +32,7 @@
  */
 public class FileAsyncRouteTest extends ContextTestSupport {
     protected Object expectedBody = "Hello there!";
-    protected String uri = 
"file:target/test-async-inbox?delete=true&consumer.delay=10000&consumer.recursive=true";
+    protected String uri = 
"file:target/test-async-inbox?delete=true&consumer.delay=10000&recursive=true";
 
     private CountDownLatch receivedLatch = new CountDownLatch(1);
     private CountDownLatch processingLatch = new CountDownLatch(1);

Modified: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java?rev=730086&r1=730085&r2=730086&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
 Tue Dec 30 02:18:41 2008
@@ -51,10 +51,10 @@
     }
 
     public void testConsumerConfigurations() throws Exception {
-        FileConsumer consumer = 
createFileConsumer("file://target/foo/bar?consumer.recursive=true");
-        assertEquals("The recurisive should be true", consumer.isRecursive(), 
true);
+        FileConsumer consumer = 
createFileConsumer("file://target/foo/bar?recursive=true");
+        assertNotNull(consumer);
         try {
-            createFileConsumer("file://target/foo/bar?consumer.recursiv=true");
+            createFileConsumer("file://target/foo/bar?recursiv=true");
             fail("Expect a configure exception here");
         } catch (Exception ex) {
             assertTrue("Get the wrong exception type here", ex instanceof 
ResolveEndpointFailedException);

Modified: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeFileOnlyTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeFileOnlyTest.java?rev=730086&r1=730085&r2=730086&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeFileOnlyTest.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeFileOnlyTest.java
 Tue Dec 30 02:18:41 2008
@@ -45,7 +45,7 @@
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                
from("file://target/fileonly/report.txt?consumer.recursive=false&delete=true").to("mock:result");
+                
from("file://target/fileonly/report.txt?recursive=false&delete=true").to("mock:result");
             }
         };
     }

Modified: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMultipleDirectoriesTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMultipleDirectoriesTest.java?rev=730086&r1=730085&r2=730086&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMultipleDirectoriesTest.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMultipleDirectoriesTest.java
 Tue Dec 30 02:18:41 2008
@@ -27,7 +27,7 @@
  */
 public class FileConsumeMultipleDirectoriesTest extends ContextTestSupport {
 
-    private String fileUrl = 
"file://target/multidir/?consumer.recursive=true&delete=true&consumer.delay=5000&sortBy=file:path";
+    private String fileUrl = 
"file://target/multidir/?recursive=true&delete=true&consumer.delay=5000&sortBy=file:path";
 
     @Override
     protected void setUp() throws Exception {

Modified: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSingleDirectoryOnlyTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSingleDirectoryOnlyTest.java?rev=730086&r1=730085&r2=730086&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSingleDirectoryOnlyTest.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeSingleDirectoryOnlyTest.java
 Tue Dec 30 02:18:41 2008
@@ -45,7 +45,7 @@
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                
from("file://target/singledirectoryonly/?consumer.recursive=false&delete=true").to("mock:result");
+                
from("file://target/singledirectoryonly/?recursive=false&delete=true").to("mock:result");
             }
         };
     }

Modified: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryNotMatchedTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryNotMatchedTest.java?rev=730086&r1=730085&r2=730086&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryNotMatchedTest.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryNotMatchedTest.java
 Tue Dec 30 02:18:41 2008
@@ -25,7 +25,7 @@
  */
 public class FileConsumerDirectoryNotMatchedTest extends ContextTestSupport {
 
-    private String fileUrl = 
"file://target/dirnotmatched/?consumer.recursive=true&consumer.regexPattern=.*\\.txt$";
+    private String fileUrl = 
"file://target/dirnotmatched/?recursive=true&regexPattern=.*\\.txt$";
 
     @Override
     protected void setUp() throws Exception {

Modified: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileDeleteRouteExceptionTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileDeleteRouteExceptionTest.java?rev=730086&r1=730085&r2=730086&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileDeleteRouteExceptionTest.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileDeleteRouteExceptionTest.java
 Tue Dec 30 02:18:41 2008
@@ -32,7 +32,7 @@
     @Override
     protected void setUp() throws Exception {
         targetdir = "target/test-delete-inbox";
-        params = "?consumer.delay=1000&delete=true&consumer.recursive=true";
+        params = "?consumer.delay=1000&delete=true&recursive=true";
         super.setUp();
     }
 

Modified: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileDeleteRouteTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileDeleteRouteTest.java?rev=730086&r1=730085&r2=730086&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileDeleteRouteTest.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileDeleteRouteTest.java
 Tue Dec 30 02:18:41 2008
@@ -28,7 +28,7 @@
     @Override
     protected void setUp() throws Exception {
         targetdir = "target/test-delete-inbox";
-        params = "?consumer.delay=1000&delete=true&consumer.recursive=true";
+        params = "?consumer.delay=1000&delete=true&recursive=true";
         super.setUp();
     }
 

Modified: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileNoOpRouteTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileNoOpRouteTest.java?rev=730086&r1=730085&r2=730086&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileNoOpRouteTest.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileNoOpRouteTest.java
 Tue Dec 30 02:18:41 2008
@@ -23,7 +23,7 @@
     @Override
     protected void setUp() throws Exception {
         targetdir = "target/test-noop-inbox";
-        params = "?noop=true&consumer.recursive=true";
+        params = "?noop=true&recursive=true";
         super.setUp();
     }
 }

Modified: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileRenameRouteTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileRenameRouteTest.java?rev=730086&r1=730085&r2=730086&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileRenameRouteTest.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileRenameRouteTest.java
 Tue Dec 30 02:18:41 2008
@@ -23,7 +23,7 @@
     @Override
     protected void setUp() throws Exception {
         targetdir = "target/test-rename-inbox";
-        params = "?moveNamePrefix=foo/?consumer.recursive=true";
+        params = "?moveNamePrefix=foo/?recursive=true";
         super.setUp();
     }
 }
\ No newline at end of file

Modified: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileRouteTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileRouteTest.java?rev=730086&r1=730085&r2=730086&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileRouteTest.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileRouteTest.java
 Tue Dec 30 02:18:41 2008
@@ -30,7 +30,7 @@
 public class FileRouteTest extends ContextTestSupport {
     protected Object expectedBody = "Hello there!";
     protected String targetdir = "target/test-default-inbox";
-    protected String params = "?consumer.recursive=true";
+    protected String params = "?recursive=true";
     protected String uri = "file:" + targetdir + params;
     protected LockRecorderProcessor recorder = new LockRecorderProcessor();
 


Reply via email to