Example usage for org.apache.http.client.utils URIBuilder getPath

List of usage examples for org.apache.http.client.utils URIBuilder getPath

Introduction

In this page you can find the example usage for org.apache.http.client.utils URIBuilder getPath.

Prototype

public String getPath() 

Source Link

Usage

From source file:org.wso2.carbon.identity.captcha.util.CaptchaUtil.java

public static String getOnFailRedirectUrl(String referrerUrl, List<String> onFailRedirectUrls,
        Map<String, String> attributes) {

    if (StringUtils.isBlank(referrerUrl) || onFailRedirectUrls.isEmpty()) {
        return getErrorPage("Human Verification Failed.", "Something went wrong. Please try again.");
    }/*from  ww w.  j  a  v  a 2  s. c om*/

    URIBuilder uriBuilder;
    try {
        uriBuilder = new URIBuilder(referrerUrl);
    } catch (URISyntaxException e) {
        return getErrorPage("Human Verification Failed.", "Something went wrong. Please try again.");
    }

    for (String url : onFailRedirectUrls) {
        if (!StringUtils.isBlank(url) && url.equalsIgnoreCase(uriBuilder.getPath())) {
            for (NameValuePair pair : uriBuilder.getQueryParams()) {
                attributes.put(pair.getName(), pair.getValue());
            }
            return getUpdatedUrl(url, attributes);
        }
    }

    return getErrorPage("Human Verification Failed.", "Something went wrong. Please try again.");
}

From source file:com.comoyo.emjar.EmJarTest.java

protected File getResourceFile(String name) throws URISyntaxException {
    final ClassLoader cl = getClass().getClassLoader();
    final URI base = cl.getResource("com/comoyo/emjar/").toURI();
    URIBuilder builder = new URIBuilder(base);
    builder.setPath(builder.getPath() + name);
    final URI uri = builder.build();
    if (!"file".equals(uri.getScheme())) {
        throw new IllegalArgumentException("Resource " + name + " not present as file (" + uri + ")");
    }/*from   w ww .j a va  2s  . co m*/
    return new File(uri.getSchemeSpecificPart());
}

From source file:org.broadleafcommerce.core.catalog.service.CatalogURLServiceImpl.java

/**
 * Adds the fragment to the end of the path and optionally adds an id param depending upon
 * the value of appendIdToRelativeURI./*from  w  w  w.ja  v  a  2s. com*/
 */
protected String buildRelativeUrlWithParam(String currentUrl, String fragment, String idParam, String idValue) {
    try {
        URIBuilder builder = new URIBuilder(currentUrl);
        builder.setPath(builder.getPath() + "/" + fragment);

        if (appendIdToRelativeURI) {
            builder.setParameter(idParam, String.valueOf(idValue));
        }

        return builder.build().toString();
    } catch (URISyntaxException e) {
        return currentUrl;
    }
}

From source file:com.linemetrics.monk.api.RestClient.java

public URI buildURI(String path, Map<String, String> params) throws URISyntaxException {
    URIBuilder ub = new URIBuilder(uri);
    ub.setPath(ub.getPath() + path);

    if (params != null) {
        for (Map.Entry<String, String> ent : params.entrySet())
            ub.addParameter(ent.getKey(), ent.getValue());
    }/* www. j  av  a  2  s . co m*/

    return ub.build();
}

From source file:ca.islandora.fcrepo.client.FcrepoClient.java

@Override
public IFcrepoResponse extendTransaction(final String uri) throws FcrepoOperationFailedException {
    try {//from ww  w  . j  a  v a  2  s . com
        URIBuilder uriBuilder = new URIBuilder(uri);
        uriBuilder.setPath(uriBuilder.getPath() + "/fcr:tx");
        final String fullUri = uriBuilder.build().toString();
        final IFcrepoRequest request = new CreateResourceRequest(httpClient, fullUri);
        return request.execute();
    } catch (URISyntaxException ex) {
        throw new FcrepoOperationFailedException(null, -1, ex.getMessage());
    }
}

From source file:ca.islandora.fcrepo.client.FcrepoClient.java

@Override
public IFcrepoResponse createTransaction() throws FcrepoOperationFailedException {
    try {//from www  . j  a va 2s.  c o  m
        URIBuilder uriBuilder = new URIBuilder(baseUri);
        uriBuilder.setPath(uriBuilder.getPath() + "/fcr:tx");
        final String uri = uriBuilder.build().toString();
        final IFcrepoRequest request = new CreateResourceRequest(httpClient, uri);
        return request.execute();
    } catch (URISyntaxException ex) {
        throw new FcrepoOperationFailedException(null, -1, ex.getMessage());
    }
}

From source file:ca.islandora.fcrepo.client.FcrepoClient.java

@Override
public IFcrepoResponse commitTransaction(final String uri) throws FcrepoOperationFailedException {
    try {//w  ww.  j  a va  2 s  .  c  o m
        URIBuilder uriBuilder = new URIBuilder(baseUri);
        uriBuilder.setPath(uriBuilder.getPath() + "/fcr:tx/fcr:commit");
        final String fullUri = uriBuilder.build().toString();
        final IFcrepoRequest request = new CreateResourceRequest(httpClient, fullUri);
        return request.execute();
    } catch (URISyntaxException ex) {
        throw new FcrepoOperationFailedException(null, -1, ex.getMessage());
    }
}

From source file:ca.islandora.fcrepo.client.FcrepoClient.java

@Override
public IFcrepoResponse rollbackTransaction(final String uri) throws FcrepoOperationFailedException {
    try {//from  w w  w  . ja  va  2  s  .  com
        URIBuilder uriBuilder = new URIBuilder(baseUri);
        uriBuilder.setPath(uriBuilder.getPath() + "/fcr:tx/fcr:rollback");
        final String fullUri = uriBuilder.build().toString();
        final IFcrepoRequest request = new CreateResourceRequest(httpClient, fullUri);
        return request.execute();
    } catch (URISyntaxException ex) {
        throw new FcrepoOperationFailedException(null, -1, ex.getMessage());
    }
}

From source file:org.obiba.magma.datasource.mongodb.MongoDBDatasourceFactory.java

public String getMongoDbDatabaseName() {
    try {/*  www .  ja v  a  2  s  .  c  om*/
        URIBuilder uriBuilder = new URIBuilder(url);
        return uriBuilder.getPath().substring(1);
    } catch (URISyntaxException e) {
        throw new RuntimeException("Cannot parse MongoDB URI", e);
    }
}

From source file:com.redhat.jenkins.plugins.bayesian.Bayesian.java

public String getApiUrl() {
    URIBuilder url;
    URI apiUrl = null;//from  w ww. j a  v  a2s. c o m
    try {
        url = new URIBuilder(getUrl());
        apiUrl = url.setPath(url.getPath() + "/api/v1").build().normalize();
    } catch (URISyntaxException e) {
        throw new IllegalStateException("Bayesian URL is invalid.");
    }
    return apiUrl.toString();
}