Example usage for java.net URI create

List of usage examples for java.net URI create

Introduction

In this page you can find the example usage for java.net URI create.

Prototype

public static URI create(String str) 

Source Link

Document

Creates a URI by parsing the given string.

Usage

From source file:com.gopivotal.cla.repository.RepositoryConfiguration.java

@Bean
DataSource dataSource() {//  w  ww  . ja v  a 2 s .  c  o m
    URI dbUri = URI.create(this.databaseUrl);

    String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + ':' + dbUri.getPort() + dbUri.getPath();

    BoneCPDataSource dataSource = new BoneCPDataSource();
    dataSource.setDriverClass(Driver.class.getCanonicalName());
    dataSource.setJdbcUrl(dbUrl);

    String[] userInfoTokens = dbUri.getUserInfo().split(":");
    dataSource.setUsername(userInfoTokens.length > 0 ? userInfoTokens[0] : "");
    dataSource.setPassword(userInfoTokens.length > 1 ? userInfoTokens[1] : "");

    dataSource.setMaxConnectionsPerPartition(2);

    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);
    flyway.setLocations("META-INF/db/migration");
    flyway.migrate();

    return dataSource;
}

From source file:com.bt.aloha.batchtest.ultramonkey.ServiceImpl.java

public String makeCall(String caller, String callee) {
    String callLegId1 = outboundCallLegBean.createCallLeg(URI.create(callee), URI.create(caller));
    String callLegId2 = outboundCallLegBean.createCallLeg(URI.create(caller), URI.create(callee));
    return callBean.joinCallLegs(callLegId1, callLegId2);
}

From source file:com.splunk.shuttl.archiver.archive.PathResolver.java

/**
 * Returns a path using configured values to where buckets can be archived.
 * Needed to avoid collisions between clusters and servers/indexers.
 * /*from   w  w w .  j  a  v  a  2 s .c om*/
 * @return Archiving path that starts with "/"
 */
private URI getArchivingPath() {
    return URI.create(configuration.getArchivingRoot().toString() + SEPARATOR + configuration.getClusterName()
            + SEPARATOR + configuration.getServerName());
}

From source file:dario.androidclient.HttpGetTaskSample.java

@Override
protected String doInBackground(String... params) {
    String serverUrl = params[0];
    String result;/*  w  w w  .  j  a  v a2s .c  o  m*/
    try {
        HttpClient httpClient = new DefaultHttpClient();
        HttpGet request = new HttpGet(URI.create(serverUrl));
        HttpResponse response = httpClient.execute(request);
        HttpEntity entity = response.getEntity();
        if (entity != null) {
            result = EntityUtils.toString(entity);
        } else {
            result = "empty body";
        }
    } catch (Exception e) {
        result = e.getMessage();
    }
    return result;
}

From source file:com.almende.eve.test.TestCall.java

/**
 * Test proxy.//  w  ww .  j a  va2s.  co m
 * 
 * @throws Exception
 *             the exception
 */
@Test
public void testCall() throws Exception {
    // Create TestAgent according to TestInterface
    final AgentHost host = AgentHost.getInstance();
    final FileStateFactory stateFactory = new FileStateFactory(".eveagents");
    host.setStateFactory(stateFactory);
    host.setSchedulerFactory(new ClockSchedulerFactory(host, new HashMap<String, Object>()));
    if (host.hasAgent("TestAgent")) {
        host.deleteAgent("TestAgent");
    }
    final TestAgent agent = host.createAgent(TestAgent.class, "TestAgent");
    final AsyncCallback<JSONResponse> callback = new AsyncCallback<JSONResponse>() {

        @Override
        public void onSuccess(JSONResponse result) {
            LOG.info("received result:" + result);
        }

        @Override
        public void onFailure(Exception exception) {
            LOG.log(Level.WARNING, "Failure:", exception);
            fail("Failure:" + exception.getLocalizedMessage());
        }
    };

    agent.send(
            new JSONRequest("helloWorld", (ObjectNode) JOM.getInstance().readTree("{\"msg\":\"hi there!\"}")),
            URI.create("local:TestAgent"), callback, null);

    agent.send(
            new JSONRequest("helloWorld2",
                    (ObjectNode) JOM.getInstance().readTree("{\"msg1\":\"hi there!\",\"msg2\":\"Bye!\"}")),
            URI.create("local:TestAgent"), callback, null);

    agent.send(new JSONRequest("scheduler.getTasks", JOM.createObjectNode()), URI.create("local:TestAgent"),
            callback, null);

    agent.send(new JSONRequest("testVoid", JOM.createObjectNode()), URI.create("local:TestAgent"), callback,
            null);

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {
    }
}

