Repository: camel
Updated Branches:
  refs/heads/master 95b60ce5e -> ca743cf73


CAMEL-9618: File endpoint - Move some options from generic to file as they are 
file specifc


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ca743cf7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ca743cf7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ca743cf7

Branch: refs/heads/master
Commit: ca743cf736b85915ac9432aaaef8997fed06a2b6
Parents: 9784d03
Author: Claus Ibsen <davscl...@apache.org>
Authored: Thu Feb 18 19:48:07 2016 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Thu Feb 18 19:57:39 2016 +0100

----------------------------------------------------------------------
 .../camel/component/file/FileConsumer.java      |   2 +-
 .../camel/component/file/FileEndpoint.java      | 166 +++++++++++++++++++
 .../component/file/GenericFileEndpoint.java     | 161 ------------------
 3 files changed, 167 insertions(+), 162 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ca743cf7/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java 
b/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
index 16c5cd2..7ffc1a7 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/FileConsumer.java
@@ -39,7 +39,7 @@ public class FileConsumer extends GenericFileConsumer<File> {
     private String endpointPath;
     private Set<String> extendedAttributes;
 
-    public FileConsumer(GenericFileEndpoint<File> endpoint, Processor 
processor, GenericFileOperations<File> operations) {
+    public FileConsumer(FileEndpoint endpoint, Processor processor, 
GenericFileOperations<File> operations) {
         super(endpoint, processor, operations);
         this.endpointPath = endpoint.getConfiguration().getDirectory();
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ca743cf7/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java 
b/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
index 2d51753..a55dc6f 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
@@ -19,6 +19,9 @@ package org.apache.camel.component.file;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.nio.file.Files;
+import java.nio.file.attribute.PosixFilePermission;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.apache.camel.Component;
 import org.apache.camel.Exchange;
@@ -38,6 +41,10 @@ import org.apache.camel.util.ObjectHelper;
 @UriEndpoint(scheme = "file", title = "File", syntax = "file:directoryName", 
consumerClass = FileConsumer.class, label = "core,file")
 public class FileEndpoint extends GenericFileEndpoint<File> {
 
+    private static final Integer CHMOD_WRITE_MASK = 02;
+    private static final Integer CHMOD_READ_MASK = 04;
+    private static final Integer CHMOD_EXECUTE_MASK = 01;
+
     private final FileOperations operations = new FileOperations(this);
 
     @UriPath(name = "directoryName") @Metadata(required = "true")
@@ -50,6 +57,12 @@ public class FileEndpoint extends GenericFileEndpoint<File> {
     private boolean forceWrites = true;
     @UriParam(label = "consumer,advanced")
     private boolean probeContentType;
+    @UriParam(label = "consumer,advanced")
+    private String extendedAttributes;
+    @UriParam(label = "producer,advanced")
+    private String chmod;
+    @UriParam(label = "producer,advanced")
+    private String chmodDirectory;
 
     public FileEndpoint() {
         // use marker file as default exclusive read locks
@@ -225,4 +238,157 @@ public class FileEndpoint extends 
GenericFileEndpoint<File> {
     public void setProbeContentType(boolean probeContentType) {
         this.probeContentType = probeContentType;
     }
+
+
+    public String getExtendedAttributes() {
+        return extendedAttributes;
+    }
+
+    /**
+     * To define which file attributes of interest. Like 
posix:permissions,posix:owner,basic:lastAccessTime,
+     * it supports basic wildcard like posix:*, basic:lastAccessTime
+     */
+    public void setExtendedAttributes(String extendedAttributes) {
+        this.extendedAttributes = extendedAttributes;
+    }
+
+    /**
+     * Chmod value must be between 000 and 777; If there is a leading digit 
like in 0755 we will ignore it.
+     */
+    public boolean chmodPermissionsAreValid(String chmod) {
+        if (chmod == null || chmod.length() < 3 || chmod.length() > 4) {
+            return false;
+        }
+        String permissionsString = chmod.trim().substring(chmod.length() - 3); 
 // if 4 digits chop off leading one
+        for (int i = 0; i < permissionsString.length(); i++) {
+            Character c = permissionsString.charAt(i);
+            if (!Character.isDigit(c) || Integer.parseInt(c.toString()) > 7) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public Set<PosixFilePermission> getPermissions() {
+        Set<PosixFilePermission> permissions = new 
HashSet<PosixFilePermission>();
+        if (ObjectHelper.isEmpty(chmod)) {
+            return permissions;
+        }
+
+        String chmodString = chmod.substring(chmod.length() - 3);  // if 4 
digits chop off leading one
+
+        Integer ownerValue = Integer.parseInt(chmodString.substring(0, 1));
+        Integer groupValue = Integer.parseInt(chmodString.substring(1, 2));
+        Integer othersValue = Integer.parseInt(chmodString.substring(2, 3));
+
+        if ((ownerValue & CHMOD_WRITE_MASK) > 0) {
+            permissions.add(PosixFilePermission.OWNER_WRITE);
+        }
+        if ((ownerValue & CHMOD_READ_MASK) > 0) {
+            permissions.add(PosixFilePermission.OWNER_READ);
+        }
+        if ((ownerValue & CHMOD_EXECUTE_MASK) > 0) {
+            permissions.add(PosixFilePermission.OWNER_EXECUTE);
+        }
+
+        if ((groupValue & CHMOD_WRITE_MASK) > 0) {
+            permissions.add(PosixFilePermission.GROUP_WRITE);
+        }
+        if ((groupValue & CHMOD_READ_MASK) > 0) {
+            permissions.add(PosixFilePermission.GROUP_READ);
+        }
+        if ((groupValue & CHMOD_EXECUTE_MASK) > 0) {
+            permissions.add(PosixFilePermission.GROUP_EXECUTE);
+        }
+
+        if ((othersValue & CHMOD_WRITE_MASK) > 0) {
+            permissions.add(PosixFilePermission.OTHERS_WRITE);
+        }
+        if ((othersValue & CHMOD_READ_MASK) > 0) {
+            permissions.add(PosixFilePermission.OTHERS_READ);
+        }
+        if ((othersValue & CHMOD_EXECUTE_MASK) > 0) {
+            permissions.add(PosixFilePermission.OTHERS_EXECUTE);
+        }
+
+        return permissions;
+    }
+
+    public String getChmod() {
+        return chmod;
+    }
+
+    /**
+     * Specify the file permissions which is sent by the producer, the chmod 
value must be between 000 and 777;
+     * If there is a leading digit like in 0755 we will ignore it.
+     */
+    public void setChmod(String chmod) throws Exception {
+        if (ObjectHelper.isNotEmpty(chmod) && chmodPermissionsAreValid(chmod)) 
{
+            this.chmod = chmod.trim();
+        } else {
+            throw new IllegalArgumentException("chmod option [" + chmod + "] 
is not valid");
+        }
+    }
+
+    public Set<PosixFilePermission> getDirectoryPermissions() {
+        Set<PosixFilePermission> permissions = new 
HashSet<PosixFilePermission>();
+        if (ObjectHelper.isEmpty(chmodDirectory)) {
+            return permissions;
+        }
+
+        String chmodString = chmodDirectory.substring(chmodDirectory.length() 
- 3);  // if 4 digits chop off leading one
+
+        Integer ownerValue = Integer.parseInt(chmodString.substring(0, 1));
+        Integer groupValue = Integer.parseInt(chmodString.substring(1, 2));
+        Integer othersValue = Integer.parseInt(chmodString.substring(2, 3));
+
+        if ((ownerValue & CHMOD_WRITE_MASK) > 0) {
+            permissions.add(PosixFilePermission.OWNER_WRITE);
+        }
+        if ((ownerValue & CHMOD_READ_MASK) > 0) {
+            permissions.add(PosixFilePermission.OWNER_READ);
+        }
+        if ((ownerValue & CHMOD_EXECUTE_MASK) > 0) {
+            permissions.add(PosixFilePermission.OWNER_EXECUTE);
+        }
+
+        if ((groupValue & CHMOD_WRITE_MASK) > 0) {
+            permissions.add(PosixFilePermission.GROUP_WRITE);
+        }
+        if ((groupValue & CHMOD_READ_MASK) > 0) {
+            permissions.add(PosixFilePermission.GROUP_READ);
+        }
+        if ((groupValue & CHMOD_EXECUTE_MASK) > 0) {
+            permissions.add(PosixFilePermission.GROUP_EXECUTE);
+        }
+
+        if ((othersValue & CHMOD_WRITE_MASK) > 0) {
+            permissions.add(PosixFilePermission.OTHERS_WRITE);
+        }
+        if ((othersValue & CHMOD_READ_MASK) > 0) {
+            permissions.add(PosixFilePermission.OTHERS_READ);
+        }
+        if ((othersValue & CHMOD_EXECUTE_MASK) > 0) {
+            permissions.add(PosixFilePermission.OTHERS_EXECUTE);
+        }
+
+        return permissions;
+    }
+
+    public String getChmodDirectory() {
+        return chmodDirectory;
+    }
+
+    /**
+     * Specify the directory permissions used when the producer creates 
missing directories, the chmod value must be between 000 and 777;
+     * If there is a leading digit like in 0755 we will ignore it.
+     */
+    public void setChmodDirectory(String chmodDirectory) throws Exception {
+        if (ObjectHelper.isNotEmpty(chmodDirectory) && 
chmodPermissionsAreValid(chmodDirectory)) {
+            this.chmodDirectory = chmodDirectory.trim();
+        } else {
+            throw new IllegalArgumentException("chmodDirectory option [" + 
chmodDirectory + "] is not valid");
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/ca743cf7/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
 
b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
index da6f235..518d127 100644
--- 
a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
+++ 
b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
@@ -59,10 +59,6 @@ public abstract class GenericFileEndpoint<T> extends 
ScheduledPollEndpoint imple
     protected static final String DEFAULT_STRATEGYFACTORY_CLASS = 
"org.apache.camel.component.file.strategy.GenericFileProcessStrategyFactory";
     protected static final int DEFAULT_IDEMPOTENT_CACHE_SIZE = 1000;
     
-    private static final Integer CHMOD_WRITE_MASK = 02;
-    private static final Integer CHMOD_READ_MASK = 04;
-    private static final Integer CHMOD_EXECUTE_MASK = 01;
-
     protected final Logger log = LoggerFactory.getLogger(getClass());
 
     // common options
@@ -94,10 +90,6 @@ public abstract class GenericFileEndpoint<T> extends 
ScheduledPollEndpoint imple
     protected String doneFileName;
     @UriParam(label = "producer,advanced")
     protected boolean allowNullBody;
-    @UriParam(label = "producer,advanced")
-    protected String chmod;
-    @UriParam(label = "producer,advanced")
-    protected String chmodDirectory;
 
     // consumer options
 
@@ -184,8 +176,6 @@ public abstract class GenericFileEndpoint<T> extends 
ScheduledPollEndpoint imple
     protected GenericFileExclusiveReadLockStrategy<T> 
exclusiveReadLockStrategy;
     @UriParam(label = "consumer,advanced")
     protected ExceptionHandler onCompletionExceptionHandler;
-    @UriParam(label = "consumer,advanced")
-    protected String extendedAttributes;
 
     public GenericFileEndpoint() {
     }
@@ -315,145 +305,6 @@ public abstract class GenericFileEndpoint<T> extends 
ScheduledPollEndpoint imple
         }
     }
 
-    /**
-     * Chmod value must be between 000 and 777; If there is a leading digit 
like in 0755 we will ignore it.
-     */
-    public boolean chmodPermissionsAreValid(String chmod) {
-        if (chmod == null || chmod.length() < 3 || chmod.length() > 4) {
-            return false;
-        }
-        String permissionsString = chmod.trim().substring(chmod.length() - 3); 
 // if 4 digits chop off leading one
-        for (int i = 0; i < permissionsString.length(); i++) {
-            Character c = permissionsString.charAt(i);
-            if (!Character.isDigit(c) || Integer.parseInt(c.toString()) > 7) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    public Set<PosixFilePermission> getPermissions() {
-        Set<PosixFilePermission> permissions = new 
HashSet<PosixFilePermission>();
-        if (ObjectHelper.isEmpty(chmod)) {
-            return permissions;
-        }
-
-        String chmodString = chmod.substring(chmod.length() - 3);  // if 4 
digits chop off leading one
-
-        Integer ownerValue = Integer.parseInt(chmodString.substring(0, 1));
-        Integer groupValue = Integer.parseInt(chmodString.substring(1, 2));
-        Integer othersValue = Integer.parseInt(chmodString.substring(2, 3));
-
-        if ((ownerValue & CHMOD_WRITE_MASK) > 0) {
-            permissions.add(PosixFilePermission.OWNER_WRITE);
-        }
-        if ((ownerValue & CHMOD_READ_MASK) > 0) {
-            permissions.add(PosixFilePermission.OWNER_READ);
-        }
-        if ((ownerValue & CHMOD_EXECUTE_MASK) > 0) {
-            permissions.add(PosixFilePermission.OWNER_EXECUTE);
-        }
-
-        if ((groupValue & CHMOD_WRITE_MASK) > 0) {
-            permissions.add(PosixFilePermission.GROUP_WRITE);
-        }
-        if ((groupValue & CHMOD_READ_MASK) > 0) {
-            permissions.add(PosixFilePermission.GROUP_READ);
-        }
-        if ((groupValue & CHMOD_EXECUTE_MASK) > 0) {
-            permissions.add(PosixFilePermission.GROUP_EXECUTE);
-        }
-
-        if ((othersValue & CHMOD_WRITE_MASK) > 0) {
-            permissions.add(PosixFilePermission.OTHERS_WRITE);
-        }
-        if ((othersValue & CHMOD_READ_MASK) > 0) {
-            permissions.add(PosixFilePermission.OTHERS_READ);
-        }
-        if ((othersValue & CHMOD_EXECUTE_MASK) > 0) {
-            permissions.add(PosixFilePermission.OTHERS_EXECUTE);
-        }
-
-        return permissions;
-    }
-
-    public String getChmod() {
-        return chmod;
-    }
-
-    /**
-     * Specify the file permissions which is sent by the producer, the chmod 
value must be between 000 and 777;
-     * If there is a leading digit like in 0755 we will ignore it.
-     */
-    public void setChmod(String chmod) throws Exception {
-        if (ObjectHelper.isNotEmpty(chmod) && chmodPermissionsAreValid(chmod)) 
{
-            this.chmod = chmod.trim();
-        } else {
-            throw new IllegalArgumentException("chmod option [" + chmod + "] 
is not valid");
-        }
-    }
-
-    public Set<PosixFilePermission> getDirectoryPermissions() {
-        Set<PosixFilePermission> permissions = new 
HashSet<PosixFilePermission>();
-        if (ObjectHelper.isEmpty(chmodDirectory)) {
-            return permissions;
-        }
-
-        String chmodString = chmodDirectory.substring(chmodDirectory.length() 
- 3);  // if 4 digits chop off leading one
-
-        Integer ownerValue = Integer.parseInt(chmodString.substring(0, 1));
-        Integer groupValue = Integer.parseInt(chmodString.substring(1, 2));
-        Integer othersValue = Integer.parseInt(chmodString.substring(2, 3));
-
-        if ((ownerValue & CHMOD_WRITE_MASK) > 0) {
-            permissions.add(PosixFilePermission.OWNER_WRITE);
-        }
-        if ((ownerValue & CHMOD_READ_MASK) > 0) {
-            permissions.add(PosixFilePermission.OWNER_READ);
-        }
-        if ((ownerValue & CHMOD_EXECUTE_MASK) > 0) {
-            permissions.add(PosixFilePermission.OWNER_EXECUTE);
-        }
-
-        if ((groupValue & CHMOD_WRITE_MASK) > 0) {
-            permissions.add(PosixFilePermission.GROUP_WRITE);
-        }
-        if ((groupValue & CHMOD_READ_MASK) > 0) {
-            permissions.add(PosixFilePermission.GROUP_READ);
-        }
-        if ((groupValue & CHMOD_EXECUTE_MASK) > 0) {
-            permissions.add(PosixFilePermission.GROUP_EXECUTE);
-        }
-
-        if ((othersValue & CHMOD_WRITE_MASK) > 0) {
-            permissions.add(PosixFilePermission.OTHERS_WRITE);
-        }
-        if ((othersValue & CHMOD_READ_MASK) > 0) {
-            permissions.add(PosixFilePermission.OTHERS_READ);
-        }
-        if ((othersValue & CHMOD_EXECUTE_MASK) > 0) {
-            permissions.add(PosixFilePermission.OTHERS_EXECUTE);
-        }
-
-        return permissions;
-    }
-
-    public String getChmodDirectory() {
-        return chmodDirectory;
-    }
-
-    /**
-     * Specify the directory permissions used when the producer creates 
missing directories, the chmod value must be between 000 and 777;
-     * If there is a leading digit like in 0755 we will ignore it.
-     */
-    public void setChmodDirectory(String chmodDirectory) throws Exception {
-        if (ObjectHelper.isNotEmpty(chmodDirectory) && 
chmodPermissionsAreValid(chmodDirectory)) {
-            this.chmodDirectory = chmodDirectory.trim();
-        } else {
-            throw new IllegalArgumentException("chmodDirectory option [" + 
chmodDirectory + "] is not valid");
-        }
-    }
-
     public boolean isNoop() {
         return noop;
     }
@@ -1253,18 +1104,6 @@ public abstract class GenericFileEndpoint<T> extends 
ScheduledPollEndpoint imple
         this.onCompletionExceptionHandler = onCompletionExceptionHandler;
     }
 
-    public String getExtendedAttributes() {
-        return extendedAttributes;
-    }
-
-    /**
-     * To define which file attributes of interest. Like 
posix:permissions,posix:owner,basic:lastAccessTime,
-     * it supports basic wildcard like posix:*, basic:lastAccessTime
-     */
-    public void setExtendedAttributes(String extendedAttributes) {
-        this.extendedAttributes = extendedAttributes;
-    }
-
     /**
      * Configures the given message with the file which sets the body to the
      * file object.

Reply via email to