You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes: #9988
Issue link: #9988
This change allows dynamic determination of `FileExistsMode` using SpEL expressions,
making the component more flexible when handling file existence conflicts.
* Add `fileExistsModeExpression` field and setter methods
* Use `resolveFileExistsMode()` in put and get operations
* Add changes to the docs
* Ignore `temporaryFileName` when `FileExistsMode.APPEND`
Improve runtime behavior by ignoring temporary filename settings when file exists mode is `APPEND`.
Now, in `FileExistsMode.APPEND` mode, content is always appended directly to the original file regardless of `useTemporaryFileName` setting.
In `RemoteFileTemplate`:
- Remove exception validation when `APPEND` mode is used with temporary filenames
- Modify logic to skip applying `temporaryFileSuffix` in `APPEND` mode
In `AbstractRemoteFileOutboundGateway`:
- Remove logic that disabled temporary filenames when setting `APPEND` mode
* Apply review feedback on `FileExistsMode` expression
- Optimize `EvaluationContext` usage by creating it once in `doInit()`
- Enhance expression evaluation to support String representation of `FileExistsMode`
- Optimize temporary filename handling logic in `RemoteFileTemplate`
- Add warning message for incompatible `APPEND` mode with temporary filenames
- Rename method to `setFileExistsModeExpressionString` for consistency
- Update Java DSL support in `RemoteFileOutboundGatewaySpec`
- Update reference documentation and release notes
* Apply additional review feedback on `FileExistsMode` expression
- Add `Function` variant to `RemoteFileOutboundGatewaySpec`
- Update documentations to use one-sentence-per-line style
- Improve code flow in `resolveFileExistsMode()` method
* Fix additional review feedback on `FileExistsMode` expression
- Use `Object` instead of `String` in `fileExistsModeFunction`
- Fix return method call in `fileExistsModeFunction` (`remoteDirectoryExpression` -> `fileExistsModeExpression`)
- Fix `standardEvaluationContext` initialization in `doInit()`
- Ensure proper `EvaluationContext` usage in other methods
Signed-off-by: Jooyoung Pyoung <[email protected]>
Copy file name to clipboardExpand all lines: spring-integration-file/src/main/java/org/springframework/integration/file/dsl/RemoteFileOutboundGatewaySpec.java
+44-1Lines changed: 44 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2016-2023 the original author or authors.
2
+
* Copyright 2016-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -44,6 +44,7 @@
44
44
*
45
45
* @author Artem Bilan
46
46
* @author Gary Russell
47
+
* @author Jooyoung Pyoung
47
48
*
48
49
* @since 5.0
49
50
*/
@@ -358,6 +359,48 @@ public S fileExistsMode(FileExistsMode fileExistsMode) {
358
359
return_this();
359
360
}
360
361
362
+
/**
363
+
* Specify a SpEL expression to determine the action to take when files already exist.
364
+
* Expression evaluation should return a {@link FileExistsMode} or a String representation.
365
+
* Used for GET and MGET operations when the file already exists locally,
366
+
* or PUT and MPUT when the file exists on the remote system.
367
+
* @param fileExistsModeExpression a SpEL expression to evaluate the file exists mode
Copy file name to clipboardExpand all lines: spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java
+67-7Lines changed: 67 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2002-2024 the original author or authors.
2
+
* Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -75,6 +75,7 @@
75
75
* @author Gary Russell
76
76
* @author Artem Bilan
77
77
* @author Mauro Molinari
78
+
* @author Jooyoung Pyoung
78
79
*
79
80
* @since 2.1
80
81
*/
@@ -114,8 +115,12 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
0 commit comments