Package org.apache.cxf.jaxrs.utils
Class JAXRSUtils
java.lang.Object
org.apache.cxf.jaxrs.utils.JAXRSUtils
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic intcompareMediaTypes(jakarta.ws.rs.core.MediaType mt1, jakarta.ws.rs.core.MediaType mt2) static intcompareMediaTypes(jakarta.ws.rs.core.MediaType mt1, jakarta.ws.rs.core.MediaType mt2, String qs) static intcompareMediaTypesQualityFactors(jakarta.ws.rs.core.MediaType mt1, jakarta.ws.rs.core.MediaType mt2) static intcompareMediaTypesQualityFactors(jakarta.ws.rs.core.MediaType mt1, jakarta.ws.rs.core.MediaType mt2, String qs) static intcompareMethodParameters(Class<?>[] paraList1, Class<?>[] paraList2) static intcompareSortedAcceptMediaTypes(List<jakarta.ws.rs.core.MediaType> mts1, List<jakarta.ws.rs.core.MediaType> mts2, List<jakarta.ws.rs.core.MediaType> acceptTypes) static intcompareSortedConsumesMediaTypes(List<jakarta.ws.rs.core.MediaType> mts1, List<jakarta.ws.rs.core.MediaType> mts2, jakarta.ws.rs.core.MediaType ct) static intcompareSortedMediaTypes(List<jakarta.ws.rs.core.MediaType> mts1, List<jakarta.ws.rs.core.MediaType> mts2, String qs) static <T extends Throwable>
jakarta.ws.rs.core.ResponseconvertFaultToResponse(T ex, Message currentMessage) static QNameconvertStringToQName(String name) static jakarta.ws.rs.core.ResponsecopyResponseIfNeeded(jakarta.ws.rs.core.Response response) static ObjectcreateBeanParamValue(Message m, Class<?> clazz, OperationResourceInfo ori) static jakarta.ws.rs.ext.ContextResolver<?>createContextResolver(Type genericType, Message m) static <T> TcreateContextValue(Message m, Type genericType, Class<T> clazz) static ObjectcreateHttpParameterValue(Parameter parameter, Class<?> parameterClass, Type genericParam, Annotation[] paramAnns, Message message, jakarta.ws.rs.core.MultivaluedMap<String, String> values, OperationResourceInfo ori) static ObjectcreateResourceValue(Message m, Type genericType, Class<?> clazz) static jakarta.ws.rs.core.ResponsecreateResponse(List<ClassResourceInfo> cris, Message msg, String responseMessage, int status, boolean addAllow) static booleandoMimeTypesIntersect(List<jakarta.ws.rs.core.MediaType> mimeTypesA, jakarta.ws.rs.core.MediaType mimeTypeB) static booleandoMimeTypesIntersect(List<jakarta.ws.rs.core.MediaType> requiredMediaTypes, List<jakarta.ws.rs.core.MediaType> userMediaTypes) static OperationResourceInfofindTargetMethod(Map<ClassResourceInfo, jakarta.ws.rs.core.MultivaluedMap<String, String>> matchedResources, Message message, String httpMethod, jakarta.ws.rs.core.MultivaluedMap<String, String> matchedValues, String requestContentType, List<jakarta.ws.rs.core.MediaType> acceptContentTypes) static OperationResourceInfofindTargetMethod(Map<ClassResourceInfo, jakarta.ws.rs.core.MultivaluedMap<String, String>> matchedResources, Message message, String httpMethod, jakarta.ws.rs.core.MultivaluedMap<String, String> matchedValues, String requestContentType, List<jakarta.ws.rs.core.MediaType> acceptContentTypes, boolean throwException, boolean recordMatchedUri) static jakarta.ws.rs.core.Response.ResponseBuilderfromResponse(jakarta.ws.rs.core.Response response) static jakarta.ws.rs.core.Response.ResponseBuilderfromResponse(jakarta.ws.rs.core.Response response, boolean copyEntity) static QNamegetClassQName(Class<?> type) static List<jakarta.ws.rs.core.MediaType>getConsumeTypes(jakarta.ws.rs.Consumes cm) static List<jakarta.ws.rs.core.MediaType>getConsumeTypes(jakarta.ws.rs.Consumes cm, List<jakarta.ws.rs.core.MediaType> defaultTypes) static Messagestatic Messagestatic LevelgetExceptionLogLevel(Message message, Class<? extends jakarta.ws.rs.WebApplicationException> exClass) getMatrixParams(String path, boolean decode) static floatstatic List<jakarta.ws.rs.core.MediaType>getMediaTypes(String[] values) static List<jakarta.ws.rs.core.PathSegment>getPathSegments(String thePath, boolean decode) static List<jakarta.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<jakarta.ws.rs.core.MediaType>getProduceTypes(jakarta.ws.rs.Produces pm) static List<jakarta.ws.rs.core.MediaType>getProduceTypes(jakarta.ws.rs.Produces pm, List<jakarta.ws.rs.core.MediaType> defaultTypes) static List<jakarta.ws.rs.core.MediaType>getProviderConsumeTypes(jakarta.ws.rs.ext.MessageBodyReader<?> provider) static List<jakarta.ws.rs.core.MediaType>getProviderProduceTypes(jakarta.ws.rs.ext.MessageBodyWriter<?> provider) static ClassResourceInfostatic List<ClassResourceInfo>getRootResources(Message message) static voidgetStructuredParams(jakarta.ws.rs.core.MultivaluedMap<String, String> queries, String query, String sep, boolean decode, boolean decodePlus) static voidgetStructuredParams(jakarta.ws.rs.core.MultivaluedMap<String, String> queries, String query, String sep, boolean decode, boolean decodePlus, boolean valueIsCollection) getStructuredParams(String query, String sep, boolean decode, boolean decodePlus) Retrieve map of query parameters from the passed in messagestatic StringgetUriTemplate(Message message, ClassResourceInfo cri, OperationResourceInfo ori) Get path URI template, combining base path, class & method templatesstatic StringgetUriTemplate(Message message, ClassResourceInfo cri, OperationResourceInfo ori, OperationResourceInfo subOri) Get path URI template, combining base path, class & method & subresource templatesstatic booleanheadMethodPossible(String expectedMethod, String httpMethod) static voidinjectParameters(OperationResourceInfo ori, Object requestObject, Message message) static voidinjectParameters(OperationResourceInfo ori, BeanResourceInfo bri, Object requestObject, Message message) static List<jakarta.ws.rs.core.MediaType>intersectMimeTypes(String mimeTypesA, String mimeTypesB) static List<jakarta.ws.rs.core.MediaType>intersectMimeTypes(List<jakarta.ws.rs.core.MediaType> mimeTypesA, jakarta.ws.rs.core.MediaType mimeTypeB) static List<jakarta.ws.rs.core.MediaType>intersectMimeTypes(List<jakarta.ws.rs.core.MediaType> requiredMediaTypes, List<jakarta.ws.rs.core.MediaType> userMediaTypes, boolean addRequiredParamsIfPossible) intersect two mime typesstatic List<jakarta.ws.rs.core.MediaType>intersectMimeTypes(List<jakarta.ws.rs.core.MediaType> requiredMediaTypes, List<jakarta.ws.rs.core.MediaType> userMediaTypes, boolean addRequiredParamsIfPossible, boolean addDistanceParameter) static booleanisStreamingLikeOutType(Class<?> cls, Type type) Consider additional types as stream-like and returns if the class and corresponding type refer to one of those.static booleanisStreamingOutType(Class<?> type) static StringlogMessageHandlerProblem(String name, Class<?> cls, jakarta.ws.rs.core.MediaType ct) static booleanmatchConsumeTypes(jakarta.ws.rs.core.MediaType requestContentType, OperationResourceInfo ori) static booleanmatchMimeTypes(jakarta.ws.rs.core.MediaType requestContentType, jakarta.ws.rs.core.MediaType acceptContentType, OperationResourceInfo ori) static booleanmatchProduceTypes(jakarta.ws.rs.core.MediaType acceptContentType, OperationResourceInfo ori) static StringmediaTypeToString(jakarta.ws.rs.core.MediaType mt, String... ignoreParams) static booleannoResourceMethodForOptions(jakarta.ws.rs.core.Response exResponse, String httpMethod) static List<jakarta.ws.rs.core.MediaType>parseMediaTypes(String types) processParameters(OperationResourceInfo ori, jakarta.ws.rs.core.MultivaluedMap<String, String> values, Message message) static voidpushOntoStack(OperationResourceInfo ori, jakarta.ws.rs.core.MultivaluedMap<String, String> params, Message msg) static ObjectreadFromMessageBodyReader(List<jakarta.ws.rs.ext.ReaderInterceptor> readers, Class<?> targetTypeClass, Type parameterType, Annotation[] parameterAnnotations, InputStream is, jakarta.ws.rs.core.MediaType mediaType, Message m) static booleanrunContainerRequestFilters(ServerProviderFactory pf, Message m, boolean preMatch, Set<String> names) static voidrunContainerResponseFilters(ServerProviderFactory pf, ResponseImpl r, Message m, OperationResourceInfo ori, Method invoked) static Map<ClassResourceInfo,jakarta.ws.rs.core.MultivaluedMap<String, String>> selectResourceClass(List<ClassResourceInfo> resources, String path, Message message) static voidsetMessageContentType(Message message, jakarta.ws.rs.core.Response response) static List<jakarta.ws.rs.core.MediaType>sortMediaTypes(String mediaTypes, String qs) static List<jakarta.ws.rs.core.MediaType>sortMediaTypes(List<jakarta.ws.rs.core.MediaType> types, String qs) static jakarta.ws.rs.core.MediaTypetoMediaType(String value) static jakarta.ws.rs.core.ResponsetoResponse(int status) static jakarta.ws.rs.core.ResponsetoResponse(jakarta.ws.rs.core.Response.Status status) static jakarta.ws.rs.core.Response.ResponseBuildertoResponseBuilder(int status) static jakarta.ws.rs.core.Response.ResponseBuildertoResponseBuilder(jakarta.ws.rs.core.Response.Status status) static voidwriteMessageBody(List<jakarta.ws.rs.ext.WriterInterceptor> writers, Object entity, Class<?> type, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mediaType, jakarta.ws.rs.core.MultivaluedMap<String, Object> httpHeaders, Message message)
-
Field Details
-
ALL_TYPES
public static final jakarta.ws.rs.core.MediaType ALL_TYPES -
ROOT_RESOURCE_CLASS
- See Also:
-
IGNORE_MESSAGE_WRITERS
- See Also:
-
ROOT_INSTANCE
- See Also:
-
ROOT_PROVIDER
- See Also:
-
EXCEPTION_FROM_MAPPER
- See Also:
-
SECOND_JAXRS_EXCEPTION
- See Also:
-
PARTIAL_HIERARCHICAL_MEDIA_SUBTYPE_CHECK
- See Also:
-
DOC_LOCATION
- See Also:
-
MEDIA_TYPE_Q_PARAM
- See Also:
-
MEDIA_TYPE_QS_PARAM
- See Also:
-
-
Method Details
-
isStreamingLikeOutType
Consider additional types as stream-like and returns if the class and corresponding type refer to one of those.- Parameters:
cls- class to checktype- type to check- Returns:
- "true" is the class and corresponding type could be considered streaming-like, "false" otherwise.
-
isStreamingOutType
-
getPathSegments
-
getPathSegments
public static List<jakarta.ws.rs.core.PathSegment> getPathSegments(String thePath, boolean decode, boolean ignoreLastSlash) Parses path segments taking into account the URI templates and template regexes. Per RFC-3986, "A path consists of a sequence of path segments separated by a slash ("/") character.", however it is possible to include slash ("/") inside template regex, for example "/my/path/{a:b/c}", see pleaseURITemplate. In this case, the whole template definition is extracted as a path segment, without breaking it.- Parameters:
thePath- pathdecode- should the path segments be decoded or notignoreLastSlash- should the last slash be ignored or not- Returns:
-
getProviderConsumeTypes
public static List<jakarta.ws.rs.core.MediaType> getProviderConsumeTypes(jakarta.ws.rs.ext.MessageBodyReader<?> provider) -
getProviderProduceTypes
public static List<jakarta.ws.rs.core.MediaType> getProviderProduceTypes(jakarta.ws.rs.ext.MessageBodyWriter<?> provider) -
getMediaTypes
-
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,jakarta.ws.rs.core.MultivaluedMap<String, selectResourceClassString>> (List<ClassResourceInfo> resources, String path, Message message) -
findTargetMethod
public static OperationResourceInfo findTargetMethod(Map<ClassResourceInfo, jakarta.ws.rs.core.MultivaluedMap<String, String>> matchedResources, Message message, String httpMethod, jakarta.ws.rs.core.MultivaluedMap<String, String> matchedValues, String requestContentType, List<jakarta.ws.rs.core.MediaType> acceptContentTypes) -
findTargetMethod
public static OperationResourceInfo findTargetMethod(Map<ClassResourceInfo, jakarta.ws.rs.core.MultivaluedMap<String, String>> matchedResources, Message message, String httpMethod, jakarta.ws.rs.core.MultivaluedMap<String, String> matchedValues, String requestContentType, List<jakarta.ws.rs.core.MediaType> acceptContentTypes, boolean throwException, boolean recordMatchedUri) -
getExceptionLogLevel
-
getRootResources
-
noResourceMethodForOptions
public static boolean noResourceMethodForOptions(jakarta.ws.rs.core.Response exResponse, String httpMethod) -
createResponse
public static jakarta.ws.rs.core.Response createResponse(List<ClassResourceInfo> cris, Message msg, String responseMessage, int status, boolean addAllow) -
headMethodPossible
-
getConsumeTypes
-
getConsumeTypes
-
getProduceTypes
-
getProduceTypes
-
compareSortedConsumesMediaTypes
-
compareSortedAcceptMediaTypes
-
compareSortedMediaTypes
-
compareMethodParameters
-
compareMediaTypes
public static int compareMediaTypes(jakarta.ws.rs.core.MediaType mt1, jakarta.ws.rs.core.MediaType mt2) -
compareMediaTypes
public static int compareMediaTypes(jakarta.ws.rs.core.MediaType mt1, jakarta.ws.rs.core.MediaType mt2, String qs) -
compareMediaTypesQualityFactors
public static int compareMediaTypesQualityFactors(jakarta.ws.rs.core.MediaType mt1, jakarta.ws.rs.core.MediaType mt2) -
compareMediaTypesQualityFactors
public static int compareMediaTypesQualityFactors(jakarta.ws.rs.core.MediaType mt1, jakarta.ws.rs.core.MediaType mt2, String qs) -
getMediaTypeQualityFactor
-
processParameters
public static List<Object> processParameters(OperationResourceInfo ori, jakarta.ws.rs.core.MultivaluedMap<String, String> values, Message message) throws IOException, jakarta.ws.rs.WebApplicationException- Throws:
IOExceptionjakarta.ws.rs.WebApplicationException
-
createHttpParameterValue
public static Object createHttpParameterValue(Parameter parameter, Class<?> parameterClass, Type genericParam, Annotation[] paramAnns, Message message, jakarta.ws.rs.core.MultivaluedMap<String, String> values, OperationResourceInfo ori) -
getMatrixParams
-
createBeanParamValue
-
getContextMessage
-
createContextValue
-
createContextResolver
-
createResourceValue
-
getStructuredParams
public static jakarta.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- Returns:
- a Map of query parameters.
-
getStructuredParams
-
getStructuredParams
-
readFromMessageBodyReader
public static Object readFromMessageBodyReader(List<jakarta.ws.rs.ext.ReaderInterceptor> readers, Class<?> targetTypeClass, Type parameterType, Annotation[] parameterAnnotations, InputStream is, jakarta.ws.rs.core.MediaType mediaType, Message m) throws IOException, jakarta.ws.rs.WebApplicationException - Throws:
IOExceptionjakarta.ws.rs.WebApplicationException
-
writeMessageBody
public static void writeMessageBody(List<jakarta.ws.rs.ext.WriterInterceptor> writers, Object entity, Class<?> type, Type genericType, Annotation[] annotations, jakarta.ws.rs.core.MediaType mediaType, jakarta.ws.rs.core.MultivaluedMap<String, Object> httpHeaders, Message message) throws jakarta.ws.rs.WebApplicationException, IOException- Throws:
jakarta.ws.rs.WebApplicationExceptionIOException
-
matchConsumeTypes
public static boolean matchConsumeTypes(jakarta.ws.rs.core.MediaType requestContentType, OperationResourceInfo ori) -
matchProduceTypes
public static boolean matchProduceTypes(jakarta.ws.rs.core.MediaType acceptContentType, OperationResourceInfo ori) -
matchMimeTypes
public static boolean matchMimeTypes(jakarta.ws.rs.core.MediaType requestContentType, jakarta.ws.rs.core.MediaType acceptContentType, OperationResourceInfo ori) -
parseMediaTypes
-
doMimeTypesIntersect
public static boolean doMimeTypesIntersect(List<jakarta.ws.rs.core.MediaType> mimeTypesA, jakarta.ws.rs.core.MediaType mimeTypeB) -
doMimeTypesIntersect
-
intersectMimeTypes
public static List<jakarta.ws.rs.core.MediaType> intersectMimeTypes(List<jakarta.ws.rs.core.MediaType> requiredMediaTypes, List<jakarta.ws.rs.core.MediaType> userMediaTypes, boolean addRequiredParamsIfPossible) intersect two mime types- Parameters:
requiredMediaTypes-userMediaTypes-addRequiredParamsIfPossible-- Returns:
- return a list of intersected mime types
-
intersectMimeTypes
-
intersectMimeTypes
-
intersectMimeTypes
-
sortMediaTypes
-
sortMediaTypes
-
convertFaultToResponse
-
setMessageContentType
-
getClassQName
-
convertStringToQName
-
runContainerRequestFilters
public static boolean runContainerRequestFilters(ServerProviderFactory pf, Message m, boolean preMatch, Set<String> names) throws IOException - Throws:
IOException
-
runContainerResponseFilters
public static void runContainerResponseFilters(ServerProviderFactory pf, ResponseImpl r, Message m, OperationResourceInfo ori, Method invoked) throws IOException, Throwable - Throws:
IOExceptionThrowable
-
mediaTypeToString
-
toMediaType
-
toResponse
public static jakarta.ws.rs.core.Response toResponse(int status) -
toResponse
public static jakarta.ws.rs.core.Response toResponse(jakarta.ws.rs.core.Response.Status status) -
toResponseBuilder
public static jakarta.ws.rs.core.Response.ResponseBuilder toResponseBuilder(int status) -
toResponseBuilder
public static jakarta.ws.rs.core.Response.ResponseBuilder toResponseBuilder(jakarta.ws.rs.core.Response.Status status) -
fromResponse
public static jakarta.ws.rs.core.Response.ResponseBuilder fromResponse(jakarta.ws.rs.core.Response response) -
fromResponse
public static jakarta.ws.rs.core.Response.ResponseBuilder fromResponse(jakarta.ws.rs.core.Response response, boolean copyEntity) -
copyResponseIfNeeded
public static jakarta.ws.rs.core.Response copyResponseIfNeeded(jakarta.ws.rs.core.Response response) -
getCurrentMessage
-
getRootResource
-
pushOntoStack
public static void pushOntoStack(OperationResourceInfo ori, jakarta.ws.rs.core.MultivaluedMap<String, String> params, Message msg) -
logMessageHandlerProblem
-
getUriTemplate
public static String getUriTemplate(Message message, ClassResourceInfo cri, OperationResourceInfo ori, OperationResourceInfo subOri) Get path URI template, combining base path, class & method & subresource templates- Parameters:
message- message instancecri- class resource infoori- operation resource infosubOri- operation subresource info- Returns:
- the URI template for the method in question
-
getUriTemplate
public static String getUriTemplate(Message message, ClassResourceInfo cri, OperationResourceInfo ori) Get path URI template, combining base path, class & method templates- Parameters:
message- message instancecri- class resource infoori- operation resource info- Returns:
- the URI template for the method in question
-