Repository: camel Updated Branches: refs/heads/master aea6e226b -> a8776920b
CAMEL-10842: Adjust connector to new JSon schema Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1abdcc05 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1abdcc05 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1abdcc05 Branch: refs/heads/master Commit: 1abdcc0522b91b2fe1e2062c34e2af6f6cf61651 Parents: aea6e22 Author: Claus Ibsen <davscl...@apache.org> Authored: Thu Feb 16 16:10:26 2017 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Thu Feb 16 16:10:26 2017 +0100 ---------------------------------------------------------------------- .../org/apache/camel/util/JsonSchemaHelper.java | 2 +- .../camel-kafka/src/main/docs/kafka-component.adoc | 4 ++-- .../camel-mqtt/src/main/docs/mqtt-component.adoc | 2 +- .../apache/camel/maven/connector/ConnectorMojo.java | 4 ++-- .../src/main/resources/camel-connector-schema.json | 4 ++-- .../src/main/resources/camel-connector-schema.json | 6 +++--- .../src/main/resources/camel-connector-schema.json | 16 ++++++++-------- .../src/main/resources/camel-connector-schema.json | 4 ++-- .../org/apache/camel/catalog/JSonSchemaHelper.java | 2 +- .../org/apache/camel/catalog/CamelCatalogTest.java | 7 ++++++- .../src/test/resources/org/foo/camel/dummy.json | 1 + .../camel/tools/apt/helper/JsonSchemaHelper.java | 2 +- .../camel/maven/packaging/JSonSchemaHelper.java | 2 +- 13 files changed, 31 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/1abdcc05/camel-core/src/main/java/org/apache/camel/util/JsonSchemaHelper.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/util/JsonSchemaHelper.java b/camel-core/src/main/java/org/apache/camel/util/JsonSchemaHelper.java index 1c2c638..d407353 100644 --- a/camel-core/src/main/java/org/apache/camel/util/JsonSchemaHelper.java +++ b/camel-core/src/main/java/org/apache/camel/util/JsonSchemaHelper.java @@ -31,7 +31,7 @@ import java.util.regex.Pattern; public final class JsonSchemaHelper { // 0 = text, 1 = enum, 2 = boolean, 3 = integer or number - private static final Pattern PATTERN = Pattern.compile("\"(.+?)\"|\\[(.+)\\]|(true|false)|(\\d+\\.?\\d+)"); + private static final Pattern PATTERN = Pattern.compile("\"(.+?)\"|\\[(.+)\\]|(true|false)|(\\d+\\.?\\d*)"); private static final String QUOT = """; private JsonSchemaHelper() { http://git-wip-us.apache.org/repos/asf/camel/blob/1abdcc05/components/camel-kafka/src/main/docs/kafka-component.adoc ---------------------------------------------------------------------- diff --git a/components/camel-kafka/src/main/docs/kafka-component.adoc b/components/camel-kafka/src/main/docs/kafka-component.adoc index 8c41c3f..211d592 100644 --- a/components/camel-kafka/src/main/docs/kafka-component.adoc +++ b/components/camel-kafka/src/main/docs/kafka-component.adoc @@ -117,8 +117,8 @@ The Kafka component supports 80 endpoint options which are listed below: | kerberosBeforeReloginMinTime | security | 60000 | Integer | Login thread sleep time between refresh attempts. | kerberosInitCmd | security | /usr/bin/kinit | String | Kerberos kinit command path. Default is /usr/bin/kinit | kerberosPrincipalToLocalRules | security | DEFAULT | String | A list of rules for mapping from principal names to short names (typically operating system usernames). The rules are evaluated in order and the first rule that matches a principal name is used to map it to a short name. Any later rules in the list are ignored. By default principal names of the form username/hostnameREALM are mapped to username. For more details on the format please see security authorization and acls. Multiple values can be separated by comma -| kerberosRenewJitter | security | 0 | Double | Percentage of random jitter added to the renewal time. -| kerberosRenewWindowFactor | security | 0 | Double | Login thread will sleep until the specified window factor of time from last refresh to ticket's expiry has been reached at which time it will try to renew the ticket. +| kerberosRenewJitter | security | 0.05 | Double | Percentage of random jitter added to the renewal time. +| kerberosRenewWindowFactor | security | 0.8 | Double | Login thread will sleep until the specified window factor of time from last refresh to ticket's expiry has been reached at which time it will try to renew the ticket. | saslKerberosServiceName | security | | String | The Kerberos principal name that Kafka runs as. This can be defined either in Kafka's JAAS config or in Kafka's config. | saslMechanism | security | GSSAPI | String | The Simple Authentication and Security Layer (SASL) Mechanism used. For the valid values see http://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml | securityProtocol | security | PLAINTEXT | String | Protocol used to communicate with brokers. Currently only PLAINTEXT and SSL are supported. http://git-wip-us.apache.org/repos/asf/camel/blob/1abdcc05/components/camel-mqtt/src/main/docs/mqtt-component.adoc ---------------------------------------------------------------------- diff --git a/components/camel-mqtt/src/main/docs/mqtt-component.adoc b/components/camel-mqtt/src/main/docs/mqtt-component.adoc index 67de942..f9b7c93 100644 --- a/components/camel-mqtt/src/main/docs/mqtt-component.adoc +++ b/components/camel-mqtt/src/main/docs/mqtt-component.adoc @@ -83,7 +83,7 @@ The MQTT component supports 40 endpoint options which are listed below: | qualityOfService | common | AtLeastOnce | String | Quality of service level to use for topics. | receiveBufferSize | common | 65536 | int | Sets the size of the internal socket receive buffer. Defaults to 65536 (64k) | reconnectAttemptsMax | common | 1 | long | The maximum number of reconnect attempts before an error is reported back to the client after a server connection had previously been established. Set to -1 to use unlimited attempts. Defaults to -1. -| reconnectBackOffMultiplier | common | 2 | double | The Exponential backoff be used between reconnect attempts. Set to 1 to disable exponential backoff. Defaults to 2. +| reconnectBackOffMultiplier | common | 2.0 | double | The Exponential backoff be used between reconnect attempts. Set to 1 to disable exponential backoff. Defaults to 2. | reconnectDelay | common | 10 | long | How long to wait in ms before the first reconnect attempt. Defaults to 10. | reconnectDelayMax | common | 30000 | long | The maximum amount of time in ms to wait between reconnect attempts. Defaults to 30000. | sendBufferSize | common | 65536 | int | Sets the size of the internal socket send buffer. Defaults to 65536 (64k) http://git-wip-us.apache.org/repos/asf/camel/blob/1abdcc05/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/ConnectorMojo.java ---------------------------------------------------------------------- diff --git a/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/ConnectorMojo.java b/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/ConnectorMojo.java index 36d514f..bd3f681 100644 --- a/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/ConnectorMojo.java +++ b/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/ConnectorMojo.java @@ -453,7 +453,7 @@ public class ConnectorMojo extends AbstractJarMojo { String name = row.get("name"); String kind = row.get("kind"); boolean required = Boolean.valueOf(row.getOrDefault("required", "false")); - String type = row.get("type"); + String javaType = row.get("javaType"); String defaultValue = row.get("defaultValue"); String description = row.get("description"); boolean deprecated = Boolean.valueOf(row.getOrDefault("deprecated", "false")); @@ -475,7 +475,7 @@ public class ConnectorMojo extends AbstractJarMojo { String prefix = row.get("prefix"); boolean multiValue = Boolean.valueOf(row.getOrDefault("multiValue", "false")); - return JSonSchemaHelper.toJson(name, kind, required, type, defaultValue, description, deprecated, secret, group, label, + return JSonSchemaHelper.toJson(name, kind, required, javaType, defaultValue, description, deprecated, secret, group, label, enumType, enums, false, null, false, optionalPrefix, prefix, multiValue); } http://git-wip-us.apache.org/repos/asf/camel/blob/1abdcc05/connectors/examples/bar-connector/src/main/resources/camel-connector-schema.json ---------------------------------------------------------------------- diff --git a/connectors/examples/bar-connector/src/main/resources/camel-connector-schema.json b/connectors/examples/bar-connector/src/main/resources/camel-connector-schema.json index ff37add..397e12e 100644 --- a/connectors/examples/bar-connector/src/main/resources/camel-connector-schema.json +++ b/connectors/examples/bar-connector/src/main/resources/camel-connector-schema.json @@ -19,8 +19,8 @@ "componentProperties": { }, "properties": { - "drink": { "kind": "path", "group": "producer", "required": true, "type": "object", "javaType": "object", "enum": [ "Wine", "GinTonic", "Beer" ], "deprecated": false, "secret": false, "description": "What drink to order" }, - "amount": { "kind": "parameter", "group": "producer", "required": false, "type": "object", "javaType": "integer", "deprecated": false, "secret": false, "defaultValue": "2" }, + "drink": { "kind": "path", "group": "producer", "required": true, "type": "object", "javaType": "org.beverage.Beverages", "enum": [ "Wine", "GinTonic", "Beer" ], "deprecated": false, "secret": false, "description": "What drink to order" }, + "amount": { "kind": "parameter", "group": "producer", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "secret": false, "defaultValue": 2 }, "celebrity": { "kind": "parameter", "group": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Is this a famous person ordering" } } } http://git-wip-us.apache.org/repos/asf/camel/blob/1abdcc05/connectors/examples/foo-connector/src/main/resources/camel-connector-schema.json ---------------------------------------------------------------------- diff --git a/connectors/examples/foo-connector/src/main/resources/camel-connector-schema.json b/connectors/examples/foo-connector/src/main/resources/camel-connector-schema.json index 24dd2c1..4286b5f 100644 --- a/connectors/examples/foo-connector/src/main/resources/camel-connector-schema.json +++ b/connectors/examples/foo-connector/src/main/resources/camel-connector-schema.json @@ -19,8 +19,8 @@ "componentProperties": { }, "properties": { - "timerName": { "kind": "path", "group": "consumer", "required": true, "type": "object", "javaType": "string", "deprecated": false, "secret": false, "description": "The name of the timer" }, - "period": { "kind": "parameter", "group": "consumer", "required": false, "type": "object", "javaType": "integer", "deprecated": false, "secret": false, "defaultValue": "5000", "description": "If greater than 0 generate periodic events every period milliseconds. The default value is 1000. You can also specify time values using units such as 60s (60 seconds) 5m30s (5 minutes and 30 seconds) and 1h (1 hour)." }, - "repeatCount": { "kind": "parameter", "group": "consumer", "required": false, "type": "object", "javaType": "integer", "deprecated": false, "secret": false, "defaultValue": "description" } + "timerName": { "kind": "path", "group": "consumer", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "The name of the timer" }, + "period": { "kind": "parameter", "group": "consumer", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "secret": false, "defaultValue": 5000, "description": "If greater than 0 generate periodic events every period milliseconds. The default value is 1000. You can also specify time values using units such as 60s (60 seconds) 5m30s (5 minutes and 30 seconds) and 1h (1 hour)." }, + "repeatCount": { "kind": "parameter", "group": "consumer", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "secret": false, "defaultValue": description } } } http://git-wip-us.apache.org/repos/asf/camel/blob/1abdcc05/connectors/examples/twitter-mention-connector/src/main/resources/camel-connector-schema.json ---------------------------------------------------------------------- diff --git a/connectors/examples/twitter-mention-connector/src/main/resources/camel-connector-schema.json b/connectors/examples/twitter-mention-connector/src/main/resources/camel-connector-schema.json index 309f20c..e40470b 100644 --- a/connectors/examples/twitter-mention-connector/src/main/resources/camel-connector-schema.json +++ b/connectors/examples/twitter-mention-connector/src/main/resources/camel-connector-schema.json @@ -7,20 +7,20 @@ "title": "TwitterMention", "description": "Connection from twitter when anyone mention you", "label": "twitter", - "deprecated": false, - "async": false, - "consumerOnly": true, - "lenientProperties": false, + "deprecated": "false", + "async": "false", + "consumerOnly": "true", + "lenientProperties": "false", "javaType": "org.foo.mention.TwitterMentionComponent", "groupId": "org.foo", "artifactId": "twitter-mention-connector", "version": "2.19.0-SNAPSHOT" }, "componentProperties": { - "accessToken": { "kind": "property", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "string", "deprecated": false, "secret": true, "description": "The access token" }, - "accessTokenSecret": { "kind": "property", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "string", "deprecated": false, "secret": true, "description": "The access token secret" }, - "consumerKey": { "kind": "property", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "string", "deprecated": false, "secret": true, "description": "The consumer key" }, - "consumerSecret": { "kind": "property", "group": "security", "label": "security", "required": false, "type": "object", "javaType": "string", "deprecated": false, "secret": true, "description": "The consumer secret" } + "accessToken": { "kind": "property", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "description": "The access token" }, + "accessTokenSecret": { "kind": "property", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "description": "The access token secret" }, + "consumerKey": { "kind": "property", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "description": "The consumer key" }, + "consumerSecret": { "kind": "property", "group": "security", "label": "security", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "description": "The consumer secret" } }, "properties": { } http://git-wip-us.apache.org/repos/asf/camel/blob/1abdcc05/connectors/examples/wine-connector/src/main/resources/camel-connector-schema.json ---------------------------------------------------------------------- diff --git a/connectors/examples/wine-connector/src/main/resources/camel-connector-schema.json b/connectors/examples/wine-connector/src/main/resources/camel-connector-schema.json index 037edaf..d2d4f1c 100644 --- a/connectors/examples/wine-connector/src/main/resources/camel-connector-schema.json +++ b/connectors/examples/wine-connector/src/main/resources/camel-connector-schema.json @@ -19,7 +19,7 @@ "componentProperties": { }, "properties": { - "drink": { "kind": "path", "group": "producer", "required": true, "type": "object", "javaType": "object", "enum": [ "Wine" ], "deprecated": false, "secret": false, "defaultValue": "Wine", "description": "You can only order wine" }, - "amount": { "kind": "parameter", "group": "producer", "required": false, "type": "object", "javaType": "integer", "deprecated": false, "secret": false, "defaultValue": "description" } + "drink": { "kind": "path", "group": "producer", "required": true, "type": "object", "javaType": "org.beverage.Beverages", "enum": [ "Wine" ], "deprecated": false, "secret": false, "defaultValue": "Wine", "description": "You can only order wine" }, + "amount": { "kind": "parameter", "group": "producer", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "secret": false, "defaultValue": description } } } http://git-wip-us.apache.org/repos/asf/camel/blob/1abdcc05/platforms/catalog/src/main/java/org/apache/camel/catalog/JSonSchemaHelper.java ---------------------------------------------------------------------- diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/JSonSchemaHelper.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/JSonSchemaHelper.java index fbd2fff..318cbf4 100644 --- a/platforms/catalog/src/main/java/org/apache/camel/catalog/JSonSchemaHelper.java +++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/JSonSchemaHelper.java @@ -28,7 +28,7 @@ import java.util.regex.Pattern; public final class JSonSchemaHelper { // 0 = text, 1 = enum, 2 = boolean, 3 = integer or number - private static final Pattern PATTERN = Pattern.compile("\"(.+?)\"|\\[(.+)\\]|(true|false)|(\\d+\\.?\\d+)"); + private static final Pattern PATTERN = Pattern.compile("\"(.+?)\"|\\[(.+)\\]|(true|false)|(\\d+\\.?\\d*)"); private static final String QUOT = """; private JSonSchemaHelper() { http://git-wip-us.apache.org/repos/asf/camel/blob/1abdcc05/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java ---------------------------------------------------------------------- diff --git a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java index 78c1052..110e763 100644 --- a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java +++ b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java @@ -1089,7 +1089,7 @@ public class CamelCatalogTest { // properties rows = JSonSchemaHelper.parseJsonSchema("properties", json, true); - assertEquals(29, rows.size()); + assertEquals(30, rows.size()); row = JSonSchemaHelper.getRow(rows, "level"); assertNotNull(row); assertEquals("INFO", row.get("defaultValue")); @@ -1101,6 +1101,11 @@ public class CamelCatalogTest { assertEquals("false", row.get("deprecated")); assertEquals("10000", row.get("defaultValue")); + row = JSonSchemaHelper.getRow(rows, "repeatCount"); + assertNotNull(row); + assertEquals("long", row.get("javaType")); + assertEquals("0", row.get("defaultValue")); + row = JSonSchemaHelper.getRow(rows, "fontSize"); assertNotNull(row); assertEquals("false", row.get("deprecated")); http://git-wip-us.apache.org/repos/asf/camel/blob/1abdcc05/platforms/catalog/src/test/resources/org/foo/camel/dummy.json ---------------------------------------------------------------------- diff --git a/platforms/catalog/src/test/resources/org/foo/camel/dummy.json b/platforms/catalog/src/test/resources/org/foo/camel/dummy.json index 8dfd7b3..844aaac 100644 --- a/platforms/catalog/src/test/resources/org/foo/camel/dummy.json +++ b/platforms/catalog/src/test/resources/org/foo/camel/dummy.json @@ -29,6 +29,7 @@ "kerberosRenewJitter": { "kind": "parameter", "group": "security", "label": "common,security", "type": "number", "javaType": "java.lang.Double", "deprecated": false, "secret": false, "defaultValue": 0.05, "description": "Percentage of random jitter added to the renewal time." }, "maxChars": { "kind": "parameter", "group": "formatting", "label": "formatting", "type": "integer", "javaType": "int", "deprecated": false, "defaultValue": 10000, "description": "Limits the number of characters logged per line." }, "multiline": { "kind": "parameter", "group": "formatting", "label": "formatting", "type": "boolean", "javaType": "boolean", "deprecated": false, "defaultValue": false, "description": "If enabled then each information is outputted on a newline." }, + "repeatCount": { "kind": "parameter", "group": "consumer", "type": "integer", "javaType": "long", "deprecated": false, "secret": false, "defaultValue": 0, "description": "Specifies a maximum limit of number of fires. So if you set it to 1 the timer will only fire once. If you set it to 5 it will only fire five times. A value of zero or negative means fire forever." }, "showAll": { "kind": "parameter", "group": "formatting", "label": "formatting", "type": "boolean", "javaType": "boolean", "deprecated": false, "defaultValue": false, "description": "Quick option for turning all options on. (multiline maxChars has to be manually set if to be used)" }, "showBody": { "kind": "parameter", "group": "formatting", "label": "formatting", "type": "boolean", "javaType": "boolean", "deprecated": false, "defaultValue": true, "description": "Show the message body." }, "showBodyType": { "kind": "parameter", "group": "formatting", "label": "formatting", "type": "boolean", "javaType": "boolean", "deprecated": false, "defaultValue": true, "description": "Show the body Java type." }, http://git-wip-us.apache.org/repos/asf/camel/blob/1abdcc05/tooling/apt/src/main/java/org/apache/camel/tools/apt/helper/JsonSchemaHelper.java ---------------------------------------------------------------------- diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/helper/JsonSchemaHelper.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/helper/JsonSchemaHelper.java index cf3588f..a8df312 100644 --- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/helper/JsonSchemaHelper.java +++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/helper/JsonSchemaHelper.java @@ -35,7 +35,7 @@ public final class JsonSchemaHelper { private static final String VALID_CHARS = ".-='/\\!&():;"; // 0 = text, 1 = enum, 2 = boolean, 3 = integer or number - private static final Pattern PATTERN = Pattern.compile("\"(.+?)\"|\\[(.+)\\]|(true|false)|(\\d+\\.?\\d+)"); + private static final Pattern PATTERN = Pattern.compile("\"(.+?)\"|\\[(.+)\\]|(true|false)|(\\d+\\.?\\d*)"); private static final String QUOT = """; private JsonSchemaHelper() { http://git-wip-us.apache.org/repos/asf/camel/blob/1abdcc05/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/JSonSchemaHelper.java ---------------------------------------------------------------------- diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/JSonSchemaHelper.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/JSonSchemaHelper.java index 2fbd27f..1e7ab3b 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/JSonSchemaHelper.java +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/JSonSchemaHelper.java @@ -26,7 +26,7 @@ import java.util.regex.Pattern; public final class JSonSchemaHelper { // 0 = text, 1 = enum, 2 = boolean, 3 = integer or number - private static final Pattern PATTERN = Pattern.compile("\"(.+?)\"|\\[(.+)\\]|(true|false)|(\\d+\\.?\\d+)"); + private static final Pattern PATTERN = Pattern.compile("\"(.+?)\"|\\[(.+)\\]|(true|false)|(\\d+\\.?\\d*)"); private static final String QUOT = """; private JSonSchemaHelper() {