Search in sources :

Example 1 with NotFoundException

use of network.bisq.api.NotFoundException in project bisq-api by mrosseel.

the class TradeResource method handlePaymentStatusChange.

private void handlePaymentStatusChange(String tradeId, AsyncResponse asyncResponse, CompletableFuture<Void> completableFuture) {
    completableFuture.thenApply(response -> asyncResponse.resume(Response.status(Response.Status.OK).build())).exceptionally(e -> {
        final Throwable cause = e.getCause();
        final Response.ResponseBuilder responseBuilder;
        if (cause instanceof ValidationException) {
            responseBuilder = toValidationErrorResponse(cause, 422);
        } else if (cause instanceof NotFoundException) {
            responseBuilder = toValidationErrorResponse(cause, 404);
        } else {
            final String message = cause.getMessage();
            responseBuilder = Response.status(500);
            if (null != message)
                responseBuilder.entity(new ValidationErrorMessage(ImmutableList.of(message)));
            log.error("Unable to confirm payment started for trade: " + tradeId, cause);
        }
        return asyncResponse.resume(responseBuilder.build());
    });
}
Also used : BisqProxy(network.bisq.api.BisqProxy) AsyncResponse(javax.ws.rs.container.AsyncResponse) ResourceHelper.toValidationErrorResponse(network.bisq.api.service.ResourceHelper.toValidationErrorResponse) TradeList(network.bisq.api.model.TradeList) CompletableFuture(java.util.concurrent.CompletableFuture) Suspended(javax.ws.rs.container.Suspended) ApiOperation(io.swagger.annotations.ApiOperation) Slf4j(lombok.extern.slf4j.Slf4j) MediaType(javax.ws.rs.core.MediaType) Collectors.toList(java.util.stream.Collectors.toList) TradeDetails(network.bisq.api.model.TradeDetails) ImmutableList(com.google.common.collect.ImmutableList) javax.ws.rs(javax.ws.rs) Response(javax.ws.rs.core.Response) ValidationException(javax.validation.ValidationException) NotEmpty(org.hibernate.validator.constraints.NotEmpty) ValidationErrorMessage(io.dropwizard.jersey.validation.ValidationErrorMessage) Api(io.swagger.annotations.Api) Authorization(io.swagger.annotations.Authorization) NotFoundException(network.bisq.api.NotFoundException) AsyncResponse(javax.ws.rs.container.AsyncResponse) ResourceHelper.toValidationErrorResponse(network.bisq.api.service.ResourceHelper.toValidationErrorResponse) Response(javax.ws.rs.core.Response) ValidationException(javax.validation.ValidationException) NotFoundException(network.bisq.api.NotFoundException) ValidationErrorMessage(io.dropwizard.jersey.validation.ValidationErrorMessage)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ValidationErrorMessage (io.dropwizard.jersey.validation.ValidationErrorMessage)1 Api (io.swagger.annotations.Api)1 ApiOperation (io.swagger.annotations.ApiOperation)1 Authorization (io.swagger.annotations.Authorization)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Collectors.toList (java.util.stream.Collectors.toList)1 ValidationException (javax.validation.ValidationException)1 javax.ws.rs (javax.ws.rs)1 AsyncResponse (javax.ws.rs.container.AsyncResponse)1 Suspended (javax.ws.rs.container.Suspended)1 MediaType (javax.ws.rs.core.MediaType)1 Response (javax.ws.rs.core.Response)1 Slf4j (lombok.extern.slf4j.Slf4j)1 BisqProxy (network.bisq.api.BisqProxy)1 NotFoundException (network.bisq.api.NotFoundException)1 TradeDetails (network.bisq.api.model.TradeDetails)1 TradeList (network.bisq.api.model.TradeList)1 ResourceHelper.toValidationErrorResponse (network.bisq.api.service.ResourceHelper.toValidationErrorResponse)1 NotEmpty (org.hibernate.validator.constraints.NotEmpty)1