Apache CXF API

org.apache.cxf.jaxrs.utils
Class JAXRSUtils

java.lang.Object
  extended by org.apache.cxf.jaxrs.utils.JAXRSUtils

public final class JAXRSUtils
extends Object


Field Summary
static javax.ws.rs.core.MediaType ALL_TYPES
           
static String DOC_LOCATION
           
static String EXCEPTION_FROM_MAPPER
           
static String IGNORE_MESSAGE_WRITERS
           
static String MEDIA_TYPE_Q_PARAM
           
static String MEDIA_TYPE_QS_PARAM
           
static String PARTIAL_HIERARCHICAL_MEDIA_SUBTYPE_CHECK
           
static String ROOT_INSTANCE
           
static String ROOT_PROVIDER
           
static String ROOT_RESOURCE_CLASS
           
 
Method Summary
static int compareMediaTypes(javax.ws.rs.core.MediaType mt1, javax.ws.rs.core.MediaType mt2)
           
static int compareMediaTypes(javax.ws.rs.core.MediaType mt1, javax.ws.rs.core.MediaType mt2, String qs)
           
static int compareMediaTypesQualityFactors(javax.ws.rs.core.MediaType mt1, javax.ws.rs.core.MediaType mt2)
           
static int compareMediaTypesQualityFactors(javax.ws.rs.core.MediaType mt1, javax.ws.rs.core.MediaType mt2, String qs)
           
static int compareSortedAcceptMediaTypes(List<javax.ws.rs.core.MediaType> mts1, List<javax.ws.rs.core.MediaType> mts2, List<javax.ws.rs.core.MediaType> acceptTypes)
           
static int compareSortedConsumesMediaTypes(List<javax.ws.rs.core.MediaType> mts1, List<javax.ws.rs.core.MediaType> mts2, javax.ws.rs.core.MediaType ct)
           
static int compareSortedMediaTypes(List<javax.ws.rs.core.MediaType> mts1, List<javax.ws.rs.core.MediaType> mts2, String qs)
           
static
<T extends Throwable>
javax.ws.rs.core.Response
convertFaultToResponse(T ex, Message currentMessage)
           
static QName convertStringToQName(String name)
           
static javax.ws.rs.core.Response copyResponseIfNeeded(javax.ws.rs.core.Response response)
           
static Object createBeanParamValue(Message m, Class<?> clazz, OperationResourceInfo ori)
           
static javax.ws.rs.ext.ContextResolver<?> createContextResolver(Type genericType, Message m)
           
static
<T> T
createContextValue(Message m, Type genericType, Class<T> clazz)
           
static Object createHttpParameterValue(Parameter parameter, Class<?> parameterClass, Type genericParam, Annotation[] paramAnns, Message message, javax.ws.rs.core.MultivaluedMap<String,String> values, OperationResourceInfo ori)
           
static Object createResourceValue(Message m, Type genericType, Class<?> clazz)
           
static javax.ws.rs.core.Response createResponse(List<ClassResourceInfo> cris, Message msg, String responseMessage, int status, boolean addAllow)
           
static
<T> T
createServletResourceValue(Message m, Class<T> clazz)
           
static OperationResourceInfo findTargetMethod(Map<ClassResourceInfo,javax.ws.rs.core.MultivaluedMap<String,String>> matchedResources, Message message, String httpMethod, javax.ws.rs.core.MultivaluedMap<String,String> matchedValues, String requestContentType, List<javax.ws.rs.core.MediaType> acceptContentTypes)
           
static OperationResourceInfo findTargetMethod(Map<ClassResourceInfo,javax.ws.rs.core.MultivaluedMap<String,String>> matchedResources, Message message, String httpMethod, javax.ws.rs.core.MultivaluedMap<String,String> matchedValues, String requestContentType, List<javax.ws.rs.core.MediaType> acceptContentTypes, boolean throwException)
           
static javax.ws.rs.core.Response.ResponseBuilder fromResponse(javax.ws.rs.core.Response response)
           
static QName getClassQName(Class<?> type)
           
static List<javax.ws.rs.core.MediaType> getConsumeTypes(javax.ws.rs.Consumes cm)
           
static Message getCurrentMessage()
           
static javax.ws.rs.core.MultivaluedMap<String,String> getMatrixParams(String path, boolean decode)
           
static float getMediaTypeQualityFactor(String q)
           
static List<javax.ws.rs.core.MediaType> getMediaTypes(String[] values)
           
static List<javax.ws.rs.core.PathSegment> getPathSegments(String thePath, boolean decode)
           
