public final class JAXRSUtils extends Object
Modifier and Type | Field and Description |
---|---|
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 |
static String |
SECOND_JAXRS_EXCEPTION |
Modifier and Type | Method and Description |
---|---|
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 |
compareMethodParameters(Class<?>[] paraList1,
Class<?>[] paraList2) |
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> |
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 boolean |
doMimeTypesIntersect(List<javax.ws.rs.core.MediaType> requiredMediaTypes,
List<javax.ws.rs.core.MediaType> userMediaTypes) |
static boolean |
doMimeTypesIntersect(List<javax.ws.rs.core.MediaType> mimeTypesA,
javax.ws.rs.core.MediaType mimeTypeB) |
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,
boolean recordMatchedUri) |
static javax.ws.rs.core.Response.ResponseBuilder |
fromResponse(javax.ws.rs.core.Response response) |
static javax.ws.rs.core.Response.ResponseBuilder |
fromResponse(javax.ws.rs.core.Response response,
boolean copyEntity) |
static QName |
getClassQName(Class<?> type) |
static List<javax.ws.rs.core.MediaType> |
getConsumeTypes(javax.ws.rs.Consumes cm) |
static List<javax.ws.rs.core.MediaType> |
getConsumeTypes(javax.ws.rs.Consumes cm,
List<javax.ws.rs.core.MediaType> defaultTypes) |
static Message |
getContextMessage(Message m) |
static Message |
getCurrentMessage() |
static Level |
getExceptionLogLevel(Message message,
Class<? extends javax.ws.rs.WebApplicationException> exClass) |
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)
Parses path segments taking into account the URI templates and template regexes.
|
static List<javax.ws.rs.core.MediaType> |
getProduceTypes(javax.ws.rs.Produces pm) |
static List<javax.ws.rs.core.MediaType> |
getProduceTypes(javax.ws.rs.Produces pm,
List<javax.ws.rs.core.MediaType> defaultTypes) |
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 void |
getStructuredParams(javax.ws.rs.core.MultivaluedMap<String,String> queries,
String query,
String sep,
boolean decode,
boolean decodePlus,
boolean valueIsCollection) |
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 String |
getUriTemplate(Message message,
ClassResourceInfo cri,
OperationResourceInfo ori)
Get path URI template, combining base path, class & method templates
|
static String |
getUriTemplate(Message message,
ClassResourceInfo cri,
OperationResourceInfo ori,
OperationResourceInfo subOri)
Get path URI template, combining base path, class & method & subresource templates
|
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 boolean |
isStreamingLikeOutType(Class<?> cls,
Type type)
Consider additional types as stream-like and returns if the class and corresponding type
refer to one of those.
|
static boolean |
isStreamingOutType(Class<?> type) |
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) |
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) |
public static final javax.ws.rs.core.MediaType ALL_TYPES
public static final String ROOT_RESOURCE_CLASS
public static final String IGNORE_MESSAGE_WRITERS
public static final String ROOT_INSTANCE
public static final String ROOT_PROVIDER
public static final String EXCEPTION_FROM_MAPPER
public static final String SECOND_JAXRS_EXCEPTION
public static final String PARTIAL_HIERARCHICAL_MEDIA_SUBTYPE_CHECK
public static final String DOC_LOCATION
public static final String MEDIA_TYPE_Q_PARAM
public static final String MEDIA_TYPE_QS_PARAM
public static boolean isStreamingLikeOutType(Class<?> cls, Type type)
cls
- class to checktype
- type to checkpublic static boolean isStreamingOutType(Class<?> type)
public static List<javax.ws.rs.core.PathSegment> getPathSegments(String thePath, boolean decode)
public static List<javax.ws.rs.core.PathSegment> getPathSegments(String thePath, boolean decode, boolean ignoreLastSlash)
URITemplate
. In this case, the whole template definition is extracted as a path
segment, without breaking it.thePath
- pathdecode
- should the path segments be decoded or notignoreLastSlash
- should the last slash be ignored or notpublic static List<javax.ws.rs.core.MediaType> getProviderConsumeTypes(javax.ws.rs.ext.MessageBodyReader<?> provider)
public static List<javax.ws.rs.core.MediaType> getProviderProduceTypes(javax.ws.rs.ext.MessageBodyWriter<?> provider)
public static void injectParameters(OperationResourceInfo ori, Object requestObject, Message message)
public static void injectParameters(OperationResourceInfo ori, BeanResourceInfo bri, Object requestObject, Message message)
public static Map<ClassResourceInfo,javax.ws.rs.core.MultivaluedMap<String,String>> selectResourceClass(List<ClassResourceInfo> resources, String path, Message message)
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)
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, boolean recordMatchedUri)
public static Level getExceptionLogLevel(Message message, Class<? extends javax.ws.rs.WebApplicationException> exClass)
public static List<ClassResourceInfo> getRootResources(Message message)
public static boolean noResourceMethodForOptions(javax.ws.rs.core.Response exResponse, String httpMethod)
public static javax.ws.rs.core.Response createResponse(List<ClassResourceInfo> cris, Message msg, String responseMessage, int status, boolean addAllow)
public static boolean headMethodPossible(String expectedMethod, String httpMethod)
public static List<javax.ws.rs.core.MediaType> getConsumeTypes(javax.ws.rs.Consumes cm)
public static List<javax.ws.rs.core.MediaType> getConsumeTypes(javax.ws.rs.Consumes cm, List<javax.ws.rs.core.MediaType> defaultTypes)
public static List<javax.ws.rs.core.MediaType> getProduceTypes(javax.ws.rs.Produces pm)
public static List<javax.ws.rs.core.MediaType> getProduceTypes(javax.ws.rs.Produces pm, List<javax.ws.rs.core.MediaType> defaultTypes)
public static int compareSortedConsumesMediaTypes(List<javax.ws.rs.core.MediaType> mts1, List<javax.ws.rs.core.MediaType> mts2, javax.ws.rs.core.MediaType ct)
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)
public static int compareSortedMediaTypes(List<javax.ws.rs.core.MediaType> mts1, List<javax.ws.rs.core.MediaType> mts2, String qs)
public static int compareMethodParameters(Class<?>[] paraList1, Class<?>[] paraList2)
public static int compareMediaTypes(javax.ws.rs.core.MediaType mt1, javax.ws.rs.core.MediaType mt2)
public static int compareMediaTypes(javax.ws.rs.core.MediaType mt1, javax.ws.rs.core.MediaType mt2, String qs)
public static int compareMediaTypesQualityFactors(javax.ws.rs.core.MediaType mt1, javax.ws.rs.core.MediaType mt2)
public static int compareMediaTypesQualityFactors(javax.ws.rs.core.MediaType mt1, javax.ws.rs.core.MediaType mt2, String qs)
public static float getMediaTypeQualityFactor(String q)
public static List<Object> processParameters(OperationResourceInfo ori, javax.ws.rs.core.MultivaluedMap<String,String> values, Message message) throws IOException, javax.ws.rs.WebApplicationException
IOException
javax.ws.rs.WebApplicationException
public static Object createHttpParameterValue(Parameter parameter, Class<?> parameterClass, Type genericParam, Annotation[] paramAnns, Message message, javax.ws.rs.core.MultivaluedMap<String,String> values, OperationResourceInfo ori)
public static javax.ws.rs.core.MultivaluedMap<String,String> getMatrixParams(String path, boolean decode)
public static Object createBeanParamValue(Message m, Class<?> clazz, OperationResourceInfo ori)
public static <T> T createContextValue(Message m, Type genericType, Class<T> clazz)
public static javax.ws.rs.ext.ContextResolver<?> createContextResolver(Type genericType, Message m)
public static Object createResourceValue(Message m, Type genericType, Class<?> clazz)
public static javax.ws.rs.core.MultivaluedMap<String,String> getStructuredParams(String query, String sep, boolean decode, boolean decodePlus)
public static void getStructuredParams(javax.ws.rs.core.MultivaluedMap<String,String> queries, String query, String sep, boolean decode, boolean decodePlus)
public static void getStructuredParams(javax.ws.rs.core.MultivaluedMap<String,String> queries, String query, String sep, boolean decode, boolean decodePlus, boolean valueIsCollection)
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
IOException
javax.ws.rs.WebApplicationException
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
javax.ws.rs.WebApplicationException
IOException
public static boolean matchConsumeTypes(javax.ws.rs.core.MediaType requestContentType, OperationResourceInfo ori)
public static boolean matchProduceTypes(javax.ws.rs.core.MediaType acceptContentType, OperationResourceInfo ori)
public static boolean matchMimeTypes(javax.ws.rs.core.MediaType requestContentType, javax.ws.rs.core.MediaType acceptContentType, OperationResourceInfo ori)
public static boolean doMimeTypesIntersect(List<javax.ws.rs.core.MediaType> mimeTypesA, javax.ws.rs.core.MediaType mimeTypeB)
public static boolean doMimeTypesIntersect(List<javax.ws.rs.core.MediaType> requiredMediaTypes, List<javax.ws.rs.core.MediaType> userMediaTypes)
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)
requiredMediaTypes
- userMediaTypes
- addRequiredParamsIfPossible
- 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)
public static List<javax.ws.rs.core.MediaType> intersectMimeTypes(List<javax.ws.rs.core.MediaType> mimeTypesA, javax.ws.rs.core.MediaType mimeTypeB)
public static List<javax.ws.rs.core.MediaType> intersectMimeTypes(String mimeTypesA, String mimeTypesB)
public static List<javax.ws.rs.core.MediaType> sortMediaTypes(String mediaTypes, String qs)
public static List<javax.ws.rs.core.MediaType> sortMediaTypes(List<javax.ws.rs.core.MediaType> types, String qs)
public static <T extends Throwable> javax.ws.rs.core.Response convertFaultToResponse(T ex, Message currentMessage)
public static void setMessageContentType(Message message, javax.ws.rs.core.Response response)
public static boolean runContainerRequestFilters(ServerProviderFactory pf, Message m, boolean preMatch, Set<String> names) throws IOException
IOException
public static void runContainerResponseFilters(ServerProviderFactory pf, ResponseImpl r, Message m, OperationResourceInfo ori, Method invoked) throws IOException, Throwable
IOException
Throwable
public static String mediaTypeToString(javax.ws.rs.core.MediaType mt, String... ignoreParams)
public static javax.ws.rs.core.MediaType toMediaType(String value)
public static javax.ws.rs.core.Response toResponse(int status)
public static javax.ws.rs.core.Response toResponse(javax.ws.rs.core.Response.Status status)
public static javax.ws.rs.core.Response.ResponseBuilder toResponseBuilder(int status)
public static javax.ws.rs.core.Response.ResponseBuilder toResponseBuilder(javax.ws.rs.core.Response.Status status)
public static javax.ws.rs.core.Response.ResponseBuilder fromResponse(javax.ws.rs.core.Response response)
public static javax.ws.rs.core.Response.ResponseBuilder fromResponse(javax.ws.rs.core.Response response, boolean copyEntity)
public static javax.ws.rs.core.Response copyResponseIfNeeded(javax.ws.rs.core.Response response)
public static Message getCurrentMessage()
public static ClassResourceInfo getRootResource(Message m)
public static void pushOntoStack(OperationResourceInfo ori, javax.ws.rs.core.MultivaluedMap<String,String> params, Message msg)
public static String logMessageHandlerProblem(String name, Class<?> cls, javax.ws.rs.core.MediaType ct)
public static String getUriTemplate(Message message, ClassResourceInfo cri, OperationResourceInfo ori, OperationResourceInfo subOri)
message
- message instancecri
- class resource infoori
- operation resource infosubOri
- operation subresource infopublic static String getUriTemplate(Message message, ClassResourceInfo cri, OperationResourceInfo ori)
message
- message instancecri
- class resource infoori
- operation resource infoApache CXF