Package javax.ws.rs.core

Examples of javax.ws.rs.core.UriInfo


        @Override
        public Response apply(ContainerRequestContext containerRequestContext) {

            final RuntimeResource resource = extendedUriInfo.getMatchedRuntimeResources().get(0);
            // TODO: support multiple resources, see ignored tests in WadlResourceTest.Wadl8Test
            final UriInfo uriInfo = containerRequestContext.getUriInfo();

            final Application wadlApplication = wadlApplicationContext.getApplication(uriInfo,
                    resource.getResources().get(0), WadlUtils.isDetailedWadlRequested(uriInfo));

            if (wadlApplication == null) {
View Full Code Here


    }


    @Override
    public void filter(ContainerRequestContext rc) throws IOException {
        UriInfo uriInfo = rc.getUriInfo();

        // Quick check for a '.' character
        String path = uriInfo.getRequestUri().getRawPath();
        if (path.indexOf('.') == -1) {
            return;
        }

        List<PathSegment> l = uriInfo.getPathSegments(false);
        if (l.isEmpty()) {
            return;
        }

        // Get the last non-empty path segment
        PathSegment segment = null;
        for (int i = l.size() - 1; i >= 0; i--) {
            segment = l.get(i);
            if (segment.getPath().length() > 0) {
                break;
            }
        }
        if (segment == null) {
            return;
        }

        final int length = path.length();

        // Get the suffixes
        final String[] suffixes = segment.getPath().split("\\.");

        for (int i = suffixes.length - 1; i >= 1; i--) {
            final String suffix = suffixes[i];
            if (suffix.length() == 0) {
                continue;
            }

            final MediaType accept = mediaTypeMappings.get(suffix);

            if (accept != null) {
                rc.getHeaders().putSingle(HttpHeaders.ACCEPT, accept.toString());

                final int index = path.lastIndexOf('.' + suffix);
                path = new StringBuilder(path).delete(index, index + suffix.length() + 1).toString();
                suffixes[i] = "";
                break;
            }
        }

        for (int i = suffixes.length - 1; i >= 1; i--) {
            final String suffix = suffixes[i];
            if (suffix.length() == 0)
                continue;

            final String acceptLanguage = languageMappings.get(suffix);
            if (acceptLanguage != null) {
                rc.getHeaders().putSingle(HttpHeaders.ACCEPT_LANGUAGE, acceptLanguage);

                final int index = path.lastIndexOf('.' + suffix);
                path = new StringBuilder(path).delete(index, index + suffix.length() + 1).toString();
                suffixes[i] = "";
                break;
            }
        }

        if (length != path.length()) {
            rc.setRequestUri(uriInfo.getRequestUriBuilder().replacePath(path).build());
        }
    }
View Full Code Here

    private String getCallbackName(final JSONP jsonp) {
        String callback = jsonp.callback();

        if (!"".equals(jsonp.queryParam())) {
            final ContainerRequest containerRequest = containerRequestProvider.get();
            final UriInfo uriInfo = containerRequest.getUriInfo();
            final MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
            final List<String> queryParameter = queryParameters.get(jsonp.queryParam());

            callback = (queryParameter != null && !queryParameter.isEmpty()) ? queryParameter.get(0) : callback;
        }
View Full Code Here

    request.job.setTitle(title);
    request.job.setPigScript(pigScript);
    request.job.setTempletonArguments(templetonArguments);
    request.job.setForcedContent(forcedContent);

    UriInfo uriInfo = createNiceMock(UriInfo.class);
    URI uri = UriBuilder.fromUri("http://host/a/b").build();
    expect(uriInfo.getAbsolutePath()).andReturn(uri);

    HttpServletResponse resp_obj = createStrictMock(HttpServletResponse.class);

    resp_obj.setHeader(eq("Location"), anyString());
View Full Code Here

        ScriptService.PigScriptRequest request = new ScriptService.PigScriptRequest();
        request.script = new PigScript();
        request.script.setTitle(title);
        request.script.setPigScript(path);

        UriInfo uriInfo = createNiceMock(UriInfo.class);
        URI uri = UriBuilder.fromUri("http://host/a/b").build();
        expect(uriInfo.getAbsolutePath()).andReturn(uri);

        HttpServletResponse resp_obj = createNiceMock(HttpServletResponse.class);

        resp_obj.setHeader(eq("Location"), anyString());
View Full Code Here

    request.file.setFileContent(content);

    HttpServletResponse resp_obj = createNiceMock(HttpServletResponse.class);
    resp_obj.setHeader(eq("Location"), anyString());

    UriInfo uriInfo = createNiceMock(UriInfo.class);
    URI uri = UriBuilder.fromUri("http://host/a/b").build();
    expect(uriInfo.getAbsolutePath()).andReturn(uri);

    replay(resp_obj, uriInfo);
    return fileService.createFile(request, resp_obj, uriInfo);
  }
View Full Code Here

    UDFService.UDFRequest request = new UDFService.UDFRequest();
    request.udf = new UDF();
    request.udf.setPath("/tmp/udf.jar");
    request.udf.setName("TestUDF");

    UriInfo uriInfo = createNiceMock(UriInfo.class);
    URI uri = UriBuilder.fromUri("http://host/a/b").build();
    expect(uriInfo.getAbsolutePath()).andReturn(uri);

    HttpServletResponse resp_obj = createNiceMock(HttpServletResponse.class);

    resp_obj.setHeader(eq("Location"), anyString());
View Full Code Here

    public ResponseBuilder location(URI loc) {
        if (!loc.isAbsolute()) {
            Message currentMessage = PhaseInterceptorChain.getCurrentMessage();
            if (currentMessage != null) {
               
                UriInfo ui = new UriInfoImpl(currentMessage.getExchange().getInMessage(), null);
                loc = ui.getBaseUriBuilder()
                        .path(loc.getRawPath())
                        .replaceQuery(loc.getRawQuery())
                        .fragment(loc.getRawFragment()).buildFromEncoded();
            }
        }
View Full Code Here

        return name != null ? name : bean.getClass().getSimpleName().toLowerCase();
    }

    protected void setRequestParameters(HttpServletRequestFilter request) {
        if (mc != null) {
            UriInfo ui = mc.getUriInfo();
            MultivaluedMap<String, String> params = ui.getPathParameters();
            for (Map.Entry<String, List<String>> entry : params.entrySet()) {
                String value = entry.getValue().get(0);
                int ind = value.indexOf(";");
                if (ind > 0) {
                    value = value.substring(0, ind);
                }
                request.setParameter(entry.getKey(), value);
            }
           
            List<PathSegment> segments = ui.getPathSegments();
            if (segments.size() > 0) {
                doSetRequestParameters(request, segments.get(segments.size() - 1).getMatrixParameters());
            }
            doSetRequestParameters(request, ui.getQueryParameters());
            request.setParameter(ABSOLUTE_PATH_PARAMETER, ui.getAbsolutePath().toString());
            request.setParameter(RELATIVE_PATH_PARAMETER, ui.getPath());
            request.setParameter(BASE_PATH_PARAMETER, ui.getBaseUri().toString());
            request.setParameter(WEBAPP_BASE_PATH_PARAMETER, (String)mc.get("http.base.path"));
        }
    }
View Full Code Here

        assertTrue(customJaxbReader instanceof JAXBElementProvider);
       
        JAXBElementProvider<Book> provider = (JAXBElementProvider<Book>)customJaxbReader;
        MessageContext mc = provider.getContext();
        assertNotNull(mc);
        UriInfo ui = mc.getUriInfo();
        MultivaluedMap<String, String> queries = ui.getQueryParameters();
        assertEquals(1, queries.size());
        List<String> uriQuery = queries.get("uri");
        assertEquals(1, uriQuery.size());
        assertEquals(property, uriQuery.get(0));
       
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.UriInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.