static List<javax.ws.rs.core.PathSegment> getPathSegments(String thePath, boolean decode, boolean ignoreLastSlash)
           
static List<javax.ws.rs.core.MediaType> getProduceTypes(javax.ws.rs.Produces pm)
           
static List<javax.ws.rs.core.MediaType> getProviderConsumeTypes(javax.ws.rs.ext.MessageBodyReader<?> provider)
           
static List<javax.ws.rs.core.MediaType> getProviderProduceTypes(javax.ws.rs.ext.MessageBodyWriter<?> provider)
           
static ClassResourceInfo getRootResource(Message m)
           
static List<ClassResourceInfo> getRootResources(Message message)
           
static void getStructuredParams(javax.ws.rs.core.MultivaluedMap<String,String> queries, String query, String sep, boolean decode, boolean decodePlus)
           
static javax.ws.rs.core.MultivaluedMap<String,String> getStructuredParams(String query, String sep, boolean decode, boolean decodePlus)
          Retrieve map of query parameters from the passed in message
static boolean headMethodPossible(String expectedMethod, String httpMethod)
           
static void injectParameters(OperationResourceInfo ori, BeanResourceInfo bri, Object requestObject, Message message)
           
static void injectParameters(OperationResourceInfo ori, Object requestObject, Message message)
           
static List<javax.ws.rs.core.MediaType> intersectMimeTypes(List<javax.ws.rs.core.MediaType> requiredMediaTypes, List<javax.ws.rs.core.MediaType> userMediaTypes, boolean addRequiredParamsIfPossible)
          intersect two mime types
static List<javax.ws.rs.core.MediaType> intersectMimeTypes(List<javax.ws.rs.core.MediaType> requiredMediaTypes, List<javax.ws.rs.core.MediaType> userMediaTypes, boolean addRequiredParamsIfPossible, boolean addDistanceParameter)
           
static List<javax.ws.rs.core.MediaType> intersectMimeTypes(List<javax.ws.rs.core.MediaType> mimeTypesA, javax.ws.rs.core.MediaType mimeTypeB)
           
static List<javax.ws.rs.core.MediaType> intersectMimeTypes(String mimeTypesA, String mimeTypesB)
           
static String logMessageHandlerProblem(String name, Class<?> cls, javax.ws.rs.core.MediaType ct)
           
static boolean matchConsumeTypes(javax.ws.rs.core.MediaType requestContentType, OperationResourceInfo ori)
           
static boolean matchMimeTypes(javax.ws.rs.core.MediaType requestContentType, javax.ws.rs.core.MediaType acceptContentType, OperationResourceInfo ori)
           
static boolean matchProduceTypes(javax.ws.rs.core.MediaType acceptContentType, OperationResourceInfo ori)
           
static String mediaTypeToString(javax.ws.rs.core.MediaType mt, String... ignoreParams)
           
static boolean noResourceMethodForOptions(javax.ws.rs.core.Response exResponse, String httpMethod)
           
static List<javax.ws.rs.core.MediaType> parseMediaTypes(String types)
           
static List<Object> processParameters(OperationResourceInfo ori, javax.ws.rs.core.MultivaluedMap<String,String> values, Message message)
           
static void pushOntoStack(OperationResourceInfo ori, javax.ws.rs.core.MultivaluedMap<String,String> params, Message msg)
           
static Object readFromMessageBodyReader(List<javax.ws.rs.ext.ReaderInterceptor> readers, Class<?> targetTypeClass, Type parameterType, Annotation[] parameterAnnotations, InputStream is, javax.ws.rs.core.MediaType mediaType, Message m)
           
static boolean runContainerRequestFilters(ServerProviderFactory pf, Message m, boolean preMatch, Set<String> names, boolean sub)
           
static void runContainerResponseFilters(ServerProviderFactory pf, ResponseImpl r, Message m, OperationResourceInfo ori, Method invoked)
           
static Map<ClassResourceInfo,javax.ws.rs.core.MultivaluedMap<String,String>> selectResourceClass(List<ClassResourceInfo> resources, String path, Message message)
           
static void setMessageContentType(Message message, javax.ws.rs.core.Response response)
           
static List<javax.ws.rs.core.MediaType> sortMediaTypes(List<javax.ws.rs.core.MediaType> types, String qs)
           
static List<javax.ws.rs.core.MediaType> sortMediaTypes(String mediaTypes, String qs)
           
static javax.ws.rs.core.MediaType toMediaType(String value)
           
static javax.ws.rs.core.Response toResponse(int status)
           
static javax.ws.rs.core.Response toResponse(javax.ws.rs.core.Response.Status status)
           
