You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/01/18 11:00:26 UTC
[2/2] camel git commit: camel-catalog - Components that cannot do
both consumer and producer should allow to be lenient in endpoint properties.
camel-catalog - Components that cannot do both consumer and producer should allow to be lenient in endpoint properties.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/550e1f3e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/550e1f3e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/550e1f3e
Branch: refs/heads/camel-2.18.x
Commit: 550e1f3efc25410e31f349186c53b3aeb2228f5c
Parents: 2e020ea
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Jan 18 11:59:15 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jan 18 12:00:16 2017 +0100
----------------------------------------------------------------------
.../apache/camel/catalog/DefaultCamelCatalog.java | 13 +++++++++++--
.../apache/camel/catalog/JSonSchemaHelper.java | 18 ++++++++++++++++++
.../apache/camel/catalog/CamelCatalogTest.java | 5 +++++
3 files changed, 34 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/550e1f3e/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
index 27d818b..ebe8a9b 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
@@ -54,7 +54,9 @@ import static org.apache.camel.catalog.JSonSchemaHelper.getPropertyKind;
import static org.apache.camel.catalog.JSonSchemaHelper.getPropertyNameFromNameWithPrefix;
import static org.apache.camel.catalog.JSonSchemaHelper.getPropertyPrefix;
import static org.apache.camel.catalog.JSonSchemaHelper.getRow;
+import static org.apache.camel.catalog.JSonSchemaHelper.isComponentConsumerOnly;
import static org.apache.camel.catalog.JSonSchemaHelper.isComponentLenientProperties;
+import static org.apache.camel.catalog.JSonSchemaHelper.isComponentProducerOnly;
import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyBoolean;
import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyConsumerOnly;
import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyInteger;
@@ -999,8 +1001,15 @@ public class DefaultCamelCatalog implements CamelCatalog {
}
rows = JSonSchemaHelper.parseJsonSchema("component", json, false);
- if (consumerOnly) {
- // lenient properties is not support in consumer only mode
+
+ // is the component capable of both consumer and producer?
+ boolean canConsumeAndProduce = false;
+ if (!isComponentConsumerOnly(rows) && !isComponentProducerOnly(rows)) {
+ canConsumeAndProduce = true;
+ }
+
+ if (canConsumeAndProduce && consumerOnly) {
+ // lenient properties is not support in consumer only mode if the component can do both of them
lenientProperties = false;
} else {
// only enable lenient properties if we should not ignore
http://git-wip-us.apache.org/repos/asf/camel/blob/550e1f3e/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 3acffdf..daaf3cd 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
@@ -123,6 +123,24 @@ public final class JSonSchemaHelper {
return false;
}
+ public static boolean isComponentConsumerOnly(List<Map<String, String>> rows) {
+ for (Map<String, String> row : rows) {
+ if (row.containsKey("consumerOnly")) {
+ return "true".equals(row.get("consumerOnly"));
+ }
+ }
+ return false;
+ }
+
+ public static boolean isComponentProducerOnly(List<Map<String, String>> rows) {
+ for (Map<String, String> row : rows) {
+ if (row.containsKey("producerOnly")) {
+ return "true".equals(row.get("producerOnly"));
+ }
+ }
+ return false;
+ }
+
public static boolean isPropertyConsumerOnly(List<Map<String, String>> rows, String name) {
for (Map<String, String> row : rows) {
String labels = null;
http://git-wip-us.apache.org/repos/asf/camel/blob/550e1f3e/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 aef9f93..5a67797 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
@@ -649,6 +649,11 @@ public class CamelCatalogTest {
assertEquals("foo", result.getUnknown().iterator().next());
assertNull(result.getLenient());
+ // lenient on rss consumer only
+ result = catalog.validateEndpointProperties("rss:file:src/test/data/rss20.xml?splitEntries=true&sortEntries=true&consumer.delay=50&foo=bar", false, true, false);
+ assertTrue(result.isSuccess());
+ assertEquals("foo", result.getLenient().iterator().next());
+
// data format
result = catalog.validateEndpointProperties("dataformat:string:marshal?charset=utf-8", true);
assertTrue(result.isSuccess());