Search in sources :

Example 91 with URIBuilder

use of org.apache.http.client.utils.URIBuilder in project sling by apache.

the class RequestUtils method appendDistributionRequest.

public static URI appendDistributionRequest(URI uri, DistributionRequest distributionRequest) throws URISyntaxException {
    URIBuilder uriBuilder = new URIBuilder(uri);
    uriBuilder.addParameter(DistributionParameter.ACTION.toString(), distributionRequest.getRequestType().name());
    String[] paths = distributionRequest.getPaths();
    if (paths != null) {
        for (String path : paths) {
            uriBuilder.addParameter(DistributionParameter.PATH.toString(), path);
        }
    }
    return uriBuilder.build();
}
Also used : URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 92 with URIBuilder

use of org.apache.http.client.utils.URIBuilder in project sling by apache.

the class AbstractSlingClient method getUrl.

/**
     * Creates a full URL for a given path with additional parameters. Same as {@link #getUrl(String)}, but adds the parameters in the URI.
     *
     * @param path path relative to server url; can start with / but should not include the server context path
     * @param parameters url parameters to be added to the url
     * @return full url as URI
     * @throws IllegalArgumentException if path or parameters cannot be parsed into an URI
     * @throws NullPointerException if path is null
     */
public URI getUrl(String path, List<NameValuePair> parameters) {
    // add server url and path
    URIBuilder uriBuilder = new URIBuilder(getUrl(path));
    // add parameters
    parameters = (parameters != null) ? parameters : new ArrayList<NameValuePair>(0);
    uriBuilder.addParameters(parameters);
    try {
        return uriBuilder.build();
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 93 with URIBuilder

use of org.apache.http.client.utils.URIBuilder in project sling by apache.

the class HttpTransportUtils method getFetchUri.

private static URI getFetchUri(URI uri) throws URISyntaxException {
    URIBuilder uriBuilder = new URIBuilder(uri);
    uriBuilder.addParameter("operation", "fetch");
    return uriBuilder.build();
}
Also used : URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 94 with URIBuilder

use of org.apache.http.client.utils.URIBuilder in project sling by apache.

the class HttpTransportUtils method getDeleteUri.

private static URI getDeleteUri(URI uri, String id) throws URISyntaxException {
    URIBuilder uriBuilder = new URIBuilder(uri);
    uriBuilder.addParameter("operation", "delete");
    uriBuilder.addParameter("id", id);
    return uriBuilder.build();
}
Also used : URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 95 with URIBuilder

use of org.apache.http.client.utils.URIBuilder in project ddf by codice.

the class BackupCommand method performSingleNodeSolrBackup.

private void performSingleNodeSolrBackup() throws Exception {
    verifySingleNodeBackupInput();
    String backupUrl = getBackupUrl(coreName);
    URIBuilder uriBuilder = new URIBuilder(backupUrl);
    uriBuilder.addParameter("command", "backup");
    if (StringUtils.isNotBlank(backupLocation)) {
        uriBuilder.addParameter("location", backupLocation);
    }
    if (numberToKeep > 0) {
        uriBuilder.addParameter("numberToKeep", Integer.toString(numberToKeep));
    }
    URI backupUri = uriBuilder.build();
    LOGGER.debug("Sending request to {}", backupUri.toString());
    HttpWrapper httpClient = getHttpClient();
    processResponse(httpClient.execute(backupUri));
}
Also used : URI(java.net.URI) URIBuilder(org.apache.http.client.utils.URIBuilder)

Aggregations

URIBuilder (org.apache.http.client.utils.URIBuilder)95 URISyntaxException (java.net.URISyntaxException)36 URI (java.net.URI)35 HttpGet (org.apache.http.client.methods.HttpGet)21 IOException (java.io.IOException)19 NameValuePair (org.apache.http.NameValuePair)12 HttpEntity (org.apache.http.HttpEntity)9 NotNull (org.jetbrains.annotations.NotNull)9 Map (java.util.Map)8 HashMap (java.util.HashMap)7 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)7 HttpResponse (org.apache.http.HttpResponse)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 HttpClient (org.apache.http.client.HttpClient)5 Gson (com.google.gson.Gson)4 URL (java.net.URL)4 HttpPost (org.apache.http.client.methods.HttpPost)4 StringEntity (org.apache.http.entity.StringEntity)4 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)4