This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch pojo-beans in repository https://gitbox.apache.org/repos/asf/camel.git
commit 79d5117eeacd5163b5852dbc83c9288b86501e72 Author: Claus Ibsen <[email protected]> AuthorDate: Thu Mar 14 19:47:37 2024 +0100 CAMEL-17641: Generate json metadata for pojo beans in camel-core that end users can use such as AggregationStrategy implementations. And have that information in camel-catalog for tooling assistance. --- .../org/apache/camel/catalog/beans.properties | 1 + .../catalog/beans/ZipAggregationStrategy.json | 16 +++++++++++++ .../services/org/apache/camel/bean.properties | 7 ++++++ .../apache/camel/bean/ZipAggregationStrategy.json | 16 +++++++++++++ .../aggregate/zipfile/ZipAggregationStrategy.java | 28 ++++++++++++++++++++++ 5 files changed, 68 insertions(+) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans.properties b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans.properties index 682e217224d..d3d0542f64e 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans.properties +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans.properties @@ -8,3 +8,4 @@ MemoryIdempotentRepository StringAggregationStrategy UseLatestAggregationStrategy UseOriginalAggregationStrategy +ZipAggregationStrategy diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/ZipAggregationStrategy.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/ZipAggregationStrategy.json new file mode 100644 index 00000000000..edd5aa7271d --- /dev/null +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/ZipAggregationStrategy.json @@ -0,0 +1,16 @@ +{ + "bean": { + "kind": "bean", + "name": "ZipAggregationStrategy", + "javaType": "org.apache.camel.processor.aggregate.zipfile.ZipAggregationStrategy", + "interfaceType": "org.apache.camel.AggregationStrategy", + "title": "Zip Aggregation Strategy", + "description": "AggregationStrategy to zip together incoming messages into a zip file. Please note that this aggregation strategy requires eager completion check to work properly.", + "deprecated": false, + "groupId": "org.apache.camel", + "artifactId": "camel-zipfile", + "version": "4.5.0-SNAPSHOT", + "properties": { "filePrefix": { "index": 0, "kind": "property", "displayName": "File Prefix", "required": false, "type": "object", "javaType": "org.apache.camel.processor.aggregate.zipfile.ZipAggregationStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the prefix that will be used when creating the ZIP filename." }, "fileSuffix": { "index": 1, "kind": "property", "displayName": "File Suffix", "required": false, "type": "object", "javaType": "or [...] + } +} + diff --git a/components/camel-zipfile/src/generated/resources/META-INF/services/org/apache/camel/bean.properties b/components/camel-zipfile/src/generated/resources/META-INF/services/org/apache/camel/bean.properties new file mode 100644 index 00000000000..625e9734846 --- /dev/null +++ b/components/camel-zipfile/src/generated/resources/META-INF/services/org/apache/camel/bean.properties @@ -0,0 +1,7 @@ +# Generated by camel build tools - do NOT edit this file! +bean=ZipAggregationStrategy +groupId=org.apache.camel +artifactId=camel-zipfile +version=4.5.0-SNAPSHOT +projectName=Camel :: Zip File +projectDescription=Camel Zip file support diff --git a/components/camel-zipfile/src/generated/resources/META-INF/services/org/apache/camel/bean/ZipAggregationStrategy.json b/components/camel-zipfile/src/generated/resources/META-INF/services/org/apache/camel/bean/ZipAggregationStrategy.json new file mode 100644 index 00000000000..edd5aa7271d --- /dev/null +++ b/components/camel-zipfile/src/generated/resources/META-INF/services/org/apache/camel/bean/ZipAggregationStrategy.json @@ -0,0 +1,16 @@ +{ + "bean": { + "kind": "bean", + "name": "ZipAggregationStrategy", + "javaType": "org.apache.camel.processor.aggregate.zipfile.ZipAggregationStrategy", + "interfaceType": "org.apache.camel.AggregationStrategy", + "title": "Zip Aggregation Strategy", + "description": "AggregationStrategy to zip together incoming messages into a zip file. Please note that this aggregation strategy requires eager completion check to work properly.", + "deprecated": false, + "groupId": "org.apache.camel", + "artifactId": "camel-zipfile", + "version": "4.5.0-SNAPSHOT", + "properties": { "filePrefix": { "index": 0, "kind": "property", "displayName": "File Prefix", "required": false, "type": "object", "javaType": "org.apache.camel.processor.aggregate.zipfile.ZipAggregationStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the prefix that will be used when creating the ZIP filename." }, "fileSuffix": { "index": 1, "kind": "property", "displayName": "File Suffix", "required": false, "type": "object", "javaType": "or [...] + } +} + diff --git a/components/camel-zipfile/src/main/java/org/apache/camel/processor/aggregate/zipfile/ZipAggregationStrategy.java b/components/camel-zipfile/src/main/java/org/apache/camel/processor/aggregate/zipfile/ZipAggregationStrategy.java index 5b59f2eee7b..8e8467fe71e 100644 --- a/components/camel-zipfile/src/main/java/org/apache/camel/processor/aggregate/zipfile/ZipAggregationStrategy.java +++ b/components/camel-zipfile/src/main/java/org/apache/camel/processor/aggregate/zipfile/ZipAggregationStrategy.java @@ -36,6 +36,7 @@ import org.apache.camel.component.file.FileConsumer; import org.apache.camel.component.file.GenericFile; import org.apache.camel.component.file.GenericFileMessage; import org.apache.camel.component.file.GenericFileOperationFailedException; +import org.apache.camel.spi.Metadata; import org.apache.camel.spi.Synchronization; import org.apache.camel.support.ExchangeHelper; import org.apache.camel.util.FileUtil; @@ -51,13 +52,24 @@ import org.apache.camel.util.FileUtil; * <b>Note:</b> Please note that this aggregation strategy requires eager completion check to work properly. * </p> */ +@Metadata(label = "bean", + description = "AggregationStrategy to zip together incoming messages into a zip file." + + " Please note that this aggregation strategy requires eager completion check to work properly.") public class ZipAggregationStrategy implements AggregationStrategy { + @Metadata(description = "Sets the prefix that will be used when creating the ZIP filename.") private String filePrefix; + @Metadata(description = "Sets the suffix that will be used when creating the ZIP filename.", defaultValue = "zip") private String fileSuffix = ".zip"; + @Metadata(label = "advanced", + description = "If the incoming message is from a file, then the folder structure of said file can be preserved") private boolean preserveFolderStructure; + @Metadata(label = "advanced", + description = "Whether to use CamelFileName header for the filename instead of using unique message id") private boolean useFilenameHeader; + @Metadata(label = "advanced", description = "Whether to use temporary files for zip manipulations instead of memory.") private boolean useTempFile; + @Metadata(label = "advanced", description = "Sets the parent directory to use for writing temporary files") private File parentDir = new File(System.getProperty("java.io.tmpdir")); public ZipAggregationStrategy() { @@ -150,6 +162,22 @@ public class ZipAggregationStrategy implements AggregationStrategy { this.parentDir = new File(parentDir); } + public boolean isPreserveFolderStructure() { + return preserveFolderStructure; + } + + public void setPreserveFolderStructure(boolean preserveFolderStructure) { + this.preserveFolderStructure = preserveFolderStructure; + } + + public boolean isUseTempFile() { + return useTempFile; + } + + public void setUseTempFile(boolean useTempFile) { + this.useTempFile = useTempFile; + } + @Override public Exchange aggregate(Exchange oldExchange, Exchange newExchange) { File zipFile;