From source file:example.customers.integration.StoreIntegration.java

private void discoverByLocationLink() {

    try {//  www .j  av  a 2s  .c o m
        URI storesUri = URI.create(env.getProperty("integration.stores.uri"));
        log.info("Trying to access the stores system at {}", storesUri);

        Traverson traverson = new Traverson(storesUri, MediaTypes.HAL_JSON);
        this.storesByLocationLink = traverson.follow("stores", "search", "by-location").asLink();

        log.info("Found stores-by-location link pointing to {}.", storesByLocationLink.getHref());

    } catch (RuntimeException o_O) {
        this.storesByLocationLink = null;
        log.info("Stores system unavailable. Got: ", o_O.getMessage());
    }
}

From source file:guru.bubl.module.neo4j_graph_manipulator.graph.graph.Neo4jWholeGraph.java

@Override
public Set<VertexInSubGraphOperator> getAllVertices() {
    String query = String.format("START n=node:node_auto_index('%s:%s') RETURN n.uri as uri",
            Neo4jFriendlyResource.props.type, GraphElementType.vertex);
    Set<VertexInSubGraphOperator> vertices = new HashSet<>();
    return NoExRun.wrap(() -> {
        Statement statement = connection.createStatement();
        ResultSet rs = statement.executeQuery(query);
        while (rs.next()) {
            vertices.add(neo4jVertexFactory.withUri(URI.create(rs.getString("uri"))));
        }/*from  www  .  ja  v  a2 s . c o  m*/
        return vertices;
    }).get();
}

From source file:com.mirth.connect.client.core.ConnectServiceUtil.java

public static void registerUser(String serverId, String mirthVersion, User user, String[] protocols,
        String[] cipherSuites) throws ClientException {
    CloseableHttpClient httpClient = null;
    CloseableHttpResponse httpResponse = null;
    NameValuePair[] params = { new BasicNameValuePair("serverId", serverId),
            new BasicNameValuePair("version", mirthVersion),
            new BasicNameValuePair("user", ObjectXMLSerializer.getInstance().serialize(user)) };

    HttpPost post = new HttpPost();
    post.setURI(URI.create(URL_CONNECT_SERVER + URL_REGISTRATION_SERVLET));
    post.setEntity(new UrlEncodedFormEntity(Arrays.asList(params), Charset.forName("UTF-8")));
    RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(TIMEOUT)
            .setConnectionRequestTimeout(TIMEOUT).setSocketTimeout(TIMEOUT).build();

    try {//from  ww w.  j av a 2s.c  om
        HttpClientContext postContext = HttpClientContext.create();
        postContext.setRequestConfig(requestConfig);
        httpClient = getClient(protocols, cipherSuites);
        httpResponse = httpClient.execute(post, postContext);
        StatusLine statusLine = httpResponse.getStatusLine();
        int statusCode = statusLine.getStatusCode();
        if ((statusCode != HttpStatus.SC_OK) && (statusCode != HttpStatus.SC_MOVED_TEMPORARILY)) {
            throw new Exception("Failed to connect to update server: " + statusLine);
        }
    } catch (Exception e) {
        throw new ClientException(e);
    } finally {
        HttpClientUtils.closeQuietly(httpResponse);
        HttpClientUtils.closeQuietly(httpClient);
    }
}

From source file:com.google.mr4c.hadoop.MR4CGenericOptions.java

public static MR4CGenericOptions extractFromConfig(Configuration conf) {
    MR4CGenericOptions opts = new MR4CGenericOptions();
    opts.setCluster(Cluster.extractFromConfig(conf));
    String fileList = conf.get(FILE_LIST_PROP);
    if (fileList != null) {
        for (String file : fileList.split(",")) {
            opts.addFile(URI.create(file));
        }/*  w ww .j a  v a  2  s.  com*/
    }
    String jarList = conf.get(JAR_LIST_PROP);
    if (jarList != null) {
        for (String jar : jarList.split(",")) {
            opts.addJar(URI.create(jar));
        }
    }
    return opts;
}

From source file:com.arpnetworking.tsdcore.sinks.KairosDbSinkTest.java

@Before
@Override// www  . j  ava 2  s  .  com
public void setUp() {
    super.setUp();
    _wireMockServer = new WireMockServer(0);
    _wireMockServer.start();
    _wireMock = new WireMock(_wireMockServer.port());

    _kairosDbSinkBuilder = new KairosDbSink.Builder().setName("kairosdb_sink_test").setActorSystem(getSystem())
            .setUri(URI.create("http://localhost:" + _wireMockServer.port() + PATH));
}