Search in sources :

Example 91 with ProcessingException

use of javax.ws.rs.ProcessingException in project admin-console-beta by connexta.

the class RequestUtils method executeGetRequest.

/**
     * Executes a request by creating a Secure CXF Client from the provided url, credentials, and query params.
     *
     * Possible Error Codes to return
     * - {@link org.codice.ddf.admin.common.report.message.DefaultMessages#CANNOT_CONNECT}
     *
     * @param clientUrl url to send GET request to
     * @param creds optional basic authentication
     * @param queryParams additional query parameters
     * @return {@link Response} of the request
     */
public ReportWithResultImpl<Response> executeGetRequest(UrlField clientUrl, CredentialsField creds, Map<String, String> queryParams) {
    WebClient client = generateClient(clientUrl.getValue(), creds, queryParams);
    ReportWithResultImpl<Response> report = new ReportWithResultImpl<>();
    Response response;
    try {
        response = client.get();
    } catch (ProcessingException e) {
        report.addResultMessage(cannotConnectError());
        return report;
    }
    report.result(response);
    return report;
}
Also used : Response(javax.ws.rs.core.Response) ReportWithResultImpl(org.codice.ddf.admin.common.report.ReportWithResultImpl) WebClient(org.apache.cxf.jaxrs.client.WebClient) ProcessingException(javax.ws.rs.ProcessingException)

Aggregations

ProcessingException (javax.ws.rs.ProcessingException)91 Test (org.junit.Test)32 IOException (java.io.IOException)26 Response (javax.ws.rs.core.Response)20 WebTarget (javax.ws.rs.client.WebTarget)19 JerseyTest (org.glassfish.jersey.test.JerseyTest)16 WebApplicationException (javax.ws.rs.WebApplicationException)11 CountDownLatch (java.util.concurrent.CountDownLatch)9 Client (javax.ws.rs.client.Client)9 ResponseProcessingException (javax.ws.rs.client.ResponseProcessingException)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 ClientRequest (org.glassfish.jersey.client.ClientRequest)8 ClientResponse (org.glassfish.jersey.client.ClientResponse)8 ByteArrayInputStream (java.io.ByteArrayInputStream)6 URI (java.net.URI)6 NoContentException (javax.ws.rs.core.NoContentException)6 OutputStream (java.io.OutputStream)5 Map (java.util.Map)5 CompletableFuture (java.util.concurrent.CompletableFuture)5 EventSource (org.glassfish.jersey.media.sse.EventSource)5