camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/6] camel git commit: Camel component docs - Should include information if an endpoint is lenient properties
Date Mon, 04 Jan 2016 20:52:49 GMT
Camel component docs - Should include information if an endpoint is lenient properties


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ea11dd9b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ea11dd9b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ea11dd9b

Branch: refs/heads/master
Commit: ea11dd9be18bef4800935ff92646f1d90fd30577
Parents: e151139
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Jan 4 21:31:52 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Jan 4 21:31:52 2016 +0100

----------------------------------------------------------------------
 .../camel/catalog/DefaultCamelCatalog.java      | 21 +++++++++++++++-----
 .../apache/camel/catalog/JSonSchemaHelper.java  |  9 +++++++++
 .../apache/camel/catalog/CamelCatalogTest.java  |  4 ++++
 3 files changed, 29 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ea11dd9b/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 79a50bf..83b9c58 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
@@ -50,6 +50,7 @@ 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.isComponentLenientProperties;
 import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyBoolean;
 import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyInteger;
 import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyMultiValue;
@@ -736,6 +737,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
 
         Map<String, String> properties;
         List<Map<String, String>> rows;
+        boolean lenientProperties;
 
         try {
             // parse the uri
@@ -746,6 +748,10 @@ public class DefaultCamelCatalog implements CamelCatalog {
                 result.addUnknownComponent(scheme);
                 return result;
             }
+
+            rows = JSonSchemaHelper.parseJsonSchema("component", json, false);
+            lenientProperties = isComponentLenientProperties(rows);
+
             rows = JSonSchemaHelper.parseJsonSchema("properties", json, true);
             properties = endpointProperties(uri);
         } catch (URISyntaxException e) {
@@ -778,11 +784,16 @@ public class DefaultCamelCatalog implements CamelCatalog {
             Map<String, String> row = getRow(rows, name);
             if (row == null) {
                 // unknown option
-                result.addUnknown(name);
-                if (suggestionStrategy != null) {
-                    String[] suggestions = suggestionStrategy.suggestEndpointOptions(getNames(rows),
name);
-                    if (suggestions != null) {
-                        result.addUnknownSuggestions(name, suggestions);
+
+                // only add as error if the component is not lenient properties
+                // as if we are lenient then the option is a dynamic extra option which we
cannot validate
+                if (!lenientProperties) {
+                    result.addUnknown(name);
+                    if (suggestionStrategy != null) {
+                        String[] suggestions = suggestionStrategy.suggestEndpointOptions(getNames(rows),
name);
+                        if (suggestions != null) {
+                            result.addUnknownSuggestions(name, suggestions);
+                        }
                     }
                 }
             } else {

http://git-wip-us.apache.org/repos/asf/camel/blob/ea11dd9b/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 4e4624a..3a31027 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
@@ -114,6 +114,15 @@ public final class JSonSchemaHelper {
         return value;
     }
 
+    public static boolean isComponentLenientProperties(List<Map<String, String>>
rows) {
+        for (Map<String, String> row : rows) {
+            if (row.containsKey("lenientProperties")) {
+                return "true".equals(row.get("lenientProperties"));
+            }
+        }
+        return false;
+    }
+
     public static boolean isPropertyRequired(List<Map<String, String>> rows,
String name) {
         for (Map<String, String> row : rows) {
             boolean required = false;

http://git-wip-us.apache.org/repos/asf/camel/blob/ea11dd9b/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 28c8cef..fc804aa 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
@@ -484,6 +484,10 @@ public class CamelCatalogTest {
         // prefix
         result = catalog.validateEndpointProperties("file:inbox?delay=5000&scheduler.foo=123&scheduler.bar=456");
         assertTrue(result.isSuccess());
+
+        // lenient
+        result = catalog.validateEndpointProperties("stub:foo?me=123&you=456");
+        assertTrue(result.isSuccess());
     }
 
     @Test


Mime
View raw message