@Test public void getUpdateUri() { Assert.assertEquals("http: .getUpdateUri("http: Assert.assertEquals("http: .getUpdateUri("http: Assert.assertTrue(UriUtils.getUpdateUri( "http: "http: Assert.assertEquals("http: .getUpdateUri("http: }
public static String getUpdateUri(final String url, final boolean encrypt) { String updatedPath = null; try { final String query = URIUtil.getQuery(url); final URIBuilder builder = new URIBuilder(url); builder.removeQuery(); final StringBuilder updatedQuery = new StringBuilder(); final List<NameValuePair> queryParams = getUserDetails(query); final ListIterator<NameValuePair> iterator = queryParams.listIterator(); while (iterator.hasNext()) { final NameValuePair param = iterator.next(); String value = null; if ("password".equalsIgnoreCase(param.getName()) && param.getValue() != null) { value = encrypt ? DBEncryptionUtil.encrypt(param.getValue()) : DBEncryptionUtil.decrypt(param.getValue()); } else { value = param.getValue(); } if (updatedQuery.length() == 0) { updatedQuery.append(param.getName()).append('=') .append(value); } else { updatedQuery.append('&').append(param.getName()) .append('=').append(value); } } String schemeAndHost = ""; final URI newUri = builder.build(); if (newUri.getScheme() != null) { schemeAndHost = newUri.getScheme() + ": } updatedPath = schemeAndHost + newUri.getPath() + "?" + updatedQuery; } catch (final URISyntaxException e) { throw new CloudRuntimeException("Couldn't generate an updated uri. " + e.getMessage()); } return updatedPath; }
UriUtils { public static String getUpdateUri(final String url, final boolean encrypt) { String updatedPath = null; try { final String query = URIUtil.getQuery(url); final URIBuilder builder = new URIBuilder(url); builder.removeQuery(); final StringBuilder updatedQuery = new StringBuilder(); final List<NameValuePair> queryParams = getUserDetails(query); final ListIterator<NameValuePair> iterator = queryParams.listIterator(); while (iterator.hasNext()) { final NameValuePair param = iterator.next(); String value = null; if ("password".equalsIgnoreCase(param.getName()) && param.getValue() != null) { value = encrypt ? DBEncryptionUtil.encrypt(param.getValue()) : DBEncryptionUtil.decrypt(param.getValue()); } else { value = param.getValue(); } if (updatedQuery.length() == 0) { updatedQuery.append(param.getName()).append('=') .append(value); } else { updatedQuery.append('&').append(param.getName()) .append('=').append(value); } } String schemeAndHost = ""; final URI newUri = builder.build(); if (newUri.getScheme() != null) { schemeAndHost = newUri.getScheme() + ": } updatedPath = schemeAndHost + newUri.getPath() + "?" + updatedQuery; } catch (final URISyntaxException e) { throw new CloudRuntimeException("Couldn't generate an updated uri. " + e.getMessage()); } return updatedPath; } }
UriUtils { public static String getUpdateUri(final String url, final boolean encrypt) { String updatedPath = null; try { final String query = URIUtil.getQuery(url); final URIBuilder builder = new URIBuilder(url); builder.removeQuery(); final StringBuilder updatedQuery = new StringBuilder(); final List<NameValuePair> queryParams = getUserDetails(query); final ListIterator<NameValuePair> iterator = queryParams.listIterator(); while (iterator.hasNext()) { final NameValuePair param = iterator.next(); String value = null; if ("password".equalsIgnoreCase(param.getName()) && param.getValue() != null) { value = encrypt ? DBEncryptionUtil.encrypt(param.getValue()) : DBEncryptionUtil.decrypt(param.getValue()); } else { value = param.getValue(); } if (updatedQuery.length() == 0) { updatedQuery.append(param.getName()).append('=') .append(value); } else { updatedQuery.append('&').append(param.getName()) .append('=').append(value); } } String schemeAndHost = ""; final URI newUri = builder.build(); if (newUri.getScheme() != null) { schemeAndHost = newUri.getScheme() + ": } updatedPath = schemeAndHost + newUri.getPath() + "?" + updatedQuery; } catch (final URISyntaxException e) { throw new CloudRuntimeException("Couldn't generate an updated uri. " + e.getMessage()); } return updatedPath; }  }
UriUtils { public static String getUpdateUri(final String url, final boolean encrypt) { String updatedPath = null; try { final String query = URIUtil.getQuery(url); final URIBuilder builder = new URIBuilder(url); builder.removeQuery(); final StringBuilder updatedQuery = new StringBuilder(); final List<NameValuePair> queryParams = getUserDetails(query); final ListIterator<NameValuePair> iterator = queryParams.listIterator(); while (iterator.hasNext()) { final NameValuePair param = iterator.next(); String value = null; if ("password".equalsIgnoreCase(param.getName()) && param.getValue() != null) { value = encrypt ? DBEncryptionUtil.encrypt(param.getValue()) : DBEncryptionUtil.decrypt(param.getValue()); } else { value = param.getValue(); } if (updatedQuery.length() == 0) { updatedQuery.append(param.getName()).append('=') .append(value); } else { updatedQuery.append('&').append(param.getName()) .append('=').append(value); } } String schemeAndHost = ""; final URI newUri = builder.build(); if (newUri.getScheme() != null) { schemeAndHost = newUri.getScheme() + ": } updatedPath = schemeAndHost + newUri.getPath() + "?" + updatedQuery; } catch (final URISyntaxException e) { throw new CloudRuntimeException("Couldn't generate an updated uri. " + e.getMessage()); } return updatedPath; }  static String formNfsUri(final String host, final String path); static String formIscsiUri(final String host, final String iqn, final Integer lun); static String formFileUri(final String path); static String encodeURIComponent(final String url); static String getCifsUriParametersProblems(final URI uri); static boolean hostAndPathPresent(final URI uri); static boolean cifsCredentialsPresent(final URI uri); static String getUpdateUri(final String url, final boolean encrypt); static Long getRemoteSize(final String url); static void checkUrlExistence(final String url); static InputStream getInputStreamFromUrl(final String url, final String user, final String password); static Pair<String, Integer> validateUrl(final String url); static Pair<String, Integer> validateUrl(final String format, final String url); }
UriUtils { public static String getUpdateUri(final String url, final boolean encrypt) { String updatedPath = null; try { final String query = URIUtil.getQuery(url); final URIBuilder builder = new URIBuilder(url); builder.removeQuery(); final StringBuilder updatedQuery = new StringBuilder(); final List<NameValuePair> queryParams = getUserDetails(query); final ListIterator<NameValuePair> iterator = queryParams.listIterator(); while (iterator.hasNext()) { final NameValuePair param = iterator.next(); String value = null; if ("password".equalsIgnoreCase(param.getName()) && param.getValue() != null) { value = encrypt ? DBEncryptionUtil.encrypt(param.getValue()) : DBEncryptionUtil.decrypt(param.getValue()); } else { value = param.getValue(); } if (updatedQuery.length() == 0) { updatedQuery.append(param.getName()).append('=') .append(value); } else { updatedQuery.append('&').append(param.getName()) .append('=').append(value); } } String schemeAndHost = ""; final URI newUri = builder.build(); if (newUri.getScheme() != null) { schemeAndHost = newUri.getScheme() + ": } updatedPath = schemeAndHost + newUri.getPath() + "?" + updatedQuery; } catch (final URISyntaxException e) { throw new CloudRuntimeException("Couldn't generate an updated uri. " + e.getMessage()); } return updatedPath; }  static String formNfsUri(final String host, final String path); static String formIscsiUri(final String host, final String iqn, final Integer lun); static String formFileUri(final String path); static String encodeURIComponent(final String url); static String getCifsUriParametersProblems(final URI uri); static boolean hostAndPathPresent(final URI uri); static boolean cifsCredentialsPresent(final URI uri); static String getUpdateUri(final String url, final boolean encrypt); static Long getRemoteSize(final String url); static void checkUrlExistence(final String url); static InputStream getInputStreamFromUrl(final String url, final String user, final String password); static Pair<String, Integer> validateUrl(final String url); static Pair<String, Integer> validateUrl(final String format, final String url); static final Logger s_logger; }