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 2016/01/03 15:28:26 UTC

[4/9] camel git commit: Camel catalog - Improved validation error summary

Camel catalog - Improved validation error summary


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

Branch: refs/heads/camel-2.16.x
Commit: 671246577c952e08fe0c013ffa89b4f156aed319
Parents: 9248691
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jan 3 14:18:54 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jan 3 14:19:43 2016 +0100

----------------------------------------------------------------------
 .../camel/catalog/EndpointValidationResult.java | 30 ++++++++++++++++----
 1 file changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/67124657/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 54c8b6a..5ae61b6 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
@@ -23,6 +23,8 @@ import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
 
+import static org.apache.camel.catalog.URISupport.isEmpty;
+
 /**
  * Details result of validating endpoint uri.
  */
@@ -271,26 +273,44 @@ public class EndpointValidationResult implements Serializable {
         }
         if (invalidReference != null) {
             for (Map.Entry<String, String> entry : invalidReference.entrySet()) {
-                if (!entry.getValue().startsWith("#")) {
+                boolean empty = isEmpty(entry.getValue());
+                if (empty) {
+                    options.put(entry.getKey(), "Empty reference value");
+                } else if (!entry.getValue().startsWith("#")) {
                     options.put(entry.getKey(), "Invalid reference value: " + entry.getValue() + " must start with #");
                 } else {
-                    options.put(entry.getKey(), "Invalid reference value: " + entry.getValue() + " must not be empty");
+                    options.put(entry.getKey(), "Invalid reference value: " + entry.getValue());
                 }
             }
         }
         if (invalidBoolean != null) {
             for (Map.Entry<String, String> entry : invalidBoolean.entrySet()) {
-                options.put(entry.getKey(), "Invalid boolean value: " + entry.getValue());
+                boolean empty = isEmpty(entry.getValue());
+                if (empty) {
+                    options.put(entry.getKey(), "Empty boolean value");
+                } else {
+                    options.put(entry.getKey(), "Invalid boolean value: " + entry.getValue());
+                }
             }
         }
         if (invalidInteger != null) {
             for (Map.Entry<String, String> entry : invalidInteger.entrySet()) {
-                options.put(entry.getKey(), "Invalid integer value: " + entry.getValue());
+                boolean empty = isEmpty(entry.getValue());
+                if (empty) {
+                    options.put(entry.getKey(), "Empty integer value");
+                } else {
+                    options.put(entry.getKey(), "Invalid integer value: " + entry.getValue());
+                }
             }
         }
         if (invalidNumber != null) {
             for (Map.Entry<String, String> entry : invalidNumber.entrySet()) {
-                options.put(entry.getKey(), "Invalid number value: " + entry.getValue());
+                boolean empty = isEmpty(entry.getValue());
+                if (empty) {
+                    options.put(entry.getKey(), "Empty number value");
+                } else {
+                    options.put(entry.getKey(), "Invalid number value: " + entry.getValue());
+                }
             }
         }