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:56 UTC

[1/6] camel git commit: removing some formating

Repository: camel
Updated Branches:
  refs/heads/master bb4d11db8 -> 0019f0b9e


removing some formating


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

Branch: refs/heads/master
Commit: df08235a9aef23a97d7cde9da1b5871c3c90c9af
Parents: 96ce569
Author: sebi <se...@softvision.ro>
Authored: Thu May 14 12:36:53 2015 +0300
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun May 17 10:04:53 2015 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/camel/model/rest/RestDefinition.java | 7 +++----
 .../main/java/org/apache/camel/model/rest/VerbDefinition.java | 7 +++----
 2 files changed, 6 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/df08235a/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 e03b2e8..bfb1624 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
@@ -5,9 +5,9 @@
  * 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
- * <p>
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
  * 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.
@@ -52,8 +52,7 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
     @XmlAttribute
     private String produces;
 
-    @XmlAttribute
-    @Metadata(defaultValue = "auto")
+    @XmlAttribute @Metadata(defaultValue = "auto")
     private RestBindingMode bindingMode;
 
     @XmlAttribute

http://git-wip-us.apache.org/repos/asf/camel/blob/df08235a/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 84a71f6..2a93f07 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
@@ -5,9 +5,9 @@
  * 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
- * <p>
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
  * 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.
@@ -50,8 +50,7 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
     @XmlAttribute
     private String produces;
 
-    @XmlAttribute
-    @Metadata(defaultValue = "auto")
+    @XmlAttribute @Metadata(defaultValue = "auto")
     private RestBindingMode bindingMode;
 
     @XmlAttribute


[2/6] camel git commit: adding swagger custom paramater definition

Posted by da...@apache.org.
adding swagger custom paramater definition


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

Branch: refs/heads/master
Commit: 96ce5691b954b5596a075fcb6625e6c9995d1a9b
Parents: bb4d11d
Author: sebi <se...@softvision.ro>
Authored: Wed May 13 19:30:57 2015 +0300
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun May 17 10:04:53 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/model/rest/RestDefinition.java |  22 ++--
 .../camel/model/rest/RestOperationParam.java    | 120 +++++++++++++++++++
 .../camel/model/rest/RestParamDefinition.java   |  76 ++++++++++++
 .../apache/camel/model/rest/VerbDefinition.java |  56 +++++++--
 .../component/swagger/RestSwaggerReader.scala   |  53 +++-----
 5 files changed, 272 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/96ce5691/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 82633ca..e03b2e8 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
@@ -5,9 +5,9 @@
  * 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
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * 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.
@@ -52,7 +52,8 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
     @XmlAttribute
     private String produces;
 
-    @XmlAttribute @Metadata(defaultValue = "auto")
+    @XmlAttribute
+    @Metadata(defaultValue = "auto")
     private RestBindingMode bindingMode;
 
     @XmlAttribute
@@ -128,7 +129,7 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
     public void setVerbs(List<VerbDefinition> verbs) {
         this.verbs = verbs;
     }
-   
+
     public Boolean getSkipBindingOnErrorCode() {
         return skipBindingOnErrorCode;
     }
@@ -267,6 +268,14 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
         return this;
     }
 
