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 2015/05/17 10:38:58 UTC
[3/6] camel git commit: style updates and added param type enum
style updates and added param type enum
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/48754b99
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/48754b99
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/48754b99
Branch: refs/heads/master
Commit: 48754b9962a6b2b60f0df1e8ff546322c582cfb5
Parents: a60f248
Author: sebi <se...@softvision.ro>
Authored: Thu May 14 17:22:33 2015 +0300
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun May 17 10:04:54 2015 +0200
----------------------------------------------------------------------
.../apache/camel/model/rest/RestDefinition.java | 2 +-
.../camel/model/rest/RestOperationParam.java | 46 +++++++++++---------
.../camel/model/rest/RestParamDefinition.java | 11 +++--
.../apache/camel/model/rest/RestParamType.java | 31 +++++++++++++
.../apache/camel/model/rest/VerbDefinition.java | 27 ++++++++----
.../org/apache/camel/model/rest/jaxb.index | 4 +-
.../component/swagger/RestSwaggerReader.scala | 2 +-
7 files changed, 86 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/48754b99/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
index bfb1624..385cbdc 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
@@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
http://git-wip-us.apache.org/repos/asf/camel/blob/48754b99/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParam.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParam.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParam.java
index 6187b3c..162396c 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParam.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParam.java
@@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,57 +16,63 @@
*/
package org.apache.camel.model.rest;
-import org.apache.camel.spi.Metadata;
-
-import javax.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
-/**
- * Created by seb on 5/13/15.
- */
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.camel.spi.Metadata;
+
+
+
+
@Metadata(label = "rest")
@XmlRootElement(name = "param")
@XmlAccessorType(XmlAccessType.FIELD)
public class RestOperationParam {
@XmlAttribute
- String paramType="query";
+ RestParamType paramType = RestParamType.query;
@XmlAttribute
String name;
@XmlAttribute
- String description="";
+ String description = "";
@XmlAttribute
- String defaultValue="";
+ String defaultValue = "";
@XmlAttribute
- Boolean required=true;
+ Boolean required = true;
@XmlAttribute
- Boolean allowMultiple=false;
+ Boolean allowMultiple = false;
@XmlAttribute
- String dataType="string";
+ String dataType = "string";
- @XmlElementWrapper( name="allowableValues" )
- @XmlElement( name="value" )
- List<String> allowableValues=new ArrayList<String>();
+ @XmlElementWrapper(name = "allowableValues")
+ @XmlElement(name = "value")
+ List<String> allowableValues = new ArrayList<String>();
@XmlAttribute
- String paramAccess=null;
+ String paramAccess;
public RestOperationParam() {
-
+
}
- public String getParamType() {
+ public RestParamType getParamType() {
return paramType;
}
- public void setParamType(String paramType) {
+ public void setParamType(RestParamType paramType) {
this.paramType = paramType;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/48754b99/camel-core/src/main/java/org/apache/camel/model/rest/RestParamDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestParamDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestParamDefinition.java
index 27dbc09..d8a6879 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestParamDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestParamDefinition.java
@@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,13 +16,12 @@
*/
package org.apache.camel.model.rest;
+import java.util.List;
+
import org.apache.camel.model.OptionalIdentifiedDefinition;
-import java.util.List;
-/**
- * Created by seb on 5/14/15.
- */
+
public class RestParamDefinition extends OptionalIdentifiedDefinition<RestParamDefinition> {
private RestOperationParam parameter = new RestOperationParam();
@@ -73,7 +72,7 @@ public class RestParamDefinition extends OptionalIdentifiedDefinition<RestParamD
return this;
}
- public RestParamDefinition type(String type) {
+ public RestParamDefinition type(RestParamType type) {
parameter.setParamType(type);
return this;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/48754b99/camel-core/src/main/java/org/apache/camel/model/rest/RestParamType.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestParamType.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestParamType.java
new file mode 100644
index 0000000..8e1381a
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestParamType.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.model.rest;
+
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlType;
+
+import org.apache.camel.spi.Metadata;
+
+@Metadata(label = "rest")
+@XmlType
+@XmlEnum(String.class)
+public enum RestParamType {
+ header, query, body, path, form
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/48754b99/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
index 2a93f07..33442a3 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/VerbDefinition.java
@@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,7 +16,18 @@
*/
package org.apache.camel.model.rest;
-import javax.xml.bind.annotation.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
import org.apache.camel.model.OptionalIdentifiedDefinition;
import org.apache.camel.model.RouteDefinition;
@@ -24,8 +35,7 @@ import org.apache.camel.model.ToDefinition;
import org.apache.camel.spi.Metadata;
import org.apache.camel.util.FileUtil;
-import java.util.ArrayList;
-import java.util.List;
+
/**
* Rest command
@@ -50,7 +60,8 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
@XmlAttribute
private String produces;
- @XmlAttribute @Metadata(defaultValue = "auto")
+ @XmlAttribute
+ @Metadata(defaultValue = "auto")
private RestBindingMode bindingMode;
@XmlAttribute
@@ -129,10 +140,10 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
// each {} is a parameter
String[] arr = allPath.split("\\/");
- for (String a: arr) {
+ for (String a : arr) {
if (a.startsWith("{") && a.endsWith("}")) {
String key = a.substring(1, a.length() - 1);
- rest.restParam().name(key).type("path").endParam();
+ rest.restParam().name(key).type(RestParamType.path).endParam();
}
}
@@ -218,7 +229,7 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
if (type.endsWith("[]")) {
bodyType = "List[" + bodyType.substring(0, type.length() - 2) + "]";
}
- rest.restParam().name("body").type("body").dataType(bodyType).endParam();
+ rest.restParam().name("body").type(RestParamType.body).dataType(bodyType).endParam();
}
public String getOutType() {
http://git-wip-us.apache.org/repos/asf/camel/blob/48754b99/camel-core/src/main/resources/org/apache/camel/model/rest/jaxb.index
----------------------------------------------------------------------
diff --git a/camel-core/src/main/resources/org/apache/camel/model/rest/jaxb.index b/camel-core/src/main/resources/org/apache/camel/model/rest/jaxb.index
index 3b0e381..9ebcd6c 100644
--- a/camel-core/src/main/resources/org/apache/camel/model/rest/jaxb.index
+++ b/camel-core/src/main/resources/org/apache/camel/model/rest/jaxb.index
@@ -26,4 +26,6 @@ RestDefinition
RestHostNameResolver
RestPropertyDefinition
RestsDefinition
-VerbDefinition
\ No newline at end of file
+VerbDefinition
+RestOperationParam
+RestParamDefinition
http://git-wip-us.apache.org/repos/asf/camel/blob/48754b99/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerReader.scala
----------------------------------------------------------------------
diff --git a/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerReader.scala b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerReader.scala
index 6e73d7c..33a801a 100644
--- a/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerReader.scala
+++ b/components/camel-swagger/src/main/scala/org/apache/camel/component/swagger/RestSwaggerReader.scala
@@ -190,7 +190,7 @@ class RestSwaggerReader {
param.getAllowMultiple.booleanValue(),
param.getDataType,
allowValues,
- param.getParamType,
+ param.getParamType.toString,
Some(param.getParamAccess)
)
}