Search in sources :

Example 36 with OctaneResponse

use of com.hp.octane.integrations.dto.connectivity.OctaneResponse in project octane-ci-java-sdk by MicroFocus.

the class OctaneRestClientImpl method createNGAResponse.

private OctaneResponse createNGAResponse(OctaneRequest request, HttpResponse response) throws IOException {
    OctaneResponse octaneResponse = dtoFactory.newDTO(OctaneResponse.class).setStatus(response.getStatusLine().getStatusCode());
    if (response.getEntity() != null) {
        octaneResponse.setBody(CIPluginSDKUtils.inputStreamToUTF8String(response.getEntity().getContent()));
    }
    if (response.getAllHeaders() != null && response.getAllHeaders().length > 0) {
        Map<String, String> mapHeaders = new HashMap<>();
        for (Header header : response.getAllHeaders()) {
            mapHeaders.put(header.getName(), header.getValue());
        }
        octaneResponse.setHeaders(mapHeaders);
    }
    if (request != null && request.getHeaders() != null) {
        octaneResponse.setCorrelationId(request.getHeaders().get(RestService.CORRELATION_ID_HEADER));
    }
    return octaneResponse;
}
Also used : Header(org.apache.http.Header) BasicHeader(org.apache.http.message.BasicHeader) OctaneResponse(com.hp.octane.integrations.dto.connectivity.OctaneResponse)

Aggregations

OctaneResponse (com.hp.octane.integrations.dto.connectivity.OctaneResponse)36 OctaneRequest (com.hp.octane.integrations.dto.connectivity.OctaneRequest)27 IOException (java.io.IOException)14 PermanentException (com.hp.octane.integrations.exceptions.PermanentException)10 TemporaryException (com.hp.octane.integrations.exceptions.TemporaryException)10 OctaneRestClient (com.hp.octane.integrations.services.rest.OctaneRestClient)10 HashMap (java.util.HashMap)7 InputStream (java.io.InputStream)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 PipelineContextList (com.hp.octane.integrations.dto.pipelines.PipelineContextList)3 RequestTimeoutException (com.hp.octane.integrations.exceptions.RequestTimeoutException)3 ResourceNotFoundException (com.hp.octane.integrations.exceptions.ResourceNotFoundException)3 InterruptedIOException (java.io.InterruptedIOException)3 HttpResponse (org.apache.http.HttpResponse)3 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)3 HttpClientContext (org.apache.http.client.protocol.HttpClientContext)3 OctaneConfiguration (com.hp.octane.integrations.OctaneConfiguration)2 PipelineContext (com.hp.octane.integrations.dto.pipelines.PipelineContext)2 OctaneConnectivityException (com.hp.octane.integrations.exceptions.OctaneConnectivityException)2 Header (org.apache.http.Header)2