@Override public String createURI(String location) { return format("%s://%s", newScheme, URIUtils.getAuthority(location)); } }
@Override protected PipeResourceAddress newResourceAddress0(String original, String location) { // Unlike a normal-looking URI, our custom "pipe://" does not have // host/port/path components. Instead, the authority component // suffices. String pipeName = URIUtils.getAuthority(location); String pathName = URIUtils.getPath(location); if (pipeName == null) { throw new IllegalArgumentException(String.format("URI %s missing pipe name", location)); } if (pathName != null && !pathName.isEmpty()) { throw new IllegalArgumentException(String.format(PIPE_PATH_ERROR_MESSAGE, pipeName, pipeName, pathName)); } URI uriLocation = URI.create(location); return new PipeResourceAddress(this, original, uriLocation); }
public ServiceContext register(String serviceURI, ServiceContext serviceContext) { if (getQuery(serviceURI) != null || getFragment(serviceURI) != null) { throw new IllegalArgumentException("Service URI query and fragment must be null"); } ServiceAuthority serviceAuthority = entries.get(getAuthority(serviceURI)); if (serviceAuthority == null) { serviceAuthority = new ServiceAuthority(); entries.put(getAuthority(serviceURI), serviceAuthority); } ServiceRegistration serviceRegistration = serviceAuthority.register(serviceURI, serviceContext); return (serviceRegistration != null) ? serviceRegistration.getServiceContext() : null; }
public static String appendURI(String uri, String postfix) { String scheme = URIUtils.getScheme(uri); String authority = URIUtils.getAuthority(uri); String path = URIUtils.getPath(uri); String query = URIUtils.getQuery(uri); String fragment = URIUtils.getFragment(uri); try { return URIUtils.buildURIAsString(scheme, authority, MULTIPLE_SLASHES.matcher(path + postfix).replaceAll(SINGLE_SLASH), query, fragment); } catch (URISyntaxException x) { IllegalArgumentException y = new IllegalArgumentException(); y.initCause(x); throw y; } }
public static String mergeQueryParameters(URI from, String into) throws URISyntaxException { if (into == null) { throw new URISyntaxException("<null>", "Cannot merge into a null URI"); } if (from == null) { return into; } final String fromQuery = from.getQuery(); final String intoQuery = URIUtils.getQuery(into); String query; if (intoQuery == null) { query = from.getQuery(); } else if (fromQuery == null) { query = intoQuery; } else { query = intoQuery; if (fromQuery.length() > 0) { query += '&' + fromQuery; } } return URIUtils.buildURIAsString(URIUtils.getScheme(into), URIUtils.getAuthority(into), URIUtils.getPath(into), query, URIUtils.getFragment(into)); }
private Collection<String> toHttpBalanceOriginURIs(Collection<String> balances) { if (balances == null || balances.isEmpty()) { return balances; } List<String> result = new ArrayList<>(balances.size()); for (String uri : balances) { if (uri != null) { try { final String scheme = getScheme(uri); if ("ws".equals(scheme)) { result.add(buildURIAsString("http", getAuthority(uri), getPath(uri), getQuery(uri), getFragment(uri))); } else if ("wss".equals(scheme)) { result.add(buildURIAsString("https", getAuthority(uri), getPath(uri), getQuery(uri), getFragment(uri))); } else { result.add(uri); } } catch (URISyntaxException e) { if (logger.isDebugEnabled()) { logger.warn(String.format("Cannot translate balanc uri '%s' into a http balance origin.", uri)); } } } } return result; }
public static String ensureTrailingSlash(String uri) { String newPath = URIUtils.getPath(uri); if ( newPath == null || newPath.equals("")) { newPath = "/"; } try { String scheme = URIUtils.getScheme(uri); String authority = URIUtils.getAuthority(uri); String query = URIUtils.getQuery(uri); String fragment = URIUtils.getFragment(uri); return URIUtils.buildURIAsString(scheme, authority, newPath, query, fragment); } catch (URISyntaxException x) { IllegalArgumentException y = new IllegalArgumentException(); y.initCause(x); throw y; } }
public static String modifyURIPath(String uri, String newPath) { String path = URIUtils.getPath(uri); if (newPath.equals(path)) { return uri; } String scheme = URIUtils.getScheme(uri); String authority = URIUtils.getAuthority(uri); String query = URIUtils.getQuery(uri); String fragment = URIUtils.getFragment(uri); try { return URIUtils.buildURIAsString(scheme, authority, newPath, query, fragment); } catch (URISyntaxException x) { IllegalArgumentException y = new IllegalArgumentException(); y.initCause(x); throw y; } }
boolean secure = protocol.isSecure(); String wsBalancerUriScheme = secure ? scheme+"+ssl" : scheme; String httpAuthority = getAuthority(uri); String httpPath = getPath(uri); String httpQuery = getQuery(uri); String authority = getAuthority(internalURI); acceptOptionsCtx.addBind(wsBalancerUriScheme, authority);
@Override public String getInternalURI(String externalURI) { String authority = getAuthority(externalURI); String internalAuthority = binds.get(getScheme(externalURI)); if (internalAuthority != null) { if (!internalAuthority.equals(authority)) { try { return buildURIAsString(getScheme(externalURI), internalAuthority, getPath(externalURI), getQuery(externalURI), getFragment(externalURI)); } catch (URISyntaxException e) { // ignore } } return externalURI; } // there's no binding for this URI, return null return null; }
mappedURIs.add(serviceAccept); } else { mappedURIs.add(serviceAccept + " @ " + URIUtils.getAuthority(mappedURI));
selectedBalanceeURI = buildURIAsString(balanceeScheme, getAuthority(selectedBalanceeURI), balanceePath, balanceeQuery, null);
String httpAuthority = getAuthority(uri); String httpPath = getPath(uri); String httpQuery = getQuery(uri); String authority = getAuthority(internalURI); acceptOptionsCtx.addBind(httpScheme, authority);
String authority = getAuthority(acceptURI); if (authority.indexOf(':') == -1) { SchemeConfig schemeConfig = supplySchemeConfig(getScheme(acceptURI));
String acceptURI = acceptToConstraints.getKey(); if (URIUtils.getAuthority(acceptURI).equals(requestAuthority)) {
boolean targetIsSecure = "https".equals(URIUtils.getScheme(targetURI)); String targetScheme = URIUtils.getScheme(targetURI); String targetAuthority = HttpUtils.getHostAndPort(URIUtils.getAuthority(targetURI), targetIsSecure); if ("privileged".equals(originScheme) || ((targetScheme.equals(originScheme) && targetAuthority.equals(originAuthority)))) {
Protocol protocol = bridgeServiceFactory.getTransportFactory().getProtocol(URIUtils.getScheme(resource)); String wsScheme = protocol.isSecure() ? "https" : "http"; String origin = wsScheme + "://" + URIUtils.getAuthority(resource);