All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sumologic.client.util.SumoEntityResponseHandler Maven / Gradle / Ivy

package com.sumologic.client.util;

import com.sumologic.client.model.SumoEntityResponse;
import org.apache.http.HttpResponse;

import java.io.IOException;
import java.io.InputStream;

public class SumoEntityResponseHandler
        implements ResponseHandler {

    private static String ETAG_HEADER = "ETag";

    private Class clazz;

    public SumoEntityResponseHandler(Class clazz) {
        this.clazz = clazz;
    }

    @Override
    public Response handle(HttpResponse httpResponse, InputStream httpStream, Request request)
            throws IOException {

        Response response = JacksonUtils.MAPPER.readValue(httpStream, clazz);
        if (httpResponse.containsHeader(ETAG_HEADER)) {
            response.setETag(httpResponse.getFirstHeader(ETAG_HEADER).getValue());
        }
        return response;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy