users@jsr311.java.net

Re: ResponseBuilder.type()

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 20 Jun 2008 10:37:42 +0200

Hi Sergey,

I think the issue here is that the media type set by the resource class
is not an acceptable media type.

If the Accept header was:

   Accept : application/bar, application/foo

then the media type returned for the Content-Type header would be
"application/foo" and that media type would be passed to the
MessageBodyWriter.writeTo().

I think the the case you present there are a number of choices:

   1) Return an not acceptable response, plus see the thread titled

      "status 406 if return object not serializable for POST, PUT,
       DELETE"

   2) Ignore the client accept header.

   3) It is an error.


There is also another case:

   @ProduceMime({"application/bar", "application/foo"})
   void Response get() {
     return response.ok().
         type(""application/baz").entity(someEntity).build();
   }

IMHO i think this should be an error because it contradicts the
declaration in @ProduceMime.

Paul.

Sergey Beryozkin wrote:
> Hi
>
> What effect, if any, the media type set in ResponseBuilder.type has on
> the MediaType parameter passed to MessageBodyWriter.writeTo() ?
>
> Ex.
>
> GET /bar
> Accept : "application/bar"
>
> @ProduceMime({"application/bar", "application/foo"})
> void Response get() {
> return
> response.ok().type(""application/foo").entity(someEntity).build();
> }
>
> and
>
> @ProduceMime("application/bar", "application/foo")
> SomeProvider implements MessageBodyWriter...
>
>
> Thanks, Sergey
>
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109