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

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new 699afc4  Server-side annotations should support "*" names like client 
side.
699afc4 is described below

commit 699afc46dd0ff13649ecd2e0074c9e54461390c0
Author: JamesBognar <jamesbog...@apache.org>
AuthorDate: Wed Jul 18 19:51:09 2018 -0400

    Server-side annotations should support "*" names like client side.
---
 .../apache/juneau/http/annotation/FormData.java    | 85 +++++++++-------------
 .../org/apache/juneau/http/annotation/Header.java  | 78 ++++++++------------
 .../org/apache/juneau/http/annotation/Path.java    | 72 +++++++-----------
 .../org/apache/juneau/http/annotation/Query.java   | 85 +++++++++-------------
 .../org/apache/juneau/rest/RequestFormData.java    | 13 ++++
 .../org/apache/juneau/rest/RequestHeaders.java     | 10 +++
 .../org/apache/juneau/rest/RequestPathMatch.java   | 10 +++
 .../java/org/apache/juneau/rest/RequestQuery.java  | 13 ++++
 8 files changed, 174 insertions(+), 192 deletions(-)

diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormData.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormData.java
index d660377..4e3bec8 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormData.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormData.java
@@ -203,10 +203,42 @@ import org.apache.juneau.urlencoding.*;
 public @interface FormData {
 
        /**
-        * The form post parameter name.
+        * Skips this value if it's an empty string or empty collection/array.
         *
         * <p>
-        * Note that {@link #name()} and {@link #value()} are synonyms.
+        * Note that <jk>null</jk> values are already ignored.
+        */
+       boolean skipIfEmpty() default false;
+
+       /**
+        * Specifies the {@link HttpPartSerializer} class used for serializing 
values to strings.
+        *
+        * <p>
+        * The default value defaults to the using the part serializer defined 
on the {@link RequestBean @RequestBean} annotation,
+        * then on the client which by default is {@link UrlEncodingSerializer}.
+        *
+        * <p>
+        * This annotation is provided to allow values to be custom serialized.
+        */
+       Class<? extends HttpPartSerializer> serializer() default 
HttpPartSerializer.Null.class;
+
+       /**
+        * Specifies the {@link HttpPartParser} class used for parsing values 
from strings.
+        *
+        * <p>
+        * The default value for this parser is inherited from the 
servlet/method which defaults to {@link OpenApiPartParser}.
+        * <br>You can use {@link SimplePartParser} to parse POJOs that are 
directly convertible from <code>Strings</code>.
+        */
+       Class<? extends HttpPartParser> parser() default 
HttpPartParser.Null.class;
+
+       
//=================================================================================================================
+       // Attributes common to all Swagger Parameter objects
+       
//=================================================================================================================
+
+       /**
+        * FORM parameter name.
+        *
+        * Required. The name of the parameter.
         *
         * <p>
         * The value should be either <js>"*"</js> to represent multiple 
name/value pairs, or a label that defines the
@@ -253,55 +285,6 @@ public @interface FormData {
         *              </p>
         *      </li>
         * </ul>
-        */
-//     String name() default "";
-
-       /**
-        * A synonym for {@link #name()}.
-        *
-        * <p>
-        * Allows you to use shortened notation if you're only specifying the 
name.
-        */
-//     String value() default "";
-
-       /**
-        * Skips this value if it's an empty string or empty collection/array.
-        *
-        * <p>
-        * Note that <jk>null</jk> values are already ignored.
-        */
-       boolean skipIfEmpty() default false;
-
-       /**
-        * Specifies the {@link HttpPartSerializer} class used for serializing 
values to strings.
-        *
-        * <p>
-        * The default value defaults to the using the part serializer defined 
on the {@link RequestBean @RequestBean} annotation,
-        * then on the client which by default is {@link UrlEncodingSerializer}.
-        *
-        * <p>
-        * This annotation is provided to allow values to be custom serialized.
-        */
-       Class<? extends HttpPartSerializer> serializer() default 
HttpPartSerializer.Null.class;
-
-       /**
-        * Specifies the {@link HttpPartParser} class used for parsing values 
from strings.
-        *
-        * <p>
-        * The default value for this parser is inherited from the 
servlet/method which defaults to {@link OpenApiPartParser}.
-        * <br>You can use {@link SimplePartParser} to parse POJOs that are 
directly convertible from <code>Strings</code>.
-        */
-       Class<? extends HttpPartParser> parser() default 
HttpPartParser.Null.class;
-
-       
//=================================================================================================================
-       // Attributes common to all Swagger Parameter objects
-       
//=================================================================================================================
-
-       /**
-        * FORM parameter name.
-        *
-        * Required. The name of the parameter.
-        *
         * <h5 class='section'>Notes:</h5>
         * <ul class='spaced-list'>
         *      <li>
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Header.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Header.java
index 77ac326..ed63a6d 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Header.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Header.java
@@ -175,9 +175,40 @@ import org.apache.juneau.urlencoding.*;
 public @interface Header {
 
        /**
-        * The HTTP header name.
+        * Skips this value if it's an empty string or empty collection/array.
+        *
+        * <p>
+        * Note that <jk>null</jk> values are already ignored.
+        */
+       boolean skipIfEmpty() default false;
+
+       /**
+        * Specifies the {@link HttpPartSerializer} class used for serializing 
values to strings.
+        *
+        * <p>
+        * The default value defaults to the using the part serializer defined 
on the {@link RequestBean @RequestBean} annotation,
+        * then on the client which by default is {@link UrlEncodingSerializer}.
+        *
+        * <p>
+        * This annotation is provided to allow values to be custom serialized.
+        */
+       Class<? extends HttpPartSerializer> serializer() default 
HttpPartSerializer.Null.class;
+       /**
+        * Specifies the {@link HttpPartParser} class used for parsing values 
from strings.
         *
         * <p>
+        * The default value for this parser is inherited from the 
servlet/method which defaults to {@link OpenApiPartParser}.
+        * <br>You can use {@link SimplePartParser} to parse POJOs that are 
directly convertible from <code>Strings</code>.
+        */
+       Class<? extends HttpPartParser> parser() default 
HttpPartParser.Null.class;
+
+       
//=================================================================================================================
+       // Attributes common to all Swagger Parameter objects
+       
//=================================================================================================================
+
+       /**
+        * HTTP header name.
+        * <p>
         * A blank value (the default) indicates to reuse the bean property 
name when used on a request bean property.
         *
         * <p>
@@ -227,51 +258,6 @@ public @interface Header {
         *      </li>
         * </ul>
         */
-//     String name() default "";
-
-       /**
-        * A synonym for {@link #name()}.
-        *
-        * <p>
-        * Allows you to use shortened notation if you're only specifying the 
name.
-        */
-//     String value() default "";
-
-       /**
-        * Skips this value if it's an empty string or empty collection/array.
-        *
-        * <p>
-        * Note that <jk>null</jk> values are already ignored.
-        */
-       boolean skipIfEmpty() default false;
-
-       /**
-        * Specifies the {@link HttpPartSerializer} class used for serializing 
values to strings.
-        *
-        * <p>
-        * The default value defaults to the using the part serializer defined 
on the {@link RequestBean @RequestBean} annotation,
-        * then on the client which by default is {@link UrlEncodingSerializer}.
-        *
-        * <p>
-        * This annotation is provided to allow values to be custom serialized.
-        */
-       Class<? extends HttpPartSerializer> serializer() default 
HttpPartSerializer.Null.class;
-       /**
-        * Specifies the {@link HttpPartParser} class used for parsing values 
from strings.
-        *
-        * <p>
-        * The default value for this parser is inherited from the 
servlet/method which defaults to {@link OpenApiPartParser}.
-        * <br>You can use {@link SimplePartParser} to parse POJOs that are 
directly convertible from <code>Strings</code>.
-        */
-       Class<? extends HttpPartParser> parser() default 
HttpPartParser.Null.class;
-
-       
//=================================================================================================================
-       // Attributes common to all Swagger Parameter objects
-       
//=================================================================================================================
-
-       /**
-        * HTTP header name.
-        */
        String name() default "";
 
        /**
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Path.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Path.java
index 0f5c020..c3ebabb 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Path.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Path.java
@@ -163,10 +163,36 @@ import org.apache.juneau.urlencoding.*;
 public @interface Path {
 
        /**
-        * The path parameter name.
+        * Specifies the {@link HttpPartSerializer} class used for serializing 
values to strings.
+        *
+        * <p>
+        * The default value defaults to the using the part serializer defined 
on the {@link RequestBean @RequestBean} annotation,
+        * then on the client which by default is {@link UrlEncodingSerializer}.
+        *
+        * <p>
+        * This annotation is provided to allow values to be custom serialized.
+        */
+       Class<? extends HttpPartSerializer> serializer() default 
HttpPartSerializer.Null.class;
+
+       /**
+        * Specifies the {@link HttpPartParser} class used for parsing values 
from strings.
+        *
+        * <p>
+        * The default value for this parser is inherited from the 
servlet/method which defaults to {@link OpenApiPartParser}.
+        * <br>You can use {@link SimplePartParser} to parse POJOs that are 
directly convertible from <code>Strings</code>.
+        */
+       Class<? extends HttpPartParser> parser() default 
HttpPartParser.Null.class;
+
+       
//=================================================================================================================
+       // Attributes common to all Swagger Parameter objects
+       
//=================================================================================================================
+
+       /**
+        * URL path variable name.
         *
         * <p>
-        * Note that {@link #name()} and {@link #value()} are synonyms.
+        * The path remainder after the path match can be referenced using the 
name <js>"/*"</js>.
+        * <br>The non-URL-decoded path remainder after the path match can be 
referenced using the name <js>"/**"</js>.
         *
         * <p>
         * The value should be either <js>"*"</js> to represent multiple 
name/value pairs, or a label that defines the
@@ -211,48 +237,6 @@ public @interface Path {
         *              String getFoo();
         *      }
         * </ul>
-        */
-//     String name() default "";
-
-       /**
-        * A synonym for {@link #name()}.
-        *
-        * <p>
-        * Allows you to use shortened notation if you're only specifying the 
name.
-        */
-//     String value() default "";
-
-       /**
-        * Specifies the {@link HttpPartSerializer} class used for serializing 
values to strings.
-        *
-        * <p>
-        * The default value defaults to the using the part serializer defined 
on the {@link RequestBean @RequestBean} annotation,
-        * then on the client which by default is {@link UrlEncodingSerializer}.
-        *
-        * <p>
-        * This annotation is provided to allow values to be custom serialized.
-        */
-       Class<? extends HttpPartSerializer> serializer() default 
HttpPartSerializer.Null.class;
-
-       /**
-        * Specifies the {@link HttpPartParser} class used for parsing values 
from strings.
-        *
-        * <p>
-        * The default value for this parser is inherited from the 
servlet/method which defaults to {@link OpenApiPartParser}.
-        * <br>You can use {@link SimplePartParser} to parse POJOs that are 
directly convertible from <code>Strings</code>.
-        */
-       Class<? extends HttpPartParser> parser() default 
HttpPartParser.Null.class;
-
-       
//=================================================================================================================
-       // Attributes common to all Swagger Parameter objects
-       
//=================================================================================================================
-
-       /**
-        * URL path variable name.
-        *
-        * <p>
-        * The path remainder after the path match can be referenced using the 
name <js>"/*"</js>.
-        * <br>The non-URL-decoded path remainder after the path match can be 
referenced using the name <js>"/**"</js>.
         *
         * <p>
         * The name field MUST correspond to the associated <a 
href='https://swagger.io/specification/v2/#pathsPath'>path</a> segment from the 
path field in the <a 
href='https://swagger.io/specification/v2/#pathsObject'>Paths Object</a>.
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
index 72bf11b..a2bb451 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
@@ -199,10 +199,42 @@ import org.apache.juneau.urlencoding.*;
 public @interface Query {
 
        /**
-        * The query parameter name.
+        * Skips this value if it's an empty string or empty collection/array.
         *
         * <p>
-        * Note that {@link #name()} and {@link #value()} are synonyms.
+        * Note that <jk>null</jk> values are already ignored.
+        */
+       boolean skipIfEmpty() default false;
+
+       /**
+        * Specifies the {@link HttpPartSerializer} class used for serializing 
values to strings.
+        *
+        * <p>
+        * The default value defaults to the using the part serializer defined 
on the {@link RequestBean @RequestBean} annotation,
+        * then on the client which by default is {@link UrlEncodingSerializer}.
+        *
+        * <p>
+        * This annotation is provided to allow values to be custom serialized.
+        */
+       Class<? extends HttpPartSerializer> serializer() default 
HttpPartSerializer.Null.class;
+
+       /**
+        * Specifies the {@link HttpPartParser} class used for parsing values 
from strings.
+        *
+        * <p>
+        * The default value for this parser is inherited from the 
servlet/method which defaults to {@link OpenApiPartParser}.
+        * <br>You can use {@link SimplePartParser} to parse POJOs that are 
directly convertible from <code>Strings</code>.
+        */
+       Class<? extends HttpPartParser> parser() default 
HttpPartParser.Null.class;
+
+       
//=================================================================================================================
+       // Attributes common to all Swagger Parameter objects
+       
//=================================================================================================================
+
+       /**
+        * URL query parameter name.
+        *
+        * Required. The name of the parameter. Parameter names are case 
sensitive.
         *
         * <p>
         * The value should be either <js>"*"</js> to represent multiple 
name/value pairs, or a label that defines the
@@ -249,55 +281,6 @@ public @interface Query {
         *              </p>
         *      </li>
         * </ul>
-        */
-//     String name() default "";
-
-       /**
-        * A synonym for {@link #name()}.
-        *
-        * <p>
-        * Allows you to use shortened notation if you're only specifying the 
name.
-        */
-//     String value() default "";
-
-       /**
-        * Skips this value if it's an empty string or empty collection/array.
-        *
-        * <p>
-        * Note that <jk>null</jk> values are already ignored.
-        */
-       boolean skipIfEmpty() default false;
-
-       /**
-        * Specifies the {@link HttpPartSerializer} class used for serializing 
values to strings.
-        *
-        * <p>
-        * The default value defaults to the using the part serializer defined 
on the {@link RequestBean @RequestBean} annotation,
-        * then on the client which by default is {@link UrlEncodingSerializer}.
-        *
-        * <p>
-        * This annotation is provided to allow values to be custom serialized.
-        */
-       Class<? extends HttpPartSerializer> serializer() default 
HttpPartSerializer.Null.class;
-
-       /**
-        * Specifies the {@link HttpPartParser} class used for parsing values 
from strings.
-        *
-        * <p>
-        * The default value for this parser is inherited from the 
servlet/method which defaults to {@link OpenApiPartParser}.
-        * <br>You can use {@link SimplePartParser} to parse POJOs that are 
directly convertible from <code>Strings</code>.
-        */
-       Class<? extends HttpPartParser> parser() default 
HttpPartParser.Null.class;
-
-       
//=================================================================================================================
-       // Attributes common to all Swagger Parameter objects
-       
//=================================================================================================================
-
-       /**
-        * URL query parameter name.
-        *
-        * Required. The name of the parameter. Parameter names are case 
sensitive.
-        *
         * <h5 class='section'>Notes:</h5>
         * <ul class='spaced-list'>
         *      <li>
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestFormData.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestFormData.java
index 8238ae1..7a6c369 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestFormData.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestFormData.java
@@ -527,6 +527,19 @@ public class RequestFormData extends 
LinkedHashMap<String,String[]> {
        /* Workhorse method */
        private <T> T getInner(HttpPartParser parser, HttpPartSchema schema, 
String name, T def, ClassMeta<T> cm) throws BadRequest, InternalServerError {
                try {
+                       if ("*".equals(name) && cm.isMapOrBean()) {
+                               ObjectMap m = new ObjectMap();
+                               for (Map.Entry<String,String[]> e : 
this.entrySet()) {
+                                       String k = e.getKey();
+                                       HttpPartSchema pschema = schema == null 
? null : schema.getProperty(k);
+                                       ClassMeta<?> cm2 = cm.getValueType();
+                                       if 
(cm.getValueType().isCollectionOrArray())
+                                               m.put(k, getAllInner(parser, 
pschema, k, null, cm2));
+                                       else
+                                               m.put(k, getInner(parser, 
pschema, k, null, cm2));
+                               }
+                               return req.getBeanSession().convertToType(m, 
cm);
+                       }
                        T t = parse(parser, schema, getString(name), cm);
                        return (t == null ? def : t);
                } catch (SchemaValidationException e) {
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestHeaders.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestHeaders.java
index e3d4e51..5592e79 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestHeaders.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestHeaders.java
@@ -389,6 +389,16 @@ public class RequestHeaders extends 
TreeMap<String,String[]> {
        /* Workhorse method */
        private <T> T getInner(HttpPartParser parser, HttpPartSchema schema, 
String name, T def, ClassMeta<T> cm) throws BadRequest, InternalServerError {
                try {
+                       if ("*".equals(name) && cm.isMapOrBean()) {
+                               ObjectMap m = new ObjectMap();
+                               for (Map.Entry<String,String[]> e : 
this.entrySet()) {
+                                       String k = e.getKey();
+                                       HttpPartSchema pschema = schema == null 
? null : schema.getProperty(k);
+                                       ClassMeta<?> cm2 = cm.getValueType();
+                                       m.put(k, getInner(parser, pschema, k, 
null, cm2));
+                               }
+                               return req.getBeanSession().convertToType(m, 
cm);
+                       }
                        T t = parse(parser, schema, getString(name), cm);
                        return (t == null ? def : t);
                } catch (SchemaValidationException e) {
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestPathMatch.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestPathMatch.java
index 6d3befc..264a703 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestPathMatch.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestPathMatch.java
@@ -251,6 +251,16 @@ public class RequestPathMatch extends 
TreeMap<String,String> {
        /* Workhorse method */
        private <T> T getInner(HttpPartParser parser, HttpPartSchema schema, 
String name, T def, ClassMeta<T> cm) throws BadRequest, InternalServerError {
                try {
+                       if ("*".equals(name) && cm.isMapOrBean()) {
+                               ObjectMap m = new ObjectMap();
+                               for (Map.Entry<String,String> e : 
this.entrySet()) {
+                                       String k = e.getKey();
+                                       HttpPartSchema pschema = schema == null 
? null : schema.getProperty(k);
+                                       ClassMeta<?> cm2 = cm.getValueType();
+                                       m.put(k, getInner(parser, pschema, k, 
null, cm2));
+                               }
+                               return req.getBeanSession().convertToType(m, 
cm);
+                       }
                        T t = parse(parser, schema, get(name), cm);
                        return (t == null ? def : t);
                } catch (SchemaValidationException e) {
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestQuery.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestQuery.java
index 38aec16..1c439b6 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestQuery.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestQuery.java
@@ -589,6 +589,19 @@ public final class RequestQuery extends 
LinkedHashMap<String,String[]> {
        /* Workhorse method */
        private <T> T getInner(HttpPartParser parser, HttpPartSchema schema, 
String name, T def, ClassMeta<T> cm) throws BadRequest, InternalServerError {
                try {
+                       if ("*".equals(name) && cm.isMapOrBean()) {
+                               ObjectMap m = new ObjectMap();
+                               for (Map.Entry<String,String[]> e : 
this.entrySet()) {
+                                       String k = e.getKey();
+                                       HttpPartSchema pschema = schema == null 
? null : schema.getProperty(k);
+                                       ClassMeta<?> cm2 = cm.getValueType();
+                                       if 
(cm.getValueType().isCollectionOrArray())
+                                               m.put(k, getAllInner(parser, 
pschema, k, null, cm2));
+                                       else
+                                               m.put(k, getInner(parser, 
pschema, k, null, cm2));
+                               }
+                               return req.getBeanSession().convertToType(m, 
cm);
+                       }
                        T t = parse(parser, schema, getString(name), cm);
                        return (t == null ? def : t);
                } catch (SchemaValidationException e) {

Reply via email to