camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [1/5] git commit: CAMEL-6099 Fix some CS error and throw IllegalArguemtExcpetion if the chmod option is not set rightly
Date Tue, 04 Nov 2014 02:42:50 GMT
Repository: camel
Updated Branches:
  refs/heads/master 5b250e35f -> eedf2360b


CAMEL-6099 Fix some CS error and throw IllegalArguemtExcpetion if the chmod option is not
set rightly


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

Branch: refs/heads/master
Commit: eedf2360b9e8bb0989484857bb7b1e680e505709
Parents: fa2df94
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Tue Nov 4 10:38:58 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Tue Nov 4 10:42:13 2014 +0800

----------------------------------------------------------------------
 .../component/file/GenericFileEndpoint.java     | 48 ++++++++++++++------
 1 file changed, 33 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/eedf2360/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 3e416b6..3b61ab6 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
@@ -57,6 +57,10 @@ 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());
 
@@ -291,7 +295,7 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint
imple
         if (ObjectHelper.isNotEmpty(chmod) && chmodPermissionsAreValid(chmod)) {
             this.chmod = chmod.trim();
         } else {
-            throw new Exception("chmod option [" + chmod + "] is not valid");
+            throw new IllegalArgumentException("chmod option [" + chmod + "] is not valid");
         }
     }
 
@@ -306,7 +310,7 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint
imple
             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++) {
+        for (int i = 0; i < permissionsString.length(); i++) {
             Character c = permissionsString.charAt(i);
             if (!Character.isDigit(c) || Integer.parseInt(c.toString()) > 7) {
                 return false;
@@ -315,10 +319,6 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint
imple
         return true;
     }
 
-    private static final Integer CHMOD_WRITE_MASK = 02;
-    private static final Integer CHMOD_READ_MASK = 04;
-    private static final Integer CHMOD_EXECUTE_MASK = 01;
-
     public Set<PosixFilePermission> getPermissions() {
         Set<PosixFilePermission> permissions = new HashSet<>();
         if (ObjectHelper.isEmpty(chmod)) {
@@ -331,17 +331,35 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint
imple
         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 ((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 ((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);}
+        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;
     }


Mime
View raw message