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.netdimensions.client.Client.java

public Client(final String url, final UsernamePasswordCredentials credentials) {
    final URI uri = URI.create(url);
    this.url = uri;

    if (credentials != null) {
        client.getCredentialsProvider().setCredentials(authScope(uri), credentials);
    }//  w ww  .  ja  va2 s . c o m
}

From source file:com.orange.clara.cloud.servicedbdumper.helper.UrlForge.java

public String createShowLink(DatabaseDumpFile databaseDumpFile) {
    if (!databaseDumpFile.isShowable()) {
        return "";
    }/*from  w  w w.  java  2 s.c o  m*/
    URI appInUri = URI.create(appUri);
    String port = this.getPortInString();
    return appInUri.getScheme() + "://" + appInUri.getHost() + port + SHOW_ROUTE + "/"
            + databaseDumpFile.getId();
}

From source file:com.github.tomakehurst.wiremock.common.ContentTypes.java

public static String determineFileExtension(String url, ContentTypeHeader contentTypeHeader,
        byte[] responseBody) {
    if (contentTypeHeader.isPresent()) {
        if (contentTypeHeader.mimeTypePart().contains("json")) {
            return "json";
        }//  w w  w.j a v a  2s.  c  om
        if (contentTypeHeader.mimeTypePart().contains("xml")) {
            return "xml";
        }
        if (contentTypeHeader.mimeTypePart().contains("text")) {
            return "txt";
        }

        String extension = COMMON_MIME_TYPES.get(contentTypeHeader.mimeTypePart());
        if (extension != null) {
            return extension;
        }
    }

    String path = URI.create(url).getPath();
    String lastPathSegment = substringAfterLast(path, "/");
    if (lastPathSegment.indexOf('.') != -1) {
        return substringAfterLast(lastPathSegment, ".");
    }

    return determineTextFileExtension(stringFromBytes(responseBody, contentTypeHeader.charset()));
}

From source file:com.seajas.search.bridge.contender.metadata.SyndEntryWriteConverter.java

/**
 * {@inheritDoc}/* w  w  w .j ava  2s.  c  o m*/
 */
@Override
public String convert(final SyndEntry source) {
    SyndFeed feed = new SyndFeedImpl(), sourceFeed = source.getSource();

    try {
        WebFeeds.validate(feed, URI.create("http://foo/"));

        // Make this element a child of this feed temporarily

        source.setSource(feed);

        feed.getEntries().add(source);

        // And serialize it to an RSS 2.0 string

        SyndFeedOutput serializer = new SyndFeedOutput();

        return serializer.outputString(feed, true);
    } catch (FeedException e) {
        logger.error("Unable to generate new feed to wrap the given element into", e);

        return null;
    } finally {
        source.setSource(sourceFeed);
    }
}

From source file:com.spotify.docker.client.UnixConnectionSocketFactoryTest.java

@Test
public void testSanitizeUri() throws Exception {
    final URI unixUri = UnixConnectionSocketFactory.sanitizeUri(URI.create("unix://localhost"));
    assertThat(unixUri, equalTo(URI.create("unix://localhost:80")));

    final URI nonUnixUri = URI.create("http://127.0.0.1");
    final URI uri = UnixConnectionSocketFactory.sanitizeUri(nonUnixUri);
    assertThat(uri, equalTo(nonUnixUri));
}

From source file:com.splunk.shuttl.archiver.clustering.ShuttlPortEndpoint.java

private HttpGet createHttpGetRequest() {
    URI shuttlPortRequestUri = URI.create(service.getScheme() + "://" + service.getHost() + ":"
            + service.getPort() + "/services/shuttl/port");
    HttpGet httpGet = new HttpGet(shuttlPortRequestUri);
    return httpGet;
}

From source file:org.projecthdata.social.api.impl.RootTemplate.java

public RootTemplate(HData hData, RestTemplate restTemplate, boolean isAuthorizedForUser) {
    super(isAuthorizedForUser);
    this.restTemplate = restTemplate;
    this.hData = hData;
    this.ehrUri = URI.create(hData.getEhrUrl());

    // setup the correct accept headers for processing an atom feed
    List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
    acceptableMediaTypes.add(MediaType.APPLICATION_ATOM_XML);
    acceptableMediaTypes.add(MediaType.APPLICATION_XML);

    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.setAccept(acceptableMediaTypes);

    this.atomFeedRequestEntity = new HttpEntity<Object>(requestHeaders);

}

From source file:com.github.fge.jsonschema.SchemaVersion.java

SchemaVersion(final String uri, final String resource) {
    try {/*from  w w w . j  av  a2s .  c o  m*/
        location = URI.create(uri);
        schema = JsonLoader.fromResource(resource);
    } catch (IOException e) {
        throw new ExceptionInInitializerError(e);
    }
}

From source file:co.cask.cdap.passport.http.client.PassportClient.java

public static PassportClient create(String uri) {
    Preconditions.checkNotNull(uri);
    return new PassportClient(URI.create(uri));
}

From source file:com.hp.autonomy.frontend.find.hod.web.HodErrorController.java

@Override
protected URI getAuthenticationErrorUrl(final HttpServletRequest request) {
    return URI.create(configService.getConfig().getHsod().getLandingPageUrl().toString());
}