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:ac.elements.io.Signature.java

/**
 * Calculate String to Sign for SignatureVersion 2.
 * /*  ww  w .ja  va2s.c  o  m*/
 * @param parameters
 *            request parameters
 * 
 * @return String to Sign
 * 
 * @throws java.security.SignatureException
 */
private static String calculateStringToSignV2(Map<String, String> parameters) {
    StringBuilder data = new StringBuilder();
    data.append("POST");
    data.append("\n");
    URI endpoint = null;
    try {
        endpoint = new URI(SERVICE_URL);
    } catch (URISyntaxException ex) {
        // log.error("URI Syntax Exception", ex);
        throw new RuntimeException("URI Syntax Exception thrown " + "while constructing string to sign", ex);
    }
    data.append(endpoint.getHost());
    data.append("\n");
    String uri = endpoint.getPath();
    if (uri == null || uri.length() == 0) {
        uri = "/";
    }
    data.append(urlEncode(uri, true));
    data.append("\n");
    Map<String, String> sorted = new TreeMap<String, String>();
    sorted.putAll(parameters);
    Iterator<Map.Entry<String, String>> pairs = sorted.entrySet().iterator();
    while (pairs.hasNext()) {
        Map.Entry<String, String> pair = pairs.next();
        String key = pair.getKey();
        data.append(urlEncode(key, false));
        data.append("=");
        String value = pair.getValue();
        data.append(urlEncode(value, false));
        if (pairs.hasNext()) {
            data.append("&");
        }
    }

    return data.toString();
}

From source file:net.rim.ejde.internal.ui.wizards.BasicBlackBerryProjectWizardPageTwo.java

protected static URI getRealLocation(String projectName, URI location) {
    if (location == null) { // inside workspace
        try {//from   w w w.  jav  a2 s .  c  om
            URI rootLocation = ResourcesPlugin.getWorkspace().getRoot().getLocationURI();

            location = new URI(rootLocation.getScheme(), null,
                    Path.fromPortableString(rootLocation.getPath()).append(projectName).toString(), null);
        } catch (URISyntaxException e) {
            Assert.isTrue(false, "Can't happen"); //$NON-NLS-1$
        }
    }
    return location;
}

From source file:io.fabric8.che.starter.util.ProjectHelper.java

public String getProjectNameFromGitRepository(final String repositoryUrl)
        throws URISyntaxException, MalformedURLException {
    String httpsRepositoryUrl = changeProtocolToHttpsIfNeeded(repositoryUrl);
    URL url = new URL(httpsRepositoryUrl);
    URI uri = url.toURI();
    String path = uri.getPath();
    return getProjectNameFromPath(path);
}

From source file:com.subgraph.vega.impl.scanner.requests.AbstractRequestBuilder.java

private URI maybeAddTrailingSlash(URI uri) {
    if (uri.getPath().endsWith("/"))
        return uri;
    final String path = uri.getPath() + "/";
    return createUri(path);
}

From source file:com.subgraph.vega.impl.scanner.requests.AbstractRequestBuilder.java

private URI maybeRemoveTrailingSlash(URI uri) {
    if (!uri.getPath().endsWith("/"))
        return uri;
    String p = uri.getPath();//www .j av  a  2  s.co  m
    while (p.length() > 0 && p.endsWith("/"))
        p = p.substring(0, p.length() - 1);

    return createUri(p);
}

From source file:edu.uw.sig.frames2owl.util.BatchFromIncludeConverter.java

private String getOntNameFromURI(URI uri) {
    String path = uri.getPath();
    int lastSlashInd = path.lastIndexOf('/');
    int lastPeriodInd = path.lastIndexOf('.');
    String fileName = path.substring(lastSlashInd + 1, lastPeriodInd);
    return fileName;
}

From source file:com.splunk.shuttl.archiver.listers.ArchivedIndexesLister.java

/**
 * @return {@link List} of indexes that are archived in a
 *         {@link ArchiveFileSystem}//w  ww  . ja  v a2 s.c om
 */
public List<String> listIndexes() {
    URI indexesHome = pathResolver.getIndexesHome();
    List<URI> indexUris = listIndexesUrisOnArchiveFileSystem(indexesHome);
    List<String> indexes = new ArrayList<String>();
    for (URI uri : indexUris)
        indexes.add(FilenameUtils.getName(uri.getPath()));
    return indexes;
}

From source file:com.collective.celos.ci.deploy.WorkflowFilesDeployer.java

URI getTargetJsFileUri(URI uri) throws URISyntaxException {
    String path = uri.getPath() + File.separator + config.getWorkflowName() + ".js";
    return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), path, uri.getQuery(),
            uri.getFragment());//from   w ww .  ja  va2s.  c om
}

From source file:at.ac.univie.isc.asio.atos.FakeAtosService.java

@Override
public void handle(final HttpExchange exchange) throws IOException {
    final URI uri = exchange.getRequestURI();
    if (uri.getPath().endsWith(LOCAL_ID_PATH)) {
        final Map<String, String> parameters = HttpServer.parseParameters(exchange);
        final String id = parameters.get(LOCAL_ID_PARAMETER);
        if (id == null) {
            exchange.sendResponseHeaders(HttpStatus.SC_INTERNAL_SERVER_ERROR, 0);
        } else if (Integration.IDENTIFIER.equals(id) || Integration.BASE_URI.equals(id)) {
            send(exchange, referenceResponse);
        } else {/*from w ww .j  a v a  2 s  . com*/
            send(exchange, notFoundResponse);
        }
    } else {
        exchange.sendResponseHeaders(HttpStatus.SC_NOT_FOUND, 0);
    }
}

From source file:org.gradle.cache.tasks.http.HttpTaskOutputCache.java

public HttpTaskOutputCache(URI root) {
    if (!root.getPath().endsWith("/")) {
        throw new IncompleteArgumentException("HTTP cache root URI must end with '/'");
    }/*from w w w .j av  a 2 s  .  c o  m*/
    this.root = root;
}