+    public RestParamDefinition restParam() {
+        if (getVerbs().isEmpty()) {
+            throw new IllegalArgumentException("Must add verb first, such as get/post/delete");
+        }
+        VerbDefinition verb = getVerbs().get(getVerbs().size() - 1);
+        return new RestParamDefinition(verb);
+    }
+
     public RestDefinition produces(String mediaType) {
         if (getVerbs().isEmpty()) {
             this.produces = mediaType;
@@ -416,10 +425,9 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
             answer = new VerbDefinition();
             answer.setMethod(verb);
         }
-
+        getVerbs().add(answer);
         answer.setRest(this);
         answer.setUri(uri);
-        getVerbs().add(answer);
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/96ce5691/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
new file mode 100644
index 0000000..258e26c
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestOperationParam.java
@@ -0,0 +1,120 @@
+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.
+ */
+@Metadata(label = "rest")
+@XmlRootElement(name = "param")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class RestOperationParam {
+    @XmlAttribute
+    String paramType="query";
+
+    @XmlAttribute
+    String name;
+
+    @XmlAttribute
+    String description="";
+
+    @XmlAttribute
+    String defaultValue="";
+
+    @XmlAttribute
+    Boolean required=true;
+
+    @XmlAttribute
+    Boolean allowMultiple=false;
+
+    @XmlAttribute
+    String dataType="string";
+
+    @XmlElementWrapper( name="allowableValues" )
+    @XmlElement( name="value" )
+    List<String> allowableValues=new ArrayList<String>();
+
+    @XmlAttribute
+    String paramAccess=null;
+
+
+    public RestOperationParam() {
+    
+    }
+
+    public String getParamType() {
+        return paramType;
+    }
+
+    public void setParamType(String paramType) {
+        this.paramType = paramType;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getDefaultValue() {
+        return defaultValue;
+    }
+
+    public void setDefaultValue(String defaultValue) {
+        this.defaultValue = defaultValue;
+    }
+
+    public Boolean getRequired() {
+        return required;
+    }
+
+    public void setRequired(Boolean required) {
+        this.required = required;
+    }
+
+    public Boolean getAllowMultiple() {
+        return allowMultiple;
+    }
+
+    public void setAllowMultiple(Boolean allowMultiple) {
+        this.allowMultiple = allowMultiple;
+    }
+
+    public String getDataType() {
+        return dataType;
+    }
+
+    public void setDataType(String dataType) {
+        this.dataType = dataType;
+    }
+
+    public List<String> getAllowableValues() {
+        return allowableValues;
+    }
+
+    public void setAllowableValues(List<String> allowableValues) {
+        this.allowableValues = allowableValues;
+    }
+
+    public String getParamAccess() {
+        return paramAccess;
+    }
+
+    public void setParamAccess(String paramAccess) {
+        this.paramAccess = paramAccess;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/96ce5691/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
new file mode 100644
index 0000000..b4a318a
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestParamDefinition.java
@@ -0,0 +1,76 @@
+package org.apache.camel.model.rest;
+
+import org.apache.camel.model.OptionalIdentifiedDefinition;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by seb on 5/14/15.
+ */
+public class RestParamDefinition extends OptionalIdentifiedDefinition<RestParamDefinition> {
+
+    private RestOperationParam parameter = new RestOperationParam();
+    private VerbDefinition verb;
+
+    public RestParamDefinition(VerbDefinition verb) {
+        this.verb = verb;
+    }
+
+    @Override
+    public String getLabel() {
+        return "param";
+    }
+
+
+    public RestParamDefinition name(String name) {
+        parameter.setName(name);
+        return this;
+    }
+
+    public RestParamDefinition description(String name) {
+        parameter.setDescription(name);
+        return this;
+    }
+
+    public RestParamDefinition defaultValue(String name) {
+        parameter.setDefaultValue(name);
+        return this;
+    }
+
+    public RestParamDefinition required(Boolean required) {
+        parameter.setRequired(required);
+        return this;
+    }
+
+    public RestParamDefinition allowMultiple(Boolean allowMultiple) {
+        parameter.setAllowMultiple(allowMultiple);
+        return this;
+    }
+
+    public RestParamDefinition dataType(String type) {
+        parameter.setDataType(type);
+        return this;
+    }
+
+    public RestParamDefinition allowableValues(List<String> allowableValues) {
+        parameter.setAllowableValues(allowableValues);
+        return this;
+    }
+
+    public RestParamDefinition type(String type) {
+        parameter.setParamType(type);
+        return this;
+    }
+
+    public RestParamDefinition paramAccess(String paramAccess) {
+        parameter.setParamAccess(paramAccess);
+        return this;
+    }
+
+    public RestDefinition endParam() {
+        verb.getParams().add(parameter);
+        return verb.getRest();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/96ce5691/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 df053fd..84a71f6 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
@@ -5,9 +5,9 @@
  * 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
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * 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.
@@ -16,18 +16,16 @@
  */
 package org.apache.camel.model.rest;
 
-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.XmlElements;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.*;
 
 import org.apache.camel.model.OptionalIdentifiedDefinition;
 import org.apache.camel.model.RouteDefinition;
 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
@@ -40,6 +38,9 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
     @XmlAttribute
     private String method;
 
+    @XmlElementRef
+    private List<RestOperationParam> params = new ArrayList<RestOperationParam>();
+
     @XmlAttribute
     private String uri;
 
@@ -49,7 +50,8 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
     @XmlAttribute
     private String produces;
 
-    @XmlAttribute @Metadata(defaultValue = "auto")
+    @XmlAttribute
+    @Metadata(defaultValue = "auto")
     private RestBindingMode bindingMode;
 
     @XmlAttribute
@@ -89,6 +91,10 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
         }
     }
 
+    public List<RestOperationParam> getParams() {
+        return params;
+    }
+
     public String getMethod() {
         return method;
     }
@@ -109,6 +115,29 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
      */
     public void setUri(String uri) {
         this.uri = uri;
+        String path = this.rest.getPath();
+
+        String s1 = FileUtil.stripTrailingSeparator(path);
+        String s2 = FileUtil.stripLeadingSeparator(uri);
+        String allPath;
+        if (s1 != null && s2 != null) {
+            allPath = s1 + "/" + s2;
+        } else if (path != null) {
+            allPath = path;
+        } else {
+            allPath = uri;
+        }
+
+        // each {} is a parameter
+        String[] arr = allPath.split("\\/");
+        for (String a: arr) {
+            if (a.startsWith("{") && a.endsWith("}")) {
+                String key = a.substring(1, a.length() - 1);
+                rest.restParam().name(key).type("path").endParam();
+            }
+        }
+
+
     }
 
     public String getConsumes() {
@@ -186,6 +215,11 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
      */
     public void setType(String type) {
         this.type = type;
+        String bodyType = type;
+        if (type.endsWith("[]")) {
+            bodyType = "List[" + bodyType.substring(0, type.length() - 2) + "]";
+        }
+        rest.restParam().name("body").type("body").dataType(bodyType).endParam();
     }
 
     public String getOutType() {

http://git-wip-us.apache.org/repos/asf/camel/blob/96ce5691/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 ca5bff2..6e73d7c 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
@@ -23,7 +23,7 @@ import com.wordnik.swagger.model._
 import com.wordnik.swagger.core.util.ModelUtil
 import com.wordnik.swagger.core.SwaggerSpec
 
-import org.apache.camel.model.rest.{VerbDefinition, RestDefinition}
+import org.apache.camel.model.rest.{RestOperationParam, VerbDefinition, RestDefinition}
 import org.apache.camel.util.FileUtil
 import org.slf4j.LoggerFactory
 
@@ -120,7 +120,7 @@ class RestSwaggerReader {
         consumes,
         List(),
         List(),
-        createParameters(verb, buildUrl(resourcePath, path)),
+        createParameters(verb),
         List(),
         None)
     }
@@ -173,46 +173,25 @@ class RestSwaggerReader {
     else None
   }
 
-  def createParameters(verb: VerbDefinition, absPath : String): List[Parameter] = {
+  def createParameters(verb: VerbDefinition): List[Parameter] = {
     val parameters = new ListBuffer[Parameter]
 
-    // each {} is a parameter
-    val arr = absPath.split("\\/")
-    for (a <- arr) {
-      if (a.startsWith("{") && a.endsWith("}")) {
-        var key = a.substring(1, a.length - 1)
-
-        parameters += Parameter(
-          key,
-          None,
-          None,
-          true,
-          false,
-          "string",
-          AnyAllowableValues,
-          "path",
-          None
-        )
-      }
-    }
+    for (param:RestOperationParam <- verb.getParams.asScala) {
+      var allowValues=AnyAllowableValues
 
-    // if we have input type then its a body parameter
-    if (verb.getType != null) {
-      var bodyType = verb.getType
-      if (bodyType.endsWith("[]")) {
-        bodyType = "List[" + bodyType.substring(0, bodyType.length - 2) + "]"
+      if(!param.getAllowableValues.isEmpty){
+        AllowableListValues(param.getAllowableValues.asScala.toList)
       }
-
       parameters += Parameter(
-        "body",
-        None,
-        None,
-        true,
-        false,
-        bodyType,
-        AnyAllowableValues,
-        "body",
-        None
+        param.getName,
+        Some( param.getDescription ),
+        Some( param.getDefaultValue),
+        param.getRequired.booleanValue(),
+        param.getAllowMultiple.booleanValue(),
+        param.getDataType,
+        allowValues,
+        param.getParamType,
+        Some(param.getParamAccess)
       )
     }
 


[4/6] camel git commit: added licence header

Posted by da...@apache.org.
added licence header


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

Branch: refs/heads/master
Commit: a60f2485eac59ef20d3c2bff173298ba93d7592a
Parents: df08235
Author: sebi <se...@softvision.ro>
Authored: Thu May 14 14:28:08 2015 +0300
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun May 17 10:04:54 2015 +0200

----------------------------------------------------------------------
 .../camel/model/rest/RestOperationParam.java       | 16 ++++++++++++++++
 .../camel/model/rest/RestParamDefinition.java      | 17 ++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a60f2485/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 258e26c..6187b3c 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
@@ -1,3 +1,19 @@
+/**
+ * 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 org.apache.camel.spi.Metadata;

http://git-wip-us.apache.org/repos/asf/camel/blob/a60f2485/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 b4a318a..27dbc09 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
@@ -1,8 +1,23 @@
+/**
+ * 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 org.apache.camel.model.OptionalIdentifiedDefinition;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**


[3/6] camel git commit: style updates and added param type enum

Posted by da...@apache.org.
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)
       )
     }


[5/6] camel git commit: ignore element

Posted by da...@apache.org.
ignore element


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

Branch: refs/heads/master
Commit: 358ebfbfb9a41afe7f57d83c824e7cfce2cbf682
Parents: 48754b9
Author: sebi <se...@softvision.ro>
Authored: Fri May 15 14:18:03 2015 +0300
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun May 17 10:04:54 2015 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/camel/model/rest/RestParamDefinition.java | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/358ebfbf/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 d8a6879..8801e7a 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
@@ -20,8 +20,10 @@ import java.util.List;
 
 import org.apache.camel.model.OptionalIdentifiedDefinition;
 
+import javax.xml.bind.annotation.XmlTransient;
 
 
+@XmlTransient
 public class RestParamDefinition extends OptionalIdentifiedDefinition<RestParamDefinition> {
 
     private RestOperationParam parameter = new RestOperationParam();


[6/6] camel git commit: Added TODO which needs to be resolved for the recent rest-dsl PR

Posted by da...@apache.org.
Added TODO which needs to be resolved for the recent rest-dsl PR


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

Branch: refs/heads/master
Commit: 0019f0b9ef5900d928d00a206c4bd1652912babd
Parents: 358ebfb
Author: Claus Ibsen <da...@apache.org>
Authored: Sun May 17 10:43:05 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun May 17 10:43:05 2015 +0200

----------------------------------------------------------------------
 .../org/apache/camel/model/rest/RestOperationParam.java     | 9 +++++----
 .../org/apache/camel/model/rest/RestParamDefinition.java    | 2 ++
 .../java/org/apache/camel/model/rest/RestParamType.java     | 4 ++--
 .../java/org/apache/camel/model/rest/VerbDefinition.java    | 8 ++++----
 4 files changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0019f0b9/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 162396c..1a9c437 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
@@ -28,8 +28,11 @@ import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.camel.spi.Metadata;
 
-
-
+// TODO: rename to Definition as this is what this is
+// TODO: Do not set default values, but infer those
+// TODO: add javadoc on the setter methods
+// TODO: add @Metadata to define the default values
+// TODO: add required=true if its required (such as name and paramType I would assume)
 
 @Metadata(label = "rest")
 @XmlRootElement(name = "param")
@@ -63,9 +66,7 @@ public class RestOperationParam {
     @XmlAttribute
     String paramAccess;
 
-
     public RestOperationParam() {
-
     }
 
     public RestParamType getParamType() {

http://git-wip-us.apache.org/repos/asf/camel/blob/0019f0b9/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 8801e7a..edc90dd 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
@@ -22,6 +22,8 @@ import org.apache.camel.model.OptionalIdentifiedDefinition;
 
 import javax.xml.bind.annotation.XmlTransient;
 
+// TODO: Should not be a Definition as its a builder for Java DSL instead.
+// instead the builder methods should be on RestOperationParam
 
 @XmlTransient
 public class RestParamDefinition extends OptionalIdentifiedDefinition<RestParamDefinition> {

http://git-wip-us.apache.org/repos/asf/camel/blob/0019f0b9/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
index 8e1381a..b857f9f 100644
--- 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
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.model.rest;
 
-
 import javax.xml.bind.annotation.XmlEnum;
 import javax.xml.bind.annotation.XmlType;
 
@@ -26,6 +25,7 @@ import org.apache.camel.spi.Metadata;
 @XmlType
 @XmlEnum(String.class)
 public enum RestParamType {
-    header, query, body, path, form
+
+    body, form, header, path, query
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0019f0b9/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 33442a3..56a4d89 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
@@ -35,8 +35,6 @@ import org.apache.camel.model.ToDefinition;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.util.FileUtil;
 
-
-
 /**
  * Rest command
  */
@@ -127,6 +125,10 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
         this.uri = uri;
         String path = this.rest.getPath();
 
+        // TODO: The setter should be a plain setter.
+        // this logic should be moved to
+        // org.apache.camel.model.rest.RestDefinition.asRouteDefinition()
+
         String s1 = FileUtil.stripTrailingSeparator(path);
         String s2 = FileUtil.stripLeadingSeparator(uri);
         String allPath;
@@ -146,8 +148,6 @@ public class VerbDefinition extends OptionalIdentifiedDefinition<VerbDefinition>
                 rest.restParam().name(key).type(RestParamType.path).endParam();
             }
         }
-
-
     }
 
     public String getConsumes() {