camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [5/7] camel git commit: CAMEL-9470: Component docs - Some options support using an optional prefix such as consumer.
Date Sun, 03 Jan 2016 16:56:25 GMT
CAMEL-9470: Component docs - Some options support using an optional prefix such as consumer.


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

Branch: refs/heads/camel-2.16.x
Commit: 2f01cf1c56228fb972bda8c3e52931e8f69d2ed6
Parents: 0d48cab
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun Jan 3 15:00:11 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun Jan 3 17:54:07 2016 +0100

----------------------------------------------------------------------
 .../apache/camel/catalog/DefaultCamelCatalog.java  | 15 ++++-----------
 .../org/apache/camel/catalog/JSonSchemaHelper.java | 17 ++++++++---------
 2 files changed, 12 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2f01cf1c/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 1c70f40..a4e638a 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
@@ -47,13 +47,13 @@ import static org.apache.camel.catalog.JSonSchemaHelper.getNames;
 import static org.apache.camel.catalog.JSonSchemaHelper.getPropertyDefaultValue;
 import static org.apache.camel.catalog.JSonSchemaHelper.getPropertyEnum;
 import static org.apache.camel.catalog.JSonSchemaHelper.getPropertyKind;
-import static org.apache.camel.catalog.JSonSchemaHelper.getPropertyOptionalPrefix;
 import static org.apache.camel.catalog.JSonSchemaHelper.getRow;
 import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyBoolean;
 import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyInteger;
 import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyNumber;
 import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyObject;
 import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyRequired;
+import static org.apache.camel.catalog.JSonSchemaHelper.stripOptionalPrefixFromName;
 import static org.apache.camel.catalog.URISupport.createQueryString;
 import static org.apache.camel.catalog.URISupport.isEmpty;
 import static org.apache.camel.catalog.URISupport.normalizeUri;
@@ -753,21 +753,14 @@ public class DefaultCamelCatalog implements CamelCatalog {
         // validate all the options
         for (Map.Entry<String, String> property : properties.entrySet()) {
             String name = property.getKey();
-            String optionalPrefix = getPropertyOptionalPrefix(rows, name);
+            // the name may be using an optional prefix, so lets strip that because the options
+            // in the schema are listed without the prefix
+            name = stripOptionalPrefixFromName(rows, name);
             String value = property.getValue();
             boolean placeholder = value.startsWith("{{") || value.startsWith("${") || value.startsWith("$simple{");
             boolean lookup = value.startsWith("#") && value.length() > 1;
 
             Map<String, String> row = getRow(rows, name);
-
-            // maybe the name was using an optional prefix, and if so then lookup without
the prefix
-            if (row == null && !isEmpty(optionalPrefix)) {
-                if (name.startsWith(optionalPrefix)) {
-                    name = name.substring(optionalPrefix.length());
-                }
-                row = getRow(rows, name);
-            }
-
             if (row == null) {
                 // unknown option
                 result.addUnknown(name);

http://git-wip-us.apache.org/repos/asf/camel/blob/2f01cf1c/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 bbfe7c1..2293a7a 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
@@ -233,7 +233,7 @@ public final class JSonSchemaHelper {
         return null;
     }
 
-    public static String getPropertyOptionalPrefix(List<Map<String, String>>
rows, String name) {
+    public static String stripOptionalPrefixFromName(List<Map<String, String>>
rows, String name) {
         for (Map<String, String> row : rows) {
             String optionalPrefix = null;
             boolean found = false;
@@ -241,20 +241,19 @@ public final class JSonSchemaHelper {
                 optionalPrefix = row.get("optionalPrefix");
             }
             if (row.containsKey("name")) {
-                String key = name;
-                if (optionalPrefix != null && key.startsWith(optionalPrefix)) {
-                    key = key.substring(optionalPrefix.length());
-                    // found the optional prefix so remove it from the key, and lookup again
-                    return getPropertyOptionalPrefix(rows, key);
+                if (optionalPrefix != null && name.startsWith(optionalPrefix)) {
+                    name = name.substring(optionalPrefix.length());
+                    // try again
+                    return stripOptionalPrefixFromName(rows, name);
                 } else {
-                    found = key.equals(row.get("name"));
+                    found = name.equals(row.get("name"));
                 }
             }
             if (found) {
-                return optionalPrefix;
+                return name;
             }
         }
-        return null;
+        return name;
     }
 
     public static String getPropertyEnum(List<Map<String, String>> rows, String
name) {


Mime
View raw message