private synchronized URI createNextResultsUri(String scheme, UriInfo uriInfo) { return uriInfo.getBaseUriBuilder() .scheme(scheme) .replacePath("/v1/statement") .path(queryId.toString()) .path(String.valueOf(resultId.incrementAndGet())) .replaceQuery("") .build(); }
@Override public URI getAbsolutePath() { if (absolutePathUri != null) return absolutePathUri; return absolutePathUri = UriBuilder.fromUri(requestUri). replaceQuery("").fragment(""). build(); }
private URI getRedirectBaseUri(URI locationURI) { if (locationURI == null) { throw new TransportException("Missing Location header in the redirect reply"); } Matcher pathMatcher = REDIRECT_PATH_REGEX.matcher(locationURI.getPath()); if (pathMatcher.matches()) { return UriBuilder.fromUri(locationURI) .host(dnsService.resolveIp(locationURI.getHost())) .replacePath(pathMatcher.group(1)) .replaceQuery(null) .build(); } logger.warn("Invalid redirect URL {}", locationURI); return null; } }
private void addHint(Application wadlApplication) { // TODO: this not-null check is here only because of unit tests if (uriInfo != null) { Doc d = new Doc(); String message; if (detailedWadl) { final String uriWithoutQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()).replaceQuery("").build() .toString(); message = LocalizationMessages.WADL_DOC_EXTENDED_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithoutQueryParam); } else { final String uriWithQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()) .queryParam(WadlUtils.DETAILED_WADL_QUERY_PARAM, "true").build().toString(); message = LocalizationMessages.WADL_DOC_SIMPLE_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithQueryParam); } d.getOtherAttributes().put(new QName(WadlApplicationContextImpl.WADL_JERSEY_NAMESPACE, "hint", "jersey"), message); wadlApplication.getDoc().add(d); } }
private void addHint(Application wadlApplication) { // TODO: this not-null check is here only because of unit tests if (uriInfo != null) { Doc d = new Doc(); String message; if (detailedWadl) { final String uriWithoutQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()).replaceQuery("").build() .toString(); message = LocalizationMessages.WADL_DOC_EXTENDED_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithoutQueryParam); } else { final String uriWithQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()) .queryParam(WadlUtils.DETAILED_WADL_QUERY_PARAM, "true").build().toString(); message = LocalizationMessages.WADL_DOC_SIMPLE_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithQueryParam); } d.getOtherAttributes().put(new QName(WadlApplicationContextImpl.WADL_JERSEY_NAMESPACE, "hint", "jersey"), message); wadlApplication.getDoc().add(d); } }
private void setHeaders(MultivaluedMap<String, Object> headers) { this.headers = headers; Object location = headers.getFirst(HttpHeaders.LOCATION); if (location != null) { if (location instanceof URI) { final URI locationUri = (URI)location; if (!locationUri.isAbsolute()) { final URI base = (statusType.getStatusCode() == Status.CREATED.getStatusCode()) ? request.getAbsolutePath() : request.getBaseUri(); location = UriBuilder.fromUri(base). path(locationUri.getRawPath()). replaceQuery(locationUri.getRawQuery()). fragment(locationUri.getRawFragment()). build(); } headers.putSingle(HttpHeaders.LOCATION, location); } } }
/** * This method checks path of the incoming request, and * redirects following URIs: * <li>/controller -> SiteToSiteResource * @param requestContext request to be modified */ @Override public void filter(ContainerRequestContext requestContext) throws IOException { final UriInfo uriInfo = requestContext.getUriInfo(); if (uriInfo.getPath().equals("controller")){ UriBuilder builder = UriBuilder.fromUri(uriInfo.getBaseUri()) .path(SiteToSiteResource.class) .replaceQuery(uriInfo.getRequestUri().getRawQuery()); URI redirectTo = builder.build(); requestContext.setRequestUri(uriInfo.getBaseUri(), redirectTo); } } }
.replaceQuery(ContainerUtils.encodeUnsafeCharacters(queryString)) .build(); } catch (final IllegalArgumentException iae) {
.replaceQuery(ContainerUtils.encodeUnsafeCharacters(queryString)) .build(); } catch (final IllegalArgumentException iae) {
public WebApplicationContext createMatchResourceContext(URI u) { final URI base = request.getBaseUri(); if (u.isAbsolute()) { // TODO check if base is a base of u URI r = base.relativize(u); if (r == u) { throw new ContainerException("The URI " + u + " is not relative to the base URI " + base); } } else { u = UriBuilder.fromUri(base). path(u.getRawPath()). replaceQuery(u.getRawQuery()). fragment(u.getRawFragment()). build(); } final ContainerRequest _request = new ContainerRequest(app, HTTP_METHOD_MATCH_RESOURCE, base, u, new InBoundHeaders(), new ByteArrayInputStream(new byte[0])); _request.setSecurityContext(request.getSecurityContext()); // Propagate security context final ContainerResponse _response = new ContainerResponse(app, _request, null); return new WebApplicationContext(app, _request, _response); }
.replaceQuery(queryParameters) .build(); } catch (final UriBuilderException | IllegalArgumentException ex) {
.replaceQuery(queryParameters) .build(); } catch (final UriBuilderException | IllegalArgumentException ex) {
.scheme(scheme) .replacePath("ui/query.html") .replaceQuery(queryId.toString()) .build();
/** Rebuild the URI query with lower case parameter names. */ private static URI rebuildQuery(final URI uri, final MultivaluedMap<String, String> parameters) { UriBuilder b = UriBuilder.fromUri(uri).replaceQuery(""); for(Map.Entry<String, List<String>> e : parameters.entrySet()) { final String key = StringUtils.toLowerCase(e.getKey()); for(String v : e.getValue()) { b = b.queryParam(key, v); } } return b.build(); } }
@Override public URI relativize(URI uri) { URI from = getRequestUri(); URI to = uri; if (uri.getScheme() == null && uri.getHost() == null) { to = getBaseUriBuilder().replaceQuery(null).path(uri.getPath()).replaceQuery(uri.getQuery()).fragment(uri.getFragment()).build(); } return ResteasyUriBuilderImpl.relativize(from, to); }
public ResteasyUriInfo(final URI base, final URI relative) { String b = base.toString(); if (!b.endsWith("/")) b += "/"; String r = relative.getRawPath(); if (r.startsWith("/")) { encodedPath = r; path = relative.getPath(); } else { encodedPath = "/" + r; path = "/" + relative.getPath(); } UriBuilder requestUriBuilder = UriBuilder.fromUri(base).path(relative.getRawPath()).replaceQuery(relative.getRawQuery()); requestURI = requestUriBuilder.build(); absolutePath = requestUriBuilder.replaceQuery(null).build(); baseURI = base; processPath(); }
private static MockHttpRequest initWithUri(URI absoluteUri, URI baseUri) { if (baseUri == null) baseUri = EMPTY_URI; MockHttpRequest request = new MockHttpRequest(); request.httpHeaders = new ResteasyHttpHeaders(new CaseInsensitiveMap<String>()); //request.uri = new UriInfoImpl(absoluteUri, absoluteUri, absoluteUri.getPath(), absoluteUri.getQuery(), PathSegmentImpl.parseSegments(absoluteUri.getPath())); // remove query part URI absolutePath = UriBuilder.fromUri(absoluteUri).replaceQuery(null).build(); // path must be relative to the application's base uri URI relativeUri = baseUri.relativize(absoluteUri); relativeUri = UriBuilder.fromUri(relativeUri.getRawPath()).replaceQuery(absoluteUri.getRawQuery()).build(); request.uri = new ResteasyUriInfo(absoluteUri.toString(), absoluteUri.getRawQuery(), baseUri.getRawPath()); return request; }
public void initializeFromRequest(URI requestURI) { String r = requestURI.getRawPath(); if (r.startsWith("/")) { encodedPath = r; path = requestURI.getPath(); } else { encodedPath = "/" + r; path = "/" + requestURI.getPath(); } this.requestURI = requestURI; baseURI = UriBuilder.fromUri(requestURI).replacePath("").build(); absolutePath = UriBuilder.fromUri(requestURI).replaceQuery(null).build(); processPath(); }
public void setUri(URI base, URI relative) { clearQueryParameters(true); clearQueryParameters(false); URI rel = base.resolve(relative); String absoluteUri = UriBuilder.fromUri(rel).replaceQuery(null).toTemplate(); initialize(absoluteUri, rel.getRawQuery(), base.getRawPath()); }
private void addHint(Application wadlApplication) { // TODO: this not-null check is here only because of unit tests if (uriInfo != null) { Doc d = new Doc(); String message; if (detailedWadl) { final String uriWithoutQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()).replaceQuery("").build() .toString(); message = LocalizationMessages.WADL_DOC_EXTENDED_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithoutQueryParam); } else { final String uriWithQueryParam = UriBuilder.fromUri(uriInfo.getRequestUri()) .queryParam(WadlUtils.DETAILED_WADL_QUERY_PARAM, "true").build().toString(); message = LocalizationMessages.WADL_DOC_SIMPLE_WADL(WadlUtils.DETAILED_WADL_QUERY_PARAM, uriWithQueryParam); } d.getOtherAttributes().put(new QName(WadlApplicationContextImpl.WADL_JERSEY_NAMESPACE, "hint", "jersey"), message); wadlApplication.getDoc().add(d); } }