Java Code Examples for javax.ws.rs.HttpMethod#GET

The following examples show how to use javax.ws.rs.HttpMethod#GET . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PagarMeModel.java    From pagarme-java with The Unlicense 6 votes vote down vote up
protected JsonArray paginate(final Integer totalPerPage, Integer page, QueriableFields modelFilter) throws PagarMeException {
    final Map<String, Object> parameters = new HashMap<String, Object>();

    if (null != totalPerPage && totalPerPage > 0) {
        parameters.put("count", totalPerPage);
    }

    if (null != page && page > 0) {
        parameters.put("page", page);
    }
    
    String path = "/" + getClassName();
    final PagarMeRequest request = new PagarMeRequest(HttpMethod.GET, path);
    request.getParameters().putAll(parameters);

    if(modelFilter != null){
        Map<String, Object> filter = modelFilter.toMap();
        request.getParameters().putAll(filter);
    }

    return request.execute();
}
 
Example 2
Source File: RequestResponeLoggingFilterTest.java    From parsec-libraries with Apache License 2.0 6 votes vote down vote up
@Test
public void getRequestShouldNotBeLogged() throws ExecutionException, InterruptedException {

    String url = "/getWithFilter200?param1=value1";
    WireMock.stubFor(get(urlEqualTo(url))
            .willReturn(okJson(stubRespBodyJson)));

    String requestMethod = HttpMethod.GET;

    Map<String, Collection<String>> headers = stubHeaders;

    ParsecAsyncHttpRequest request =
            new ParsecAsyncHttpRequest.Builder()
                    .setUrl(wireMockBaseUrl+url)
                    .setHeaders(headers)
                    .setRequestTimeout(30)
                    .setMethod(requestMethod)
                    .setBody("").setBodyEncoding("UTF-8").build();

    Response response = parsecHttpClient.criticalExecute(request).get();
    assertThat(response.getStatus(), equalTo(200));

    then(mockAppender).should(never()).doAppend(any());

}
 
Example 3
Source File: ClientInfoClient.java    From oxAuth with MIT License 5 votes vote down vote up
@Override
public String getHttpMethod() {
    if (getRequest().getAuthorizationMethod() == null
            || getRequest().getAuthorizationMethod() == AuthorizationMethod.AUTHORIZATION_REQUEST_HEADER_FIELD
            || getRequest().getAuthorizationMethod() == AuthorizationMethod.FORM_ENCODED_BODY_PARAMETER) {
        return HttpMethod.POST;
    } else { // AuthorizationMethod.URL_QUERY_PARAMETER
        return HttpMethod.GET;
    }
}
 
Example 4
Source File: Customer.java    From pagarme-java with The Unlicense 5 votes vote down vote up
public Customer find(int id) throws PagarMeException {

        final PagarMeRequest request = new PagarMeRequest(HttpMethod.GET,
                String.format("/%s/%s", getClassName(), id));

        final Customer other = JSONUtils.getAsObject((JsonObject) request.execute(), Customer.class);
        copy(other);
        flush();

        return other;
    }
 
Example 5
Source File: AnnotationProcessor.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
/**
 * Read Method annotations indicating HTTP Methods
 *
 * @param annotation
 */
private String getHTTPMethodAnnotation(Annotation annotation) {
    if (annotation.annotationType().getName().equals(GET.class.getName())) {
        return HttpMethod.GET;
    } else if (annotation.annotationType().getName().equals(POST.class.getName())) {
        return HttpMethod.POST;
    } else if (annotation.annotationType().getName().equals(OPTIONS.class.getName())) {
        return HttpMethod.OPTIONS;
    } else if (annotation.annotationType().getName().equals(DELETE.class.getName())) {
        return HttpMethod.DELETE;
    } else if (annotation.annotationType().getName().equals(PUT.class.getName())) {
        return HttpMethod.PUT;
    }
    return null;
}
 
Example 6
Source File: Recipient.java    From pagarme-java with The Unlicense 5 votes vote down vote up
private BulkAnticipationLimits getAnticipationLimits(DateTime paymentDate, Timeframe timeframe) throws PagarMeException{
    validateId();
    String path = String.format("/%s/%s/bulk_anticipations/limits", getClassName(), getId());
    final PagarMeRequest request = new PagarMeRequest(HttpMethod.GET, path);
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("payment_date", paymentDate.getMillis());
    parameters.put("timeframe", timeframe.name().toLowerCase());
    request.setParameters(parameters);
    JsonObject response = request.execute();
    BulkAnticipationLimits limits = JSONUtils.getAsObject(response, BulkAnticipationLimits.class);
    return limits;
}
 
Example 7
Source File: Transaction.java    From pagarme-java with The Unlicense 5 votes vote down vote up
/**
 * Retorna um objeto {@link Payable} informando os dados de um pagamento
 * referente a uma determinada transação.
 *
 * @param payableId
 *            ID do {@link Payable}
 * @return Um {@link Payable}
 * @throws PagarMeException
 */