static javax.ws.rs.core.Response.ResponseBuilder toResponseBuilder(int status)
           
static javax.ws.rs.core.Response.ResponseBuilder toResponseBuilder(javax.ws.rs.core.Response.Status status)
           
static void writeMessageBody(List<javax.ws.rs.ext.WriterInterceptor> writers, Object entity, Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders, Message message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_TYPES

public static final javax.ws.rs.core.MediaType ALL_TYPES

ROOT_RESOURCE_CLASS

public static final String ROOT_RESOURCE_CLASS
See Also:
Constant Field Values

IGNORE_MESSAGE_WRITERS

public static final String IGNORE_MESSAGE_WRITERS
See Also:
Constant Field Values

ROOT_INSTANCE

public static final String ROOT_INSTANCE
See Also:
Constant Field Values

ROOT_PROVIDER

public static final String ROOT_PROVIDER
See Also:
Constant Field Values

EXCEPTION_FROM_MAPPER

public static final String EXCEPTION_FROM_MAPPER
See Also:
Constant Field Values

PARTIAL_HIERARCHICAL_MEDIA_SUBTYPE_CHECK

public static final String PARTIAL_HIERARCHICAL_MEDIA_SUBTYPE_CHECK
See Also:
Constant Field Values

DOC_LOCATION

public static final String DOC_LOCATION
See Also:
Constant Field Values

MEDIA_TYPE_Q_PARAM

public static final String MEDIA_TYPE_Q_PARAM
See Also:
Constant Field Values

MEDIA_TYPE_QS_PARAM

public static final String MEDIA_TYPE_QS_PARAM
See Also:
Constant Field Values
Method Detail

getPathSegments

public static List<javax.ws.rs.core.PathSegment> getPathSegments(String thePath,
                                                                 boolean decode)

getPathSegments

public static List<javax.ws.rs.core.PathSegment> getPathSegments(String thePath,
                                                                 boolean decode,
                                                                 boolean ignoreLastSlash)

getProviderConsumeTypes

public static List<javax.ws.rs.core.MediaType> getProviderConsumeTypes(javax.ws.rs.ext.MessageBodyReader<?> provider)

getProviderProduceTypes

public static List<javax.ws.rs.core.MediaType> getProviderProduceTypes(javax.ws.rs.ext.MessageBodyWriter<?> provider)

getMediaTypes

public static List<javax.ws.rs.core.MediaType> getMediaTypes(String[] values)

injectParameters

public static void injectParameters(OperationResourceInfo ori,
                                    Object requestObject,
                                    Message message)

injectParameters

public static void injectParameters(OperationResourceInfo ori,
                                    BeanResourceInfo bri,
                                    Object requestObject,
                                    Message message)

selectResourceClass

public static Map<ClassResourceInfo,javax.ws.rs.core.MultivaluedMap<String,String>> selectResourceClass(List<ClassResourceInfo> resources,
                                                                                                        String path,
                                                                                                        Message message)

findTargetMethod

public static OperationResourceInfo findTargetMethod(Map<ClassResourceInfo,javax.ws.rs.core.MultivaluedMap<String,String>> matchedResources,
                                                     Message message,
                                                     String httpMethod,
                                                     javax.ws.rs.core.MultivaluedMap<String,String> matchedValues,
                                                     String requestContentType,
                                                     List<javax.ws.rs.core.MediaType> acceptContentTypes)

findTargetMethod

public static OperationResourceInfo findTargetMethod(Map<ClassResourceInfo,javax.ws.rs.core.MultivaluedMap<String,String>> matchedResources,
                                                     Message message,
                                                     String httpMethod,
                                                     javax.ws.rs.core.MultivaluedMap<String,String> matchedValues,
                                                     String requestContentType,
                                                     List<javax.ws.rs.core.MediaType> acceptContentTypes,
                                                     boolean throwException)

getRootResources

public static List<ClassResourceInfo> getRootResources(Message message)

noResourceMethodForOptions

public static boolean noResourceMethodForOptions(javax.ws.rs.core.Response exResponse,
                                                 String httpMethod)

createResponse

public static javax.ws.rs.core.Response createResponse(List<ClassResourceInfo> cris,
                                                       Message msg,
                                                       String responseMessage,
                                                       int status,
                                                       boolean addAllow)

headMethodPossible

public static boolean headMethodPossible(String expectedMethod,
                                         String httpMethod)

getConsumeTypes

public static List<javax.ws.rs.core.MediaType> getConsumeTypes(javax.ws.rs.Consumes cm)

getProduceTypes

public static List<javax.ws.rs.core.MediaType> getProduceTypes(javax.ws.rs.Produces pm)

compareSortedConsumesMediaTypes

public static int compareSortedConsumesMediaTypes(List<javax.ws.rs.core.MediaType> mts1,
                                                  List<javax.ws.rs.core.MediaType> mts2,
                                                  javax.ws.rs.core.MediaType ct)

compareSortedAcceptMediaTypes

public static int compareSortedAcceptMediaTypes(List<javax.ws.rs.core.MediaType> mts1,
                                                List<javax.ws.rs.core.MediaType> mts2,
                                                List<javax.ws.rs.core.MediaType> acceptTypes)

compareSortedMediaTypes

public static int compareSortedMediaTypes(List<javax.ws.rs.core.MediaType> mts1,
                                          List<javax.ws.rs.core.MediaType> mts2,
                                          String qs)

compareMediaTypes

public static int compareMediaTypes(javax.ws.rs.core.MediaType mt1,
                                    javax.ws.rs.core.MediaType mt2)

compareMediaTypes

public static int compareMediaTypes(javax.ws.rs.core.MediaType mt1,
                                    javax.ws.rs.core.MediaType mt2,
                                    String qs)

compareMediaTypesQualityFactors

public static int compareMediaTypesQualityFactors(javax.ws.rs.core.MediaType mt1,
                                                  javax.ws.rs.core.MediaType mt2)

compareMediaTypesQualityFactors

public static int compareMediaTypesQualityFactors(javax.ws.rs.core.MediaType mt1,
                                                  javax.ws.rs.core.MediaType mt2,
                                                  String qs)

getMediaTypeQualityFactor

public static float getMediaTypeQualityFactor(String q)

processParameters

public static List<Object> processParameters(OperationResourceInfo ori,
                                             javax.ws.rs.core.MultivaluedMap<String,String> values,
                                             Message message)
                                      throws IOException,
                                             javax.ws.rs.WebApplicationException
Throws:
IOException
javax.ws.rs.WebApplicationException

createHttpParameterValue

public static Object createHttpParameterValue(Parameter parameter,
                                              Class<?> parameterClass,
                                              Type genericParam,
                                              Annotation[] paramAnns,
                                              Message message,
                                              javax.ws.rs.core.MultivaluedMap<String,String> values,
                                              OperationResourceInfo ori)

getMatrixParams

public static javax.ws.rs.core.MultivaluedMap<String,String> getMatrixParams(String path,
                                                                             boolean decode)

createBeanParamValue

public static Object createBeanParamValue(Message m,
                                          Class<?> clazz,
                                          OperationResourceInfo ori)

createContextValue

public static <T> T createContextValue(Message m,
                                       Type genericType,
                                       Class<T> clazz)

createContextResolver

public static javax.ws.rs.ext.ContextResolver<?> createContextResolver(Type genericType,
                                                                       Message m)

createResourceValue

public static Object createResourceValue(Message m,
                                         Type genericType,
                                         Class<?> clazz)

createServletResourceValue

public static <T> T createServletResourceValue(Message m,
                                               Class<T> clazz)

getStructuredParams

public static javax.ws.rs.core.MultivaluedMap<String,String> getStructuredParams(String query,
                                                                                 String sep,
                                                                                 boolean decode,
                                                                                 boolean decodePlus)
Retrieve map of query parameters from the passed in message

Parameters:
message -
Returns:
a Map of query parameters.

getStructuredParams

public static void getStructuredParams(javax.ws.rs.core.MultivaluedMap<String,String> queries,
                                       String query,
                                       String sep,
                                       boolean decode,
                                       boolean decodePlus)

readFromMessageBodyReader

public static Object readFromMessageBodyReader(List<javax.ws.rs.ext.ReaderInterceptor> readers,
                                               Class<?> targetTypeClass,
                                               Type parameterType,
                                               Annotation[] parameterAnnotations,
                                               InputStream is,
                                               javax.ws.rs.core.MediaType mediaType,
                                               Message m)
                                        throws IOException,
                                               javax.ws.rs.WebApplicationException
Throws:
IOException
javax.ws.rs.WebApplicationException

writeMessageBody

public static void writeMessageBody(List<javax.ws.rs.ext.WriterInterceptor> writers,
                                    Object entity,
                                    Class<?> type,
                                    Type genericType,
                                    Annotation[] annotations,
                                    javax.ws.rs.core.MediaType mediaType,
                                    javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders,
                                    Message message)
                             throws javax.ws.rs.WebApplicationException,
                                    IOException
Throws:
javax.ws.rs.WebApplicationException
IOException

matchConsumeTypes

public static boolean matchConsumeTypes(javax.ws.rs.core.MediaType requestContentType,
                                        OperationResourceInfo ori)

matchProduceTypes

public static boolean matchProduceTypes(javax.ws.rs.core.MediaType acceptContentType,
                                        OperationResourceInfo ori)

matchMimeTypes

public static boolean matchMimeTypes(javax.ws.rs.core.MediaType requestContentType,
                                     javax.ws.rs.core.MediaType acceptContentType,
                                     OperationResourceInfo ori)

parseMediaTypes

public static List<javax.ws.rs.core.MediaType> parseMediaTypes(String types)

intersectMimeTypes

public static List<javax.ws.rs.core.MediaType> intersectMimeTypes(List<javax.ws.rs.core.MediaType> requiredMediaTypes,
                                                                  List<javax.ws.rs.core.MediaType> userMediaTypes,
                                                                  boolean addRequiredParamsIfPossible)
intersect two mime types

Parameters:
mimeTypesA -
mimeTypesB -
Returns:
return a list of intersected mime types

intersectMimeTypes

public static List<javax.ws.rs.core.MediaType> intersectMimeTypes(List<javax.ws.rs.core.MediaType> requiredMediaTypes,
                                                                  List<javax.ws.rs.core.MediaType> userMediaTypes,
                                                                  boolean addRequiredParamsIfPossible,
                                                                  boolean addDistanceParameter)

intersectMimeTypes

public static List<javax.ws.rs.core.MediaType> intersectMimeTypes(List<javax.ws.rs.core.MediaType> mimeTypesA,
                                                                  javax.ws.rs.core.MediaType mimeTypeB)

intersectMimeTypes

public static List<javax.ws.rs.core.MediaType> intersectMimeTypes(String mimeTypesA,
                                                                  String mimeTypesB)

sortMediaTypes

public static List<javax.ws.rs.core.MediaType> sortMediaTypes(String mediaTypes,
                                                              String qs)

sortMediaTypes

public static List<javax.ws.rs.core.MediaType> sortMediaTypes(List<javax.ws.rs.core.MediaType> types,
                                                              String qs)

convertFaultToResponse

public static <T extends Throwable> javax.ws.rs.core.Response convertFaultToResponse(T ex,
                                                                                     Message currentMessage)

setMessageContentType

public static void setMessageContentType(Message message,
                                         javax.ws.rs.core.Response response)

getClassQName

public static QName getClassQName(Class<?> type)

convertStringToQName

public static QName convertStringToQName(String name)

runContainerRequestFilters

public static boolean runContainerRequestFilters(ServerProviderFactory pf,
                                                 Message m,
                                                 boolean preMatch,
                                                 Set<String> names,
                                                 boolean sub)

runContainerResponseFilters

public static void runContainerResponseFilters(ServerProviderFactory pf,
                                               ResponseImpl r,
                                               Message m,
                                               OperationResourceInfo ori,
                                               Method invoked)
                                        throws IOException,
                                               Throwable
Throws:
IOException
Throwable

mediaTypeToString

public static String mediaTypeToString(javax.ws.rs.core.MediaType mt,
                                       String... ignoreParams)

toMediaType

public static javax.ws.rs.core.MediaType toMediaType(String value)

toResponse

public static javax.ws.rs.core.Response toResponse(int status)

toResponse

public static javax.ws.rs.core.Response toResponse(javax.ws.rs.core.Response.Status status)

toResponseBuilder

public static javax.ws.rs.core.Response.ResponseBuilder toResponseBuilder(int status)

toResponseBuilder

public static javax.ws.rs.core.Response.ResponseBuilder toResponseBuilder(javax.ws.rs.core.Response.Status status)

fromResponse

public static javax.ws.rs.core.Response.ResponseBuilder fromResponse(javax.ws.rs.core.Response response)

copyResponseIfNeeded

public static javax.ws.rs.core.Response copyResponseIfNeeded(javax.ws.rs.core.Response response)

getCurrentMessage

public static Message getCurrentMessage()

getRootResource

public static ClassResourceInfo getRootResource(Message m)

pushOntoStack

public static void pushOntoStack(OperationResourceInfo ori,
                                 javax.ws.rs.core.MultivaluedMap<String,String> params,
                                 Message msg)

logMessageHandlerProblem

public static String logMessageHandlerProblem(String name,
                                              Class<?> cls,
                                              javax.ws.rs.core.MediaType ct)

Apache CXF API

Apache CXF