Author: davsclaus
Date: Sat Mar  7 08:51:30 2009
New Revision: 751226

URL: http://svn.apache.org/viewvc?rev=751226&view=rev
Log:
CAMEL-1433: only 2 options for include/exclude file name pattern based on regex.

Modified:
    
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
    
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
    
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMoveMultipleDirectoriesTest.java
    
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryNotMatchedTest.java
    
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExcludeNameTest.java
    
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeAndExcludeNameTest.java
    
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeNameTest.java
    
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveExpressionTest.java

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java?rev=751226&r1=751225&r2=751226&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileConsumer.java
 Sat Mar  7 08:51:30 2009
@@ -283,15 +283,14 @@
      * <p/>
      * Will always return <tt>false</tt> for certain files/folders:
      * <ul>
-     * <li>Starting with a dot</li>
-     * <li>lock files</li>
+     *   <li>Starting with a dot</li>
+     *   <li>lock files</li>
      * </ul>
      * And then <tt>true</tt> for directories.
      *
      * @param file        the remote file
      * @param isDirectory wether 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 remote file is matched, <tt>false</tt> if 
not
      */
     protected boolean isMatched(GenericFile<T> file, boolean isDirectory) {
         String name = file.getFileName();
@@ -317,30 +316,14 @@
             }
         }
 
