users@jersey.java.net

[Jersey] Detecting selected variant/media type.

From: Jeff Adamson <jwa_at_urbancode.com>
Date: Fri, 26 Aug 2011 10:49:35 -0400

Hi,
  I have a quick question.

Given a resource like

    private final String MEDIA_ZIP = "application/zip";
> private final String MEDIA_TAR = "application/x-tar";
> private final String MEDIA_TGZ = "application/x-gzip";
>


    @GET
> @Path("path")
> @Produces({MEDIA_ZIP, MEDIA_TAR, MEDIA_TGZ})
> public Response downloadArchive(@PathParam("path"))
> throws Exception {


How do i detect which of the produces variant is the request/most-preferred
by the client? I have to write back a native stream (Apache Commons
Compress ArchiveOutputStream) so my code needs to know which type it should
be producing.

Thanks
--Jeff