This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 09e07dd714c92084854e2f58ec4c8349b808878c Author: Claus Ibsen <[email protected]> AuthorDate: Thu Jan 12 11:17:14 2023 +0100 CAMEL-18891: Remove camel-xstream --- .../services/org/apache/camel/model.properties | 1 - .../apache/camel/model/dataformat/dataFormats.json | 2 +- .../org/apache/camel/model/dataformat/jaxb.index | 1 - .../org/apache/camel/model/dataformat/xstream.json | 28 -- .../resources/org/apache/camel/model/marshal.json | 2 +- .../org/apache/camel/model/unmarshal.json | 2 +- .../camel/builder/DataFormatBuilderFactory.java | 8 - .../org/apache/camel/builder/DataFormatClause.java | 62 --- .../org/apache/camel/model/MarshalDefinition.java | 2 - .../apache/camel/model/UnmarshalDefinition.java | 2 - .../model/dataformat/DataFormatsDefinition.java | 1 - .../camel/model/dataformat/XStreamDataFormat.java | 468 --------------------- .../DataFormatTransformerDefinition.java | 2 - .../reifier/dataformat/DataFormatReifier.java | 3 - .../dataformat/XStreamDataFormatReifier.java | 43 -- .../camel/model/routeWithXStreamDataFormat.xml | 30 -- .../java/org/apache/camel/xml/in/ModelParser.java | 24 -- .../test/resources/routeWithXStreamDataFormat.xml | 30 -- 18 files changed, 3 insertions(+), 708 deletions(-) diff --git a/core/camel-core-model/src/generated/resources/META-INF/services/org/apache/camel/model.properties b/core/camel-core-model/src/generated/resources/META-INF/services/org/apache/camel/model.properties index d6fe889aad1..28f24db97e3 100644 --- a/core/camel-core-model/src/generated/resources/META-INF/services/org/apache/camel/model.properties +++ b/core/camel-core-model/src/generated/resources/META-INF/services/org/apache/camel/model.properties @@ -220,7 +220,6 @@ wireTap xmlSecurity xpath xquery -xstream xtokenize yaml zipDeflater diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/dataFormats.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/dataFormats.json index f3512e463ec..78ab2a10f56 100644 --- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/dataFormats.json +++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/dataFormats.json @@ -12,6 +12,6 @@ "output": false }, "properties": { - "dataFormats": { "kind": "element", "displayName": "Data Formats", "required": true, "type": "array", "javaType": "java.util.List<org.apache.camel.model.DataFormatDefinition>", "oneOf": [ "any23", "asn1", "avro", "barcode", "base64", "bindy", "cbor", "crypto", "csv", "custom", "fhirJson", "fhirXml", "flatpack", "grok", "gzipDeflater", "hl7", "ical", "jacksonXml", "jaxb", "json", "jsonApi", "lzf", "mimeMultipart", "pgp", "protobuf", "rss", "soap", "swiftMt", "swiftMx", "syslog", "tarF [...] + "dataFormats": { "kind": "element", "displayName": "Data Formats", "required": true, "type": "array", "javaType": "java.util.List<org.apache.camel.model.DataFormatDefinition>", "oneOf": [ "any23", "asn1", "avro", "barcode", "base64", "bindy", "cbor", "crypto", "csv", "custom", "fhirJson", "fhirXml", "flatpack", "grok", "gzipDeflater", "hl7", "ical", "jacksonXml", "jaxb", "json", "jsonApi", "lzf", "mimeMultipart", "pgp", "protobuf", "rss", "soap", "swiftMt", "swiftMx", "syslog", "tarF [...] } } diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/jaxb.index b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/jaxb.index index 91eb2aedfbe..5d628701583 100644 --- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/jaxb.index +++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/jaxb.index @@ -43,7 +43,6 @@ UniVocityFixedDataFormat UniVocityHeader UniVocityTsvDataFormat XMLSecurityDataFormat -XStreamDataFormat YAMLDataFormat YAMLLibrary YAMLTypeFilterDefinition diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/xstream.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/xstream.json deleted file mode 100644 index 0ff73355d4e..00000000000 --- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/xstream.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "model": { - "kind": "model", - "name": "xstream", - "title": "XStream", - "description": "Marshal and unmarshal POJOs to\/from XML using XStream library.", - "deprecated": true, - "firstVersion": "1.3.0", - "label": "dataformat,transformation,xml,json", - "javaType": "org.apache.camel.model.dataformat.XStreamDataFormat", - "abstract": false, - "input": false, - "output": false - }, - "properties": { - "permissions": { "kind": "attribute", "displayName": "Permissions", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Adds permissions that controls which Java packages and classes XStream is allowed to use during unmarshal from xml\/json to Java beans. A permission must be configured either here or globally using a JVM system property. The permission can be specified in a syntax where a plus [...] - "encoding": { "kind": "attribute", "displayName": "Encoding", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the encoding to use" }, - "driver": { "kind": "attribute", "displayName": "Driver", "label": "advanced", "required": false, "type": "object", "javaType": "com.thoughtworks.xstream.io.HierarchicalStreamDriver", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom XStream driver. The instance must be of type com.thoughtworks.xstream.io.HierarchicalStreamDriver" }, - "driverRef": { "kind": "attribute", "displayName": "Driver Ref", "label": "advanced", "required": false, "type": "object", "javaType": "com.thoughtworks.xstream.io.HierarchicalStreamDriver", "deprecated": false, "autowired": false, "secret": false, "description": "To refer to a custom XStream driver to lookup in the registry. The instance must be of type com.thoughtworks.xstream.io.HierarchicalStreamDriver" }, - "mode": { "kind": "attribute", "displayName": "Mode", "label": "advanced", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "NO_REFERENCES", "ID_REFERENCES", "XPATH_RELATIVE_REFERENCES", "XPATH_ABSOLUTE_REFERENCES", "SINGLE_NODE_XPATH_RELATIVE_REFERENCES", "SINGLE_NODE_XPATH_ABSOLUTE_REFERENCES" ], "deprecated": false, "autowired": false, "secret": false, "description": "Mode for dealing with duplicate references The possible values are: NO_REFERENCES ID_R [...] - "contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the data format should set the Content-Type header with the type from the data format. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JSON" }, - "converters": { "kind": "element", "displayName": "Converters", "required": false, "type": "array", "javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>", "deprecated": false, "autowired": false, "secret": false, "description": "List of class names for using custom XStream converters. The classes must be of type com.thoughtworks.xstream.converters.Converter" }, - "aliases": { "kind": "element", "displayName": "Aliases", "required": false, "type": "array", "javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>", "deprecated": false, "autowired": false, "secret": false, "description": "Alias a Class to a shorter name to be used in XML elements." }, - "omitFields": { "kind": "element", "displayName": "Omit Fields", "required": false, "type": "array", "javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>", "deprecated": false, "autowired": false, "secret": false, "description": "Prevents a field from being serialized. To omit a field you must always provide the declaring type and not necessarily the type that is converted. Multiple values can be separated by comma." }, - "implicitCollections": { "kind": "element", "displayName": "Implicit Collections", "required": false, "type": "array", "javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>", "deprecated": false, "autowired": false, "secret": false, "description": "Adds a default implicit collection which is used for any unmapped XML tag. Multiple values can be separated by comma." }, - "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" } - } -} diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/marshal.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/marshal.json index c290002203d..51761863692 100644 --- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/marshal.json +++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/marshal.json @@ -12,7 +12,7 @@ "output": false }, "properties": { - "dataFormatType": { "kind": "element", "displayName": "Data Format Type", "required": true, "type": "object", "javaType": "org.apache.camel.model.DataFormatDefinition", "oneOf": [ "any23", "asn1", "avro", "barcode", "base64", "bindy", "cbor", "crypto", "csv", "custom", "fhirJson", "fhirXml", "flatpack", "grok", "gzipDeflater", "hl7", "ical", "jacksonXml", "jaxb", "json", "jsonApi", "lzf", "mimeMultipart", "pgp", "protobuf", "rss", "soap", "swiftMt", "swiftMx", "syslog", "tarFile", "t [...] + "dataFormatType": { "kind": "element", "displayName": "Data Format Type", "required": true, "type": "object", "javaType": "org.apache.camel.model.DataFormatDefinition", "oneOf": [ "any23", "asn1", "avro", "barcode", "base64", "bindy", "cbor", "crypto", "csv", "custom", "fhirJson", "fhirXml", "flatpack", "grok", "gzipDeflater", "hl7", "ical", "jacksonXml", "jaxb", "json", "jsonApi", "lzf", "mimeMultipart", "pgp", "protobuf", "rss", "soap", "swiftMt", "swiftMx", "syslog", "tarFile", "t [...] "disabled": { "kind": "attribute", "displayName": "Disabled", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to disable this EIP from the route during build time. Once an EIP has been disabled then it cannot be enabled later at runtime." }, "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the id of this node" }, "description": { "kind": "element", "displayName": "Description", "required": false, "type": "object", "javaType": "org.apache.camel.model.DescriptionDefinition", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the description of this node" } diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/unmarshal.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/unmarshal.json index 45dccff325a..a4e367d41f3 100644 --- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/unmarshal.json +++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/unmarshal.json @@ -12,7 +12,7 @@ "output": false }, "properties": { - "dataFormatType": { "kind": "element", "displayName": "Data Format Type", "required": true, "type": "object", "javaType": "org.apache.camel.model.DataFormatDefinition", "oneOf": [ "any23", "asn1", "avro", "barcode", "base64", "bindy", "cbor", "crypto", "csv", "custom", "fhirJson", "fhirXml", "flatpack", "grok", "gzipDeflater", "hl7", "ical", "jacksonXml", "jaxb", "json", "jsonApi", "lzf", "mimeMultipart", "pgp", "protobuf", "rss", "soap", "swiftMt", "swiftMx", "syslog", "tarFile", "t [...] + "dataFormatType": { "kind": "element", "displayName": "Data Format Type", "required": true, "type": "object", "javaType": "org.apache.camel.model.DataFormatDefinition", "oneOf": [ "any23", "asn1", "avro", "barcode", "base64", "bindy", "cbor", "crypto", "csv", "custom", "fhirJson", "fhirXml", "flatpack", "grok", "gzipDeflater", "hl7", "ical", "jacksonXml", "jaxb", "json", "jsonApi", "lzf", "mimeMultipart", "pgp", "protobuf", "rss", "soap", "swiftMt", "swiftMx", "syslog", "tarFile", "t [...] "allowNullBody": { "kind": "attribute", "displayName": "Allow Null Body", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Indicates whether null is allowed as value of a body to unmarshall." }, "disabled": { "kind": "attribute", "displayName": "Disabled", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to disable this EIP from the route during build time. Once an EIP has been disabled then it cannot be enabled later at runtime." }, "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the id of this node" }, diff --git a/core/camel-core-model/src/main/java/org/apache/camel/builder/DataFormatBuilderFactory.java b/core/camel-core-model/src/main/java/org/apache/camel/builder/DataFormatBuilderFactory.java index 76349645217..c113d84ac9f 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/builder/DataFormatBuilderFactory.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/builder/DataFormatBuilderFactory.java @@ -53,7 +53,6 @@ import org.apache.camel.model.dataformat.UniVocityCsvDataFormat; import org.apache.camel.model.dataformat.UniVocityFixedDataFormat; import org.apache.camel.model.dataformat.UniVocityTsvDataFormat; import org.apache.camel.model.dataformat.XMLSecurityDataFormat; -import org.apache.camel.model.dataformat.XStreamDataFormat; import org.apache.camel.model.dataformat.YAMLDataFormat; import org.apache.camel.model.dataformat.ZipDeflaterDataFormat; import org.apache.camel.model.dataformat.ZipFileDataFormat; @@ -319,13 +318,6 @@ public final class DataFormatBuilderFactory { return new XMLSecurityDataFormat.Builder(); } - /** - * Uses the XStream data format. - */ - public XStreamDataFormat.Builder xstream() { - return new XStreamDataFormat.Builder(); - } - /** * Uses the YAML data format */ diff --git a/core/camel-core-model/src/main/java/org/apache/camel/builder/DataFormatClause.java b/core/camel-core-model/src/main/java/org/apache/camel/builder/DataFormatClause.java index d1687d4e5e7..4961952cce4 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/builder/DataFormatClause.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/builder/DataFormatClause.java @@ -16,10 +16,8 @@ */ package org.apache.camel.builder; -import java.nio.charset.Charset; import java.util.List; import java.util.Map; -import java.util.StringJoiner; import org.w3c.dom.Node; @@ -61,7 +59,6 @@ import org.apache.camel.model.dataformat.TarFileDataFormat; import org.apache.camel.model.dataformat.ThriftDataFormat; import org.apache.camel.model.dataformat.TidyMarkupDataFormat; import org.apache.camel.model.dataformat.XMLSecurityDataFormat; -import org.apache.camel.model.dataformat.XStreamDataFormat; import org.apache.camel.model.dataformat.YAMLDataFormat; import org.apache.camel.model.dataformat.YAMLLibrary; import org.apache.camel.model.dataformat.ZipDeflaterDataFormat; @@ -924,65 +921,6 @@ public class DataFormatClause<T extends ProcessorDefinition<?>> { return dataFormat(new TidyMarkupDataFormat(Node.class)); } - /** - * Uses the XStream data format. - * <p/> - * Favor using {@link #xstream(String)} to pass in a permission - */ - @Deprecated - public T xstream() { - return dataFormat(new XStreamDataFormat()); - } - - /** - * Uses the xstream by setting the encoding or permission - * - * @param encodingOrPermission is either an encoding or permission syntax - */ - public T xstream(String encodingOrPermission) { - // is it an encoding? if not we assume its a permission - if (Charset.isSupported(encodingOrPermission)) { - return xstream(encodingOrPermission, (String) null); - } else { - return xstream(null, encodingOrPermission); - } - } - - /** - * Uses the xstream by setting the encoding - */ - @Deprecated - public T xstream(String encoding, String permission) { - XStreamDataFormat xdf = new XStreamDataFormat(); - xdf.setPermissions(permission); - xdf.setEncoding(encoding); - return dataFormat(xdf); - } - - /** - * Uses the xstream by permitting the java type - * - * @param type the pojo xstream should use as allowed permission - */ - public T xstream(Class<?> type) { - return xstream(null, type); - } - - /** - * Uses the xstream by permitting the java type - * - * @param encoding encoding to use - * @param type the pojo class(es) xstream should use as allowed permission - */ - public T xstream(String encoding, Class<?>... type) { - StringJoiner stringBuilder = new StringJoiner(","); - for (Class<?> clazz : type) { - stringBuilder.add("+"); - stringBuilder.add(clazz.getName()); - } - return xstream(encoding, stringBuilder.toString()); - } - /** * Uses the YAML data format * diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/MarshalDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/MarshalDefinition.java index fa5f1c39076..2e10b378967 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/MarshalDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/MarshalDefinition.java @@ -59,7 +59,6 @@ import org.apache.camel.model.dataformat.UniVocityCsvDataFormat; import org.apache.camel.model.dataformat.UniVocityFixedDataFormat; import org.apache.camel.model.dataformat.UniVocityTsvDataFormat; import org.apache.camel.model.dataformat.XMLSecurityDataFormat; -import org.apache.camel.model.dataformat.XStreamDataFormat; import org.apache.camel.model.dataformat.YAMLDataFormat; import org.apache.camel.model.dataformat.ZipDeflaterDataFormat; import org.apache.camel.model.dataformat.ZipFileDataFormat; @@ -110,7 +109,6 @@ public class MarshalDefinition extends NoOutputDefinition<MarshalDefinition> imp @XmlElement(name = "univocityFixed", type = UniVocityFixedDataFormat.class), @XmlElement(name = "univocityTsv", type = UniVocityTsvDataFormat.class), @XmlElement(name = "xmlSecurity", type = XMLSecurityDataFormat.class), - @XmlElement(name = "xstream", type = XStreamDataFormat.class), @XmlElement(name = "pgp", type = PGPDataFormat.class), @XmlElement(name = "yaml", type = YAMLDataFormat.class), @XmlElement(name = "zipDeflater", type = ZipDeflaterDataFormat.class), diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/UnmarshalDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/UnmarshalDefinition.java index 9bab3b13b61..72b578d5b23 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/UnmarshalDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/UnmarshalDefinition.java @@ -60,7 +60,6 @@ import org.apache.camel.model.dataformat.UniVocityCsvDataFormat; import org.apache.camel.model.dataformat.UniVocityFixedDataFormat; import org.apache.camel.model.dataformat.UniVocityTsvDataFormat; import org.apache.camel.model.dataformat.XMLSecurityDataFormat; -import org.apache.camel.model.dataformat.XStreamDataFormat; import org.apache.camel.model.dataformat.YAMLDataFormat; import org.apache.camel.model.dataformat.ZipDeflaterDataFormat; import org.apache.camel.model.dataformat.ZipFileDataFormat; @@ -111,7 +110,6 @@ public class UnmarshalDefinition extends NoOutputDefinition<UnmarshalDefinition> @XmlElement(name = "univocityFixed", type = UniVocityFixedDataFormat.class), @XmlElement(name = "univocityTsv", type = UniVocityTsvDataFormat.class), @XmlElement(name = "xmlSecurity", type = XMLSecurityDataFormat.class), - @XmlElement(name = "xstream", type = XStreamDataFormat.class), @XmlElement(name = "pgp", type = PGPDataFormat.class), @XmlElement(name = "yaml", type = YAMLDataFormat.class), @XmlElement(name = "zipDeflater", type = ZipDeflaterDataFormat.class), diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java index 5a9d4010d72..848e70636c8 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java @@ -75,7 +75,6 @@ public class DataFormatsDefinition { @XmlElement(name = "univocityFixed", type = UniVocityFixedDataFormat.class), @XmlElement(name = "univocityTsv", type = UniVocityTsvDataFormat.class), @XmlElement(name = "xmlSecurity", type = XMLSecurityDataFormat.class), - @XmlElement(name = "xstream", type = XStreamDataFormat.class), @XmlElement(name = "pgp", type = PGPDataFormat.class), @XmlElement(name = "yaml", type = YAMLDataFormat.class), @XmlElement(name = "zipDeflater", type = ZipDeflaterDataFormat.class), diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java deleted file mode 100644 index 54eee9f1408..00000000000 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.model.dataformat; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.StringJoiner; - -import jakarta.xml.bind.annotation.XmlAccessType; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlTransient; - -import org.apache.camel.builder.DataFormatBuilder; -import org.apache.camel.model.DataFormatDefinition; -import org.apache.camel.model.PropertyDefinition; -import org.apache.camel.spi.Metadata; - -/** - * Marshal and unmarshal POJOs to/from XML using <a href="https://x-stream.github.io/">XStream</a> library. - */ -@Metadata(firstVersion = "1.3.0", label = "dataformat,transformation,xml,json", title = "XStream") -@XmlRootElement(name = "xstream") -@XmlAccessorType(XmlAccessType.NONE) -@Deprecated -public class XStreamDataFormat extends DataFormatDefinition implements ContentTypeHeaderAware { - - @XmlAttribute - private String permissions; - @XmlAttribute - private String encoding; - @XmlAttribute - @Metadata(label = "advanced", javaType = "com.thoughtworks.xstream.io.HierarchicalStreamDriver") - private String driver; - @XmlAttribute - @Metadata(label = "advanced", javaType = "com.thoughtworks.xstream.io.HierarchicalStreamDriver") - private String driverRef; - @XmlAttribute - @Metadata(label = "advanced", - enums = "NO_REFERENCES,ID_REFERENCES,XPATH_RELATIVE_REFERENCES,XPATH_ABSOLUTE_REFERENCES,SINGLE_NODE_XPATH_RELATIVE_REFERENCES,SINGLE_NODE_XPATH_ABSOLUTE_REFERENCES") - private String mode; - @XmlAttribute - @Metadata(javaType = "java.lang.Boolean", defaultValue = "true", - description = "Whether the data format should set the Content-Type header with the type from the data format." - + " For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON") - private String contentTypeHeader; - @XmlElement(name = "converters") - private List<PropertyDefinition> converters; - @XmlElement(name = "aliases") - private List<PropertyDefinition> aliases; - @XmlElement(name = "omitFields") - private List<PropertyDefinition> omitFields; - @XmlElement(name = "implicitCollections") - private List<PropertyDefinition> implicitCollections; - - public XStreamDataFormat() { - super("xstream"); - } - - public XStreamDataFormat(String encoding) { - this(); - setEncoding(encoding); - } - - private XStreamDataFormat(Builder builder) { - this(); - this.permissions = builder.permissions; - this.encoding = builder.encoding; - this.driver = builder.driver; - this.driverRef = builder.driverRef; - this.mode = builder.mode; - this.contentTypeHeader = builder.contentTypeHeader; - this.converters = builder.converters; - this.aliases = builder.aliases; - this.omitFields = builder.omitFields; - this.implicitCollections = builder.implicitCollections; - } - - @Override - public String getDataFormatName() { - return "json".equals(driver) ? "xstreamJson" : "xstream"; - } - - public String getEncoding() { - return encoding; - } - - /** - * Sets the encoding to use - */ - public void setEncoding(String encoding) { - this.encoding = encoding; - } - - public String getDriver() { - return driver; - } - - /** - * To use a custom XStream driver. The instance must be of type com.thoughtworks.xstream.io.HierarchicalStreamDriver - */ - public void setDriver(String driver) { - this.driver = driver; - } - - public String getDriverRef() { - return driverRef; - } - - /** - * To refer to a custom XStream driver to lookup in the registry. The instance must be of type - * com.thoughtworks.xstream.io.HierarchicalStreamDriver - */ - public void setDriverRef(String driverRef) { - this.driverRef = driverRef; - } - - public String getMode() { - return mode; - } - - /** - * Mode for dealing with duplicate references The possible values are: - * <ul> - * <li>NO_REFERENCES</li> - * <li>ID_REFERENCES</li> - * <li>XPATH_RELATIVE_REFERENCES</li> - * <li>XPATH_ABSOLUTE_REFERENCES</li> - * <li>SINGLE_NODE_XPATH_RELATIVE_REFERENCES</li> - * <li>SINGLE_NODE_XPATH_ABSOLUTE_REFERENCES</li> - * </ul> - */ - public void setMode(String mode) { - this.mode = mode; - } - - public List<PropertyDefinition> getConverters() { - return converters; - } - - public Map<String, String> getConvertersAsMap() { - if (converters == null || converters.isEmpty()) { - return null; - } - Map<String, String> answer = new LinkedHashMap<>(); - for (PropertyDefinition def : converters) { - answer.put(def.getKey(), def.getValue()); - } - return answer; - } - - /** - * List of class names for using custom XStream converters. The classes must be of type - * com.thoughtworks.xstream.converters.Converter - */ - public void setConverters(List<PropertyDefinition> converters) { - this.converters = converters; - } - - public void setConverters(Map<String, String> converters) { - setConverters(toList(converters)); - } - - private static List<PropertyDefinition> toList(Map<String, String> map) { - List<PropertyDefinition> result = new ArrayList<>(map.size()); - map.forEach((k, v) -> result.add(new PropertyDefinition(k, v))); - return result; - } - - public List<PropertyDefinition> getAliases() { - return aliases; - } - - public Map<String, String> getAliasesAsMap() { - if (aliases == null || aliases.isEmpty()) { - return null; - } - Map<String, String> answer = new LinkedHashMap<>(); - for (PropertyDefinition def : aliases) { - answer.put(def.getKey(), def.getValue()); - } - return answer; - } - - /** - * Alias a Class to a shorter name to be used in XML elements. - */ - public void setAliases(List<PropertyDefinition> aliases) { - this.aliases = aliases; - } - - public void setAliases(Map<String, String> aliases) { - setAliases(toList(aliases)); - } - - public List<PropertyDefinition> getOmitFields() { - return omitFields; - } - - /** - * Prevents a field from being serialized. To omit a field you must always provide the declaring type and not - * necessarily the type that is converted. Multiple values can be separated by comma. - */ - public void setOmitFields(List<PropertyDefinition> omitFields) { - this.omitFields = omitFields; - } - - public void setOmitFields(Map<String, String> aliases) { - setOmitFields(toList(aliases)); - } - - public Map<String, String> getOmitFieldsAsMap() { - if (omitFields == null || omitFields.isEmpty()) { - return null; - } - Map<String, String> answer = new LinkedHashMap<>(); - for (PropertyDefinition def : omitFields) { - answer.put(def.getKey(), def.getValue()); - } - return answer; - } - - public List<PropertyDefinition> getImplicitCollections() { - return implicitCollections; - } - - /** - * Adds a default implicit collection which is used for any unmapped XML tag. Multiple values can be separated by - * comma. - */ - public void setImplicitCollections(List<PropertyDefinition> implicitCollections) { - this.implicitCollections = implicitCollections; - } - - public void setImplicitCollections(Map<String, String> implicitCollections) { - setImplicitCollections(toList(implicitCollections)); - } - - public Map<String, String> getImplicitCollectionsAsMap() { - if (implicitCollections == null || implicitCollections.isEmpty()) { - return null; - } - Map<String, String> answer = new LinkedHashMap<>(); - for (PropertyDefinition def : implicitCollections) { - answer.put(def.getKey(), def.getValue()); - } - return answer; - } - - public String getPermissions() { - return permissions; - } - - /** - * Adds permissions that controls which Java packages and classes XStream is allowed to use during unmarshal from - * xml/json to Java beans. - * <p/> - * A permission must be configured either here or globally using a JVM system property. The permission can be - * specified in a syntax where a plus sign is allow, and minus sign is deny. <br/> - * Wildcards is supported by using <tt>.*</tt> as prefix. For example to allow <tt>com.foo</tt> and all subpackages - * then specify <tt>+com.foo.*</tt>. Multiple permissions can be configured separated by comma, such as - * <tt>+com.foo.*,-com.foo.bar.MySecretBean</tt>. <br/> - * The following default permission is always included: <tt>"-*,java.lang.*,java.util.*"</tt> unless its overridden - * by specifying a JVM system property with they key <tt>org.apache.camel.xstream.permissions</tt>. - */ - public void setPermissions(String permissions) { - this.permissions = permissions; - } - - /** - * To add permission for the given pojo classes. - * - * @param type the pojo class(es) xstream should use as allowed permission - * @see #setPermissions(String) - */ - public void setPermissions(Class<?>... type) { - setPermissions(toString(type)); - } - - private static String toString(Class<?>[] type) { - StringJoiner permissionsBuilder = new StringJoiner(","); - for (Class<?> clazz : type) { - permissionsBuilder.add("+"); - permissionsBuilder.add(clazz.getName()); - } - return permissionsBuilder.toString(); - } - - public String getContentTypeHeader() { - return contentTypeHeader; - } - - public void setContentTypeHeader(String contentTypeHeader) { - this.contentTypeHeader = contentTypeHeader; - } - - /** - * {@code Builder} is a specific builder for {@link XStreamDataFormat}. - */ - @XmlTransient - @Deprecated - public static class Builder implements DataFormatBuilder<XStreamDataFormat> { - - private String permissions; - private String encoding; - private String driver; - private String driverRef; - private String mode; - private String contentTypeHeader; - private List<PropertyDefinition> converters; - private List<PropertyDefinition> aliases; - private List<PropertyDefinition> omitFields; - private List<PropertyDefinition> implicitCollections; - - /** - * Sets the encoding to use - */ - public Builder encoding(String encoding) { - this.encoding = encoding; - return this; - } - - /** - * To use a custom XStream driver. The instance must be of type - * com.thoughtworks.xstream.io.HierarchicalStreamDriver - */ - public Builder driver(String driver) { - this.driver = driver; - return this; - } - - /** - * To refer to a custom XStream driver to lookup in the registry. The instance must be of type - * com.thoughtworks.xstream.io.HierarchicalStreamDriver - */ - public Builder driverRef(String driverRef) { - this.driverRef = driverRef; - return this; - } - - /** - * Mode for dealing with duplicate references The possible values are: - * <ul> - * <li>NO_REFERENCES</li> - * <li>ID_REFERENCES</li> - * <li>XPATH_RELATIVE_REFERENCES</li> - * <li>XPATH_ABSOLUTE_REFERENCES</li> - * <li>SINGLE_NODE_XPATH_RELATIVE_REFERENCES</li> - * <li>SINGLE_NODE_XPATH_ABSOLUTE_REFERENCES</li> - * </ul> - */ - public Builder mode(String mode) { - this.mode = mode; - return this; - } - - /** - * List of class names for using custom XStream converters. The classes must be of type - * com.thoughtworks.xstream.converters.Converter - */ - public Builder converters(List<PropertyDefinition> converters) { - this.converters = converters; - return this; - } - - public Builder converters(Map<String, String> converters) { - return converters(XStreamDataFormat.toList(converters)); - } - - /** - * Alias a Class to a shorter name to be used in XML elements. - */ - public Builder aliases(List<PropertyDefinition> aliases) { - this.aliases = aliases; - return this; - } - - public Builder aliases(Map<String, String> aliases) { - return aliases(toList(aliases)); - } - - /** - * Prevents a field from being serialized. To omit a field you must always provide the declaring type and not - * necessarily the type that is converted. Multiple values can be separated by comma. - */ - public Builder omitFields(List<PropertyDefinition> omitFields) { - this.omitFields = omitFields; - return this; - } - - public Builder omitFields(Map<String, String> aliases) { - return omitFields(XStreamDataFormat.toList(aliases)); - } - - /** - * Adds a default implicit collection which is used for any unmapped XML tag. Multiple values can be separated - * by comma. - */ - public Builder implicitCollections(List<PropertyDefinition> implicitCollections) { - this.implicitCollections = implicitCollections; - return this; - } - - public Builder implicitCollections(Map<String, String> implicitCollections) { - return implicitCollections(XStreamDataFormat.toList(implicitCollections)); - } - - /** - * Adds permissions that controls which Java packages and classes XStream is allowed to use during unmarshal - * from xml/json to Java beans. - * <p/> - * A permission must be configured either here or globally using a JVM system property. The permission can be - * specified in a syntax where a plus sign is allow, and minus sign is deny. <br/> - * Wildcards is supported by using <tt>.*</tt> as prefix. For example to allow <tt>com.foo</tt> and all - * subpackages then specify <tt>+com.foo.*</tt>. Multiple permissions can be configured separated by comma, such - * as <tt>+com.foo.*,-com.foo.bar.MySecretBean</tt>. <br/> - * The following default permission is always included: <tt>"-*,java.lang.*,java.util.*"</tt> unless its - * overridden by specifying a JVM system property with they key <tt>org.apache.camel.xstream.permissions</tt>. - */ - public Builder permissions(String permissions) { - this.permissions = permissions; - return this; - } - - /** - * To add permission for the given pojo classes. - * - * @param type the pojo class(es) xstream should use as allowed permission - * @see #setPermissions(String) - */ - public Builder permissions(Class<?>... type) { - return permissions(XStreamDataFormat.toString(type)); - } - - public Builder contentTypeHeader(String contentTypeHeader) { - this.contentTypeHeader = contentTypeHeader; - return this; - } - - public Builder contentTypeHeader(boolean contentTypeHeader) { - this.contentTypeHeader = Boolean.toString(contentTypeHeader); - return this; - } - - @Override - public XStreamDataFormat end() { - return new XStreamDataFormat(this); - } - } -} diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/transformer/DataFormatTransformerDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/transformer/DataFormatTransformerDefinition.java index 78995c2eafe..cc3a95998f7 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/transformer/DataFormatTransformerDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/transformer/DataFormatTransformerDefinition.java @@ -60,7 +60,6 @@ import org.apache.camel.model.dataformat.UniVocityCsvDataFormat; import org.apache.camel.model.dataformat.UniVocityFixedDataFormat; import org.apache.camel.model.dataformat.UniVocityTsvDataFormat; import org.apache.camel.model.dataformat.XMLSecurityDataFormat; -import org.apache.camel.model.dataformat.XStreamDataFormat; import org.apache.camel.model.dataformat.YAMLDataFormat; import org.apache.camel.model.dataformat.ZipDeflaterDataFormat; import org.apache.camel.model.dataformat.ZipFileDataFormat; @@ -113,7 +112,6 @@ public class DataFormatTransformerDefinition extends TransformerDefinition { @XmlElement(name = "univocityFixed", type = UniVocityFixedDataFormat.class), @XmlElement(name = "univocityTsv", type = UniVocityTsvDataFormat.class), @XmlElement(name = "xmlSecurity", type = XMLSecurityDataFormat.class), - @XmlElement(name = "xstream", type = XStreamDataFormat.class), @XmlElement(name = "pgp", type = PGPDataFormat.class), @XmlElement(name = "yaml", type = YAMLDataFormat.class), @XmlElement(name = "zipDeflater", type = ZipDeflaterDataFormat.class), diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/DataFormatReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/DataFormatReifier.java index 58c46116cd4..f7360c85dbd 100644 --- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/DataFormatReifier.java +++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/DataFormatReifier.java @@ -64,7 +64,6 @@ import org.apache.camel.model.dataformat.UniVocityCsvDataFormat; import org.apache.camel.model.dataformat.UniVocityFixedDataFormat; import org.apache.camel.model.dataformat.UniVocityTsvDataFormat; import org.apache.camel.model.dataformat.XMLSecurityDataFormat; -import org.apache.camel.model.dataformat.XStreamDataFormat; import org.apache.camel.model.dataformat.YAMLDataFormat; import org.apache.camel.model.dataformat.ZipDeflaterDataFormat; import org.apache.camel.model.dataformat.ZipFileDataFormat; @@ -253,8 +252,6 @@ public abstract class DataFormatReifier<T extends DataFormatDefinition> extends return new UniVocityTsvDataFormatReifier(camelContext, definition); } else if (definition instanceof XMLSecurityDataFormat) { return new XMLSecurityDataFormatReifier(camelContext, definition); - } else if (definition instanceof XStreamDataFormat) { - return new XStreamDataFormatReifier(camelContext, definition); } else if (definition instanceof YAMLDataFormat) { return new YAMLDataFormatReifier(camelContext, definition); } else if (definition instanceof ZipDeflaterDataFormat) { diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/XStreamDataFormatReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/XStreamDataFormatReifier.java deleted file mode 100644 index 1c8052eb7c4..00000000000 --- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/XStreamDataFormatReifier.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.reifier.dataformat; - -import java.util.Map; - -import org.apache.camel.CamelContext; -import org.apache.camel.model.DataFormatDefinition; -import org.apache.camel.model.dataformat.XStreamDataFormat; - -public class XStreamDataFormatReifier extends DataFormatReifier<XStreamDataFormat> { - - public XStreamDataFormatReifier(CamelContext camelContext, DataFormatDefinition definition) { - super(camelContext, (XStreamDataFormat) definition); - } - - @Override - protected void prepareDataFormatConfig(Map<String, Object> properties) { - properties.put("xstreamDriver", asRef(definition.getDriverRef())); - properties.put("permissions", definition.getPermissions()); - properties.put("encoding", definition.getEncoding()); - properties.put("converters", definition.getConvertersAsMap()); - properties.put("aliases", definition.getAliasesAsMap()); - properties.put("omitFields", definition.getOmitFieldsAsMap()); - properties.put("implicitCollections", definition.getImplicitCollectionsAsMap()); - properties.put("mode", definition.getMode()); - } - -} diff --git a/core/camel-core/src/test/resources/org/apache/camel/model/routeWithXStreamDataFormat.xml b/core/camel-core/src/test/resources/org/apache/camel/model/routeWithXStreamDataFormat.xml deleted file mode 100644 index d50e1594803..00000000000 --- a/core/camel-core/src/test/resources/org/apache/camel/model/routeWithXStreamDataFormat.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<routes id="camel" xmlns="http://camel.apache.org/schema/spring"> - <route> - <from uri="seda:a"/> - <pipeline> - <marshal> - <xstream/> - </marshal> - <to uri="seda:b"/> - </pipeline> - </route> -</routes> diff --git a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java index fbf45a10575..59bec9f2dec 100644 --- a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java +++ b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java @@ -2473,29 +2473,6 @@ public class ModelParser extends BaseParser { return true; }, noElementHandler(), noValueHandler()); } - protected XStreamDataFormat doParseXStreamDataFormat() throws IOException, XmlPullParserException { - return doParse(new XStreamDataFormat(), (def, key, val) -> { - switch (key) { - case "contentTypeHeader": def.setContentTypeHeader(val); break; - case "driver": def.setDriver(val); break; - case "driverRef": def.setDriverRef(val); break; - case "encoding": def.setEncoding(val); break; - case "mode": def.setMode(val); break; - case "permissions": def.setPermissions(val); break; - default: return identifiedTypeAttributeHandler().accept(def, key, val); - } - return true; - }, (def, key) -> { - switch (key) { - case "aliases": doAdd(doParsePropertyDefinition(), def.getAliases(), def::setAliases); break; - case "converters": doAdd(doParsePropertyDefinition(), def.getConverters(), def::setConverters); break; - case "implicitCollections": doAdd(doParsePropertyDefinition(), def.getImplicitCollections(), def::setImplicitCollections); break; - case "omitFields": doAdd(doParsePropertyDefinition(), def.getOmitFields(), def::setOmitFields); break; - default: return false; - } - return true; - }, noValueHandler()); - } protected YAMLDataFormat doParseYAMLDataFormat() throws IOException, XmlPullParserException { return doParse(new YAMLDataFormat(), (def, key, val) -> { switch (key) { @@ -3426,7 +3403,6 @@ public class ModelParser extends BaseParser { case "univocityFixed": return doParseUniVocityFixedDataFormat(); case "univocityTsv": return doParseUniVocityTsvDataFormat(); case "xmlSecurity": return doParseXMLSecurityDataFormat(); - case "xstream": return doParseXStreamDataFormat(); case "yaml": return doParseYAMLDataFormat(); case "zipDeflater": return doParseZipDeflaterDataFormat(); case "zipFile": return doParseZipFileDataFormat(); diff --git a/core/camel-xml-io/src/test/resources/routeWithXStreamDataFormat.xml b/core/camel-xml-io/src/test/resources/routeWithXStreamDataFormat.xml deleted file mode 100644 index d50e1594803..00000000000 --- a/core/camel-xml-io/src/test/resources/routeWithXStreamDataFormat.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<routes id="camel" xmlns="http://camel.apache.org/schema/spring"> - <route> - <from uri="seda:a"/> - <pipeline> - <marshal> - <xstream/> - </marshal> - <to uri="seda:b"/> - </pipeline> - </route> -</routes>
