@Test public void testToUriComponentsEncodeSpaces() { UriComponents uri = RpcUriUtils.toUriComponents("vrpcb: uri = uri.encode(); assertThat(uri.getScheme(), is(VISTA_RPC_BROKER_SCHEME)); assertThat(uri.getHost(), is("example.org")); assertThat(uri.getPort(), is(1234)); assertThat(uri.getPathSegments(), hasItems("FOO%20BAR", "BAZ%20SPAZ")); }
public static UriComponents toUriComponents(String uri) { int ssp = uri.indexOf(": int at = uri.lastIndexOf("@"); if (ssp != -1 && at != -1) { String userInfo = uri.substring(ssp + 3, at); int slash = uri.indexOf("/", at); String hostAndPort = (slash != -1 ? uri.substring(at + 1, slash) : uri.substring(at + 1)); int colon = hostAndPort.indexOf(":"); String host = hostAndPort; String port = null; if (colon != -1) { host = hostAndPort.substring(0, colon); port = hostAndPort.substring(colon + 1); } String path = (slash != -1 ? uri.substring(slash) : null); UriComponentsBuilder builder = UriComponentsBuilder.newInstance() .scheme(uri.substring(0, ssp)) .userInfo(userInfo) .host(host); if (StringUtils.hasText(port)) { builder.port(Integer.parseInt(port)); } builder.path(path); UriComponents uriComponents = builder.build(); return uriComponents; } else { UriComponents uriComponents = UriComponentsBuilder.fromUriString(uri).build(); return uriComponents; } }
RpcUriUtils { public static UriComponents toUriComponents(String uri) { int ssp = uri.indexOf(": int at = uri.lastIndexOf("@"); if (ssp != -1 && at != -1) { String userInfo = uri.substring(ssp + 3, at); int slash = uri.indexOf("/", at); String hostAndPort = (slash != -1 ? uri.substring(at + 1, slash) : uri.substring(at + 1)); int colon = hostAndPort.indexOf(":"); String host = hostAndPort; String port = null; if (colon != -1) { host = hostAndPort.substring(0, colon); port = hostAndPort.substring(colon + 1); } String path = (slash != -1 ? uri.substring(slash) : null); UriComponentsBuilder builder = UriComponentsBuilder.newInstance() .scheme(uri.substring(0, ssp)) .userInfo(userInfo) .host(host); if (StringUtils.hasText(port)) { builder.port(Integer.parseInt(port)); } builder.path(path); UriComponents uriComponents = builder.build(); return uriComponents; } else { UriComponents uriComponents = UriComponentsBuilder.fromUriString(uri).build(); return uriComponents; } } }
RpcUriUtils { public static UriComponents toUriComponents(String uri) { int ssp = uri.indexOf(": int at = uri.lastIndexOf("@"); if (ssp != -1 && at != -1) { String userInfo = uri.substring(ssp + 3, at); int slash = uri.indexOf("/", at); String hostAndPort = (slash != -1 ? uri.substring(at + 1, slash) : uri.substring(at + 1)); int colon = hostAndPort.indexOf(":"); String host = hostAndPort; String port = null; if (colon != -1) { host = hostAndPort.substring(0, colon); port = hostAndPort.substring(colon + 1); } String path = (slash != -1 ? uri.substring(slash) : null); UriComponentsBuilder builder = UriComponentsBuilder.newInstance() .scheme(uri.substring(0, ssp)) .userInfo(userInfo) .host(host); if (StringUtils.hasText(port)) { builder.port(Integer.parseInt(port)); } builder.path(path); UriComponents uriComponents = builder.build(); return uriComponents; } else { UriComponents uriComponents = UriComponentsBuilder.fromUriString(uri).build(); return uriComponents; } }  }
RpcUriUtils { public static UriComponents toUriComponents(String uri) { int ssp = uri.indexOf(": int at = uri.lastIndexOf("@"); if (ssp != -1 && at != -1) { String userInfo = uri.substring(ssp + 3, at); int slash = uri.indexOf("/", at); String hostAndPort = (slash != -1 ? uri.substring(at + 1, slash) : uri.substring(at + 1)); int colon = hostAndPort.indexOf(":"); String host = hostAndPort; String port = null; if (colon != -1) { host = hostAndPort.substring(0, colon); port = hostAndPort.substring(colon + 1); } String path = (slash != -1 ? uri.substring(slash) : null); UriComponentsBuilder builder = UriComponentsBuilder.newInstance() .scheme(uri.substring(0, ssp)) .userInfo(userInfo) .host(host); if (StringUtils.hasText(port)) { builder.port(Integer.parseInt(port)); } builder.path(path); UriComponents uriComponents = builder.build(); return uriComponents; } else { UriComponents uriComponents = UriComponentsBuilder.fromUriString(uri).build(); return uriComponents; } }  @Deprecated static void isVistaRpcUri(URI uri); @Deprecated static void isVistaLinkUri(URI uri); @Deprecated static URI toURI(RpcRequest request); @Deprecated static URI toURI(RpcHost host, String rpcContext, String rpcName, List params, int timeout); static UriComponents toUriComponents(String uri); static UriComponents toUriComponents(RpcRequest request); static UriComponents toUriComponents(RpcHost host, String rpcContext, String rpcName, List params, int timeout); static UriComponents toUriComponents(RpcHost host, ConnectionSpec auth); static String toUriString(RpcHost host, ConnectionSpec auth); static String toAuthority(String vistaId, String division, String accessCode, String verifyCode, String clientAddress, String clientHostName); static String toAuthority(String vistaId, String division, String accessCode, String verifyCode, String newVerifyCode, String confirmNewVerifyCode, String clientAddress, String clientHostName); static String toAuthority(RpcHost host, String division, String accessCode, String verifyCode); static String toAuthority(RpcHost host, String credentials); static String toAuthority(String vistaId, String division, String appHandle, String clientAddress, String clientHostName); static String toPath(String rpcContext, String rpcName); static String toQuery(RpcRequest request); static String toQuery(List params, int timeout); static String toCredentials(ConnectionSpec auth); static String toCredentials(String division, String accessCode, String verifyCode, String clientAddress, String clientHostName); static String toCredentials(String division, String accessCode, String verifyCode, String newVerifyCode, String confirmNewVerifyCode, String clientAddress, String clientHostName); static String toCredentials(String division, String appHandle, String clientAddress, String clientHostName); static String extractUserInfo(String uri); static String extractDivision(String uri); @Deprecated static String extractDivision(URI uri); static String extractAccessCode(String uri); static String extractVerifyCode(String uri); static String extractCredentials(String uri); @Deprecated static String extractCredentials(URI uri); @Deprecated static String extractAccessCode(URI uri); @Deprecated static String extractVerifyCode(URI uri); @Deprecated static String extractRpcContext(URI uri); @Deprecated static String extractRpcName(URI uri); static String extractScheme(String uri); @Deprecated static String extractScheme(URI uri); static String extractHostname(String uri); @Deprecated static String extractHostname(URI uri); static int extractPort(String uri); @Deprecated static int extractPort(URI uri); static RpcHost extractHost(String uri); @Deprecated static RpcHost extractHost(URI uri); static String extractRpcContext(String uri); static String extractRpcName(String uri); static String sanitize(String uri, ConnectionSpec auth); @Deprecated static String sanitize(URI uri, ConnectionSpec auth); @Deprecated static URI toURI(String location); @Deprecated static URI toURI(String uri, List params); @Deprecated static URI toSafeURI(String uriString); static ConnectionSpec extractConnectionSpec(String uriString); }
RpcUriUtils { public static UriComponents toUriComponents(String uri) { int ssp = uri.indexOf(": int at = uri.lastIndexOf("@"); if (ssp != -1 && at != -1) { String userInfo = uri.substring(ssp + 3, at); int slash = uri.indexOf("/", at); String hostAndPort = (slash != -1 ? uri.substring(at + 1, slash) : uri.substring(at + 1)); int colon = hostAndPort.indexOf(":"); String host = hostAndPort; String port = null; if (colon != -1) { host = hostAndPort.substring(0, colon); port = hostAndPort.substring(colon + 1); } String path = (slash != -1 ? uri.substring(slash) : null); UriComponentsBuilder builder = UriComponentsBuilder.newInstance() .scheme(uri.substring(0, ssp)) .userInfo(userInfo) .host(host); if (StringUtils.hasText(port)) { builder.port(Integer.parseInt(port)); } builder.path(path); UriComponents uriComponents = builder.build(); return uriComponents; } else { UriComponents uriComponents = UriComponentsBuilder.fromUriString(uri).build(); return uriComponents; } }  @Deprecated static void isVistaRpcUri(URI uri); @Deprecated static void isVistaLinkUri(URI uri); @Deprecated static URI toURI(RpcRequest request); @Deprecated static URI toURI(RpcHost host, String rpcContext, String rpcName, List params, int timeout); static UriComponents toUriComponents(String uri); static UriComponents toUriComponents(RpcRequest request); static UriComponents toUriComponents(RpcHost host, String rpcContext, String rpcName, List params, int timeout); static UriComponents toUriComponents(RpcHost host, ConnectionSpec auth); static String toUriString(RpcHost host, ConnectionSpec auth); static String toAuthority(String vistaId, String division, String accessCode, String verifyCode, String clientAddress, String clientHostName); static String toAuthority(String vistaId, String division, String accessCode, String verifyCode, String newVerifyCode, String confirmNewVerifyCode, String clientAddress, String clientHostName); static String toAuthority(RpcHost host, String division, String accessCode, String verifyCode); static String toAuthority(RpcHost host, String credentials); static String toAuthority(String vistaId, String division, String appHandle, String clientAddress, String clientHostName); static String toPath(String rpcContext, String rpcName); static String toQuery(RpcRequest request); static String toQuery(List params, int timeout); static String toCredentials(ConnectionSpec auth); static String toCredentials(String division, String accessCode, String verifyCode, String clientAddress, String clientHostName); static String toCredentials(String division, String accessCode, String verifyCode, String newVerifyCode, String confirmNewVerifyCode, String clientAddress, String clientHostName); static String toCredentials(String division, String appHandle, String clientAddress, String clientHostName); static String extractUserInfo(String uri); static String extractDivision(String uri); @Deprecated static String extractDivision(URI uri); static String extractAccessCode(String uri); static String extractVerifyCode(String uri); static String extractCredentials(String uri); @Deprecated static String extractCredentials(URI uri); @Deprecated static String extractAccessCode(URI uri); @Deprecated static String extractVerifyCode(URI uri); @Deprecated static String extractRpcContext(URI uri); @Deprecated static String extractRpcName(URI uri); static String extractScheme(String uri); @Deprecated static String extractScheme(URI uri); static String extractHostname(String uri); @Deprecated static String extractHostname(URI uri); static int extractPort(String uri); @Deprecated static int extractPort(URI uri); static RpcHost extractHost(String uri); @Deprecated static RpcHost extractHost(URI uri); static String extractRpcContext(String uri); static String extractRpcName(String uri); static String sanitize(String uri, ConnectionSpec auth); @Deprecated static String sanitize(URI uri, ConnectionSpec auth); @Deprecated static URI toURI(String location); @Deprecated static URI toURI(String uri, List params); @Deprecated static URI toSafeURI(String uriString); static ConnectionSpec extractConnectionSpec(String uriString); static final String VISTA_RPC_BROKER_SCHEME; static final String VISTALINK_SCHEME; static final int DEFAULT_PORT; static final String DIVISION_CREDENTIALS_DELIMITER; static final String ACCESS_VERIFY_CODE_DELIMITER; }