camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [3/4] camel git commit: Camel catalog - Add validation error about incapable of parsing uri
Date Thu, 07 Jan 2016 20:26:19 GMT
Camel catalog - Add validation error about incapable of parsing uri


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

Branch: refs/heads/camel-2.16.x
Commit: 9e8fc4ab14c7d3c54eb681d0602e53ffae09cfe8
Parents: e8b1ba6
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Jan 7 21:12:06 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Jan 7 21:26:02 2016 +0100

----------------------------------------------------------------------
 .../apache/camel/catalog/DefaultCamelCatalog.java |  6 ++++++
 .../camel/catalog/EndpointValidationResult.java   | 18 +++++++++++++++---
 .../apache/camel/catalog/CamelCatalogTest.java    |  5 +++++
 3 files changed, 26 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9e8fc4ab/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 24baa69..735d88d 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
@@ -745,6 +745,12 @@ public class DefaultCamelCatalog implements CamelCatalog {
         boolean lenientProperties;
         String scheme;
 
+        // skip uris that may start with a placeholder
+        if (uri.startsWith("{{")) {
+            result.addIncapable(uri);
+            return result;
+        }
+
         try {
             // parse the uri
             URI u = normalizeUri(uri);

http://git-wip-us.apache.org/repos/asf/camel/blob/9e8fc4ab/platforms/catalog/src/main/java/org/apache/camel/catalog/EndpointValidationResult.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/EndpointValidationResult.java
b/platforms/catalog/src/main/java/org/apache/camel/catalog/EndpointValidationResult.java
index 5ae61b6..55e133f 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/EndpointValidationResult.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/EndpointValidationResult.java
@@ -33,9 +33,10 @@ public class EndpointValidationResult implements Serializable {
     private final String uri;
     private int errors;
 
-    // component
+    // general
     private String syntaxError;
     private String unknownComponent;
+    private String incapable;
 
     // options
     private Set<String> unknown;
@@ -62,7 +63,7 @@ public class EndpointValidationResult implements Serializable {
     }
 
     public boolean isSuccess() {
-        boolean ok = syntaxError == null && unknownComponent == null
+        boolean ok = syntaxError == null && unknownComponent == null && incapable
== null
                 && unknown == null && required == null;
         if (ok) {
             ok = invalidEnum == null && invalidEnumChoices == null && invalidReference
== null
@@ -76,6 +77,11 @@ public class EndpointValidationResult implements Serializable {
         errors++;
     }
 
+    public void addIncapable(String uri) {
+        this.incapable = uri;
+        errors++;
+    }
+
     public void addUnknownComponent(String name) {
         this.unknownComponent = name;
         errors++;
@@ -176,6 +182,10 @@ public class EndpointValidationResult implements Serializable {
         return syntaxError;
     }
 
+    public String getIncapable() {
+        return incapable;
+    }
+
     public Set<String> getUnknown() {
         return unknown;
     }
@@ -231,7 +241,9 @@ public class EndpointValidationResult implements Serializable {
             return null;
         }
 
-        if (syntaxError != null) {
+        if (incapable != null) {
+            return "Incapable of parsing uri " + incapable;
+        } else if (syntaxError != null) {
             return "Syntax error " + syntaxError;
         } else if (unknownComponent != null) {
             return "Unknown component " + unknownComponent;

http://git-wip-us.apache.org/repos/asf/camel/blob/9e8fc4ab/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 b764e1b..8132107 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
@@ -543,6 +543,11 @@ public class CamelCatalogTest {
         // placeholder for a bunch of optional options
         result = catalog.validateEndpointProperties("aws-swf://activity?{{options}}");
         assertTrue(result.isSuccess());
+
+        // incapable to parse
+        result = catalog.validateEndpointProperties("{{getFtpUrl}}?recursive=true");
+        assertFalse(result.isSuccess());
+        assertTrue(result.getIncapable() != null);
     }
 
     @Test


Mime
View raw message