@Override public URI getTargetUrl(URI targetPath) { if (targetPath.isAbsolute()) { throw new IllegalArgumentException("Target url was absolute (" + targetPath.toString() + "). Expected relative path to base URL of add-on (" + getBaseUrl().toString() + ")."); } Uri baseUri = Uri.fromJavaUri(getBaseUrl()); String path = baseUri.getPath() + "/" + targetPath.getRawPath(); path = path.replaceAll("/+", "/"); UriBuilder uriBuilder = new UriBuilder(baseUri); uriBuilder.setPath(path); uriBuilder.setQuery(targetPath.getRawQuery()); return uriBuilder.toUri().toJavaUri(); }
public String getAbsoluteUrl(String pluginKey, String url) throws URISyntaxException { URI uri = new URI(url); if (!uri.isAbsolute()) { RemotablePluginAccessor remotablePluginAccessor = remotablePluginAccessorFactory.get(pluginKey); URI baseUrl = remotablePluginAccessor.getBaseUrl(); return new UriBuilder() .setScheme(baseUrl.getScheme()) .setAuthority(baseUrl.getAuthority()) .setPath(uri.getPath()) .setQuery(uri.getQuery()) .setFragment(uri.getFragment()) .toString(); } return url; }
public URI getTargetUrl(URI targetPath) { if (targetPath.isAbsolute()) { throw new IllegalArgumentException("Target url was absolute (" + targetPath.toString() + "). Expected relative path to base URL of add-on (" + getBaseUrl().toString() + ")."); } UriBuilder uriBuilder = new UriBuilder(Uri.fromJavaUri(getBaseUrl())); String path = new PathBuilder() .withPathFragment(uriBuilder.getPath()) .withPathFragment(targetPath.getRawPath()) .build(); uriBuilder.setPath(path); uriBuilder.setQuery(targetPath.getRawQuery()); uriBuilder.setFragment(targetPath.getFragment()); return uriBuilder.toUri().toJavaUri(); }
public URI getTargetUrl(URI targetPath) { if (targetPath.isAbsolute()) { throw new IllegalArgumentException("Target url was absolute (" + targetPath.toString() + "). Expected relative path to base URL of add-on (" + getBaseUrl().toString() + ")."); } UriBuilder uriBuilder = new UriBuilder(Uri.fromJavaUri(getBaseUrl())); String path = new PathBuilder() .withPathFragment(uriBuilder.getPath()) .withPathFragment(targetPath.getRawPath()) .build(); uriBuilder.setPath(path); uriBuilder.setQuery(targetPath.getRawQuery()); return uriBuilder.toUri().toJavaUri(); }
public String getAbsoluteUrl(ShallowConnectAddonBean addon, String url) { try { URI uri = new URI(url); if (!uri.isAbsolute()) { URI baseUrl = remotablePluginAccessorFactory.get(addon).getBaseUrl(); return new UriBuilder() .setScheme(baseUrl.getScheme()) .setAuthority(baseUrl.getAuthority()) .setPath(uri.getPath()) .setQuery(uri.getQuery()) .setFragment(uri.getFragment()) .toString(); } return url; } catch (URISyntaxException e) { throw new PluginParseException("Malformed url declared by " + addon.getKey() + ": " + url, e); } } }