Skip to content

GH-9988: Add FileExistsMode expression support #10019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 15, 2025

Conversation

anthologia
Copy link
Contributor

Fixes #9988

In AbstractRemoteFileOutboundGateway:

  • Add fileExistsModeExpression field and setter methods
  • Use resolveFileExistsMode in put and get operations
  • Remove logic that disabled temporary filenames when setting APPEND mode

In RemoteFileTemplate:

  • Remove exception validation when APPEND mode is used with temporary filenames
  • Modify logic to skip applying temporaryFileSuffix in APPEND mode

Fixes: spring-projects#9988
Issue link: spring-projects#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

Signed-off-by: Jooyoung Pyoung <[email protected]>
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

Signed-off-by: Jooyoung Pyoung <[email protected]>
Signed-off-by: Jooyoung Pyoung <[email protected]>
Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, consider to describe this new feature in the: https://docs.spring.io/spring-integration/reference/ftp/rft.html#page-title. (src/reference/antora/modules/ROOT/pages/sftp/rft.adoc file)

And also mention new feature in the whats-new.adoc.

And as a bonus we also can consider to expose this new option on the RemoteFileOutboundGatewaySpec for Java DSL.

Thanks

- 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

Signed-off-by: Jooyoung Pyoung <[email protected]>
@anthologia
Copy link
Contributor Author

I've implemented all these suggestions:

  • Added documentation to the rft.adoc and whats-new.adoc
  • Implemented Java DSL support in RemoteFileOutboundGatewaySpec with both Expression and String parameter variants

Thank you for the helpful guidance! Please let me know if any further adjustments are needed.

- Add Function variant to RemoteFileOutboundGatewaySpec
- Update documentations to use one-sentence-per-line style
- Improve code flow in resolveFileExistsMode method

Signed-off-by: Jooyoung Pyoung <[email protected]>
- 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]>
@anthologia
Copy link
Contributor Author

I've fixed all the issues you pointed out in your reviews, as well as additional mistake I noticed. I think I made these mistakes because I was rushing with the 6.5 release timeline in mind. Please let me know if there's anything else I might have missed! Thanks.

@artembilan artembilan merged commit debd4d4 into spring-projects:main May 15, 2025
3 checks passed
@artembilan
Copy link
Member

@anthologia ,

thank you very much for the contribution; looking forward for more!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support fileExistModeExpression() in Ftp.outboundGateway
2 participants