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:org.vsepml.storm.sensapp.RestRequest.java

public static boolean isSensorRegistred(Sensor sensor) {
    URI target = null;/*  w  ww  .  j  ava 2  s .  c  o  m*/
    try {
        target = new URI(sensor.getUri().toString() + SENSOR_PATH + "/" + sensor.getName());
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    HttpClient client = new DefaultHttpClient();
    HttpGet request = new HttpGet(target);
    StatusLine status = null;
    try {
        status = client.execute(request).getStatusLine();
    } catch (Exception e) {
    }
    if (status.getStatusCode() == 200) {
        return true;
    }
    return false;
}

From source file:net.i2cat.netconf.test.BaseNetconfTest.java

@BeforeClass
public static void setUpBeforeClass() throws Exception {

    sessionContext = new SessionContext();
    sessionContext.setURI(new URI(
            System.getProperty("net.i2cat.netconf.test.transportUri", "mock://foo:bar@foo:22/okServer")));

    session = new NetconfSession(sessionContext);
    session.connect();/*  www. j a va2 s  . c  om*/
}

From source file:com.hpe.elderberry.ConnectionJsonTest.java

@Test
public void serialize() throws URISyntaxException, JsonProcessingException {
    TaxiiConnection c = new TaxiiConnection();
    c.setDiscoveryUri(new URI("http://www.google.com"));
    c.setTrustedPemCertificates(singletonList("trusted certificate"));
    c.setClientCertificatePemChain(singletonList("client certificate"));
    c.setPrivateKeyPem("private key");
    c.setKeyStoreFile(new File("/dev/null"));
    c.setKeyStorePassword("key store password");
    c.setUsername("user");
    c.setPassword("password");
    c.setProxyHost("web-proxy");
    c.setProxyPort(8888);/*from   www  .j  a va2  s .c om*/

    ObjectMapper mapper = new ObjectMapper();

    assertThat(mapper.writeValueAsString(c)).isNotEmpty().contains("key store password").contains("private key")
            .contains("web-proxy");
}

From source file:io.milton.httpclient.UnLockMethod.java

public UnLockMethod(String uri, String lockToken) throws URISyntaxException {
    setURI(new URI(uri));
    this.lockToken = lockToken;
    addHeader("Lock-Token", String.format("<%s>", lockToken));
}

From source file:com.autentia.web.rest.wadl.zipper.WadlZipper.java

public WadlZipper(String wadlUri) throws URISyntaxException {
    this.wadlUri = new URI(wadlUri);
}

From source file:org.chaplib.TestHttpResourceFactory.java

@Before
public void setUp() throws Exception {
    uri = new URI("http://www.example.com/");
    impl = new HttpResourceFactory(mockClient);
}

From source file:Main.java

private void goWebsite(JLabel website) {
    website.addMouseListener(new MouseAdapter() {
        @Override/*from   ww  w  .j a  va2 s .c  o m*/
        public void mouseClicked(MouseEvent e) {
            try {
                try {
                    Desktop.getDesktop().browse(new URI("http://www.java2s.com"));
                } catch (IOException ex) {
                    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                }
            } catch (URISyntaxException ex) {

            }
        }
    });
}

From source file:eu.over9000.skadi.remote.VersionRetriever.java

public static RemoteVersionResult getLatestVersion() {
    try {/*from  www.  jav  a  2 s .  c om*/
        final URI URL = new URI(API_URL);
        final HttpResponse response = httpClient.execute(new HttpGet(URL));

        final String responseString = new BasicResponseHandler().handleResponse(response);

        final JsonArray tagsArray = parser.parse(responseString).getAsJsonArray();
        final JsonObject latest = tagsArray.get(0).getAsJsonObject();
        final JsonObject latestFiles = latest.getAsJsonArray("assets").get(0).getAsJsonObject();

        final String downloadURL = latestFiles.get("browser_download_url").getAsString();
        final int downloadSize = latestFiles.get("size").getAsInt();
        final String version = latest.get("tag_name").getAsString();
        final String published = latest.get("published_at").getAsString();
        final String changeLog = latest.get("body").getAsString();

        return new RemoteVersionResult(version, published, downloadURL, changeLog, downloadSize);

    } catch (Exception e) {
        LOGGER.error("VersionRetriever exception", e);
        return null;
    }
}

From source file:org.dthume.maven.xpom.impl.XPOMUtil.java

public static String resolveURI(final String href, final String base) throws TransformerException {
    try {//from w  ww . j  av a2 s. c om
        return StringUtils.isBlank(base) ? href : new URI(base).resolve(href).toString();
    } catch (final URISyntaxException e) {
        return href;
    }
}

From source file:test.pl.chilldev.web.spring.context.PageMetaModelFactoryBeanTest.java

@Test
public void setXmlNamespaces() throws URISyntaxException {
    Map<URI, String> xmlNamespaces = new HashMap<>();
    xmlNamespaces.put(new URI("http://chilldev.pl/"), "cdv");

    PageMetaModelFactoryBean factory = new PageMetaModelFactoryBean();
    factory.setXmlNamespaces(xmlNamespaces);

    PageMetaModel page = factory.createPageMetaModel();

    assertEquals("PageMetaModelFactoryBean.setXmlNamespaces() should set XML namespaces list.",
            " xmlns:cdv=\"http://chilldev.pl/\"", page.generateXmlnsAttributes());
}