users@jersey.java.net

[Jersey] Re: Digest for list users_at_jersey.java.net

From: Simon Roberts <dancingcloudphotography_at_gmail.com>
Date: Wed, 7 Dec 2016 14:49:02 -0700

If you want a sub resource, you must not use the HTTP method annotation on
the method.

On Dec 7, 2016 03:05, <users-request_at_jersey.java.net> wrote:

> Table of contents:
>
> 1. [Jersey] PUT not delegating to sub-resource - "Trenton D. Adams" <
> trenton.d.adams_at_gmail.com>
>
>
>
> ---------- Forwarded message ----------
> From: "Trenton D. Adams" <trenton.d.adams_at_gmail.com>
> To: users_at_jersey.java.net
> Cc:
> Date: Tue, 6 Dec 2016 03:15:31 -0700
> Subject: [Jersey] PUT not delegating to sub-resource
> I'm playing around with Jersey. I'm finding that PUT doesn't seem to
> delegate to a sub-resource, while POST does...
>
> Note how it simply outputs the class name...
>
>
> @PUT
> @Path("{keyId}")
> public Class<? extends PostApiKeys> putApiKey(
> @PathParam("keyId") final String keyId, @Valid ApiKey apiKey)
> {
> return PostApiKeys.class;
> }
>
> $ curl -X PUT -H 'Accept: application/json' -H "Content-Type:
> application/json" -d '{"keyId": "2123", "verificationCode":
> "cjklsdjlkjsdf"}' 'http://localhost:8080/eve-manufacturing-manager/api-
> keys/2123'
>
> "com.github.trentonadams.eve.features.apikeys.services.PostApiKeys"
>
>
> But with a POST, it works just fine...
>
> /**
> * Stores api keys using a service which simple returns 200, with a JSON
> * response.
> *
> * @return the service for posting api keys.
> */
> @Path("post")
> public Class<? extends PostApiKeys> postService()
> {
> return PostApiKeys.class;
> }
>
> [03:12:12 trenta_at_developer-VirtualBox ~/LocalDocuments/development/
> java/eve-manufacturing-manager]
> $ curl -X POST -H 'Accept: application/json' -H "Content-Type:
> application/json" -d '{"keyId": "2123", "verificationCode":
> "cjklsdjlkjsdf"}' 'http://localhost:8080/eve-manufacturing-manager/api-
> keys/post'
>
> {"keyId":"2123","verificationCode":"cjklsdjlkjsdf"}
>
>
> public interface IPostApiKeys
> {
> @POST
> @Consumes({
> MediaType.APPLICATION_JSON, MediaType.MULTIPART_FORM_DATA,
> MediaType.APPLICATION_XML})
> @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
> Response postForm(@Valid ApiKey apiKey) throws URISyntaxException;
>
> @PUT
> @Consumes({
> MediaType.APPLICATION_JSON,
> MediaType.APPLICATION_XML})
> @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
> @Path("{keyId}")
> Response putForm(@PathParam("keyId") String keyId, @Valid ApiKey apiKey)
> throws URISyntaxException;
> }
>
>
> End of digest for list users_at_jersey.java.net - Wed, 07 Dec 2016
>
>