-        if (ObjectHelper.isNotEmpty(endpoint.getRegexPattern())) {
-            if (!name.matches(endpoint.getRegexPattern())) {
+        if (ObjectHelper.isNotEmpty(endpoint.getExclude())) {
+            if (name.matches(endpoint.getExclude())) {
                 return false;
             }
         }
 
-        if (ObjectHelper.isNotEmpty(endpoint.getExcludeNamePrefix())) {
-            if (name.startsWith(endpoint.getExcludeNamePrefix())) {
-                return false;
-            }
-        }
-        if (ObjectHelper.isNotEmpty(endpoint.getExcludeNamePostfix())) {
-            if (name.endsWith(endpoint.getExcludeNamePostfix())) {
-                return false;
-            }
-        }
-
-        if (ObjectHelper.isNotEmpty(endpoint.getIncludeNamePrefix())) {
-            if (!name.startsWith(endpoint.getIncludeNamePrefix())) {
-                return false;
-            }
-        }
-        if (ObjectHelper.isNotEmpty(endpoint.getIncludeNamePostfix())) {
-            if (!name.endsWith(endpoint.getIncludeNamePostfix())) {
+        if (ObjectHelper.isNotEmpty(endpoint.getInclude())) {
+            if (!name.matches(endpoint.getInclude())) {
                 return false;
             }
         }

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java?rev=751226&r1=751225&r2=751226&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
 Sat Mar  7 08:51:30 2009
@@ -51,7 +51,6 @@
     protected GenericFileOperations<T> operations;
     protected GenericFileConfiguration configuration;
 
-    protected boolean directory = true;
     protected String localWorkDirectory;
     protected boolean autoCreate = true;
     protected int bufferSize = 128 * 1024;
@@ -60,11 +59,8 @@
     protected boolean recursive;
     protected boolean delete;
     protected String tempPrefix;
-    protected String excludeNamePrefix;
-    protected String excludeNamePostfix;
-    protected String includeNamePrefix;
-    protected String includeNamePostfix;
-    protected String regexPattern;
+    protected String include;
+    protected String exclude;
     protected Expression fileExpression;
     protected Expression moveExpression;
     protected Expression preMoveExpression;
@@ -157,38 +153,6 @@
         this.noop = noop;
     }
 
-    public String getExcludeNamePrefix() {
-        return excludeNamePrefix;
-    }
-
-    public void setExcludeNamePrefix(String excludeNamePrefix) {
-        this.excludeNamePrefix = excludeNamePrefix;
-    }
-
-    public String getExcludeNamePostfix() {
-        return excludeNamePostfix;
-    }
-
-    public void setExcludeNamePostfix(String excludeNamePostfix) {
-        this.excludeNamePostfix = excludeNamePostfix;
-    }
-
-    public String getIncludeNamePrefix() {
-        return includeNamePrefix;
-    }
-
-    public void setIncludeNamePrefix(String includeNamePrefix) {
-        this.includeNamePrefix = includeNamePrefix;
-    }
-
-    public String getIncludeNamePostfix() {
-        return includeNamePostfix;
-    }
-
-    public void setIncludeNamePostfix(String includeNamePostfix) {
-        this.includeNamePostfix = includeNamePostfix;
-    }
-
     public boolean isRecursive() {
         return recursive;
     }
@@ -197,12 +161,20 @@
         this.recursive = recursive;
     }
 
-    public String getRegexPattern() {
-        return regexPattern;
+    public String getInclude() {
+        return include;
+    }
+
+    public void setInclude(String include) {
+        this.include = include;
+    }
+
+    public String getExclude() {
+        return exclude;
     }
 
-    public void setRegexPattern(String regexPattern) {
-        this.regexPattern = regexPattern;
+    public void setExclude(String exclude) {
+        this.exclude = exclude;
     }
 
     public boolean isDelete() {

Modified: 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMoveMultipleDirectoriesTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMoveMultipleDirectoriesTest.java?rev=751226&r1=751225&r2=751226&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMoveMultipleDirectoriesTest.java
 (original)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMoveMultipleDirectoriesTest.java
 Sat Mar  7 08:51:30 2009
@@ -27,7 +27,7 @@
 public class FileConsumeMoveMultipleDirectoriesTest extends ContextTestSupport 
{
 
     private String fileUrl = 
"file://target/multidir/?recursive=true&initialDelay=2000&delay=5000"
-            + "&excludeNamePostfix=old&moveExpression=done/${file:name}.old";
+            + "&exclude=.*old&moveExpression=done/${file:name}.old";
 
     @Override
     protected void setUp() throws Exception {

Modified: 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryNotMatchedTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryNotMatchedTest.java?rev=751226&r1=751225&r2=751226&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryNotMatchedTest.java
 (original)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerDirectoryNotMatchedTest.java
 Sat Mar  7 08:51:30 2009
@@ -26,7 +26,7 @@
  */
 public class FileConsumerDirectoryNotMatchedTest extends ContextTestSupport {
 
-    private String fileUrl = 
"file://target/dirnotmatched/?recursive=true&regexPattern=.*\\.txt$";
+    private String fileUrl = 
"file://target/dirnotmatched/?recursive=true&include=.*txt$";
 
     @Override
     protected void setUp() throws Exception {

Modified: 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExcludeNameTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExcludeNameTest.java?rev=751226&r1=751225&r2=751226&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExcludeNameTest.java
 (original)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerExcludeNameTest.java
 Sat Mar  7 08:51:30 2009
@@ -47,7 +47,7 @@
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                
from("file://target/exclude/?excludeNamePrefix=secret&excludeNamePostfix=xml")
+                from("file://target/exclude/?exclude=^secret.*|.*xml$")
                     .to("mock:result");
             }
         };

Modified: 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeAndExcludeNameTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeAndExcludeNameTest.java?rev=751226&r1=751225&r2=751226&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeAndExcludeNameTest.java
 (original)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeAndExcludeNameTest.java
 Sat Mar  7 08:51:30 2009
@@ -38,7 +38,7 @@
 
     private void prepareFiles() throws Exception {
         String url = "file://target/includeexclude";
-        template.sendBodyAndHeader(url, "Hello World", Exchange.FILE_NAME, 
"hello.xml");
+        template.sendBodyAndHeader(url, "Hello World", Exchange.FILE_NAME, 
"hello.txt");
         template.sendBodyAndHeader(url, "Report 1", Exchange.FILE_NAME, 
"report1.xml");
         template.sendBodyAndHeader(url, "Report 2", Exchange.FILE_NAME, 
"report2.txt");
         template.sendBodyAndHeader(url, "Report 3", Exchange.FILE_NAME, 
"report3.txt");
@@ -47,7 +47,7 @@
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                
from("file://target/includeexclude/?includeNamePrefix=report&excludeNamePostfix=xml")
+                
from("file://target/includeexclude/?include=.*txt&exclude=hello.*")
                     .to("mock:result");
             }
         };

Modified: 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeNameTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeNameTest.java?rev=751226&r1=751225&r2=751226&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeNameTest.java
 (original)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIncludeNameTest.java
 Sat Mar  7 08:51:30 2009
@@ -47,7 +47,7 @@
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                
from("file://target/include/?includeNamePrefix=report&includeNamePostfix=txt")
+                from("file://target/include/?include=^report.*txt$")
                     .to("mock:result");
             }
         };

Modified: 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveExpressionTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveExpressionTest.java?rev=751226&r1=751225&r2=751226&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveExpressionTest.java
 (original)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerMoveExpressionTest.java
 Sat Mar  7 08:51:30 2009
@@ -52,7 +52,7 @@
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("file://target/filelanguage/?excludeNamePostfix=.bak"
+                from("file://target/filelanguage/?exclude=.*bak"
                         + "&moveExpression=${id}.bak").to("mock:result");
             }
         });
@@ -77,7 +77,7 @@
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("file://target/filelanguage/?excludeNamePostfix=.bak"
+                from("file://target/filelanguage/?exclude=.*bak"
                      + 
"&moveExpression=backup-${id}-${file:name.noext}.bak").to("mock:result");
             }
         });
@@ -102,7 +102,7 @@
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("file://target/filelanguage/?excludeNamePostfix=.bak"
+                from("file://target/filelanguage/?exclude=.*bak"
                       + 
"&moveExpression=backup/${bean:myguidgenerator.guid}.txt").to("mock:result");
             }
         });
@@ -120,7 +120,7 @@
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("file://target/filelanguage/?excludeNamePostfix=.bak"
+                from("file://target/filelanguage/?exclude=.*bak"
                      + 
"&moveExpression=../backup/${file:name}.bak").to("mock:result");
             }
         });
@@ -145,7 +145,7 @@
                 endpoint.setOperations(new FileOperations(endpoint));
                 endpoint.setAutoCreate(false);
                 
endpoint.setMoveExpression(BeanLanguage.bean("myguidgenerator"));
-                endpoint.setExcludeNamePostfix(".bak");
+                endpoint.setExclude(".*bak");
 
                 from(endpoint).to("mock:result");
             }


Reply via email to