public class ContainerRequest extends Object implements HttpRequestContext
WebApplication
.
By default the implementation of SecurityContext
will throw
UnsupportedOperationException
if the methods are invoked.
Containers SHOULD use the method setSecurityContext(javax.ws.rs.core.SecurityContext)
to define security context behaviour rather than extending from this class
and overriding the methods.Modifier and Type | Field and Description |
---|---|
static String |
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
Constructor and Description |
---|
ContainerRequest(WebApplication wa,
String method,
URI baseUri,
URI requestUri,
InBoundHeaders headers,
InputStream entity)
Create a new container request.
|
Modifier and Type | Method and Description |
---|---|
javax.ws.rs.core.Response.ResponseBuilder |
evaluatePreconditions() |
javax.ws.rs.core.Response.ResponseBuilder |
evaluatePreconditions(Date lastModified) |
javax.ws.rs.core.Response.ResponseBuilder |
evaluatePreconditions(Date lastModified,
javax.ws.rs.core.EntityTag eTag) |
javax.ws.rs.core.Response.ResponseBuilder |
evaluatePreconditions(javax.ws.rs.core.EntityTag eTag) |
URI |
getAbsolutePath()
Get the absolute path of the request.
|
javax.ws.rs.core.UriBuilder |
getAbsolutePathBuilder()
Get the absolute path of the request in the form of a UriBuilder.
|
List<Locale> |
getAcceptableLanguages() |
javax.ws.rs.core.MediaType |
getAcceptableMediaType(List<javax.ws.rs.core.MediaType> mediaTypes)
Select the first media type, from a list of media types, that is most
acceptable according to the requested acceptable media types.
|
List<javax.ws.rs.core.MediaType> |
getAcceptableMediaTypes() |
List<javax.ws.rs.core.MediaType> |
getAcceptableMediaTypes(List<QualitySourceMediaType> priorityMediaTypes)
Get a list of media types that are acceptable for the response.
|
String |
getAuthenticationScheme() |
URI |
getBaseUri()
Get the base URI of the application.
|
javax.ws.rs.core.UriBuilder |
getBaseUriBuilder()
Get the base URI of the application in the form of a UriBuilder.
|
javax.ws.rs.core.MultivaluedMap<String,String> |
getCookieNameValueMap()
Get the cookie name value map.
|
Map<String,javax.ws.rs.core.Cookie> |
getCookies() |
<T> T |
getEntity(Class<T> type)
Get the request entity, returns null if the request does not
contain an entity body.
|
<T> T |
getEntity(Class<T> type,
Type genericType,
Annotation[] as)
Get the request entity, returns null if the request does not
contain an entity body.
|
InputStream |
getEntityInputStream()
Get the input stream of the entity.
|
Form |
getFormParameters()
Get the form parameters of the request entity.
|
String |
getHeaderValue(String name)
Get a HTTP header value.
|
Locale |
getLanguage() |
javax.ws.rs.core.MediaType |
getMediaType() |
MessageBodyWorkers |
getMessageBodyWorkers()
Get the message body workers.
|
String |
getMethod() |
String |
getPath()
Get the path of the current request relative to the base URI as
a string.
|
String |
getPath(boolean decode)
Get the path of the current request relative to the base URI as
a string.
|
List<javax.ws.rs.core.PathSegment> |
getPathSegments()
Get the path of the current request relative to the base URI as a
list of
PathSegment . |
List<javax.ws.rs.core.PathSegment> |
getPathSegments(boolean decode)
Get the path of the current request relative to the base URI as a
list of
PathSegment . |
Map<String,Object> |
getProperties()
Get the mutable properties.
|
javax.ws.rs.core.MultivaluedMap<String,String> |
getQueryParameters()
Get the URI query parameters of the current request.
|
javax.ws.rs.core.MultivaluedMap<String,String> |
getQueryParameters(boolean decode)
Get the URI query parameters of the current request.
|
List<String> |
getRequestHeader(String name) |
javax.ws.rs.core.MultivaluedMap<String,String> |
getRequestHeaders() |
URI |
getRequestUri()
Get the absolute request URI.
|
javax.ws.rs.core.UriBuilder |
getRequestUriBuilder()
Get the absolute request URI in the form of a UriBuilder.
|
javax.ws.rs.core.SecurityContext |
getSecurityContext()
Get the security context.
|
Principal |
getUserPrincipal() |
boolean |
isSecure() |
boolean |
isTracingEnabled()
Check if tracing is enabled.
|
boolean |
isUserInRole(String role) |
javax.ws.rs.core.Variant |
selectVariant(List<javax.ws.rs.core.Variant> variants) |
<T> void |
setEntity(Class<T> type,
Type genericType,
Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType,
javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders,
T entity)
Set the request entity.
|
void |
setEntityInputStream(InputStream entity)
Set the input stream of the entity.
|
void |
setHeaders(InBoundHeaders headers)
Set the request headers.
|
void |
setMethod(String method)
Set the HTTP method.
|
void |
setSecurityContext(javax.ws.rs.core.SecurityContext securityContext)
Set the security context.
|
void |
setUris(URI baseUri,
URI requestUri)
Set the base and request URI.
|
void |
trace(String message)
Add a trace message.
|
public static final String VARY_HEADER
public ContainerRequest(WebApplication wa, String method, URI baseUri, URI requestUri, InBoundHeaders headers, InputStream entity)
wa
- the web applicationmethod
- the HTTP methodbaseUri
- the base URI of the requestrequestUri
- the request URIheaders
- the request headersentity
- the InputStream of the request entitypublic Map<String,Object> getProperties()
public void setMethod(String method)
method
- the method.public void setUris(URI baseUri, URI requestUri)
baseUri
- the base URI.requestUri
- the (complete) request URI.public InputStream getEntityInputStream()
public void setEntityInputStream(InputStream entity)
entity
- the input stream of the entity.public void setHeaders(InBoundHeaders headers)
headers
- the request headers.public void setSecurityContext(javax.ws.rs.core.SecurityContext securityContext)
securityContext
- the security context.public javax.ws.rs.core.SecurityContext getSecurityContext()
public MessageBodyWorkers getMessageBodyWorkers()
public boolean isTracingEnabled()
Traceable
isTracingEnabled
in interface Traceable
public void trace(String message)
Traceable
A trace message will be added if Traceable.isTracingEnabled()
returns
true and tracing contraints are satisfied.
public URI getBaseUri()
HttpRequestContext
getBaseUri
in interface HttpRequestContext
public javax.ws.rs.core.UriBuilder getBaseUriBuilder()
HttpRequestContext
getBaseUriBuilder
in interface HttpRequestContext
public URI getRequestUri()
HttpRequestContext
getRequestUri
in interface HttpRequestContext
public javax.ws.rs.core.UriBuilder getRequestUriBuilder()
HttpRequestContext
getRequestUriBuilder
in interface HttpRequestContext
public URI getAbsolutePath()
HttpRequestContext
uriInfo.getBase().resolve(uriInfo.getPath()).
getAbsolutePath
in interface HttpRequestContext
public javax.ws.rs.core.UriBuilder getAbsolutePathBuilder()
HttpRequestContext
getAbsolutePathBuilder
in interface HttpRequestContext
public String getPath()
HttpRequestContext
getPath(true)
.getPath
in interface HttpRequestContext
public String getPath(boolean decode)
HttpRequestContext
getPath
in interface HttpRequestContext
decode
- controls whether sequences of escaped octets are decoded
(true) or not (false).public List<javax.ws.rs.core.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
PathSegment
. The matrix parameter
map of each path segment is also unmodifiable.PathSegment
,
Matrix URIspublic List<javax.ws.rs.core.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
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 javax.ws.rs.core.MultivaluedMap<String,String> getQueryParameters()
HttpRequestContext
getQueryParameters(true)
.getQueryParameters
in interface HttpRequestContext
public javax.ws.rs.core.MultivaluedMap<String,String> getQueryParameters(boolean decode)
HttpRequestContext
getQueryParameters
in interface HttpRequestContext
decode
- controls whether sequences of escaped octets in parameter
names and values are decoded (true) or not (false).public String getHeaderValue(String name)
HttpRequestContext
getHeaderValue
in interface HttpRequestContext
name
- the HTTP headerpublic <T> T getEntity(Class<T> type, Type genericType, Annotation[] as)
HttpRequestContext
getEntity
in interface HttpRequestContext
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 typepublic <T> void setEntity(Class<T> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders, T entity)
type
- the class of object that is to be written.genericType
- the type of object to be written, obtained either
by reflection of a resource method return type or by inspection
of the returned instance. GenericEntity
provides a way to specify this information at runtime.annotations
- an array of the annotations on the resource
method that returns the object.mediaType
- the media type of the HTTP entity.httpHeaders
- a mutable map of the HTTP response headers.entity
- the entity instance to write.MappableContainerException
- encapsulates exceptions thrown while
serializing the entity.public <T> T getEntity(Class<T> type)
HttpRequestContext
getEntity
in interface HttpRequestContext
type
- the type of entitypublic javax.ws.rs.core.MediaType getAcceptableMediaType(List<javax.ws.rs.core.MediaType> mediaTypes)
HttpRequestContext
getAcceptableMediaType
in interface HttpRequestContext
mediaTypes
- the list of media typespublic List<javax.ws.rs.core.MediaType> getAcceptableMediaTypes(List<QualitySourceMediaType> priorityMediaTypes)
HttpRequestContext
getAcceptableMediaTypes
in interface HttpRequestContext
priorityMediaTypes
- the list of media types that take priority,
ordered according to the quality source parameter, "qs" as the
primary key.public javax.ws.rs.core.MultivaluedMap<String,String> getCookieNameValueMap()
HttpRequestContext
getCookieNameValueMap
in interface HttpRequestContext
public 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
public javax.ws.rs.core.MultivaluedMap<String,String> getRequestHeaders()
getRequestHeaders
in interface javax.ws.rs.core.HttpHeaders
public List<String> getRequestHeader(String name)
getRequestHeader
in interface javax.ws.rs.core.HttpHeaders
public List<javax.ws.rs.core.MediaType> getAcceptableMediaTypes()
getAcceptableMediaTypes
in interface javax.ws.rs.core.HttpHeaders
public List<Locale> getAcceptableLanguages()
getAcceptableLanguages
in interface javax.ws.rs.core.HttpHeaders
public javax.ws.rs.core.MediaType getMediaType()
getMediaType
in interface javax.ws.rs.core.HttpHeaders
public Locale getLanguage()
getLanguage
in interface javax.ws.rs.core.HttpHeaders
public Map<String,javax.ws.rs.core.Cookie> getCookies()
getCookies
in interface javax.ws.rs.core.HttpHeaders
public String getMethod()
getMethod
in interface javax.ws.rs.core.Request
public javax.ws.rs.core.Variant selectVariant(List<javax.ws.rs.core.Variant> variants)
selectVariant
in interface javax.ws.rs.core.Request
public javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions()
evaluatePreconditions
in interface javax.ws.rs.core.Request
public javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(javax.ws.rs.core.EntityTag eTag)
evaluatePreconditions
in interface javax.ws.rs.core.Request
public javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(Date lastModified)
evaluatePreconditions
in interface javax.ws.rs.core.Request
public javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(Date lastModified, javax.ws.rs.core.EntityTag eTag)
evaluatePreconditions
in interface javax.ws.rs.core.Request
public Principal getUserPrincipal()
getUserPrincipal
in interface javax.ws.rs.core.SecurityContext
public boolean isUserInRole(String role)
isUserInRole
in interface javax.ws.rs.core.SecurityContext
public boolean isSecure()
isSecure
in interface javax.ws.rs.core.SecurityContext
public String getAuthenticationScheme()
getAuthenticationScheme
in interface javax.ws.rs.core.SecurityContext
Copyright © 2013 Oracle Corporation. All rights reserved.