public class AdaptingContainerRequest extends ContainerRequest
ContainerRequest
.Modifier and Type | Field and Description |
---|---|
protected ContainerRequest |
acr
The adapted container request.
|
VARY_HEADER
ACCEPT, ACCEPT_CHARSET, ACCEPT_ENCODING, ACCEPT_LANGUAGE, AUTHORIZATION, CACHE_CONTROL, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_TYPE, COOKIE, DATE, ETAG, EXPIRES, HOST, IF_MATCH, IF_MODIFIED_SINCE, IF_NONE_MATCH, IF_UNMODIFIED_SINCE, LAST_MODIFIED, LOCATION, SET_COOKIE, USER_AGENT, VARY, WWW_AUTHENTICATE
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
Modifier | Constructor and Description |
---|---|
protected |
AdaptingContainerRequest(ContainerRequest acr)
Create the adapting container request.
|
Modifier and Type | Method and Description |
---|---|
Response.ResponseBuilder |
evaluatePreconditions()
Evaluate request preconditions for a resource that does not currently
exist.
|
Response.ResponseBuilder |
evaluatePreconditions(java.util.Date lastModified)
Evaluate request preconditions based on the passed in value.
|
Response.ResponseBuilder |
evaluatePreconditions(java.util.Date lastModified,
EntityTag eTag)
Evaluate request preconditions based on the passed in value.
|
Response.ResponseBuilder |
evaluatePreconditions(EntityTag eTag)
Evaluate request preconditions based on the passed in value.
|
java.net.URI |
getAbsolutePath()
Get the absolute path of the request.
|
UriBuilder |
getAbsolutePathBuilder()
Get the absolute path of the request in the form of a UriBuilder.
|
java.util.List<java.util.Locale> |
getAcceptableLanguages()
Get a list of languages that are acceptable for the response.
|
MediaType |
getAcceptableMediaType(java.util.List<MediaType> mediaTypes)
Select the first media type, from a list of media types, that is most
acceptable according to the requested acceptable media types.
|
java.util.List<MediaType> |
getAcceptableMediaTypes()
Get a list of media types that are acceptable for the response.
|
java.util.List<MediaType> |
getAcceptableMediaTypes(java.util.List<QualitySourceMediaType> priorityMediaTypes)
Get a list of media types that are acceptable for the response.
|
java.lang.String |
getAuthenticationScheme()
Returns the string value of the authentication scheme used to protect
the resource.
|
java.net.URI |
getBaseUri()
Get the base URI of the application.
|
UriBuilder |
getBaseUriBuilder()
Get the base URI of the application in the form of a UriBuilder.
|
MultivaluedMap<java.lang.String,java.lang.String> |
getCookieNameValueMap()
Get the cookie name value map.
|
java.util.Map<java.lang.String,Cookie> |
getCookies()
Get any cookies that accompanied the request.
|
<T> T |
getEntity(java.lang.Class<T> type)
Get the request entity, returns null if the request does not
contain an entity body.
|
<T> T |
getEntity(java.lang.Class<T> type,
java.lang.reflect.Type genericType,
java.lang.annotation.Annotation[] as)
Get the request entity, returns null if the request does not
contain an entity body.
|
java.io.InputStream |
getEntityInputStream()
Get the input stream of the entity.
|
Form |
getFormParameters()
Get the form parameters of the request entity.
|
java.lang.String |
getHeaderValue(java.lang.String name)
Get a HTTP header value.
|
java.util.Locale |
getLanguage()
Get the language of the request entity
|
MediaType |
getMediaType()
Get the media type of the request entity
|
MessageBodyWorkers |
getMessageBodyWorkers()
Get the message body workers.
|
java.lang.String |
getMethod()
Get the request method, e.g.
|
java.lang.String |
getPath()
Get the path of the current request relative to the base URI as
a string.
|
java.lang.String |
getPath(boolean decode)
Get the path of the current request relative to the base URI as
a string.
|
java.util.List<PathSegment> |
getPathSegments()
Get the path of the current request relative to the base URI as a
list of
PathSegment . |
java.util.List<PathSegment> |
getPathSegments(boolean decode)
Get the path of the current request relative to the base URI as a
list of
PathSegment . |
java.util.Map<java.lang.String,java.lang.Object> |
getProperties()
Get the mutable properties.
|
MultivaluedMap<java.lang.String,java.lang.String> |
getQueryParameters()
Get the URI query parameters of the current request.
|
MultivaluedMap<java.lang.String,java.lang.String> |
getQueryParameters(boolean decode)
Get the URI query parameters of the current request.
|
java.util.List<java.lang.String> |
getRequestHeader(java.lang.String name)
Get the values of a HTTP request header.
|
MultivaluedMap<java.lang.String,java.lang.String> |
getRequestHeaders()
Get the values of HTTP request headers.
|
java.net.URI |
getRequestUri()
Get the absolute request URI.
|
UriBuilder |
getRequestUriBuilder()
Get the absolute request URI in the form of a UriBuilder.
|
SecurityContext |
getSecurityContext()
Get the security context.
|
java.security.Principal |
getUserPrincipal()
Returns a
java.security.Principal object containing the
name of the current authenticated user. |
boolean |
isSecure()
Returns a boolean indicating whether this request was made
using a secure channel, such as HTTPS.
|
boolean |
isTracingEnabled()
Check if tracing is enabled.
|
boolean |
isUserInRole(java.lang.String role)
Returns a boolean indicating whether the authenticated user is included
in the specified logical "role".
|
Variant |
selectVariant(java.util.List<Variant> variants)
Select the representation variant that best matches the request.
|
void |
setEntityInputStream(java.io.InputStream entity)
Set the input stream of the entity.
|
void |
setHeaders(InBoundHeaders headers)
Set the request headers.
|
void |
setMethod(java.lang.String method)
Set the HTTP method.
|
void |
setSecurityContext(SecurityContext securityContext)
Set the security context.
|
void |
setUris(java.net.URI baseUri,
java.net.URI requestUri)
Set the base and request URI.
|
void |
trace(java.lang.String message)
Add a trace message.
|
setEntity
protected final ContainerRequest acr
protected AdaptingContainerRequest(ContainerRequest acr)
acr
- the container request to adapt.public java.util.Map<java.lang.String,java.lang.Object> getProperties()
ContainerRequest
getProperties
in class ContainerRequest
public void setMethod(java.lang.String method)
ContainerRequest
setMethod
in class ContainerRequest
method
- the method.public void setUris(java.net.URI baseUri, java.net.URI requestUri)
ContainerRequest
setUris
in class ContainerRequest
baseUri
- the base URI.requestUri
- the (complete) request URI.public java.io.InputStream getEntityInputStream()
ContainerRequest
getEntityInputStream
in class ContainerRequest
public void setEntityInputStream(java.io.InputStream entity)
ContainerRequest
setEntityInputStream
in class ContainerRequest
entity
- the input stream of the entity.public void setHeaders(InBoundHeaders headers)
ContainerRequest
setHeaders
in class ContainerRequest
headers
- the request headers.public void setSecurityContext(SecurityContext securityContext)
ContainerRequest
setSecurityContext
in class ContainerRequest
securityContext
- the security context.public SecurityContext getSecurityContext()
ContainerRequest
getSecurityContext
in class ContainerRequest
public MessageBodyWorkers getMessageBodyWorkers()
ContainerRequest
getMessageBodyWorkers
in class ContainerRequest
public boolean isTracingEnabled()
Traceable
isTracingEnabled
in interface Traceable
isTracingEnabled
in class ContainerRequest
public void trace(java.lang.String message)
Traceable
A trace message will be added if Traceable.isTracingEnabled()
returns
true and tracing contraints are satisfied.
trace
in interface Traceable
trace
in class ContainerRequest
message
- the trace message to add.public java.net.URI getBaseUri()
HttpRequestContext
getBaseUri
in interface HttpRequestContext
getBaseUri
in class ContainerRequest
public UriBuilder getBaseUriBuilder()
HttpRequestContext
getBaseUriBuilder
in interface HttpRequestContext
getBaseUriBuilder
in class ContainerRequest
public java.net.URI getRequestUri()
HttpRequestContext
getRequestUri
in interface HttpRequestContext
getRequestUri
in class ContainerRequest
public UriBuilder getRequestUriBuilder()
HttpRequestContext
getRequestUriBuilder
in interface HttpRequestContext
getRequestUriBuilder
in class ContainerRequest
public java.net.URI getAbsolutePath()
HttpRequestContext
uriInfo.getBase().resolve(uriInfo.getPath()).
getAbsolutePath
in interface HttpRequestContext
getAbsolutePath
in class ContainerRequest
public UriBuilder getAbsolutePathBuilder()
HttpRequestContext
getAbsolutePathBuilder
in interface HttpRequestContext
getAbsolutePathBuilder
in class ContainerRequest
public java.lang.String getPath()
HttpRequestContext
getPath(true)
.getPath
in interface HttpRequestContext
getPath
in class ContainerRequest
public java.lang.String getPath(boolean decode)
HttpRequestContext
getPath
in interface HttpRequestContext
getPath
in class ContainerRequest
decode
- controls whether sequences of escaped octets are decoded
(true) or not (false).public java.util.List<PathSegment> getPathSegments()
HttpRequestContext
PathSegment
. This method is useful when the
path needs to be parsed, particularly when matrix parameters may be
present in the path. All sequences of escaped octets in path segments
and matrix parameter names and values are decoded,
equivalent to getPathSegments(true)
.getPathSegments
in interface HttpRequestContext
getPathSegments
in class ContainerRequest
PathSegment
. The matrix parameter
map of each path segment is also unmodifiable.PathSegment
,
Matrix URIspublic java.util.List<PathSegment> getPathSegments(boolean decode)
HttpRequestContext
PathSegment
. This method is useful when the
path needs to be parsed, particularly when matrix parameters may be
present in the path.getPathSegments
in interface HttpRequestContext
getPathSegments
in class ContainerRequest
decode
- controls whether sequences of escaped octets in path segments
and matrix parameter names and values are decoded (true) or not (false).PathSegment
. The matrix parameter
map of each path segment is also unmodifiable.PathSegment
,
Matrix URIspublic MultivaluedMap<java.lang.String,java.lang.String> getQueryParameters()
HttpRequestContext
getQueryParameters(true)
.getQueryParameters
in interface HttpRequestContext
getQueryParameters
in class ContainerRequest
public MultivaluedMap<java.lang.String,java.lang.String> getQueryParameters(boolean decode)
HttpRequestContext
getQueryParameters
in interface HttpRequestContext
getQueryParameters
in class ContainerRequest
decode
- controls whether sequences of escaped octets in parameter
names and values are decoded (true) or not (false).public java.lang.String getHeaderValue(java.lang.String name)
HttpRequestContext
getHeaderValue
in interface HttpRequestContext
getHeaderValue
in class ContainerRequest
name
- the HTTP headerpublic MediaType getAcceptableMediaType(java.util.List<MediaType> mediaTypes)
HttpRequestContext
getAcceptableMediaType
in interface HttpRequestContext
getAcceptableMediaType
in class ContainerRequest
mediaTypes
- the list of media typespublic java.util.List<MediaType> getAcceptableMediaTypes(java.util.List<QualitySourceMediaType> priorityMediaTypes)
HttpRequestContext
getAcceptableMediaTypes
in interface HttpRequestContext
getAcceptableMediaTypes
in class ContainerRequest
priorityMediaTypes
- the list of media types that take priority,
ordered according to the quality source parameter, "qs" as the
primary key.public MultivaluedMap<java.lang.String,java.lang.String> getCookieNameValueMap()
HttpRequestContext
getCookieNameValueMap
in interface HttpRequestContext
getCookieNameValueMap
in class ContainerRequest
public <T> T getEntity(java.lang.Class<T> type) throws WebApplicationException
HttpRequestContext
getEntity
in interface HttpRequestContext
getEntity
in class ContainerRequest
type
- the type of entityWebApplicationException
- if the content of the request
cannot be mapped to an entity of the requested typepublic <T> T getEntity(java.lang.Class<T> type, java.lang.reflect.Type genericType, java.lang.annotation.Annotation[] as) throws WebApplicationException
HttpRequestContext
getEntity
in interface HttpRequestContext
getEntity
in class ContainerRequest
type
- the type of entitygenericType
- type the generic type of entity, it is the responsibility
of the callee to ensure that the type and generic type are
consistent otherwise the behaviour of this method is undefined.as
- the annotations associated with the typeWebApplicationException
- if the content of the request
cannot be mapped to an entity of the requested typepublic Form getFormParameters()
HttpRequestContext
This method will ensure that the request entity is buffered such that it may be consumed by the application.
getFormParameters
in interface HttpRequestContext
getFormParameters
in class ContainerRequest
public java.util.List<java.lang.String> getRequestHeader(java.lang.String name)
HttpHeaders
getRequestHeaders().get(name)
.getRequestHeader
in interface HttpHeaders
getRequestHeader
in class ContainerRequest
name
- the header name, case insensitivepublic MultivaluedMap<java.lang.String,java.lang.String> getRequestHeaders()
HttpHeaders
getRequestHeaders
in interface HttpHeaders
getRequestHeaders
in class ContainerRequest
public java.util.List<MediaType> getAcceptableMediaTypes()
HttpHeaders
getAcceptableMediaTypes
in interface HttpHeaders
getAcceptableMediaTypes
in class ContainerRequest
public java.util.List<java.util.Locale> getAcceptableLanguages()
HttpHeaders
getAcceptableLanguages
in interface HttpHeaders
getAcceptableLanguages
in class ContainerRequest
public MediaType getMediaType()
HttpHeaders
getMediaType
in interface HttpHeaders
getMediaType
in class ContainerRequest
public java.util.Locale getLanguage()
HttpHeaders
getLanguage
in interface HttpHeaders
getLanguage
in class ContainerRequest
public java.util.Map<java.lang.String,Cookie> getCookies()
HttpHeaders
getCookies
in interface HttpHeaders
getCookies
in class ContainerRequest
public java.lang.String getMethod()
Request
getMethod
in interface Request
getMethod
in class ContainerRequest
HttpMethod
public Variant selectVariant(java.util.List<Variant> variants) throws java.lang.IllegalArgumentException
Request
selectVariant
in interface Request
selectVariant
in class ContainerRequest
variants
- a list of Variant that describe all of the
available representation variants.java.lang.IllegalArgumentException
- if variants is empty or nullVariant.VariantListBuilder
public Response.ResponseBuilder evaluatePreconditions(EntityTag eTag)
Request
evaluatePreconditions
in interface Request
evaluatePreconditions
in class ContainerRequest
eTag
- an ETag for the current state of the resourcepublic Response.ResponseBuilder evaluatePreconditions(java.util.Date lastModified)
Request
evaluatePreconditions
in interface Request
evaluatePreconditions
in class ContainerRequest
lastModified
- a date that specifies the modification date of the resourcepublic Response.ResponseBuilder evaluatePreconditions(java.util.Date lastModified, EntityTag eTag)
Request
evaluatePreconditions
in interface Request
evaluatePreconditions
in class ContainerRequest
lastModified
- a date that specifies the modification date of the resourceeTag
- an ETag for the current state of the resourcepublic Response.ResponseBuilder evaluatePreconditions()
Request
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.
evaluatePreconditions
in interface Request
evaluatePreconditions
in class ContainerRequest
public java.security.Principal getUserPrincipal()
SecurityContext
java.security.Principal
object containing the
name of the current authenticated user. If the user
has not been authenticated, the method returns null.getUserPrincipal
in interface SecurityContext
getUserPrincipal
in class ContainerRequest
java.security.Principal
containing the name
of the user making this request; null if the user has not been
authenticatedpublic boolean isUserInRole(java.lang.String role)
SecurityContext
false
.isUserInRole
in interface SecurityContext
isUserInRole
in class ContainerRequest
role
- a String
specifying the name of the roleboolean
indicating whether the user making
the request belongs to a given role; false
if the user
has not been authenticatedpublic boolean isSecure()
SecurityContext
isSecure
in interface SecurityContext
isSecure
in class ContainerRequest
true
if the request was made using a secure
channel, false
otherwisepublic java.lang.String getAuthenticationScheme()
SecurityContext
getAuthenticationScheme
in interface SecurityContext
getAuthenticationScheme
in class ContainerRequest
Copyright © 2016 Oracle Corporation. All Rights Reserved.