Example usage for java.net URI getPath

List of usage examples for java.net URI getPath

Introduction

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

Prototype

public String getPath() 

Source Link

Document

Returns the decoded path component of this URI.

Usage

From source file:com.abiquo.model.enumerator.RemoteServiceType.java

public String fixUri(final URI uri) {
    String protocol = uri.getScheme();
    String domainName = uri.getHost();
    Integer port = uri.getPort();
    String path = uri.getPath();

    String domainHost = domainName + (port != null ? ":" + port : "");

    String fullURL = StringUtils.join(new String[] { fixProtocol(protocol), domainHost });

    if (!StringUtils.isEmpty(path)) {
        fullURL = UriHelper.appendPathToBaseUri(fullURL, path);
    }/*from  w  w w.j a v  a  2 s  .  c om*/

    return fullURL;
}

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

private String composesGrammarFileNameWith(URI grammarUri) {
    String pathName = "";

    final String host = grammarUri.getHost();
    if (host != null) {
        pathName = host + '/';
    }//from w w w.j  av  a2s.  c om

    String uriPath = grammarUri.getPath();
    if (uriPath.startsWith("/")) {
        uriPath = uriPath.substring(1);
    }
    pathName += uriPath;

    if (!pathName.toLowerCase().endsWith(DEFAULT_SCHEMA_EXTENSION)) {
        pathName += DEFAULT_SCHEMA_EXTENSION;
    }
    return pathName;
}

From source file:com.github.jknack.handlebars.helper.DefaultHelperRegistry.java

@Override
public HelperRegistry registerHelpers(final URI location) throws Exception {
    return registerHelpers(location.getPath(), Files.read(location.toString()));
}

From source file:f1db.configuration.ProductionProfile.java

@Bean
public BasicDataSource dataSource() throws URISyntaxException {
    URI dbUri = new URI(System.getenv("DATABASE_URL"));
    String username = dbUri.getUserInfo().split(":")[0];
    String password = dbUri.getUserInfo().split(":")[1];
    String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + ':' + dbUri.getPort() + dbUri.getPath();
    BasicDataSource basicDataSource = new BasicDataSource();
    basicDataSource.setUrl(dbUrl);//from   w w w  .  j a v  a2s. c  om
    basicDataSource.setUsername(username);
    basicDataSource.setPassword(password);
    return basicDataSource;
}

From source file:io.druid.storage.oss.OssDataSegmentPuller.java

private String getKey(URI uri) {

    // remove '/' from key
    return uri.getPath().substring(1);
}

From source file:com.hp.autonomy.hod.client.api.authentication.AuthenticationServiceImplTest.java

private void checkCombinedUrl(final SignedRequest request, final List<NameValuePair> expectedParameters)
        throws URISyntaxException {
    final URI uri = new URI(request.getUrl());
    assertThat(uri.getScheme() + "://" + uri.getHost(), is(ENDPOINT));
    assertThat(uri.getPath(), is(COMBINED_PATH));

    final List<NameValuePair> pairs = URLEncodedUtils.parse(uri, "UTF-8");
    assertThat(pairs, containsInAnyOrder(expectedParameters.toArray()));
}

From source file:eu.project.ttc.resources.DictionaryResource.java

@Override
public void load(URI resourceIdentifier) throws Exception {
    URLConnection connection = resourceIdentifier.toURL().openConnection();
    this.load(resourceIdentifier.getPath(), connection.getInputStream());
}

From source file:bibibi.configs.ProductionProfile.java

@Bean
public BasicDataSource dataSource() throws URISyntaxException {
    URI dbUri = new URI(System.getenv("DATABASE_URL"));

    String username = dbUri.getUserInfo().split(":")[0];
    String password = dbUri.getUserInfo().split(":")[1];
    String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + ':' + dbUri.getPort() + dbUri.getPath();

    BasicDataSource basicDataSource = new BasicDataSource();
    basicDataSource.setUrl(dbUrl);/*  w  w w .  j a  va  2s .co  m*/
    basicDataSource.setUsername(username);
    basicDataSource.setPassword(password);

    return basicDataSource;
}

From source file:com.buaa.cfs.utils.NetUtils.java

/**
 * Create an InetSocketAddress from the given target string and default port. If the string cannot be parsed
 * correctly, the <code>configName</code> parameter is used as part of the exception message, allowing the user to
 * better diagnose the misconfiguration.
 *
 * @param target      a string of either "host" or "host:port"
 * @param defaultPort the default port if <code>target</code> does not include a port number
 * @param configName  the name of the configuration from which <code>target</code> was loaded. This is used in the
 *                    exception message in the case that parsing fails.
 *///  ww  w .j a v  a  2s. c  om
public static InetSocketAddress createSocketAddr(String target, int defaultPort, String configName) {
    String helpText = "";
    if (configName != null) {
        helpText = " (configuration property '" + configName + "')";
    }
    if (target == null) {
        throw new IllegalArgumentException("Target address cannot be null." + helpText);
    }
    target = target.trim();
    boolean hasScheme = target.contains("://");
    URI uri = null;
    try {
        uri = hasScheme ? URI.create(target) : URI.create("dummyscheme://" + target);
    } catch (IllegalArgumentException e) {
        throw new IllegalArgumentException(
                "Does not contain a valid host:port authority: " + target + helpText);
    }

    String host = uri.getHost();
    int port = uri.getPort();
    if (port == -1) {
        port = defaultPort;
    }
    String path = uri.getPath();

    if ((host == null) || (port < 0) || (!hasScheme && path != null && !path.isEmpty())) {
        throw new IllegalArgumentException(
                "Does not contain a valid host:port authority: " + target + helpText);
    }
    return createSocketAddrForHost(host, port);
}

From source file:org.bedework.synch.cnctrs.file.FileConnectorInstance.java

@Override
public URI getUri() throws SynchException {
    try {// ww  w .  j  a  v a2s  .c o m
        //Get yesterdays date
        final LocalDate yesterday = LocalDate.now().minus(1, ChronoUnit.DAYS);
        final String yesterdayStr = yesterday.format(DateTimeFormatter.ISO_LOCAL_DATE);

        final URI infoUri = new URI(info.getUri());
        return new URIBuilder().setScheme(infoUri.getScheme()).setHost(infoUri.getHost())
                .setPort(infoUri.getPort()).setPath(infoUri.getPath()).build();
    } catch (final SynchException se) {
        throw se;
    } catch (final Throwable t) {
        throw new SynchException(t);
    }
}