Java Code Examples for org.apache.cxf.jaxrs.utils.HttpUtils#getPathToMatch()

The following examples show how to use org.apache.cxf.jaxrs.utils.HttpUtils#getPathToMatch() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CrossOriginResourceSharingFilter.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Method getResourceMethod(Message m, String httpMethod) {
    String requestUri = HttpUtils.getPathToMatch(m, true);

    List<ClassResourceInfo> resources = JAXRSUtils.getRootResources(m);
    Map<ClassResourceInfo, MultivaluedMap<String, String>> matchedResources =
        JAXRSUtils.selectResourceClass(resources, requestUri, m);
    if (matchedResources == null) {
        return null;
    }
    MultivaluedMap<String, String> values = new MetadataMap<>();
    OperationResourceInfo ori = findPreflightMethod(matchedResources, requestUri, httpMethod, values, m);
    return ori == null ? null : ori.getAnnotatedMethod();
}
 
Example 2
Source File: CxfRsHttpListener.java    From tomee with Apache License 2.0 5 votes vote down vote up
public boolean isCXFResource(final HttpServletRequest request) {
    try {
        Application application = findApplication();
        if (!applicationProvidesResources(application)) {
            JAXRSServiceImpl service = (JAXRSServiceImpl)server.getEndpoint().getService();

            if( service == null ) {
                return false;
            }

            String pathToMatch = HttpUtils.getPathToMatch(request.getServletPath(), pattern, true);

            final List<ClassResourceInfo> resources = service.getClassResourceInfos();
            for (final ClassResourceInfo info : resources) {
                if (info.getResourceClass() == null || info.getURITemplate() == null) { // possible?
                    continue;
                }
               
                final MultivaluedMap<String, String> parameters = new MultivaluedHashMap<>();
                if (info.getURITemplate().match(pathToMatch, parameters)) {
                    return true;
                }
            }
        } else {
            return true;
        }
    } catch (final Exception e) {
        LOGGER.info("No JAX-RS service");
    }
    return false;
}
 
Example 3
Source File: UriInfoImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
private String doGetPath(boolean decode, boolean addSlash) {
    String path = HttpUtils.getPathToMatch(message, addSlash);
    return decode ? HttpUtils.pathDecode(path) : path;
}