Example usage for org.apache.http.client.fluent Request Get

List of usage examples for org.apache.http.client.fluent Request Get

Introduction

In this page you can find the example usage for org.apache.http.client.fluent Request Get.

Prototype

public static Request Get(final String uri) 

Source Link

Usage

From source file:com.birt.airvantage.AVRequest.java

private String getRequest(String url) {
    try {//ww w  .j av a2  s  .c  o  m
        Response ex = Request.Get(url).execute();
        return ex.handleResponse(new ResponseHandler<String>() {
            public String handleResponse(final HttpResponse response) throws IOException {
                StatusLine statusLine = response.getStatusLine();
                HttpEntity entity = response.getEntity();
                if (statusLine.getStatusCode() >= 300) {
                    throw new HttpResponseException(statusLine.getStatusCode(), statusLine.getReasonPhrase());
                }
                if (entity == null)
                    throw new ClientProtocolException("No data");
                return IOUtils.toString(entity.getContent());
            }
        });
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.cognifide.aet.worker.drivers.HttpRequestBuilderImpl.java

private Request createRawRequest(String url, String methodName) {
    Request rawRequest;//from   w w  w . j ava2 s  .  c  o  m
    switch (HttpMethod.valueOf(methodName)) {
    case POST:
        rawRequest = Request.Post(url);
        break;
    case GET:
    default:
        rawRequest = Request.Get(url);
        break;
    }
    return rawRequest;
}

From source file:com.baifendian.swordfish.common.storm.StormRestUtil.java

/**
 * Id??/*  w w w  .  ja v a2  s .  c  o  m*/
 */
public static TopologyInfoDto getTopologyInfo(String topologyId) throws IOException {
    String res = Request.Get(getTopologyInfoUrl(topologyId)).execute().returnContent().toString();

    return JsonUtil.parseObject(res, TopologyInfoDto.class);
}

From source file:com.qwazr.database.TableSingleClient.java

@Override
public ColumnDefinition getColumn(String table_name, String column_name) {
    UBuilder uriBuilder = new UBuilder("/table/", table_name, "/column/", column_name);
    Request request = Request.Get(uriBuilder.build());
    return commonServiceRequest(request, null, null, ColumnDefinition.class, 200);
}

From source file:org.obm.locator.StartupTest.java

private String request(String query) throws IOException {
    return Request.Get(webAppUrl + "location/host/" + query).execute().returnContent().asString();
}

From source file:me.vertretungsplan.parser.CSVParser.java

@Override
public SubstitutionSchedule getSubstitutionSchedule()
        throws IOException, JSONException, CredentialInvalidException {
    new LoginHandler(scheduleData, credential, cookieProvider).handleLogin(executor, cookieStore);
    String url = data.getString(PARAM_URL);
    String response = executor.execute(Request.Get(url)).returnContent().asString();

    return parseCSV(response);
}

From source file:io.bitgrillr.gocddockerexecplugin.utils.GoTestUtils.java

/**
 * Returns the status of the named pipeline instance.
 *
 * @param pipeline Name of the pipeline.
 * @param counter Counter of the pipeline instance.
 * @return The status./*from   w w  w .ja  v a 2  s. c o m*/
 * @throws GoError If Go.CD returns a non 2XX reponse.
 * @throws IOException If a communication error occurs.
 */
public static String getPipelineStatus(String pipeline, int counter) throws GoError, IOException {
    final HttpResponse response = executor
            .execute(Request.Get(PIPELINES + pipeline + "/instance/" + Integer.toString(counter)))
            .returnResponse();
    final int status = response.getStatusLine().getStatusCode();
    if (status != HttpStatus.SC_OK) {
        throw new GoError(status);
    }
    final JsonArray stages = Json.createReader(response.getEntity().getContent()).readObject()
            .getJsonArray("stages");
    String pipelineStatus = "Completed";
    for (JsonValue stage : stages) {
        final JsonArray jobs = ((JsonObject) stage).getJsonArray("jobs");
        for (JsonValue job : jobs) {
            pipelineStatus = job.asJsonObject().getString("state");
            if (!"Completed".equals(pipelineStatus)) {
                return pipelineStatus;
            }
        }
    }
    return pipelineStatus;
}

From source file:de.elomagic.carafile.server.bl.RegistryClientBean.java

/**
 * Returns a set all known file identifier of the registry.
 *
 * @return A set but never null//from www.ja va  2s.c o  m
 * @throws IOException Thrown when unable to call REST service at the registry
 */
public Set<String> getFileIdSet() throws IOException {
    LOG.debug("Getting set of file ID's from registry");

    Set<String> fileIdSet;

    if (ownPeerURI.equals(registryURI)) {
        fileIdSet = registryBean.getFileIdSet();
    } else {
        URI restURI = UriBuilder.fromUri(registryURI).path(REGISTRY).path("listFiles")
                .path(URLEncoder.encode(ownPeerURI, "utf-8")).build();

        HttpResponse response = Request.Get(restURI).addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON)
                .execute().returnResponse();

        Charset charset = ContentType.getOrDefault(response.getEntity()).getCharset();
        fileIdSet = JsonUtil.read(new InputStreamReader(response.getEntity().getContent(), charset),
                HashSet.class);
        fileIdSet = fileIdSet == null ? new HashSet<>() : fileIdSet;
    }

    LOG.debug("Registry response a set of " + fileIdSet.size() + " file ID('s).");

    return fileIdSet;
}

From source file:org.exist.security.RestApiSecurityTest.java

@Override
protected String getXmlResourceContent(final String resourceUri, final String uid, final String pwd)
        throws ApiException {
    final Executor exec = getExecutor(uid, pwd);
    try {//from  w ww. ja  va2s . c  om
        final HttpResponse resp = exec.execute(Request.Get(REST_URI + resourceUri)).returnResponse();

        if (resp.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
            throw new ApiException("Could not get XML resource from uri: " + resourceUri + ". "
                    + getResponseBody(resp.getEntity()));
        } else {
            return getResponseBody(resp.getEntity());
        }
    } catch (final IOException ioe) {
        throw new ApiException(ioe);
    }
}

From source file:io.gravitee.gateway.standalone.QueryParametersTest.java

@Test
public void call_get_query_with_special_separator() throws Exception {
    String query = "from:2016-01-01;to:2016-01-31";

    URI target = new URIBuilder("http://localhost:8082/test/my_team").addParameter("id", "20000047")
            .addParameter("idType", "1").addParameter("q", query).build();

    Response response = Request.Get(target).execute();

    HttpResponse returnResponse = response.returnResponse();
    assertEquals(HttpStatus.SC_OK, returnResponse.getStatusLine().getStatusCode());

    String responseContent = StringUtils.copy(returnResponse.getEntity().getContent());
    assertEquals(query, responseContent);
}