Top Description Methods
javax.ws.rs.core

public Interface Request

Imports
java.util.Date, .List, javax.ws.rs.core.Response.ResponseBuilder

An injectable helper for request processing, all methods throw an IllegalStateException if called outside the scope of a request (e.g. from a provider constructor). Precondition processing (see the evaluatePreconditions methods) can result in either a null return value to indicate that preconditions have been met and that the request should continue, or a non-null return value to indicate that preconditions were not met. In the event that preconditions were not met, the returned ResponseBuilder instance will have an appropriate status and will also include a Vary header if the selectVariant(List) method was called prior to to calling evaluatePreconditions. It is the responsibility of the caller to check the status and add additional metadata if required. E.g., see HTTP/1.1, section 10.3.5 for details of the headers that are expected to accompany a 304 Not Modified response.
Authors
Paul Sandoz, Marc Hadley, Marek Potociar
Since
1.0

Method Summary

Modifier and TypeMethod and Description
public Response.ResponseBuilder

Returns:

null if the preconditions are met or a ResponseBuilder set with the appropriate status if the preconditions are not met. A returned ResponseBuilder will include an ETag header set with the value of eTag, provided none of the precondition evaluation has failed, in which case the ETag header would not be included and the status code of the returned ResponseBuilder would be set to Response.Status#PRECONDITION_FAILED.
evaluatePreconditions
(EntityTag
an ETag for the current state of the resource
eTag
)

Evaluate request preconditions based on the passed in value.

public Response.ResponseBuilder

Returns:

null if the preconditions are met or a ResponseBuilder set with the appropriate status if the preconditions are not met.
evaluatePreconditions
(Date
a date that specifies the modification date of the resource
lastModified
)

Evaluate request preconditions based on the passed in value.

public Response.ResponseBuilder

Returns:

null if the preconditions are met or a ResponseBuilder set with the appropriate status if the preconditions are not met. A returned ResponseBuilder will include an ETag header set with the value of eTag, provided none of the precondition evaluation has failed, in which case the ETag header would not be included and the status code of the returned ResponseBuilder would be set to Response.Status#PRECONDITION_FAILED.
evaluatePreconditions
(Date
a date that specifies the modification date of the resource
lastModified
,
EntityTag
an ETag for the current state of the resource
eTag
)

Evaluate request preconditions based on the passed in value.

public Response.ResponseBuilder

Returns:

null if the preconditions are met or a ResponseBuilder set with the appropriate status if the preconditions are not met.
evaluatePreconditions
()

Evaluate request preconditions for a resource that does not currently exist.

public String

Returns:

the request method.
getMethod
()

Get the request method, e.g. GET, POST, etc.

public Variant

Returns:

the variant that best matches the request or null if there's no match.
selectVariant
(List<Variant>
a list of Variant that describe all of the available representation variants.
variants
)

Select the representation variant that best matches the request.

Method Detail

evaluatePreconditionsback to summary
public Response.ResponseBuilder evaluatePreconditions(EntityTag eTag)

Evaluate request preconditions based on the passed in value.

Parameters
eTag:EntityTag

an ETag for the current state of the resource

Returns:Response.ResponseBuilder

null if the preconditions are met or a ResponseBuilder set with the appropriate status if the preconditions are not met. A returned ResponseBuilder will include an ETag header set with the value of eTag, provided none of the precondition evaluation has failed, in which case the ETag header would not be included and the status code of the returned ResponseBuilder would be set to Response.Status#PRECONDITION_FAILED.

Exceptions
IllegalArgumentException:
if eTag is null.
IllegalStateException:
if called outside the scope of a request.
evaluatePreconditionsback to summary
public Response.ResponseBuilder evaluatePreconditions(Date lastModified)

Evaluate request preconditions based on the passed in value.

Parameters
lastModified:Date

a date that specifies the modification date of the resource

Returns:Response.ResponseBuilder

null if the preconditions are met or a ResponseBuilder set with the appropriate status if the preconditions are not met.

Exceptions
IllegalArgumentException:
if lastModified is null.
IllegalStateException:
if called outside the scope of a request.
evaluatePreconditionsback to summary
public Response.ResponseBuilder evaluatePreconditions(Date lastModified, EntityTag eTag)

Evaluate request preconditions based on the passed in value.

Parameters
lastModified:Date

a date that specifies the modification date of the resource

eTag:EntityTag

an ETag for the current state of the resource

Returns:Response.ResponseBuilder

null if the preconditions are met or a ResponseBuilder set with the appropriate status if the preconditions are not met. A returned ResponseBuilder will include an ETag header set with the value of eTag, provided none of the precondition evaluation has failed, in which case the ETag header would not be included and the status code of the returned ResponseBuilder would be set to Response.Status#PRECONDITION_FAILED.

Exceptions
IllegalArgumentException:
if lastModified or eTag is null.
IllegalStateException:
if called outside the scope of a request.
evaluatePreconditionsback to summary
public Response.ResponseBuilder evaluatePreconditions()

Evaluate request preconditions for a resource that does not currently exist. The primary use of this method is to support the href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24"> If-Match: *</a> and href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26"> If-None-Match: *</a> preconditions.

Note that both preconditions If-None-Match: * and If-None-Match: something will always be considered to have been met and it is the applications responsibility to enforce any additional method-specific semantics. E.g. a PUT on a resource that does not exist might succeed whereas a GET on a resource that does not exist would likely result in a 404 response. It would be the responsibility of the application to generate the 404 response.

Returns:Response.ResponseBuilder

null if the preconditions are met or a ResponseBuilder set with the appropriate status if the preconditions are not met.

Exceptions
IllegalStateException:
if called outside the scope of a request.
Since
1.1
getMethodback to summary
public String getMethod()

Get the request method, e.g. GET, POST, etc.

Returns:String

the request method.

See Also
javax.ws.rs.HttpMethod
selectVariantback to summary
public Variant selectVariant(List<Variant> variants)

Select the representation variant that best matches the request. Returns null in case there is no matching variant in the list.

More explicit variants are chosen ahead of less explicit ones. A vary header is computed from the supplied list and automatically added to the response.

Parameters
variants:List<Variant>

a list of Variant that describe all of the available representation variants.

Returns:Variant

the variant that best matches the request or null if there's no match.

Exceptions
IllegalArgumentException:
if variants is empty or null.
IllegalStateException:
if called outside the scope of a request.
See Also
Variant.VariantListBuilder