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.microsoft.alm.common.utils.UrlHelperTest.java

@Test
public void testResolveEndpointURI() throws Exception {

    URI expected, resolved;/*  ww  w . j  ava2s  .c o  m*/

    expected = URI.create("http://foo/Bar");

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo"), "Bar");
    assertEquals(expected, resolved);

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo/"), "Bar");
    assertEquals(expected, resolved);

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo"), "/Bar");
    assertEquals(expected, resolved);

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo/"), "/Bar");
    assertEquals(expected, resolved);

    expected = URI.create("http://foo:8080/Bar");

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo:8080"), "Bar");
    assertEquals(expected, resolved);

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo:8080/"), "Bar");
    assertEquals(expected, resolved);

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo:8080"), "/Bar");
    assertEquals(expected, resolved);

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo:8080/"), "/Bar");
    assertEquals(expected, resolved);

    expected = URI.create("http://foo:8080/serverPath/Bar");

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo:8080/serverPath"), "Bar");
    assertEquals(expected, resolved);

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo:8080/serverPath/"), "Bar");
    assertEquals(expected, resolved);

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo:8080/serverPath"), "/Bar");
    assertEquals(expected, resolved);

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo:8080/serverPath/"), "/Bar");
    assertEquals(expected, resolved);

    expected = URI.create("http://foo:8080/serverPath/servicePath/Bar");

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo:8080/serverPath"), "servicePath/Bar");
    assertEquals(expected, resolved);

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo:8080/serverPath/"), "servicePath/Bar");
    assertEquals(expected, resolved);

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo:8080/serverPath"), "/servicePath/Bar");
    assertEquals(expected, resolved);

    resolved = UrlHelper.resolveEndpointUri(URI.create("http://foo:8080/serverPath/"), "/servicePath/Bar");
    assertEquals(expected, resolved);

}

From source file:com.grummages.app.rest.service.CreditCardRESTFacade.java

@POST
@Consumes({ "application/json" })
@Transactional/*w  w  w. j  av a  2 s.  c  o m*/
public Response create(CreditCard entity) {
    entityManager.persist(entity);
    return Response.created(URI.create(entity.getCcId().toString())).build();
}

From source file:com.grummages.app.rest.service.AuthoritiesRESTFacade.java

@POST
@Consumes({ "application/json" })
@Transactional//from   w ww  . java  2 s  .  c o  m
public Response create(Authorities entity) {
    entityManager.persist(entity);
    return Response.created(URI.create(entity.getAuthoritiesId().toString())).build();
}

From source file:com.grummages.app.rest.entity.service.AddonRESTFacade.java

@POST
@Consumes({ "application/json" })
@Transactional/*from   w  w w  .  j  a v a  2  s .co  m*/
public Response create(Addon entity) {
    entityManager.persist(entity);
    return Response.created(URI.create(entity.getAddonId().toString())).build();
}

From source file:com.hp.autonomy.frontend.find.idol.web.IdolErrorController.java

private URI getUrl(final HttpServletRequest request) {
    return URI.create(request.getContextPath() + BASE_SEARCH_URL);
}

From source file:org.zalando.zmon.actuator.backend.ControllerContactingBackendDirectly.java

@RequestMapping(method = RequestMethod.GET, value = "/timeConsumingCall")
public String callBackendThroughRestTemplate() {
    restTemplate.delete(URI.create("http://localhost:9999/something"));

    return "success";
}

From source file:com.splunk.shuttl.server.mbeans.util.EndpointUtils.java

public static URI getShuttlEndpointUri(String shuttlHost, int shuttlPort, String endpoint) {
    URI copyBucketEndpoint = URI.create(
            "http://" + shuttlHost + ":" + shuttlPort + "/" + ENDPOINT_CONTEXT + ENDPOINT_ARCHIVER + endpoint);
    return copyBucketEndpoint;
}

From source file:org.syphr.mythtv.ws.impl.ServiceUtils.java

public static String getVersion(URI serviceBaseUri) throws IOException {
    URI uri = URI.create(serviceBaseUri.toString() + "/" + VERSION_URI_PATH);

    HttpClient httpclient = new DefaultHttpClient();
    try {/*from  ww w  .  j  a  va  2  s .co  m*/
        HttpGet httpget = new HttpGet(uri);
        LOGGER.debug("Retrieving service version from {}", httpget.getURI());

        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        String responseBody = httpclient.execute(httpget, responseHandler);
        LOGGER.trace("Version response: {}", responseBody);

        Matcher matcher = VERSION_PATTERN.matcher(responseBody);
        if (matcher.matches()) {
            return matcher.group(1);
        }

        throw new IOException("Failed to retrieve version information");
    } finally {
        httpclient.getConnectionManager().shutdown();
    }
}

From source file:org.apache.camel.component.olingo2.api.impl.HttpMerge.java

public HttpMerge(final String uri) {
    super();
    setURI(URI.create(uri));
}

From source file:com.github.sardine.impl.methods.HttpUnlock.java

/**
 * @param url   The resource/*from  w w  w . j  av  a 2s .co  m*/
 * @param token The Lock-Token request header is used with the UNLOCK method to identify the lock to be removed.
 *              The lock token in the Lock-Token request header must identify a lock that contains the resource
 *              identified by Request-URI as a member.
 */
public HttpUnlock(String url, String token) {
    this(URI.create(url), token);
}