This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit c97394b66f5a9bb0cf8e696639aac0735813c874
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Feb 18 10:38:36 2022 +0100

    CAMEL-17673: camel-core-model - Cleanup Rest DSL
---
 .../java/org/apache/camel/impl/RouteIdFactory.java |  4 ++--
 .../org/apache/camel/model/rest/delete.json        |  3 ++-
 .../resources/org/apache/camel/model/rest/get.json |  3 ++-
 .../org/apache/camel/model/rest/head.json          |  3 ++-
 .../org/apache/camel/model/rest/patch.json         |  3 ++-
 .../org/apache/camel/model/rest/post.json          |  3 ++-
 .../resources/org/apache/camel/model/rest/put.json |  3 ++-
 .../apache/camel/model/rest/RestDefinition.java    | 18 +++++++++---------
 .../apache/camel/model/rest/VerbDefinition.java    | 22 +++++++++++++++++++---
 .../component/rest/FromRestUriPrefixTest.java      |  6 +++---
 .../org/apache/camel/model/XmlRestParseTest.java   |  2 +-
 .../apache/camel/model/XmlRestParseToDTest.java    |  2 +-
 .../java/org/apache/camel/xml/in/ModelParser.java  |  3 ++-
 13 files changed, 49 insertions(+), 26 deletions(-)

diff --git 
a/core/camel-core-engine/src/main/java/org/apache/camel/impl/RouteIdFactory.java
 
