public static URI createRequestURI(String rootUrl, Map<String, String> query) throws MalformedURLException, URISyntaxException { List<NameValuePair> queryTokens = Lists.newArrayList(); for (Map.Entry<String, String> entry : query.entrySet()) { queryTokens.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } String encodedQuery = URLEncodedUtils.format(queryTokens, Charsets.UTF_8); URI actualURL = new URIBuilder(rootUrl).setQuery(encodedQuery).build(); return actualURL; }
public static URI appendQueryStringToUri(URI uri, String parameterName, String parameterValue) { URI modifiedUri = null; try { URIBuilder uriBuilder = new URIBuilder(uri); uriBuilder.setQuery(parameterName + "=" + parameterValue); modifiedUri = uriBuilder.build(); } catch(Exception e) { throw new EFhirClientException("Unable to append query parameter '" + parameterName + "=" + parameterValue + " to URI " + uri, e); } return modifiedUri; }
public static URI appendQueryStringToUri(URI uri, String parameterName, String parameterValue) { URI modifiedUri = null; try { URIBuilder uriBuilder = new URIBuilder(uri); uriBuilder.setQuery(parameterName + "=" + parameterValue); modifiedUri = uriBuilder.build(); } catch(Exception e) { throw new EFhirClientException("Unable to append query parameter '" + parameterName + "=" + parameterValue + " to URI " + uri, e); } return modifiedUri; }
public static URI createRequestURI(String rootUrl, Map<String, String> query) throws MalformedURLException, URISyntaxException { List<NameValuePair> queryTokens = Lists.newArrayList(); for (Map.Entry<String, String> entry : query.entrySet()) { queryTokens.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } String encodedQuery = URLEncodedUtils.format(queryTokens, Charsets.UTF_8); URI actualURL = new URIBuilder(rootUrl).setQuery(encodedQuery).build(); return actualURL; }
public static URI createRequestURI(String rootUrl, Map<String, String> query) throws MalformedURLException, URISyntaxException { List<NameValuePair> queryTokens = Lists.newArrayList(); for (Map.Entry<String, String> entry : query.entrySet()) { queryTokens.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } String encodedQuery = URLEncodedUtils.format(queryTokens, Charsets.UTF_8); URI actualURL = new URIBuilder(rootUrl).setQuery(encodedQuery).build(); return actualURL; }
protected static URI makeURI(String scheme, String host, String requestURI, String rawQueryString) { try { return new URIBuilder() .setScheme(scheme) .setHost(host) .setPath(requestURI) // No need to encode-decode queryString, it is already encoded .setQuery(rawQueryString) .build(); } catch (URISyntaxException e) { log.error(e, "Unable to rewrite URI [%s]", e.getMessage()); throw Throwables.propagate(e); } }
public URI rewriteUri(URI url) throws URISyntaxException, MalformedURLException { if (requestedUrlPointsToServlet(url)) { final String targetPath = rewritePathIfNeeded(url.getPath()); return new URIBuilder() .setScheme(targetServer.getProtocol()) .setHost(targetServer.getHost()) .setPort(targetServer.getPort()) .setPath(targetPath) .setQuery(servletRequest.getQueryString()) .build(); } else { return url; } }
public HttpUriRequest request (final HttpRequestDescriptor descriptor) throws IllegalArgumentException, URISyntaxException, UnsupportedEncodingException { final URI uri = descriptor.getUri(); final String method = descriptor.getMethod(); if ("GET".equalsIgnoreCase(method)) { final String query = descriptor.getParametersAsString(); URI result = null; if (query != null && !query.isEmpty()) { result = new URIBuilder() .setScheme(uri.getScheme()) .setHost(uri.getHost()) .setPort(uri.getPort()) .setPath(uri.getPath()) .setQuery(query) .build(); } else { result = uri; } return new HttpGet(result); } else if ("POST".equalsIgnoreCase(method)) { final List<NameValuePair> parameters = descriptor.getParameters(); final HttpPost post = new HttpPost(uri); //FIXME:should we externalize RVD encoding default? post.setEntity(new UrlEncodedFormEntity(parameters, "UTF-8")); return post; } else { throw new IllegalArgumentException(method + " is not a supported downloader method."); } }
.setPort(uri.getPort()) .setPath(uri.getPath()) .setQuery(query) .build(); } else {
/** * Create a {@code GetMethod} and adds the ACI parameters to the query string. * @param serverDetails The details of the ACI server the request will be sent to * @param parameters The parameters to send with the ACI action. * @return a {@code HttpGet} that is ready to execute the ACI action. * @throws URISyntaxException If there was a problem construction the request URI from the <tt>serverDetails</tt> * and <tt>parameters</tt> */ private HttpUriRequest createGetMethod(final AciServerDetails serverDetails, final Set<? extends ActionParameter<?>> parameters) throws URISyntaxException { LOGGER.trace("createGetMethod() called..."); // Create the URI to use... final URI uri = new URIBuilder() .setScheme(serverDetails.getProtocol().toString().toLowerCase(Locale.ENGLISH)) .setHost(serverDetails.getHost()) .setPort(serverDetails.getPort()) .setPath("/") .setQuery(convertParameters(parameters, serverDetails.getCharsetName())) .build(); // Return the constructed get method... return new HttpGet(uri); }