GH-9452: Expose ZipTransformer.setFileNameGenerator()

Fixes: #9452
Issue link: https://github.com/spring-projects/spring-integration/issues/9452

* Move the logic about `fileNameGenerator` configuration out of `AbstractZipTransformer`
since this property is not used by `UnZipTransformer` implementation
* Add more docs about `ZipTransformer` logic
This commit is contained in:
Artem Bilan
2024-09-12 16:19:17 -04:00
parent e3a46ca528
commit a6c3a30d5b
5 changed files with 56 additions and 52 deletions

View File

@@ -78,3 +78,9 @@ See xref:sftp/session-factory.adoc[SFTP Session Factory] for more information.
Multiple instances of `MqttPahoMessageDrivenChannelAdapter` and `Mqttv5PahoMessageDrivenChannelAdapter` can now be added at runtime using corresponding `ClientManager` through `IntegrationFlowContext`
Also a `MqttMessageNotDeliveredEvent` event has been introduced to emit when action callback reacts to the delivery failure.
See xref:mqtt.adoc[MQTT Support] for more information.
[[x6.4-zip-support-changes]]
=== Zip Support Changes
The `ZipTransformer` now exposes a `fileNameGenerator` property to customize a target zip file (and optional zip entry) name generation.
See xref:zip.adoc[Zip Support] for more information.

View File

@@ -69,6 +69,14 @@ The `ZipTransformer` can be customized by setting several properties:
Default is `Deflater#DEFAULT_COMPRESSION`.
* `useFileAttributes` - specifies whether the name of the file shall be used for the zip entry.
* `fileNameGenerator` - uses to generate an original file name based on the request message.
Defaults to `DefaultFileNameGenerator`.
The `.zip` extension is added into this name for the target zip file name.
Unless it is already present as a result of this generator.
In addition, a `ZipHeaders.ZIP_ENTRY_FILE_NAME` and `ZipHeaders.ZIP_ENTRY_LAST_MODIFIED_DATE` can be supplied for the name of zip entry and its `lastmodified` attribute.
If not provided, the entry name is exact result of the `fileNameGenerator` and `lastmodified` falls back to the current date and time.
If the payload of request message is an `Iterable`, then this entry name is modified with an index starting `1`.
For example to zip a simple `test.txt` file into a `test.txt.zip`, only this configuration is enough: