Java Code Examples for javax.ws.rs.core.UriBuilder#replacePath()
The following examples show how to use
javax.ws.rs.core.UriBuilder#replacePath() .
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: DcCoreContainerFilter.java From io with Apache License 2.0 | 5 votes |
/** * Uriのオーバーライド処理. * @param request 加工するリクエスト */ private void uriOverride(final ContainerRequest request) { String xForwardedProto = request.getHeaderValue(DcCoreUtils.HttpHeaders.X_FORWARDED_PROTO); String xForwardedHost = request.getHeaderValue(DcCoreUtils.HttpHeaders.X_FORWARDED_HOST); String xForwardedPath = request.getHeaderValue(DcCoreUtils.HttpHeaders.X_FORWARDED_PATH); UriBuilder bub = request.getBaseUriBuilder(); UriBuilder rub = request.getRequestUriBuilder(); if (xForwardedProto != null) { bub.scheme(xForwardedProto); rub.scheme(xForwardedProto); } if (xForwardedHost != null) { bub.host(xForwardedHost); rub.host(xForwardedHost); } if (xForwardedPath != null) { bub.replacePath("/"); // クエリを含んでいる場合は、クエリを削除してリクエストパスに設定する if (xForwardedPath.contains("?")) { xForwardedPath = xForwardedPath.substring(0, xForwardedPath.indexOf("?")); } rub.replacePath(xForwardedPath); } request.setUris(bub.build(), rub.build()); }
Example 2
Source File: DataResourceLocator.java From onos with Apache License 2.0 | 5 votes |
private static URI removeDeviceProxyPrefix(URI uri) { if (uri == null) { return null; } UriBuilder builder = UriBuilder.fromUri(uri); String newPath = rmDeviceStr(uri.getRawPath()); builder.replacePath(newPath); return builder.build(); }
Example 3
Source File: RestconfUtils.java From onos with Apache License 2.0 | 5 votes |
/** * Removes the last path segment from the given URI. That is, returns * the parent of the given URI. * * @param uri given URI * @return parent URI */ public static URI rmLastPathSegment(URI uri) { if (uri == null) { return null; } UriBuilder builder = UriBuilder.fromUri(uri); String newPath = rmLastPathSegmentStr(uri.getRawPath()); builder.replacePath(newPath); return builder.build(); }
Example 4
Source File: KeycloakUriInfo.java From keycloak with Apache License 2.0 | 5 votes |
private UriBuilder initUriBuilder(UriBuilder b) { b.scheme(scheme); b.host(hostname); b.port(port); b.replacePath(contextPath); return b; }
Example 5
Source File: PreviewUrlLinksVariableGenerator.java From che with Eclipse Public License 2.0 | 4 votes |
private String createPreviewUrlLinkValue(UriBuilder uriBuilder, Command command) { UriBuilder previewUriBuilder = uriBuilder.clone().host(command.getAttributes().get(PREVIEW_URL_ATTRIBUTE)); previewUriBuilder.replacePath(null); return previewUriBuilder.build().toString(); }
Example 6
Source File: ContentViewerController.java From nifi with Apache License 2.0 | 4 votes |
/** * @param request request * @return Get the content request context based on the specified request */ @SuppressWarnings("deprecation") private ContentRequestContext getContentRequest(final HttpServletRequest request) { final String ref = request.getParameter("ref"); final String clientId = request.getParameter("clientId"); final UriBuilder refUriBuilder = UriBuilder.fromUri(ref); // base the data ref on the request parameter but ensure the scheme is based off the incoming request... // this is necessary for scenario's where the NiFi instance is behind a proxy running a different scheme refUriBuilder.scheme(request.getScheme()); // If there is path context from a proxy, remove it since this request will be used inside the cluster final String proxyContextPath = getFirstHeaderValue(request, PROXY_CONTEXT_PATH_HTTP_HEADER, FORWARDED_CONTEXT_HTTP_HEADER, FORWARDED_PREFIX_HTTP_HEADER); if (StringUtils.isNotBlank(proxyContextPath)) { refUriBuilder.replacePath(StringUtils.substringAfter(UriBuilder.fromUri(ref).build().getPath(), proxyContextPath)); } final URI refUri = refUriBuilder.build(); final String query = refUri.getQuery(); String rawClusterNodeId = null; if (query != null) { final String[] queryParameters = query.split("&"); for (int i = 0; i < queryParameters.length; i++) { if (queryParameters[0].startsWith("clusterNodeId=")) { rawClusterNodeId = StringUtils.substringAfterLast(queryParameters[0], "clusterNodeId="); } } } final String clusterNodeId = rawClusterNodeId; return new ContentRequestContext() { @Override public String getDataUri() { return refUri.toString(); } @Override public String getClusterNodeId() { return clusterNodeId; } @Override public String getClientId() { return clientId; } @Override public String getProxiedEntitiesChain() { return null; } }; }