camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [3/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.
Date Wed, 17 Feb 2016 08:51:39 GMT
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/41510874
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/41510874
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/41510874

Branch: refs/heads/camel-2.15.x
Commit: 41510874ae1dc95baccbf9b42bc6a4ba19a14ec1
Parents: b727189
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Feb 17 09:18:24 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Feb 17 09:51:27 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/41510874/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 5bf82bb..cfb4d37 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();


Mime
View raw message