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 bd0b99d RestClient API improvements. bd0b99d is described below commit bd0b99dd8d3367be58934c78103468ac986f39c5 Author: JamesBognar <james.bog...@salesforce.com> AuthorDate: Wed Jun 9 16:07:06 2021 -0400 RestClient API improvements. --- .../java/org/apache/juneau/http/remote/Remote.java | 10 ++-- .../11.RestcProxies/01.RestcRemote.html | 8 +-- .../org/apache/juneau/rest/client/RestClient.java | 63 ---------------------- .../org/apache/juneau/rest/client/RestRequest.java | 54 +++++++++---------- .../apache/juneau/rest/ClientVersionMatcher.java | 4 +- .../java/org/apache/juneau/rest/RestContext.java | 4 +- .../org/apache/juneau/rest/RestContextBuilder.java | 2 +- .../apache/juneau/rest/RestOperationContext.java | 12 ++--- .../apache/juneau/rest/annotation/RestDelete.java | 12 ++--- .../org/apache/juneau/rest/annotation/RestGet.java | 12 ++--- .../org/apache/juneau/rest/annotation/RestOp.java | 10 ++-- .../apache/juneau/rest/annotation/RestPost.java | 10 ++-- .../org/apache/juneau/rest/annotation/RestPut.java | 10 ++-- .../rest/annotation/RestOp_ClientVersion_Test.java | 2 +- .../rest/client/RestClient_Headers_Test.java | 4 +- 15 files changed, 77 insertions(+), 140 deletions(-) diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/remote/Remote.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/remote/Remote.java index 68fde15..cceae7b 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/remote/Remote.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/remote/Remote.java @@ -82,7 +82,7 @@ public @interface Remote { * Specifies the client version of this interface. * * <p> - * Used to populate the <js>"X-Client-Version"</js> header that identifies what version of client this is + * Used to populate the <js>"Client-Version"</js> header that identifies what version of client this is * so that the server side can handle older versions accordingly. * * <p> @@ -91,16 +91,16 @@ public @interface Remote { * <p> * The server side then uses an OSGi-version matching pattern to identify which methods to call: * <p class='bcode w800'> - * <jc>// Call this method if X-Client-Version is at least 2.0. + * <jc>// Call this method if Client-Version is at least 2.0. * // Note that this also matches 2.0.1.</jc> * <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"2.0"</js>) * <jk>public</jk> Object method1() {...} * - * <jc>// Call this method if X-Client-Version is at least 1.1, but less than 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 1.1, but less than 2.0.</jc> * <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[1.1,2.0)"</js>) * <jk>public</jk> Object method2() {...} * - * <jc>// Call this method if X-Client-Version is less than 1.1.</jc> + * <jc>// Call this method if Client-Version is less than 1.1.</jc> * <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[0,1.1)"</js>) * <jk>public</jk> Object method3() {...} * </p> @@ -117,7 +117,7 @@ public @interface Remote { * Specifies the client version header name. * * <p> - * The default value is <js>"X-Client-Version"</js>. + * The default value is <js>"Client-Version"</js>. * * <ul class='notes'> * <li> diff --git a/juneau-doc/docs/Topics/09.juneau-rest-client/11.RestcProxies/01.RestcRemote.html b/juneau-doc/docs/Topics/09.juneau-rest-client/11.RestcProxies/01.RestcRemote.html index 41f4efa..2a04aed 100644 --- a/juneau-doc/docs/Topics/09.juneau-rest-client/11.RestcProxies/01.RestcRemote.html +++ b/juneau-doc/docs/Topics/09.juneau-rest-client/11.RestcProxies/01.RestcRemote.html @@ -148,7 +148,7 @@ specific language governing permissions and limitations under the License. <p class='bpcode w800'> <ja>@Remote</ja>( path=<js>"/petstore"</js>, - version=<js>"1.2.3"</js> <jc>// Adds "X-Client-Version: 1.2.3" header to all requests.</jc> + version=<js>"1.2.3"</js> <jc>// Adds "Client-Version: 1.2.3" header to all requests.</jc> ) <jk>public interface</jk> PetStore {...} </p> @@ -157,16 +157,16 @@ specific language governing permissions and limitations under the License. This can be used in conjunction with the server-side client-versioning support. </p> <p class='bpcode w800'> - <jc>// Call this method if X-Client-Version is at least 2.0. + <jc>// Call this method if Client-Version is at least 2.0. // Note that this also matches 2.0.1.</jc> <ja>@RestGet</ja>(clientVersion=<js>"2.0"</js>) <jk>public</jk> Object foo() {...} - <jc>// Call this method if X-Client-Version is at least 1.1, but less than 2.0.</jc> + <jc>// Call this method if Client-Version is at least 1.1, but less than 2.0.</jc> <ja>@RestGet</ja>(clientVersion=<js>"[1.1,2.0)"</js>) <jk>public</jk> Object foo() {...} - <jc>// Call this method if X-Client-Version is less than 1.1.</jc> + <jc>// Call this method if Client-Version is less than 1.1.</jc> <ja>@RestGet</ja>(clientVersion=<js>"[0,1.1)"</js>) <jk>public</jk> Object foo() {...} </p> diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java index f4e5ff0..1ad0afb 100644 --- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java +++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java @@ -33,7 +33,6 @@ import java.net.*; import java.net.URI; import java.nio.charset.*; import java.text.*; -import java.time.*; import java.util.*; import java.util.concurrent.*; import java.util.function.*; @@ -1290,37 +1289,6 @@ public class RestClient extends BeanContext implements HttpClient, Closeable, Re * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#header(Header) header(Header)} * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#headers(Object...) headers(Object...)} * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#headerPairs(Object...) headerPairs(Object...)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#accept(String) accept(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#acceptCharset(String) acceptCharset(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#acceptEncoding(String) acceptEncoding(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#acceptLanguage(String) acceptLanguage(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#authorization(String) authorization(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#cacheControl(String) cacheControl(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#clientVersion(String) clientVersion(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#connection(String) connection(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#contentLength(Long) contentLength(Long)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#contentType(String) contentType(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#date(ZonedDateTime) date(ZonedDateTime)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#expect(String) expect(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#forwarded(String) forwarded(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#from(String) from(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#host(String) host(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#ifMatch(String) ifMatch(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#ifModifiedSince(String) ifModifiedSince(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#ifNoneMatch(String) ifNoneMatch(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#ifRange(String) ifRange(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#ifUnmodifiedSince(String) ifUnmodifiedSince(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#maxForwards(Integer) maxForwards(Integer)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#origin(String) origin(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#pragma(String) pragma(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#proxyAuthorization(String) proxyAuthorization(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#range(String) proxyAuthorization(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#referer(String) referer(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#te(String) te(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#userAgent(String) userAgent(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#upgrade(String) upgrade(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#via(String) via(String)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestClientBuilder#warning(String) warning(String)} * </ul> * <li class='jc'>{@link org.apache.juneau.rest.client.RestRequest} * <ul> @@ -1330,37 +1298,6 @@ public class RestClient extends BeanContext implements HttpClient, Closeable, Re * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#headers(Object...) headers(Object...)} * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#headers(ListOperation,Object...) headers(EnumSet>ListOperation>,Object...)} * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#headerPairs(Object...) headerPairs(Object...)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#accept(Object) accept(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#acceptCharset(Object) acceptCharset(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#acceptEncoding(Object) acceptEncoding(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#acceptLanguage(Object) acceptLanguage(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#authorization(Object) authorization(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#cacheControl(Object) cacheControl(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#clientVersion(Object) clientVersion(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#connection(Object) connection(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#contentLength(Object) contentLength(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#contentType(Object) contentType(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#date(Object) date(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#expect(Object) expect(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#forwarded(Object) forwarded(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#from(Object) from(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#hostHeader(Object) hostHeader(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#ifMatch(Object) ifMatch(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#ifModifiedSince(Object) ifModifiedSince(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#ifNoneMatch(Object) ifNoneMatch(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#ifRange(Object) ifRange(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#ifUnmodifiedSince(Object) ifUnmodifiedSince(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#maxForwards(Object) maxForwards(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#origin(Object) origin(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#pragma(Object) pragma(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#proxyAuthorization(Object) proxyAuthorization(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#range(Object) proxyAuthorization(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#referer(Object) referer(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#te(Object) te(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#userAgent(Object) userAgent(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#upgrade(Object) upgrade(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#via(Object) via(Object)} - * <li class='jm'>{@link org.apache.juneau.rest.client.RestRequest#warning(Object) warning(Object)} * </ul> * </ul> * </ul> diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java index 0e50964..b42a17c 100644 --- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java +++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestRequest.java @@ -2503,6 +2503,17 @@ public class RestRequest extends BeanSession implements HttpUriRequest, Configur } /** + * Sets the client version by setting the value for the <js>"Client-Version"</js> header. + * + * @param value The version string (e.g. <js>"1.2.3"</js>) + * @return This object (for method chaining). + * @throws RestCallException Invalid input. + */ + public RestRequest clientVersion(String value) throws RestCallException { + return header(ClientVersion.of(value)); + } + + /** * Sets the value for the <c>Connection</c> request header. * * <p> @@ -2778,7 +2789,7 @@ public class RestRequest extends BeanSession implements HttpUriRequest, Configur * @throws RestCallException Invalid input. */ public RestRequest proxyAuthorization(String value) throws RestCallException { - return header("Proxy-Authorization", value); + return header(ProxyAuthorization.of(value)); } /** @@ -2791,8 +2802,8 @@ public class RestRequest extends BeanSession implements HttpUriRequest, Configur * @return This object (for method chaining). * @throws RestCallException Invalid input. */ - public RestRequest range(Object value) throws RestCallException { - return header("Range", value); + public RestRequest range(String value) throws RestCallException { + return header(Range.of(value)); } /** @@ -2805,8 +2816,8 @@ public class RestRequest extends BeanSession implements HttpUriRequest, Configur * @return This object (for method chaining). * @throws RestCallException Invalid input. */ - public RestRequest referer(Object value) throws RestCallException { - return header("Referer", value); + public RestRequest referer(String value) throws RestCallException { + return header(Referer.of(value)); } /** @@ -2819,8 +2830,8 @@ public class RestRequest extends BeanSession implements HttpUriRequest, Configur * @return This object (for method chaining). * @throws RestCallException Invalid input. */ - public RestRequest te(Object value) throws RestCallException { - return header("TE", value); + public RestRequest te(String value) throws RestCallException { + return header(TE.of(value)); } /** @@ -2833,8 +2844,8 @@ public class RestRequest extends BeanSession implements HttpUriRequest, Configur * @return This object (for method chaining). * @throws RestCallException Invalid input. */ - public RestRequest userAgent(Object value) throws RestCallException { - return header("User-Agent", value); + public RestRequest userAgent(String value) throws RestCallException { + return header(UserAgent.of(value)); } /** @@ -2847,8 +2858,8 @@ public class RestRequest extends BeanSession implements HttpUriRequest, Configur * @return This object (for method chaining). * @throws RestCallException Invalid input. */ - public RestRequest upgrade(Object value) throws RestCallException { - return header("Upgrade", value); + public RestRequest upgrade(String value) throws RestCallException { + return header(Upgrade.of(value)); } /** @@ -2861,8 +2872,8 @@ public class RestRequest extends BeanSession implements HttpUriRequest, Configur * @return This object (for method chaining). * @throws RestCallException Invalid input. */ - public RestRequest via(Object value) throws RestCallException { - return header("Via", value); + public RestRequest via(String value) throws RestCallException { + return header(Via.of(value)); } /** @@ -2875,21 +2886,10 @@ public class RestRequest extends BeanSession implements HttpUriRequest, Configur * @return This object (for method chaining). * @throws RestCallException Invalid input. */ - public RestRequest warning(Object value) throws RestCallException { - return header("Warning", value); + public RestRequest warning(String value) throws RestCallException { + return header(Warning.of(value)); } - - /** - * Sets the client version by setting the value for the <js>"X-Client-Version"</js> header. - * - * @param value The version string (e.g. <js>"1.2.3"</js>) - * @return This object (for method chaining). - * @throws RestCallException Invalid input. - */ - public RestRequest clientVersion(Object value) throws RestCallException { - return header("X-Client-Version", value); - } - + //------------------------------------------------------------------------------------------------------------------ // Execution methods. //------------------------------------------------------------------------------------------------------------------ diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/ClientVersionMatcher.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/ClientVersionMatcher.java index 12b79d6..f4b826d 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/ClientVersionMatcher.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/ClientVersionMatcher.java @@ -37,11 +37,11 @@ public class ClientVersionMatcher extends RestMatcher { * * @param clientVersionHeader * The HTTP request header name containing the client version. - * If <jk>null</jk> or an empty string, uses <js>"X-Client-Version"</js> + * If <jk>null</jk> or an empty string, uses <js>"Client-Version"</js> * @param mi The version string that the client version must match. */ protected ClientVersionMatcher(String clientVersionHeader, MethodInfo mi) { - this.clientVersionHeader = isEmpty(clientVersionHeader) ? "X-Client-Version" : clientVersionHeader; + this.clientVersionHeader = isEmpty(clientVersionHeader) ? "Client-Version" : clientVersionHeader; String clientVersion = mi.getAnnotationGroupList(RestOp.class).getValues(String.class, "clientVersion").stream().filter(x->!x.isEmpty()).findFirst().orElse(null); range = new VersionRange(clientVersion); } diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java index 30bb3a1..ed7ebef 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java @@ -606,7 +606,7 @@ public class RestContext extends BeanContext { * <li><b>Data type:</b> <c>String</c> * <li><b>System property:</b> <c>RestContext.clientVersionHeader</c> * <li><b>Environment variable:</b> <c>RESTCONTEXT_CLIENTVERSIONHEADER</c> - * <li><b>Default:</b> <js>"X-Client-Version"</js> + * <li><b>Default:</b> <js>"Client-Version"</js> * <li><b>Session property:</b> <jk>false</jk> * <li><b>Annotations:</b> * <ul> @@ -3547,7 +3547,7 @@ public class RestContext extends BeanContext { allowedMethodParams = newCaseInsensitiveSet(cp.getString(REST_allowedMethodParams).map(x -> "NONE".equals(x) ? "" : x).orElse("HEAD,OPTIONS")); allowedMethodHeaders = newCaseInsensitiveSet(cp.getString(REST_allowedMethodHeaders).map(x -> "NONE".equals(x) ? "" : x).orElse("")); renderResponseStackTraces = cp.getBoolean(REST_renderResponseStackTraces).orElse(false); - clientVersionHeader = cp.getString(REST_clientVersionHeader).orElse("X-Client-Version"); + clientVersionHeader = cp.getString(REST_clientVersionHeader).orElse("Client-Version"); debugEnablement = createDebugEnablement(r, cp, bf); diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java index feafa5e..4efd5b4 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java @@ -735,7 +735,7 @@ public class RestContextBuilder extends BeanContextBuilder implements ServletCon * * @param value * The new value for this setting. - * <br>The default is <js>"X-Client-Version"</js>. + * <br>The default is <js>"Client-Version"</js>. * @return This object (for method chaining). */ @FluentSetter diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContext.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContext.java index 07a372f..bac18db 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContext.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOperationContext.java @@ -110,7 +110,7 @@ public class RestOperationContext extends BeanContext implements Comparable<Rest * * <p> * The client version is identified via the HTTP request header identified by - * {@link Rest#clientVersionHeader() @Rest(clientVersionHeader)} which by default is <js>"X-Client-Version"</js>. + * {@link Rest#clientVersionHeader() @Rest(clientVersionHeader)} which by default is <js>"Client-Version"</js>. * * <p> * This is a specialized kind of {@link RestMatcher} that allows you to invoke different Java methods for the same @@ -122,16 +122,16 @@ public class RestOperationContext extends BeanContext implements Comparable<Rest * <p> * In the following example, the Java methods are mapped to the same HTTP method and URL <js>"/foobar"</js>. * <p class='bcode w800'> - * <jc>// Call this method if X-Client-Version is at least 2.0. + * <jc>// Call this method if Client-Version is at least 2.0. * // Note that this also matches 2.0.1.</jc> * <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"2.0"</js>) * <jk>public</jk> Object method1() {...} * - * <jc>// Call this method if X-Client-Version is at least 1.1, but less than 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 1.1, but less than 2.0.</jc> * <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[1.1,2.0)"</js>) * <jk>public</jk> Object method2() {...} * - * <jc>// Call this method if X-Client-Version is less than 1.1.</jc> + * <jc>// Call this method if Client-Version is less than 1.1.</jc> * <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[0,1.1)"</js>) * <jk>public</jk> Object method3() {...} * </p> @@ -140,11 +140,11 @@ public class RestOperationContext extends BeanContext implements Comparable<Rest * It's common to combine the client version with transforms that will convert new POJOs into older POJOs for * backwards compatibility. * <p class='bcode w800'> - * <jc>// Call this method if X-Client-Version is at least 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 2.0.</jc> * <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"2.0"</js>) * <jk>public</jk> NewPojo newMethod() {...} * - * <jc>// Call this method if X-Client-Version is at least 1.1, but less than 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 1.1, but less than 2.0.</jc> * <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[1.1,2.0)"</js>, transforms={NewToOldPojoSwap.<jk>class</jk>}) * <jk>public</jk> NewPojo oldMethod() { * <jk>return</jk> newMethod(); diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDelete.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDelete.java index 65bcafb..3fab182 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDelete.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDelete.java @@ -44,7 +44,7 @@ public @interface RestDelete { * * <p> * The client version is identified via the HTTP request header identified by - * {@link Rest#clientVersionHeader() @Rest(clientVersionHeader)} which by default is <js>"X-Client-Version"</js>. + * {@link Rest#clientVersionHeader() @Rest(clientVersionHeader)} which by default is <js>"Client-Version"</js>. * * <p> * This is a specialized kind of {@link RestMatcher} that allows you to invoke different Java methods for the same @@ -56,16 +56,16 @@ public @interface RestDelete { * <p> * In the following example, the Java methods are mapped to the same HTTP method and URL <js>"/foobar"</js>. * <p class='bcode w800'> - * <jc>// Call this method if X-Client-Version is at least 2.0. + * <jc>// Call this method if Client-Version is at least 2.0. * // Note that this also matches 2.0.1.</jc> * <ja>@RestDelete</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"2.0"</js>) * <jk>public</jk> Object method1() {...} * - * <jc>// Call this method if X-Client-Version is at least 1.1, but less than 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 1.1, but less than 2.0.</jc> * <ja>@RestDelete</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[1.1,2.0)"</js>) * <jk>public</jk> Object method2() {...} * - * <jc>// Call this method if X-Client-Version is less than 1.1.</jc> + * <jc>// Call this method if Client-Version is less than 1.1.</jc> * <ja>@RestDelete</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[0,1.1)"</js>) * <jk>public</jk> Object method3() {...} * </p> @@ -74,11 +74,11 @@ public @interface RestDelete { * It's common to combine the client version with transforms that will convert new POJOs into older POJOs for * backwards compatibility. * <p class='bcode w800'> - * <jc>// Call this method if X-Client-Version is at least 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 2.0.</jc> * <ja>@RestDelete</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"2.0"</js>) * <jk>public void</jk> newMethod() {...} * - * <jc>// Call this method if X-Client-Version is at least 1.1, but less than 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 1.1, but less than 2.0.</jc> * <ja>@RestDelete</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[1.1,2.0)"</js>}) * <jk>public void</jk> oldMethod() {...} * diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGet.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGet.java index fc0d3a6..c4118be 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGet.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGet.java @@ -44,7 +44,7 @@ public @interface RestGet { * * <p> * The client version is identified via the HTTP request header identified by - * {@link Rest#clientVersionHeader() @Rest(clientVersionHeader)} which by default is <js>"X-Client-Version"</js>. + * {@link Rest#clientVersionHeader() @Rest(clientVersionHeader)} which by default is <js>"Client-Version"</js>. * * <p> * This is a specialized kind of {@link RestMatcher} that allows you to invoke different Java methods for the same @@ -56,16 +56,16 @@ public @interface RestGet { * <p> * In the following example, the Java methods are mapped to the same HTTP method and URL <js>"/foobar"</js>. * <p class='bcode w800'> - * <jc>// Call this method if X-Client-Version is at least 2.0. + * <jc>// Call this method if Client-Version is at least 2.0. * // Note that this also matches 2.0.1.</jc> * <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"2.0"</js>) * <jk>public</jk> Object method1() {...} * - * <jc>// Call this method if X-Client-Version is at least 1.1, but less than 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 1.1, but less than 2.0.</jc> * <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[1.1,2.0)"</js>) * <jk>public</jk> Object method2() {...} * - * <jc>// Call this method if X-Client-Version is less than 1.1.</jc> + * <jc>// Call this method if Client-Version is less than 1.1.</jc> * <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[0,1.1)"</js>) * <jk>public</jk> Object method3() {...} * </p> @@ -74,11 +74,11 @@ public @interface RestGet { * It's common to combine the client version with transforms that will convert new POJOs into older POJOs for * backwards compatibility. * <p class='bcode w800'> - * <jc>// Call this method if X-Client-Version is at least 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 2.0.</jc> * <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"2.0"</js>) * <jk>public</jk> NewPojo newMethod() {...} * - * <jc>// Call this method if X-Client-Version is at least 1.1, but less than 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 1.1, but less than 2.0.</jc> * <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[1.1,2.0)"</js>, transforms={NewToOldPojoSwap.<jk>class</jk>}) * <jk>public</jk> NewPojo oldMethod() { * <jk>return</jk> newMethod(); diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOp.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOp.java index 911bd5a..6bd33b2 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOp.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOp.java @@ -42,7 +42,7 @@ public @interface RestOp { * * <p> * The client version is identified via the HTTP request header identified by - * {@link Rest#clientVersionHeader() @Rest(clientVersionHeader)} which by default is <js>"X-Client-Version"</js>. + * {@link Rest#clientVersionHeader() @Rest(clientVersionHeader)} which by default is <js>"Client-Version"</js>. * * <p> * This is a specialized kind of {@link RestMatcher} that allows you to invoke different Java methods for the same @@ -54,16 +54,16 @@ public @interface RestOp { * <p> * In the following example, the Java methods are mapped to the same HTTP method and URL <js>"/foobar"</js>. * <p class='bcode w800'> - * <jc>// Call this method if X-Client-Version is at least 2.0. + * <jc>// Call this method if Client-Version is at least 2.0. * // Note that this also matches 2.0.1.</jc> * <ja>@RestOp</ja>(method=<jsf>GET</jsf>, path=<js>"/foobar"</js>, clientVersion=<js>"2.0"</js>) * <jk>public</jk> Object method1() {...} * - * <jc>// Call this method if X-Client-Version is at least 1.1, but less than 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 1.1, but less than 2.0.</jc> * <ja>@RestOp</ja>(method=<jsf>GET</jsf>, path=<js>"/foobar"</js>, clientVersion=<js>"[1.1,2.0)"</js>) * <jk>public</jk> Object method2() {...} * - * <jc>// Call this method if X-Client-Version is less than 1.1.</jc> + * <jc>// Call this method if Client-Version is less than 1.1.</jc> * <ja>@RestOp</ja>(method=<jsf>GET</jsf>, path=<js>"/foobar"</js>, clientVersion=<js>"[0,1.1)"</js>) * <jk>public</jk> Object method3() {...} * </p> @@ -72,7 +72,7 @@ public @interface RestOp { * It's common to combine the client version with transforms that will convert new POJOs into older POJOs for * backwards compatibility. * <p class='bcode w800'> - * <jc>// Call this method if X-Client-Version is at least 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 2.0.</jc> * <ja>@RestOp</ja>(method=<jsf>GET</jsf>, path=<js>"/foobar"</js>, clientVersion=<js>"2.0"</js>) * <jk>public</jk> NewPojo newMethod() {...} * diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPost.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPost.java index 274061b..5892f2e 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPost.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPost.java @@ -44,7 +44,7 @@ public @interface RestPost { * * <p> * The client version is identified via the HTTP request header identified by - * {@link Rest#clientVersionHeader() @Rest(clientVersionHeader)} which by default is <js>"X-Client-Version"</js>. + * {@link Rest#clientVersionHeader() @Rest(clientVersionHeader)} which by default is <js>"Client-Version"</js>. * * <p> * This is a specialized kind of {@link RestMatcher} that allows you to invoke different Java methods for the same @@ -56,16 +56,16 @@ public @interface RestPost { * <p> * In the following example, the Java methods are mapped to the same HTTP method and URL <js>"/foobar"</js>. * <p class='bcode w800'> - * <jc>// Call this method if X-Client-Version is at least 2.0. + * <jc>// Call this method if Client-Version is at least 2.0. * // Note that this also matches 2.0.1.</jc> * <ja>@RestPost</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"2.0"</js>) * <jk>public</jk> Object method1() {...} * - * <jc>// Call this method if X-Client-Version is at least 1.1, but less than 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 1.1, but less than 2.0.</jc> * <ja>@RestPost</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[1.1,2.0)"</js>) * <jk>public</jk> Object method2() {...} * - * <jc>// Call this method if X-Client-Version is less than 1.1.</jc> + * <jc>// Call this method if Client-Version is less than 1.1.</jc> * <ja>@RestPost</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[0,1.1)"</js>) * <jk>public</jk> Object method3() {...} * </p> @@ -74,7 +74,7 @@ public @interface RestPost { * It's common to combine the client version with transforms that will convert new POJOs into older POJOs for * backwards compatibility. * <p class='bcode w800'> - * <jc>// Call this method if X-Client-Version is at least 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 2.0.</jc> * <ja>@RestPost</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"2.0"</js>) * <jk>public</jk> NewPojo newMethod() {...} * diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPut.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPut.java index 2c578f1..740ad11 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPut.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPut.java @@ -44,7 +44,7 @@ public @interface RestPut { * * <p> * The client version is identified via the HTTP request header identified by - * {@link Rest#clientVersionHeader() @Rest(clientVersionHeader)} which by default is <js>"X-Client-Version"</js>. + * {@link Rest#clientVersionHeader() @Rest(clientVersionHeader)} which by default is <js>"Client-Version"</js>. * * <p> * This is a specialized kind of {@link RestMatcher} that allows you to invoke different Java methods for the same @@ -56,16 +56,16 @@ public @interface RestPut { * <p> * In the following example, the Java methods are mapped to the same HTTP method and URL <js>"/foobar"</js>. * <p class='bcode w800'> - * <jc>// Call this method if X-Client-Version is at least 2.0. + * <jc>// Call this method if Client-Version is at least 2.0. * // Note that this also matches 2.0.1.</jc> * <ja>@RestPut</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"2.0"</js>) * <jk>public</jk> Object method1() {...} * - * <jc>// Call this method if X-Client-Version is at least 1.1, but less than 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 1.1, but less than 2.0.</jc> * <ja>@RestPut</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[1.1,2.0)"</js>) * <jk>public</jk> Object method2() {...} * - * <jc>// Call this method if X-Client-Version is less than 1.1.</jc> + * <jc>// Call this method if Client-Version is less than 1.1.</jc> * <ja>@RestPut</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[0,1.1)"</js>) * <jk>public</jk> Object method3() {...} * </p> @@ -74,7 +74,7 @@ public @interface RestPut { * It's common to combine the client version with transforms that will convert new POJOs into older POJOs for * backwards compatibility. * <p class='bcode w800'> - * <jc>// Call this method if X-Client-Version is at least 2.0.</jc> + * <jc>// Call this method if Client-Version is at least 2.0.</jc> * <ja>@RestPut</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"2.0"</js>) * <jk>public</jk> NewPojo newMethod() {...} * diff --git a/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/RestOp_ClientVersion_Test.java b/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/RestOp_ClientVersion_Test.java index 197adfd..ae65fbb 100644 --- a/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/RestOp_ClientVersion_Test.java +++ b/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/RestOp_ClientVersion_Test.java @@ -23,7 +23,7 @@ import org.junit.*; public class RestOp_ClientVersion_Test { //------------------------------------------------------------------------------------------------------------------ - // Basic tests - default X-Client-Version header. + // Basic tests - default Client-Version header. //------------------------------------------------------------------------------------------------------------------ @Rest diff --git a/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Headers_Test.java b/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Headers_Test.java index 700476c..1a5be7b 100644 --- a/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Headers_Test.java +++ b/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Headers_Test.java @@ -251,7 +251,7 @@ public class RestClient_Headers_Test { checkClient("Accept-Language").build().get("/headers").acceptLanguage("en").run().assertBody().is("['en']"); checkClient("Authorization").build().get("/headers").authorization("foo").run().assertBody().is("['foo']"); checkClient("Cache-Control").build().get("/headers").cacheControl("none").run().assertBody().is("['none']"); - checkClient("X-Client-Version").build().get("/headers").clientVersion("1").run().assertBody().is("['1']"); + checkClient("Client-Version").build().get("/headers").clientVersion("1").run().assertBody().is("['1']"); checkClient("Connection").build().get("/headers").connection("foo").run().assertBody().is("['foo']"); checkClient("Content-Length").build().get("/headers").contentLength(123l).run().assertBody().is("['123']"); checkClient("Content-Type").build().get("/headers").contentType("foo").run().assertBody().is("['foo']"); @@ -274,7 +274,7 @@ public class RestClient_Headers_Test { checkClient("Range").build().get("/headers").range("foo").run().assertBody().is("['foo']"); checkClient("Referer").build().get("/headers").referer("foo").run().assertBody().is("['foo']"); checkClient("TE").build().get("/headers").te("foo").run().assertBody().is("['foo']"); - checkClient("User-Agent").build().get("/headers").userAgent(new StringBuilder("foo")).run().assertBody().is("['foo']"); + checkClient("User-Agent").build().get("/headers").userAgent("foo").run().assertBody().is("['foo']"); checkClient("Upgrade").build().get("/headers").upgrade("foo").run().assertBody().is("['foo']"); checkClient("Via").build().get("/headers").via("foo").run().assertBody().is("['foo']"); checkClient("Warning").build().get("/headers").warning("foo").run().assertBody().is("['foo']");