Search in sources :

Example 26 with URIBuilder

use of org.apache.http.client.utils.URIBuilder in project wechat-mp-sdk by usc.

the class QRcodeUtil method bulidQRcodeImgUrl.

public static String bulidQRcodeImgUrl(String ticket) {
    if (StringUtils.isEmpty(ticket)) {
        return StringUtils.EMPTY;
    }
    String url = WechatRequest.SHOW_QRCODE.getUrl();
    try {
        URI uri = new URIBuilder(url).setParameter("ticket", ticket).build();
        log.info("build qrcode img url: url={}", uri);
        return uri.toString();
    } catch (Exception e) {
        String msg = "build qrcode img url failed: url=" + url + "?ticket=" + ticket;
        log.error(msg, e);
        return StringUtils.EMPTY;
    }
}
Also used : URI(java.net.URI) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 27 with URIBuilder

use of org.apache.http.client.utils.URIBuilder in project intellij-community by JetBrains.

the class PluginDownloader method getUrl.

@NotNull
private static String getUrl(@NotNull IdeaPluginDescriptor descriptor, @Nullable String host, @Nullable BuildNumber buildNumber) throws URISyntaxException, MalformedURLException {
    if (host != null && descriptor instanceof PluginNode) {
        String url = ((PluginNode) descriptor).getDownloadUrl();
        return new URI(url).isAbsolute() ? url : new URL(new URL(host), url).toExternalForm();
    } else {
        Application app = ApplicationManager.getApplication();
        ApplicationInfoEx appInfo = ApplicationInfoImpl.getShadowInstance();
        String buildNumberAsString = buildNumber != null ? buildNumber.asString() : app != null ? ApplicationInfo.getInstance().getApiVersion() : appInfo.getBuild().asString();
        URIBuilder uriBuilder = new URIBuilder(appInfo.getPluginsDownloadUrl());
        uriBuilder.addParameter("action", "download");
        uriBuilder.addParameter("id", descriptor.getPluginId().getIdString());
        uriBuilder.addParameter("build", buildNumberAsString);
        uriBuilder.addParameter("uuid", PermanentInstallationID.get());
        return uriBuilder.build().toString();
    }
}
Also used : ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) URIBuilder(org.apache.http.client.utils.URIBuilder) NotNull(org.jetbrains.annotations.NotNull)

Example 28 with URIBuilder

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

the class ToopherAPI method get.

private JSONObject get(String endpoint) throws Exception {
    URI uri = new URIBuilder().setScheme(URI_SCHEME).setHost(URI_HOST).setPath(URI_BASE + endpoint).build();
    HttpGet get = new HttpGet(uri);
    consumer.sign(get);
    return httpClient.execute(get, jsonHandler);
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) URI(java.net.URI) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 29 with URIBuilder

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

the class AstrophysicsDataSystem method getURLForEntry.

@Override
public URL getURLForEntry(BibEntry entry) throws URISyntaxException, MalformedURLException, FetcherException {
    URIBuilder uriBuilder = getBaseUrl(API_ENTRY_URL);
    // Search astronomy + physics + arXiv db
    uriBuilder.addParameter("db_key", "AST");
    uriBuilder.addParameter("db_key", "PHY");
    uriBuilder.addParameter("db_key", "PRE");
    // Add title search
    entry.getFieldOrAlias(FieldName.TITLE).ifPresent(title -> {
        uriBuilder.addParameter("ttl_logic", "OR");
        uriBuilder.addParameter("title", title);
        uriBuilder.addParameter("ttl_syn", "YES");
        uriBuilder.addParameter("ttl_wt", "0.3");
        uriBuilder.addParameter("ttl_wgt", "YES");
    });
    // Add author search
    entry.getFieldOrAlias(FieldName.AUTHOR).ifPresent(author -> {
        uriBuilder.addParameter("aut_logic", "OR");
        uriBuilder.addParameter("author", author);
        uriBuilder.addParameter("aut_syn", "YES");
        uriBuilder.addParameter("aut_wt", "1.0");
        uriBuilder.addParameter("aut_wgt", "YES");
    });
    return uriBuilder.build().toURL();
}
Also used : URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 30 with URIBuilder

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

the class AstrophysicsDataSystem method getBaseUrl.

private URIBuilder getBaseUrl(String apiUrl) throws URISyntaxException {
    URIBuilder uriBuilder = new URIBuilder(apiUrl);
    uriBuilder.addParameter("data_type", "BIBTEXPLUS");
    uriBuilder.addParameter("start_nr", String.valueOf(1));
    uriBuilder.addParameter("nr_to_return", String.valueOf(200));
    return uriBuilder;
}
Also used : 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