Package ubic.gemma.rest.util
Class MediaTypeUtils
java.lang.Object
ubic.gemma.rest.util.MediaTypeUtils
Utilities for
MediaType
.- Author:
- poirigui
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic javax.ws.rs.core.MediaType
negotiate
(javax.ws.rs.core.HttpHeaders headers, javax.ws.rs.core.MediaType... types) Perform content negotiation of a given set of HTTP headers against a list of possible media types.static javax.ws.rs.core.MediaType
withoutQuality
(javax.ws.rs.core.MediaType mediaType) Create a media type without a quality indicator.static javax.ws.rs.core.MediaType
withQuality
(javax.ws.rs.core.MediaType mediaType, double quality) Create a media type with a quality indicator.
-
Constructor Details
-
MediaTypeUtils
public MediaTypeUtils()
-
-
Method Details
-
withQuality
public static javax.ws.rs.core.MediaType withQuality(javax.ws.rs.core.MediaType mediaType, double quality) Create a media type with a quality indicator. -
withoutQuality
public static javax.ws.rs.core.MediaType withoutQuality(javax.ws.rs.core.MediaType mediaType) Create a media type without a quality indicator. -
negotiate
public static javax.ws.rs.core.MediaType negotiate(javax.ws.rs.core.HttpHeaders headers, javax.ws.rs.core.MediaType... types) throws javax.ws.rs.NotAcceptableException Perform content negotiation of a given set of HTTP headers against a list of possible media types.Media type may include a quality score by setting the
q
parameter. If omitted, this score defaults to1.0
. The pair of compatible accepted and produced types with the highest product is returned.- Parameters:
headers
- HTTP headers from the client,HttpHeaders.getAcceptableMediaTypes()
is used to determine acceptable media typestypes
- an array of produced media types- Returns:
- one of the produced media type, stripped if its quality score with
withoutQuality(MediaType)
- Throws:
javax.ws.rs.NotAcceptableException
- if the negotiation fails (i.e. no media types can be satisfied)
-