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 2016/02/17 09:51:38 UTC

[2/3] camel git commit: CAMEL-9607: chmod does not work for the File producer whitout setting a charset. Thanks to Nicolas Mugnier for spotting this.

CAMEL-9607: chmod does not work for the File producer whitout setting a charset. Thanks to Nicolas Mugnier for spotting this.


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

Branch: refs/heads/camel-2.16.x
Commit: dd59bf8765b8e99b89c512beeca69c25ccd39fd6
Parents: abe610d
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Feb 17 09:18:24 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Feb 17 09:51:10 2016 +0100

----------------------------------------------------------------------
 .../camel/component/file/FileOperations.java      | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/dd59bf87/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java b/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
index 4164a07..412d81a 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
@@ -242,6 +242,14 @@ public class FileOperations implements GenericFileOperations<File> {
                     if (renamed) {
                         // try to keep last modified timestamp if configured to do so
                         keepLastModified(exchange, file);
+                        // set permissions if the chmod option was set
+                        if (ObjectHelper.isNotEmpty(endpoint.getChmod())) {
+                            Set<PosixFilePermission> permissions = endpoint.getPermissions();
+                            if (!permissions.isEmpty()) {
+                                Files.setPosixFilePermissions(file.toPath(), permissions);
+                                LOG.trace("Setting chmod: {} on file: {} ", PosixFilePermissions.toString(permissions), file);
+                            }
+                        }
                         // clear header as we have renamed the file
                         exchange.getIn().setHeader(Exchange.FILE_LOCAL_WORK_PATH, null);
                         // return as the operation is complete, we just renamed the local work file
@@ -253,6 +261,14 @@ public class FileOperations implements GenericFileOperations<File> {
                     writeFileByFile(source, file);
                     // try to keep last modified timestamp if configured to do so
                     keepLastModified(exchange, file);
+                    // set permissions if the chmod option was set
+                    if (ObjectHelper.isNotEmpty(endpoint.getChmod())) {
+                        Set<PosixFilePermission> permissions = endpoint.getPermissions();
+                        if (!permissions.isEmpty()) {
+                            Files.setPosixFilePermissions(file.toPath(), permissions);
+                            LOG.trace("Setting chmod: {} on file: {} ", PosixFilePermissions.toString(permissions), file);
+                        }
+                    }
                     return true;
                 }
             }
@@ -273,9 +289,9 @@ public class FileOperations implements GenericFileOperations<File> {
                 InputStream in = exchange.getIn().getMandatoryBody(InputStream.class);
                 writeFileByStream(in, file);
             }
+
             // try to keep last modified timestamp if configured to do so
             keepLastModified(exchange, file);
-
             // set permissions if the chmod option was set
             if (ObjectHelper.isNotEmpty(endpoint.getChmod())) {
                 Set<PosixFilePermission> permissions = endpoint.getPermissions();