public Payable payables(final Integer payableId) throws PagarMeException {
    validateId();

    final Payable splitRule = new Payable();

    final PagarMeRequest request = new PagarMeRequest(HttpMethod.GET,
            String.format("/%s/%s/%s/%s", getClassName(), getId(), splitRule.getClassName(), payableId));

    return JSONUtils.getAsObject((JsonObject) request.execute(), Payable.class);
}
 
Example 8
Source File: Card.java    From pagarme-java with The Unlicense 5 votes vote down vote up
public Card find(String id) throws PagarMeException {

        final PagarMeRequest request = new PagarMeRequest(HttpMethod.GET,
                String.format("/%s/%s", getClassName(), id));

        final Card other = JSONUtils.getAsObject((JsonObject) request.execute(), Card.class);
        copy(other);
        flush();
        return other;
    }
 
Example 9
Source File: Subscription.java    From pagarme-java with The Unlicense 5 votes vote down vote up
public Collection<Transaction> transactions(Integer count, Integer page) throws PagarMeException {
    validateId();

    final Transaction transaction = new Transaction();

    final PagarMeRequest request = new PagarMeRequest(HttpMethod.GET,
            String.format("/%s/%s/%s", getClassName(), getId(), transaction.getClassName()));
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("count", count);
        params.put("page", page);
        request.setParameters(params);
    return JSONUtils.getAsList((JsonArray) request.execute(), new TypeToken<Collection<Transaction>>() {
    }.getType());
}
 
Example 10
Source File: Transaction.java    From pagarme-java with The Unlicense 5 votes vote down vote up
/**
 * Retorna um array com objetos {@link Payable} informando os dados dos
 * pagamentos referentes a uma transação.
 *
 * @return Lista de {@link Payable}
 * @throws PagarMeException
 */
public Collection<Payable> payables() throws PagarMeException {
    validateId();

    final Payable payable = new Payable();

    final PagarMeRequest request = new PagarMeRequest(HttpMethod.GET,
            String.format("/%s/%s/%s", getClassName(), getId(), payable.getClassName()));

    return JSONUtils.getAsList((JsonArray) request.execute(), new TypeToken<Collection<Payable>>() {
    }.getType());
}
 
Example 11
Source File: PagarMeModel.java    From pagarme-java with The Unlicense 5 votes vote down vote up
protected JsonObject get(final PK id) throws PagarMeException {
    validateId();

    if (null == id) {
        throw new IllegalArgumentException("You must provide an ID to get this object data");
    }

    final PagarMeRequest request = new PagarMeRequest(HttpMethod.GET, String.format("/%s/%s", className, id));

    return request.execute();
}
 
Example 12
Source File: ThreadPoolRequestReplicator.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
protected NodeResponse replicateRequest(final WebResource.Builder resourceBuilder, final NodeIdentifier nodeId, final String method, final URI uri, final String requestId,
                                        final Map<String, String> headers) {
    final ClientResponse clientResponse;
    final long startNanos = System.nanoTime();
    logger.debug("Replicating request to {} {}, request ID = {}, headers = {}", method, uri, requestId, headers);

    switch (method.toUpperCase()) {
        case HttpMethod.DELETE:
            clientResponse = resourceBuilder.delete(ClientResponse.class);
            break;
        case HttpMethod.GET:
            clientResponse = resourceBuilder.get(ClientResponse.class);
            break;
        case HttpMethod.HEAD:
            clientResponse = resourceBuilder.head();
            break;
        case HttpMethod.OPTIONS:
            clientResponse = resourceBuilder.options(ClientResponse.class);
            break;
        case HttpMethod.POST:
            clientResponse = resourceBuilder.post(ClientResponse.class);
            break;
        case HttpMethod.PUT:
            clientResponse = resourceBuilder.put(ClientResponse.class);
            break;
        default:
            throw new IllegalArgumentException("HTTP Method '" + method + "' not supported for request replication.");
    }

    return new NodeResponse(nodeId, method, uri, clientResponse, System.nanoTime() - startNanos, requestId);
}
 
Example 13
Source File: EndSessionClient.java    From oxAuth with MIT License 4 votes vote down vote up
@Override
public String getHttpMethod() {
    return HttpMethod.GET;
}
 
Example 14
Source File: GluuConfigurationClient.java    From oxAuth with MIT License 4 votes vote down vote up
@Override
public String getHttpMethod() {
    return HttpMethod.GET;
}
 
Example 15
Source File: AtlasBaseClient.java    From atlas with Apache License 2.0 4 votes vote down vote up
public AtlasServer getServer(String serverName) throws AtlasServiceException {
    API api = new API(String.format(ADMIN_SERVER_TEMPLATE, BASE_URI, serverName), HttpMethod.GET, Response.Status.OK);
    return callAPI(api, AtlasServer.class, null);
}
 
