com.sun.ws.rest.spi.container
Class AbstractContainerRequest

java.lang.Object
  extended by com.sun.ws.rest.spi.container.AbstractContainerRequest
All Implemented Interfaces:
HttpRequestContext, ContainerRequest, javax.ws.rs.core.HttpHeaders, javax.ws.rs.core.Request, javax.ws.rs.core.SecurityContext, javax.ws.rs.core.UriInfo

public abstract class AbstractContainerRequest
extends java.lang.Object
implements ContainerRequest

An abstract implementation of ContainerRequest.

Specific containers may extend this class and instances may be passed to the runtime using the method WebApplication.handleRequest(com.sun.ws.rest.spi.container.ContainerRequest, com.sun.ws.rest.spi.container.ContainerResponse).

The following are required by a concrete implementation when constructed or before the instance is passed to the runtime.


Field Summary
protected  java.net.URI baseUri
          The base URI of the request.
protected  java.net.URI completeUri
          The complete URI of a request, including the query and fragment components (if any).
 
Fields inherited from interface javax.ws.rs.core.SecurityContext
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
protected AbstractContainerRequest(MessageBodyContext bodyContext, java.lang.String method, java.io.InputStream entity)
           
 
Method Summary
 void addTemplateValues(java.util.List<java.lang.String> names, java.util.List<java.lang.String> values)
          Add templates values to the HTTP request.
 javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(java.util.Date lastModified)
           
 javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(java.util.Date lastModified, javax.ws.rs.core.EntityTag eTag)
           
 javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(javax.ws.rs.core.EntityTag eTag)
           
 java.net.URI getAbsolutePath()
           
 javax.ws.rs.core.UriBuilder getAbsolutePathBuilder()
           
 javax.ws.rs.core.MediaType getAcceptableMediaType(java.util.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.
 java.util.List<javax.ws.rs.core.MediaType> getAcceptableMediaTypes()
           
 java.lang.String getAuthenticationScheme()
           
 java.net.URI getBaseUri()
           
 javax.ws.rs.core.UriBuilder getBaseUriBuilder()
           
 java.util.Map<java.lang.String,javax.ws.rs.core.Cookie> getCookies()
           
<T> T
getEntity(java.lang.Class<T> type)
          Get the request entity, returns null if the request does not contain an entity body.
 java.lang.String getHeaderValue(java.lang.String name)
          Get a HTTP header value.
 java.lang.String getHttpMethod()
          Get the HTTP method name
 java.lang.String getLanguage()
           
 javax.ws.rs.core.MediaType getMediaType()
           
 java.lang.String getPath()
           
 java.lang.String getPath(boolean decode)
           
 java.util.List<javax.ws.rs.core.PathSegment> getPathSegments()
           
 java.util.List<javax.ws.rs.core.PathSegment> getPathSegments(boolean decode)
           
 javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getQueryParameters()
           
 javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getQueryParameters(boolean decode)
           
 javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getRequestHeaders()
           
 java.net.URI getRequestUri()
           
 javax.ws.rs.core.UriBuilder getRequestUriBuilder()
           
 javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getTemplateParameters()
           
 javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getTemplateParameters(boolean decode)
           
 java.security.Principal getUserPrincipal()
           
 boolean isSecure()
           
 boolean isUserInRole(java.lang.String role)
           
 javax.ws.rs.core.Variant selectVariant(java.util.List<javax.ws.rs.core.Variant> variants)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseUri

protected java.net.URI baseUri
The base URI of the request.

The scheme, user info, host and port components must be equivalent to the same componnents of the complete URI. The base URI must not contain the query and fragment components. The encoded path component of the complete URI must start with the encoded path component of the base URI. The encoded path component must end in a '/' character.


completeUri

protected java.net.URI completeUri
The complete URI of a request, including the query and fragment components (if any).

Constructor Detail

AbstractContainerRequest

protected AbstractContainerRequest(MessageBodyContext bodyContext,
                                   java.lang.String method,
                                   java.io.InputStream entity)
Parameters:
bodyContext - the message body context
method - the HTTP method
entity - the InputStream of the request entity
Method Detail

addTemplateValues

public void addTemplateValues(java.util.List<java.lang.String> names,
                              java.util.List<java.lang.String> values)
Description copied from interface: ContainerRequest
Add templates values to the HTTP request.

The template names and values must be in encoded form.

Specified by:
addTemplateValues in interface ContainerRequest
Parameters:
names - the list of template names.
values - the list of template values.

getHeaderValue

public java.lang.String getHeaderValue(java.lang.String name)
Description copied from interface: HttpRequestContext
Get a HTTP header value.

Specified by:
getHeaderValue in interface HttpRequestContext
Parameters:
name - the HTTP header
Returns:
the HTTP header value. If the HTTP header is not present then null is returned. If the HTTP header is present but has no value then the empty string is returned. If the HTTP header is present more than once then the values of joined together and separated by a ',' character.

getEntity

public <T> T getEntity(java.lang.Class<T> type)
Description copied from interface: HttpRequestContext
Get the request entity, returns null if the request does not contain an entity body.

Specified by:
getEntity in interface HttpRequestContext
Parameters:
type - the type of entity
Returns:
the request entity or null

getHttpMethod

public java.lang.String getHttpMethod()
Description copied from interface: HttpRequestContext
Get the HTTP method name

Specified by:
getHttpMethod in interface HttpRequestContext
Returns:
the method name as a String

getAcceptableMediaType

public javax.ws.rs.core.MediaType getAcceptableMediaType(java.util.List<javax.ws.rs.core.MediaType> mediaTypes)
Description copied from interface: HttpRequestContext
Select the first media type, from a list of media types, that is most acceptable according to the requested acceptable media types.

Specified by:
getAcceptableMediaType in interface HttpRequestContext
Parameters:
mediaTypes - the list of media types
Returns:
the most acceptable media type, or null if no media type was found to be acceptable.

getPath

public java.lang.String getPath()
Specified by:
getPath in interface javax.ws.rs.core.UriInfo

getPath

public java.lang.String getPath(boolean decode)
Specified by:
getPath in interface javax.ws.rs.core.UriInfo

getPathSegments

public java.util.List<javax.ws.rs.core.PathSegment> getPathSegments()
Specified by:
getPathSegments in interface javax.ws.rs.core.UriInfo

getPathSegments

public java.util.List<javax.ws.rs.core.PathSegment> getPathSegments(boolean decode)
Specified by:
getPathSegments in interface javax.ws.rs.core.UriInfo

getBaseUri

public java.net.URI getBaseUri()
Specified by:
getBaseUri in interface javax.ws.rs.core.UriInfo

getBaseUriBuilder

public javax.ws.rs.core.UriBuilder getBaseUriBuilder()
Specified by:
getBaseUriBuilder in interface javax.ws.rs.core.UriInfo

getAbsolutePath

public java.net.URI getAbsolutePath()
Specified by:
getAbsolutePath in interface javax.ws.rs.core.UriInfo

getAbsolutePathBuilder

public javax.ws.rs.core.UriBuilder getAbsolutePathBuilder()
Specified by:
getAbsolutePathBuilder in interface javax.ws.rs.core.UriInfo

getRequestUri

public java.net.URI getRequestUri()
Specified by:
getRequestUri in interface javax.ws.rs.core.UriInfo

getRequestUriBuilder

public javax.ws.rs.core.UriBuilder getRequestUriBuilder()
Specified by:
getRequestUriBuilder in interface javax.ws.rs.core.UriInfo

getTemplateParameters

public javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getTemplateParameters()
Specified by:
getTemplateParameters in interface javax.ws.rs.core.UriInfo

getTemplateParameters

public javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getTemplateParameters(boolean decode)
Specified by:
getTemplateParameters in interface javax.ws.rs.core.UriInfo

getQueryParameters

public javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getQueryParameters()
Specified by:
getQueryParameters in interface javax.ws.rs.core.UriInfo

getQueryParameters

public javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getQueryParameters(boolean decode)
Specified by:
getQueryParameters in interface javax.ws.rs.core.UriInfo

getRequestHeaders

public javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> getRequestHeaders()
Specified by:
getRequestHeaders in interface javax.ws.rs.core.HttpHeaders

getAcceptableMediaTypes

public java.util.List<javax.ws.rs.core.MediaType> getAcceptableMediaTypes()
Specified by:
getAcceptableMediaTypes in interface javax.ws.rs.core.HttpHeaders

getMediaType

public javax.ws.rs.core.MediaType getMediaType()
Specified by:
getMediaType in interface javax.ws.rs.core.HttpHeaders

getLanguage

public java.lang.String getLanguage()
Specified by:
getLanguage in interface javax.ws.rs.core.HttpHeaders

getCookies

public java.util.Map<java.lang.String,javax.ws.rs.core.Cookie> getCookies()
Specified by:
getCookies in interface javax.ws.rs.core.HttpHeaders

selectVariant

public javax.ws.rs.core.Variant selectVariant(java.util.List<javax.ws.rs.core.Variant> variants)
Specified by:
selectVariant in interface javax.ws.rs.core.Request

evaluatePreconditions

public javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(javax.ws.rs.core.EntityTag eTag)
Specified by:
evaluatePreconditions in interface javax.ws.rs.core.Request

evaluatePreconditions

public javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(java.util.Date lastModified)
Specified by:
evaluatePreconditions in interface javax.ws.rs.core.Request

evaluatePreconditions

public javax.ws.rs.core.Response.ResponseBuilder evaluatePreconditions(java.util.Date lastModified,
                                                                       javax.ws.rs.core.EntityTag eTag)
Specified by:
evaluatePreconditions in interface javax.ws.rs.core.Request

getUserPrincipal

public java.security.Principal getUserPrincipal()
Specified by:
getUserPrincipal in interface javax.ws.rs.core.SecurityContext

isUserInRole

public boolean isUserInRole(java.lang.String role)
Specified by:
isUserInRole in interface javax.ws.rs.core.SecurityContext

isSecure

public boolean isSecure()
Specified by:
isSecure in interface javax.ws.rs.core.SecurityContext

getAuthenticationScheme

public java.lang.String getAuthenticationScheme()
Specified by:
getAuthenticationScheme in interface javax.ws.rs.core.SecurityContext