List of usage examples for org.apache.http.client.utils URIBuilder URIBuilder
public URIBuilder(final URI uri)
From source file:com.vmware.identity.openidconnect.protocol.URIUtils.java
public static URI appendQueryParameters(URI uri, Map<String, String> parameters) { Validate.notNull(uri, "uri"); Validate.notNull(parameters, "parameters"); List<NameValuePair> pairs = new ArrayList<NameValuePair>(parameters.size()); for (Map.Entry<String, String> entry : parameters.entrySet()) { pairs.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); }/* www. j av a 2s.c om*/ URIBuilder uriBuilder = new URIBuilder(uri); uriBuilder.addParameters(pairs); try { return uriBuilder.build(); } catch (URISyntaxException e) { throw new IllegalArgumentException("failed to add parameters to uri", e); } }
From source file:com.launchkey.sdk.transport.v1.ApacheHttpClientTransport.java
/** * @param client HTTP Client to use for requests * @param baseUrl Base URL for the v1 API * @param crypto Crypto service to encrypt, decrypt and sign data *//*from w ww. j av a 2 s. c om*/ public ApacheHttpClientTransport(HttpClient client, String baseUrl, Crypto crypto) { this.client = client; this.crypto = crypto; if (baseUrl.endsWith("/")) { this.baseUrl = baseUrl.substring(0, baseUrl.length() - 1); } else { this.baseUrl = baseUrl; } // Test the URI for good measure try { new URIBuilder(this.baseUrl); } catch (URISyntaxException e) { throw new IllegalArgumentException("baseURL must be be a valid parseable URI with URIBuilder", e); } }
From source file:ezbake.azkaban.manager.ProjectManager.java
/** * Manages Azkaban projects/*from ww w . java2 s . co m*/ * * @param sessionId The sessionId of the logged in Azkaban user * @param azkabanUri The URL of the Azkaban server */ public ProjectManager(String sessionId, URI azkabanUri) { this.azkabanUri = azkabanUri; try { this.managerUri = new URIBuilder(azkabanUri).setPath("/manager").build(); } catch (URISyntaxException e) { e.printStackTrace(); } this.sessionId = sessionId; }
From source file:ezbake.azkaban.manager.ExecutionManager.java
/** * Class for executing a flow in Azkaban * * @param sessionId The session ID of an already connected session * @param azkabanUri The Azkaban URL/*from ww w.j av a 2s .c o m*/ */ public ExecutionManager(String sessionId, URI azkabanUri) { try { this.executionUri = new URIBuilder(azkabanUri).setPath("/executor").build(); } catch (URISyntaxException e) { e.printStackTrace(); } this.sessionId = sessionId; }
From source file:edu.berkeley.ground.plugins.hive.util.PluginUtil.java
public static String buildURL(String path, String name) throws GroundException { try {/* w w w . j a v a 2s . co m*/ URIBuilder uri = new URIBuilder(groundServerAddress); StringBuilder pathBuilder = new StringBuilder(); pathBuilder.append("/").append(path); if (name != null) { pathBuilder.append("/").append(name); } return uri.setPath(pathBuilder.toString()).build().toString(); } catch (URISyntaxException e) { throw new GroundException(e); } }
From source file:com.google.appengine.tck.byteman.SameEntityGroupTest.java
private void doTest(URI root, boolean xg) throws Exception { try (CloseableHttpClient client = HttpClients.createMinimal()) { List<Thread> threads = new ArrayList<>(); Holder h1 = new Holder(); URIBuilder builder = new URIBuilder(root + "/ctx"); builder.addParameter("eg", "EG1"); builder.addParameter("c", "1"); builder.addParameter("xg", String.valueOf(xg)); threads.add(execute(client, new HttpPost(builder.build()), h1)); Holder h2 = new Holder(); builder = new URIBuilder(root + "/ctx"); builder.addParameter("eg", "EG1"); builder.addParameter("c", "2"); builder.addParameter("xg", String.valueOf(xg)); threads.add(execute(client, new HttpPost(builder.build()), h2)); join(threads);//from ww w .j av a 2 s . c o m System.out.println("h1 = " + h1); System.out.println("h2 = " + h2); if (h1.out.startsWith("ERROR1")) { Assert.assertTrue("Expected ok: " + h2, h2.out.startsWith("OK2")); Assert.assertTrue("Expected CME: " + h2, h1.out.contains(ConcurrentModificationException.class.getName())); } else { Assert.assertTrue("Expected ok: " + h1, h1.out.startsWith("OK1")); Assert.assertTrue("Expected error: " + h2, h2.out.startsWith("ERROR2")); Assert.assertTrue("Expected CME: " + h2, h2.out.contains(ConcurrentModificationException.class.getName())); } } }
From source file:io.cloudslang.content.httpclient.consume.FinalLocationConsumerTest.java
@Test(expected = IllegalArgumentException.class) public void consumeWithException() throws URISyntaxException { URI uri = new URIBuilder("/test").build(); HttpHost httpHost = new HttpHost("te[]st1", 8080); Map<String, String> returnResult = new HashMap<>(); finalLocationConsumer.setUri(uri).setTargetHost(httpHost).setRedirectLocations(null).consume(returnResult); }
From source file:jenkins.plugins.logstash.persistence.ElasticSearchDao.java
ElasticSearchDao(HttpClientBuilder factory, String host, int port, String key, String username, String password) {//from w w w .j a va 2 s . c om super(host, port, key, username, password); if (StringUtils.isBlank(key)) { throw new IllegalArgumentException("elastic index name is required"); } try { uri = new URIBuilder(host).setPort(port) // Normalizer will remove extra starting slashes, but missing slash will cause annoying failures .setPath("/" + key).build(); } catch (URISyntaxException e) { throw new IllegalArgumentException("Could not create uri", e); } if (StringUtils.isBlank(uri.getScheme())) { throw new IllegalArgumentException("host field must specify scheme, such as 'http://'"); } if (StringUtils.isNotBlank(username)) { auth = Base64.encodeBase64String((username + ":" + StringUtils.defaultString(password)).getBytes()); } else { auth = null; } clientBuilder = factory == null ? HttpClientBuilder.create() : factory; }
From source file:com.ritesh.idea.plugin.util.HttpRequestBuilder.java
public static HttpRequestBuilder put(String url) throws URISyntaxException { HttpRequestBuilder builder = new HttpRequestBuilder(); builder.urlBuilder = new URIBuilder(url); builder.request = new HttpPut(); return builder; }