Example usage for java.net URI URI

List of usage examples for java.net URI URI

Introduction

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

Prototype

public URI(String str) throws URISyntaxException 

Source Link

Document

Constructs a URI by parsing the given string.

Usage

From source file:jp.go.nict.langrid.p2pgridbasis.data.langrid.converter.URIConverter.java

public Object convert(Class type, Object value) {
    if (value == null) {
        return null;
    }//ww w .  j  a  v  a  2  s  .  com

    if (URI.class.isAssignableFrom(type) && String.class.isInstance(value)) {
        try {
            return new URI((String) value);
        } catch (URISyntaxException e) {
            return null;
        }
    }

    return null;
}

From source file:jp.go.nict.langrid.commons.jxpath.BPELUtil.java

/**
 * //  ww  w  . j a  va 2  s  .  c o  m
 * 
 */
public static URI getTargetNamespace(InputStream body) throws IOException, SAXException, URISyntaxException {
    String value = (String) newBPELContext(body, "_").getValue("_:process/@targetNamespace");
    if (value == null)
        return null;
    return new URI(value);
}

From source file:com.emc.ecs.s3.sample.ECSS3Factory.java

public static S3Client getS3Client() throws URISyntaxException {
    // for client-side load balancing
    //S3Config config = new S3Config(S3_SCHEME, S3_HOST1, S3_HOST2);
    // ditto with multiple VDCs
    //S3Config config = new S3Config(S3_SCHEME, new Vdc(S3_V1_HOST), new Vdc(S3_V2_HOST));

    S3Config config = new S3Config(new URI(S3_URI));

    config.withIdentity(S3_ACCESS_KEY_ID).withSecretKey(S3_SECRET_KEY);
    if (S3_ECS_NAMESPACE != null) {
        config.withNamespace(S3_ECS_NAMESPACE);
    }//  w  w  w .ja va 2s  .  c  om

    S3Client client = new S3JerseyClient(config);

    return client;
}

From source file:com.snaplogic.snaps.uniteller.CustomUFSConfigMgr.java

private CustomUFSConfigMgr(String fileLocation) throws UFSConfigMgrException {
    try {//from   w  ww  .ja  va  2 s . com
        URL fileUrl = new URI(fileLocation).toURL();
        this.configProperties = new Properties();
        try (InputStream inputStream = getInputStream(fileUrl)) {
            this.configProperties.load(inputStream);
        }
    } catch (IOException e) {
        log.error(e.getMessage(), e);
        throw new UFSConfigMgrException(e.getMessage());
    } catch (URISyntaxException ex) {
        log.error(ex.getMessage(), ex);
        throw new UFSConfigMgrException(ex.getMessage());
    } finally {
        IOUtils.close(urlConnection);
    }
}

From source file:au.org.ncallister.goodbudget.tools.coms.GoodBudgetSession.java

public GoodBudgetSession() throws URISyntaxException {
    BASE_URI = new URI("https://goodbudget.com/");
}

From source file:org.eel.kitchen.jsonschema.syntax.URISyntaxChecker.java

@Override
void checkValue(final Message.Builder msg, final List<Message> messages, final JsonNode schema) {
    final String value = schema.get(keyword).textValue();

    try {// w w  w.j a v a 2 s  .  co m
        new URI(value);
    } catch (URISyntaxException ignored) {
        msg.setMessage("not a valid URI").addInfo("found", value);
        messages.add(msg.build());
    }
}

From source file:org.springframework.cloud.dataflow.rest.util.HttpClientConfigurerTests.java

/**
 * Basic test ensuring that the {@link HttpClient} is built successfully.
 *///from w w  w.  j a va  2 s .  c  om
@Test
public void testThatHttpClientWithProxyIsCreated() throws Exception {

    final URI targetHost = new URI("http://test.com");
    final HttpClientConfigurer builder = HttpClientConfigurer.create(targetHost);
    builder.withProxyCredentials(URI.create("https://spring.io"), "spring", "cloud");
    builder.buildHttpClient();
}

From source file:beadsan.AppConfig.java

@ConfigurationProperties("spring.datasource")
@Bean(destroyMethod = "close")
DataSource realDataSource() throws URISyntaxException {
    String url;//from   w w w .ja v  a 2 s. c o  m
    String username;
    String password;

    String databaseUrl = System.getenv("DATABASE_URL");
    if (databaseUrl != null) {
        URI dbUri = new URI(databaseUrl);
        url = "jdbc:postgresql://" + dbUri.getHost() + ":" + dbUri.getPort() + dbUri.getPath();
        username = dbUri.getUserInfo().split(":")[0];
        password = dbUri.getUserInfo().split(":")[1];
    } else {
        url = this.properties.getUrl();
        username = this.properties.getUsername();
        password = this.properties.getPassword();
    }

    DataSourceBuilder factory = DataSourceBuilder.create(this.properties.getClassLoader()).url(url)
            .username(username).password(password);
    this.dataSource = factory.build();
    return this.dataSource;
}

From source file:org.openscore.content.httpclient.build.RequestBuilderTest.java

@Test
public void testMethods() throws URISyntaxException {
    HttpRequestBase httpRequestBase = new org.openscore.content.httpclient.build.RequestBuilder()
            .setUri(new URI("/")).setMethod("GET").build();
    assertEquals(httpRequestBase.getMethod(), "GET");
    httpRequestBase = new org.openscore.content.httpclient.build.RequestBuilder().setUri(new URI("/"))
            .setMethod("POST").build();
    assertEquals(httpRequestBase.getMethod(), "POST");
    httpRequestBase = new org.openscore.content.httpclient.build.RequestBuilder().setUri(new URI("/"))
            .setMethod("PUT").build();
    assertEquals(httpRequestBase.getMethod(), "PUT");
    httpRequestBase = new org.openscore.content.httpclient.build.RequestBuilder().setUri(new URI("/"))
            .setMethod("DELETE").build();
    assertEquals(httpRequestBase.getMethod(), "DELETE");
    httpRequestBase = new org.openscore.content.httpclient.build.RequestBuilder().setUri(new URI("/"))
            .setMethod("TRACE").build();
    assertEquals(httpRequestBase.getMethod(), "TRACE");
    httpRequestBase = new org.openscore.content.httpclient.build.RequestBuilder().setUri(new URI("/"))
            .setMethod("OPTIONS").build();
    assertEquals(httpRequestBase.getMethod(), "OPTIONS");
    httpRequestBase = new org.openscore.content.httpclient.build.RequestBuilder().setUri(new URI("/"))
            .setMethod("HEAD").build();
    assertEquals(httpRequestBase.getMethod(), "HEAD");

    httpRequestBase = new org.openscore.content.httpclient.build.RequestBuilder().setUri(new URI("/"))
            .setMethod("get").build();
    assertEquals(httpRequestBase.getMethod(), "GET");
    httpRequestBase = new org.openscore.content.httpclient.build.RequestBuilder().setUri(new URI("/"))
            .setMethod("post").build();
    assertEquals(httpRequestBase.getMethod(), "POST");
    httpRequestBase = new org.openscore.content.httpclient.build.RequestBuilder().setUri(new URI("/"))
            .setMethod("put").build();
    assertEquals(httpRequestBase.getMethod(), "PUT");
}

From source file:corner.hadoop.services.impl.LocalFileAccessorProxy.java

public LocalFileAccessorProxy(String basePath) {
    URI uri;//  w  w  w  .j av  a2s.c  o  m
    try {
        uri = new URI(basePath);
        this.path = uri.getPath();
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }

}