private void populateQueryParams() throws MalformedURLException { StringBuilder url = new StringBuilder(); url.append(new EndpointURIFromRequestFunction().apply(request)); if (!request.hasQueryParams()) { connectionUrl = new URL(url.toString()); return; } url.append("?"); for (Map.Entry<String, List<Object>> entry : request.getQueryParams().entrySet()) { for (Object o : entry.getValue()) { try { url.append(URLEncoder.encode(entry.getKey(), "UTF-8")).append("=").append(URLEncoder.encode(String.valueOf(o), "UTF-8")); url.append("&"); } catch (UnsupportedEncodingException e) { LOG.error(e.getMessage(), e); } } } if (url.charAt(url.length() - 1) == '&') { url.deleteCharAt(url.length() - 1); } connectionUrl = new URL(url.toString()); }
private URI populateQueryParams(HttpRequest<R> request) throws URISyntaxException { URIBuilder uri = new URIBuilder(new EndpointURIFromRequestFunction().apply(request)); if (!request.hasQueryParams()) return uri.build(); for (Map.Entry<String, List<Object>> entry : request.getQueryParams().entrySet()) { for (Object o : entry.getValue()) { uri.addParameter(entry.getKey(), String.valueOf(o)); } } return uri.build(); }
private void populateQueryParams(HttpRequest<R> request) { StringBuilder url = new StringBuilder(); url.append(new EndpointURIFromRequestFunction().apply(request)); if (!request.hasQueryParams()) { clientReq.url(url.toString()); return; } url.append("?"); for(Map.Entry<String, List<Object> > entry : request.getQueryParams().entrySet()) { for (Object o : entry.getValue()) { try { url.append(URLEncoder.encode(entry.getKey(), "UTF-8")).append("=").append(URLEncoder.encode(String.valueOf(o), "UTF-8")); url.append("&"); } catch (UnsupportedEncodingException e) { LOG.error(e.getMessage(), e); } } } if (url.charAt(url.length() - 1) == '&') { url.deleteCharAt(url.length() - 1); } clientReq.url(url.toString()); }
private void initialize() { resteasyWebTarget = new ResteasyClientBuilder().httpEngine(ApacheHttpClientEngine.create(request.getConfig())) .providerFactory(ResteasyClientFactory.getInstance()).build() .target(UriBuilder.fromUri(new EndpointURIFromRequestFunction().apply(request))); populateQueryParams(request); resteasyRequest = resteasyWebTarget.request(); populateHeaders(request); }