Example 16
Source File: ClassIntrospectorTest.java    From aries-jax-rs-whiteboard with Apache License 2.0 4 votes vote down vote up
@Test
public void testResourceWithSubresource() {
    Bus bus = BusFactory.getDefaultBus(true);

    ResourceMethodInfoDTO[] resourceMethodInfoDTOS =
        ClassIntrospector.getResourceMethodInfos(
            ResourceWithSubResource.class, bus
        ).toArray(
            new ResourceMethodInfoDTO[0]
        );

    assertEquals(5, resourceMethodInfoDTOS.length);

    List<ResourceMethodInfoDTOWrapper> wrappers = Arrays.stream(
        resourceMethodInfoDTOS
    ).map(
        ResourceMethodInfoDTOWrapper::new
    ).collect(
        Collectors.toList()
    );

    ResourceMethodInfoDTO resourceMethodInfoDTO =
        new ResourceMethodInfoDTO();

    resourceMethodInfoDTO.method = HttpMethod.GET;
    resourceMethodInfoDTO.consumingMimeType = null;
    resourceMethodInfoDTO.producingMimeType =
        new String[]{MediaType.APPLICATION_XML};
    resourceMethodInfoDTO.path = "/resource";
    resourceMethodInfoDTO.nameBindings = null;

    assertTrue(
        wrappers.remove(
            new ResourceMethodInfoDTOWrapper(resourceMethodInfoDTO)));

    resourceMethodInfoDTO = new ResourceMethodInfoDTO();

    resourceMethodInfoDTO.method = HttpMethod.GET;
    resourceMethodInfoDTO.consumingMimeType =
        new String[]{MediaType.APPLICATION_JSON};
    resourceMethodInfoDTO.producingMimeType =
        new String[]{MediaType.APPLICATION_JSON};
    resourceMethodInfoDTO.path = "/resource/subresource";
    resourceMethodInfoDTO.nameBindings = null;

    assertTrue(
        wrappers.remove(
            new ResourceMethodInfoDTOWrapper(resourceMethodInfoDTO)));

    resourceMethodInfoDTO = new ResourceMethodInfoDTO();

    resourceMethodInfoDTO.method = HttpMethod.POST;
    resourceMethodInfoDTO.consumingMimeType =
        new String[]{MediaType.APPLICATION_XML};
    resourceMethodInfoDTO.producingMimeType =
        new String[]{
            MediaType.TEXT_PLAIN,
            MediaType.APPLICATION_JSON
        };
    resourceMethodInfoDTO.path = "/resource/subresource";
    resourceMethodInfoDTO.nameBindings = null;

    assertTrue(
        wrappers.remove(
            new ResourceMethodInfoDTOWrapper(resourceMethodInfoDTO)));

    resourceMethodInfoDTO = new ResourceMethodInfoDTO();

    resourceMethodInfoDTO.method = HttpMethod.GET;
    resourceMethodInfoDTO.consumingMimeType =
        new String[]{MediaType.APPLICATION_JSON};
    resourceMethodInfoDTO.producingMimeType =
        new String[]{MediaType.APPLICATION_JSON};
    resourceMethodInfoDTO.path = "/resource/subresource/{path}";
    resourceMethodInfoDTO.nameBindings = null;

    assertTrue(
        wrappers.remove(
            new ResourceMethodInfoDTOWrapper(resourceMethodInfoDTO)));

    resourceMethodInfoDTO = new ResourceMethodInfoDTO();

    resourceMethodInfoDTO.method = HttpMethod.POST;
    resourceMethodInfoDTO.consumingMimeType =
        new String[]{MediaType.APPLICATION_XML};
    resourceMethodInfoDTO.producingMimeType = new String[]{
        MediaType.TEXT_PLAIN,
        MediaType.APPLICATION_JSON
    };
    resourceMethodInfoDTO.path = "/resource/subresource/{path}";
    resourceMethodInfoDTO.nameBindings = null;

    assertTrue(
        wrappers.remove(
            new ResourceMethodInfoDTOWrapper(resourceMethodInfoDTO)));

    assertTrue(wrappers.isEmpty());
}
 
Example 17
Source File: AtlasClientV2.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
private <T> T getTypeDefByName(final String name, Class<T> typeDefClass) throws AtlasServiceException {
    String atlasPath = getAtlasPath(typeDefClass);
    APIInfo apiInfo = new APIInfo(String.format(GET_BY_NAME_TEMPLATE, atlasPath, name), HttpMethod.GET, Response.Status.OK);
    return callAPI(apiInfo, typeDefClass, null);
}
 
Example 18
Source File: Balance.java    From pagarme-java with The Unlicense 4 votes vote down vote up
public Balance refresh() throws PagarMeException {
    final PagarMeRequest request = new PagarMeRequest(HttpMethod.GET, String.format("/%s", getClass().getName()));
    final Balance other = JSONUtils.getAsObject((JsonObject) request.execute(), Balance.class);
    copy(other);
    return other;
}
 
Example 19
Source File: DcRequest.java    From io with Apache License 2.0 4 votes vote down vote up
/**
 * GETメソッドとしてDcRequestオブジェクトを生成する.
 * @param url URL
 * @return req DcRequestオブジェクト
 */
public static DcRequest get(String url) {
    DcRequest req = new DcRequest(url);
    req.method = HttpMethod.GET;
    return req;
}
 
Example 20
Source File: OpenIdConnectDiscoveryClient.java    From oxAuth with MIT License 4 votes vote down vote up
@Override
public String getHttpMethod() {
    return HttpMethod.GET;
}