List of usage examples for java.net URI create
public static URI create(String str)
From source file:com.almende.salig.Client.java
/** * Start./* w w w . j a v a 2s.c om*/ */ @Access(AccessType.PUBLIC) public void start() { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try { final ObjectNode input = (ObjectNode) JOM.getInstance().readTree(br); br.close(); Params params = new Params(); params.add("message", createMessage(input)); call(URI.create(getConfig().get("publisherUrl").asText()), "sendMessage", params); schedule("shutdown", null, 1000); } catch (JsonParseException e) { e.printStackTrace(); } } catch (IOException io) { io.printStackTrace(); } }
From source file:com.google.acre.util.http.HttpPropFind.java
/** * @throws IllegalArgumentException if the uri is invalid. */ public HttpPropFind(final String uri) { super(); setURI(URI.create(uri)); }
From source file:com.mycompany.projecta.JenkinsScraper.java
public String scrape(String urlString, String username, String password) throws ClientProtocolException, IOException { URI uri = URI.create(urlString); HttpHost host = new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme()); CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(new AuthScope(uri.getHost(), uri.getPort()), new UsernamePasswordCredentials(username, password)); // Create AuthCache instance AuthCache authCache = new BasicAuthCache(); // Generate BASIC scheme object and add it to the local auth cache BasicScheme basicAuth = new BasicScheme(); authCache.put(host, basicAuth);//from w ww . j av a 2 s . c om CloseableHttpClient httpClient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build(); HttpGet httpGet = new HttpGet(uri); // Add AuthCache to the execution context HttpClientContext localContext = HttpClientContext.create(); localContext.setAuthCache(authCache); HttpResponse response = httpClient.execute(host, httpGet, localContext); String resp = response.toString(); return EntityUtils.toString(response.getEntity()); }
From source file:com.eviware.soapui.impl.wsdl.submit.transports.http.support.methods.HttpDeleteWithBody.java
/** * @throws IllegalArgumentException if the uri is invalid. *//*from w w w .ja v a2 s.c o m*/ public HttpDeleteWithBody(final String uri) { super(); setURI(URI.create(uri)); }
From source file:com.morphoss.acal.service.connector.DavRequest.java
public DavRequest(String method, String uri) { super(); this.method = method; setURI(URI.create(uri)); }
From source file:io.servicecomb.foundation.common.net.URIEndpointObject.java
public URIEndpointObject(String endpoint) { URI uri = URI.create(endpoint); setHostOrIp(uri.getHost());/*from w ww .j a v a 2s .c o m*/ if (uri.getPort() < 0) { // do not use default port throw new IllegalArgumentException("port not specified."); } setPort(uri.getPort()); querys = splitQuery(uri); sslEnabled = Boolean.parseBoolean(getFirst(SSL_ENABLED_KEY)); }
From source file:eu.unifiedviews.plugins.transformer.gunzipper.GunzipperTest.java
@Test public void testSmallFile() throws Exception { GunzipperConfig_V1 config = new GunzipperConfig_V1(); // Prepare DPU. Gunzipper dpu = new Gunzipper(); dpu.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString()); // Prepare test environment. TestEnvironment environment = new TestEnvironment(); // Prepare data unit. WritableFilesDataUnit filesOutput = environment.createFilesOutput("filesOutput"); WritableFilesDataUnit filesInput = environment.createFilesInput("filesInput"); File inputFile = new File(URI.create(filesInput.addNewFile("LICENSE.gz"))); try (FileOutputStream fout = new FileOutputStream(inputFile)) { IOUtils.copy(Thread.currentThread().getContextClassLoader().getResourceAsStream("LICENSE.gz"), fout); }// w w w. ja v a2 s .c o m try { // Run. environment.run(dpu); // Get file iterator. Set<FilesDataUnit.Entry> outputFiles = FilesHelper.getFiles(filesOutput); Assert.assertEquals(1, outputFiles.size()); FilesDataUnit.Entry entry = outputFiles.iterator().next(); String outputContent = IOUtils.toString(new URI(entry.getFileURIString()), "US-ASCII"); String expectedContent = IOUtils.toString( Thread.currentThread().getContextClassLoader().getResourceAsStream("LICENSE"), "US-ASCII"); Assert.assertEquals(expectedContent, outputContent); Assert.assertEquals("LICENSE", VirtualPathHelpers.getVirtualPath(filesOutput, "LICENSE.gz")); } finally { // Release resources. environment.release(); } }
From source file:com.netflix.spinnaker.echo.config.JedisConfig.java
@Bean
JedisPool jedisPool(EchoPubsubConfigurationProperties echoPubsubConfigurationProperties) {
EchoPubsubConfigurationProperties.RedisProperties redis = echoPubsubConfigurationProperties.getRedis();
return new JedisPool(URI.create(redis.getConnection()), redis.getTimeout());
}
From source file:com.grummages.app.rest.entity.service.UsersRESTFacade.java
@POST @Consumes({ "application/xml", "application/json" }) @Transactional/*from w w w . ja v a2s .c o m*/ public Response create(Users entity) { entityManager.persist(entity); return Response.created(URI.create(entity.getUsername().toString())).build(); }
From source file:co.cask.cdap.gateway.router.DatasetsProxyRule.java
@Override public HttpRequest apply(HttpRequest request) { String path = URI.create(request.getUri()).normalize().getPath(); String[] uriParts = StringUtils.split(path, '/'); if ((uriParts.length >= 4) && uriParts[1].equals("data") && uriParts[2].equals("datasets")) { // three parts with '/' wrapping them int insertAt = uriParts[0].length() + uriParts[1].length() + uriParts[2].length() + 4; String datasetName = uriParts[3]; request.setUri(processDatasetPath(path, insertAt, datasetName)); } else if ((uriParts.length == 6) && uriParts[1].equals("data") && uriParts[2].equals("explore") && uriParts[3].equals("datasets") && uriParts[5].equals("schema")) { // four parts with '/' wrapping them int insertAt = uriParts[0].length() + uriParts[1].length() + uriParts[2].length() + uriParts[3].length() + 5;/* www. j a va 2 s.c o m*/ String datasetName = uriParts[4]; request.setUri(processDatasetPath(path, insertAt, datasetName)); } return request; }