b/core/camel-core-engine/src/main/java/org/apache/camel/impl/RouteIdFactory.java
index fda16e8..4a50771 100644
--- 
a/core/camel-core-engine/src/main/java/org/apache/camel/impl/RouteIdFactory.java
+++ 
b/core/camel-core-engine/src/main/java/org/apache/camel/impl/RouteIdFactory.java
@@ -131,8 +131,8 @@ public class RouteIdFactory implements NodeIdFactory {
             routeId.append(verb.asVerb());
             appendWithSeparator(routeId, prepareUri(restDefinition.getPath()));
 
-            if (verb.getUri() != null && verb.getUri().length() > 0) {
-                appendWithSeparator(routeId, prepareUri(verb.getUri()));
+            if (verb.getPath() != null && verb.getPath().length() > 0) {
+                appendWithSeparator(routeId, prepareUri(verb.getPath()));
             }
 
             verb.setUsedForGeneratingNodeId(true);
diff --git 
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/delete.json
 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/delete.json
index ce3200f..4d66dbd 100644
--- 
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/delete.json
+++ 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/delete.json
@@ -12,7 +12,8 @@
     "output": false
   },
   "properties": {
-    "uri": { "kind": "attribute", "displayName": "Uri", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "Uri template of this REST 
service such as \/{id}." },
+    "uri": { "kind": "attribute", "displayName": "Uri", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": true, 
"autowired": false, "secret": false, "description": "Deprecated use path 
instead." },
+    "path": { "kind": "attribute", "displayName": "Path", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "The path mapping URIs of 
this REST operation such as \/{id}." },
     "consumes": { "kind": "attribute", "displayName": "Consumes", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "To define the content type 
what the REST service consumes (accept as input), such as application\/xml or 
application\/json. This option will override what may be configured on a parent 
level" },
     "produces": { "kind": "attribute", "displayName": "Produces", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "To define the content type 
what the REST service produces (uses for output), such as application\/xml or 
application\/json This option will override what may be configured on a parent 
level" },
     "bindingMode": { "kind": "attribute", "displayName": "Binding Mode", 
"required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ 
"off", "auto", "json", "xml", "json_xml" ], "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": "off", "description": "Sets the binding 
mode to use. This option will override what may be configured on a parent level 
The default value is off" },
diff --git 
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/get.json
 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/get.json
index c051715..8df3292 100644
--- 
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/get.json
+++ 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/get.json
@@ -12,7 +12,8 @@
     "output": false
   },
   "properties": {
-    "uri": { "kind": "attribute", "displayName": "Uri", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "Uri template of this REST 
service such as \/{id}." },
+    "uri": { "kind": "attribute", "displayName": "Uri", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": true, 
"autowired": false, "secret": false, "description": "Deprecated use path 
instead." },
+    "path": { "kind": "attribute", "displayName": "Path", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "The path mapping URIs of 
this REST operation such as \/{id}." },
     "consumes": { "kind": "attribute", "displayName": "Consumes", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "To define the content type 
what the REST service consumes (accept as input), such as application\/xml or 
application\/json. This option will override what may be configured on a parent 
level" },
     "produces": { "kind": "attribute", "displayName": "Produces", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "To define the content type 
what the REST service produces (uses for output), such as application\/xml or 
application\/json This option will override what may be configured on a parent 
level" },
     "bindingMode": { "kind": "attribute", "displayName": "Binding Mode", 
"required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ 
"off", "auto", "json", "xml", "json_xml" ], "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": "off", "description": "Sets the binding 
mode to use. This option will override what may be configured on a parent level 
The default value is off" },
diff --git 
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/head.json
 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/head.json
index a09a0ef..1612b71 100644
--- 
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/head.json
+++ 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/head.json
@@ -12,7 +12,8 @@
     "output": false
   },
   "properties": {
-    "uri": { "kind": "attribute", "displayName": "Uri", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "Uri template of this REST 
service such as \/{id}." },
+    "uri": { "kind": "attribute", "displayName": "Uri", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": true, 
"autowired": false, "secret": false, "description": "Deprecated use path 
instead." },
+    "path": { "kind": "attribute", "displayName": "Path", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "The path mapping URIs of 
this REST operation such as \/{id}." },
     "consumes": { "kind": "attribute", "displayName": "Consumes", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "To define the content type 
what the REST service consumes (accept as input), such as application\/xml or 
application\/json. This option will override what may be configured on a parent 
level" },
     "produces": { "kind": "attribute", "displayName": "Produces", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "To define the content type 
what the REST service produces (uses for output), such as application\/xml or 
application\/json This option will override what may be configured on a parent 
level" },
     "bindingMode": { "kind": "attribute", "displayName": "Binding Mode", 
"required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ 
"off", "auto", "json", "xml", "json_xml" ], "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": "off", "description": "Sets the binding 
mode to use. This option will override what may be configured on a parent level 
The default value is off" },
diff --git 
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/patch.json
 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/patch.json
index 460b1f6..975cb54 100644
--- 
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/patch.json
+++ 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/patch.json
@@ -12,7 +12,8 @@
     "output": false
   },
   "properties": {
-    "uri": { "kind": "attribute", "displayName": "Uri", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "Uri template of this REST 
service such as \/{id}." },
+    "uri": { "kind": "attribute", "displayName": "Uri", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": true, 
"autowired": false, "secret": false, "description": "Deprecated use path 
instead." },
+    "path": { "kind": "attribute", "displayName": "Path", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "The path mapping URIs of 
this REST operation such as \/{id}." },
     "consumes": { "kind": "attribute", "displayName": "Consumes", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "To define the content type 
what the REST service consumes (accept as input), such as application\/xml or 
application\/json. This option will override what may be configured on a parent 
level" },
     "produces": { "kind": "attribute", "displayName": "Produces", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "To define the content type 
what the REST service produces (uses for output), such as application\/xml or 
application\/json This option will override what may be configured on a parent 
level" },
     "bindingMode": { "kind": "attribute", "displayName": "Binding Mode", 
"required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ 
"off", "auto", "json", "xml", "json_xml" ], "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": "off", "description": "Sets the binding 
mode to use. This option will override what may be configured on a parent level 
The default value is off" },
diff --git 
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/post.json
 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/post.json
index ae00e37..850e5ad 100644
--- 
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/post.json
+++ 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/post.json
@@ -12,7 +12,8 @@
     "output": false
   },
   "properties": {
-    "uri": { "kind": "attribute", "displayName": "Uri", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "Uri template of this REST 
service such as \/{id}." },
+    "uri": { "kind": "attribute", "displayName": "Uri", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": true, 
"autowired": false, "secret": false, "description": "Deprecated use path 
instead." },
+    "path": { "kind": "attribute", "displayName": "Path", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "The path mapping URIs of 
this REST operation such as \/{id}." },
     "consumes": { "kind": "attribute", "displayName": "Consumes", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "To define the content type 
what the REST service consumes (accept as input), such as application\/xml or 
application\/json. This option will override what may be configured on a parent 
level" },
     "produces": { "kind": "attribute", "displayName": "Produces", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "To define the content type 
what the REST service produces (uses for output), such as application\/xml or 
application\/json This option will override what may be configured on a parent 
level" },
     "bindingMode": { "kind": "attribute", "displayName": "Binding Mode", 
"required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ 
"off", "auto", "json", "xml", "json_xml" ], "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": "off", "description": "Sets the binding 
mode to use. This option will override what may be configured on a parent level 
The default value is off" },
diff --git 
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/put.json
 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/put.json
index b41f5a4..4018c38 100644
--- 
a/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/put.json
+++ 
b/core/camel-core-model/src/generated/resources/org/apache/camel/model/rest/put.json
@@ -12,7 +12,8 @@
     "output": false
   },
   "properties": {
-    "uri": { "kind": "attribute", "displayName": "Uri", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "Uri template of this REST 
service such as \/{id}." },
+    "uri": { "kind": "attribute", "displayName": "Uri", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": true, 
"autowired": false, "secret": false, "description": "Deprecated use path 
instead." },
+    "path": { "kind": "attribute", "displayName": "Path", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "The path mapping URIs of 
this REST operation such as \/{id}." },
     "consumes": { "kind": "attribute", "displayName": "Consumes", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "To define the content type 
what the REST service consumes (accept as input), such as application\/xml or 
application\/json. This option will override what may be configured on a parent 
level" },
     "produces": { "kind": "attribute", "displayName": "Produces", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "To define the content type 
what the REST service produces (uses for output), such as application\/xml or 
application\/json This option will override what may be configured on a parent 
level" },
     "bindingMode": { "kind": "attribute", "displayName": "Binding Mode", 
"required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ 
"off", "auto", "json", "xml", "json_xml" ], "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": "off", "description": "Sets the binding 
mode to use. This option will override what may be configured on a parent level 
The default value is off" },
diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/model/rest/RestDefinition.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/model/rest/RestDefinition.java
index b6d0549..e4c9f0e 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/model/rest/RestDefinition.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/model/rest/RestDefinition.java
@@ -691,7 +691,7 @@ public class RestDefinition extends 
OptionalIdentifiedDefinition<RestDefinition>
         }
         getVerbs().add(answer);
         answer.setRest(this);
-        answer.setUri(uri);
+        answer.setPath(uri);
         return this;
     }
 
@@ -721,8 +721,8 @@ public class RestDefinition extends 
OptionalIdentifiedDefinition<RestDefinition>
         Set<String> paths = new HashSet<>();
         for (VerbDefinition verb : verbs) {
             String path = verb.asVerb();
-            if (verb.getUri() != null) {
-                path += ":" + verb.getUri();
+            if (verb.getPath() != null) {
+                path += ":" + verb.getPath();
             }
             if (!paths.add(path)) {
                 throw new IllegalArgumentException("Duplicate verb detected in 
rest-dsl: " + path);
@@ -922,14 +922,14 @@ public class RestDefinition extends 
OptionalIdentifiedDefinition<RestDefinition>
 
             String path = getPath();
             String s1 = FileUtil.stripTrailingSeparator(path);
-            String s2 = FileUtil.stripLeadingSeparator(verb.getUri());
+            String s2 = FileUtil.stripLeadingSeparator(verb.getPath());
             String allPath;
             if (s1 != null && s2 != null) {
                 allPath = s1 + "/" + s2;
             } else if (path != null) {
                 allPath = path;
             } else {
-                allPath = verb.getUri();
+                allPath = verb.getPath();
             }
 
             // each {} is a parameter (url templating)
@@ -1047,12 +1047,12 @@ public class RestDefinition extends 
OptionalIdentifiedDefinition<RestDefinition>
     }
 
     private String buildUri(VerbDefinition verb) {
-        if (path != null && verb.getUri() != null) {
-            return path + ":" + verb.getUri();
+        if (path != null && verb.getPath() != null) {
+            return path + ":" + verb.getPath();
         } else if (path != null) {
             return path;
-        } else if (verb.getUri() != null) {
-            return verb.getUri();
+        } else if (verb.getPath() != null) {
+            return verb.getPath();
         } else {
             return "";
         }
diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
index 9b58702..fcf1116 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
@@ -51,8 +51,11 @@ public abstract class VerbDefinition extends 
OptionalIdentifiedDefinition<VerbDe
     private List<SecurityDefinition> security = new ArrayList<>();
 
     @XmlAttribute
+    @Deprecated
     private String uri;
     @XmlAttribute
+    private String path;
+    @XmlAttribute
     private String consumes;
     @XmlAttribute
     private String produces;
@@ -174,15 +177,28 @@ public abstract class VerbDefinition extends 
OptionalIdentifiedDefinition<VerbDe
         this.security = security;
     }
 
+    @Deprecated
     public String getUri() {
-        return uri;
+        return path;
     }
 
     /**
-     * Uri template of this REST service such as /{id}.
+     * Deprecated use path instead.
      */
+    @Deprecated
     public void setUri(String uri) {
-        this.uri = uri;
+        this.path = uri;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    /**
+     * The path mapping URIs of this REST operation such as /{id}.
+     */
+    public void setPath(String path) {
+        this.path = path;
     }
 
     public String getConsumes() {
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/component/rest/FromRestUriPrefixTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/component/rest/FromRestUriPrefixTest.java
index 6cac3f7..8f18f57 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/component/rest/FromRestUriPrefixTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/component/rest/FromRestUriPrefixTest.java
@@ -36,9 +36,9 @@ public class FromRestUriPrefixTest extends FromRestGetTest {
         assertNotNull(rest);
         assertEquals("/say/", rest.getPath());
         assertEquals(3, rest.getVerbs().size());
-        assertEquals("/hello", rest.getVerbs().get(0).getUri());
-        assertEquals("/bye", rest.getVerbs().get(1).getUri());
-        assertEquals("/hi", rest.getVerbs().get(2).getUri());
+        assertEquals("/hello", rest.getVerbs().get(0).getPath());
+        assertEquals("/bye", rest.getVerbs().get(1).getPath());
+        assertEquals("/hi", rest.getVerbs().get(2).getPath());
         ToDefinition to = assertIsInstanceOf(ToDefinition.class, 
rest.getVerbs().get(0).getTo());
         assertEquals("direct:hello", to.getUri());
         to = assertIsInstanceOf(ToDefinition.class, 
rest.getVerbs().get(1).getTo());
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/model/XmlRestParseTest.java 
b/core/camel-core/src/test/java/org/apache/camel/model/XmlRestParseTest.java
index 0da4094..5b790f3 100644
--- a/core/camel-core/src/test/java/org/apache/camel/model/XmlRestParseTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/model/XmlRestParseTest.java
@@ -34,7 +34,7 @@ public class XmlRestParseTest extends XmlTestSupport {
 
         assertEquals(1, rest.getVerbs().size());
         GetDefinition get = (GetDefinition) rest.getVerbs().get(0);
-        assertEquals("/view/{id}", get.getUri());
+        assertEquals("/view/{id}", get.getPath());
         assertEquals("direct:getUser", get.getTo().getUri());
     }
 
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/model/XmlRestParseToDTest.java 
b/core/camel-core/src/test/java/org/apache/camel/model/XmlRestParseToDTest.java
index 2314828..a0e2430 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/model/XmlRestParseToDTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/model/XmlRestParseToDTest.java
@@ -34,7 +34,7 @@ public class XmlRestParseToDTest extends XmlTestSupport {
 
         assertEquals(1, rest.getVerbs().size());
         GetDefinition get = (GetDefinition) rest.getVerbs().get(0);
-        assertEquals("/view/{id}", get.getUri());
+        assertEquals("/view/{id}", get.getPath());
         assertEquals("bean:getUser?id=${header.id}", get.getToD().getUri());
     }
 
diff --git 
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java 
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
index 46b8d5f..523093c 100644
--- 
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
+++ 
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
@@ -2813,9 +2813,10 @@ public class ModelParser extends BaseParser {
                 case "bindingMode": def.setBindingMode(val); break;
                 case "clientRequestValidation": 
def.setClientRequestValidation(val); break;
                 case "consumes": def.setConsumes(val); break;
-                case "deprecated": def.setDeprecated(Boolean.valueOf(val)); 
break;
+                case "deprecated": def.setDeprecated(val); break;
                 case "enableCORS": def.setEnableCORS(val); break;
                 case "outType": def.setOutType(val); break;
+                case "path": def.setPath(val); break;
                 case "produces": def.setProduces(val); break;
                 case "routeId": def.setRouteId(val); break;
                 case "skipBindingOnErrorCode": 
def.setSkipBindingOnErrorCode(val); break;

Reply via email to