Search in sources :

Example 1 with BodyAndStatusResponseHandler

use of io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.BodyAndStatusResponseHandler in project docker-maven-plugin by fabric8io.

the class DockerAccessWithHcClient method removeImage.

@Override
public boolean removeImage(String image, boolean... forceOpt) throws DockerAccessException {
    boolean force = forceOpt != null && forceOpt.length > 0 && forceOpt[0];
    try {
        String url = urlBuilder.deleteImage(image, force);
        HttpBodyAndStatus response = delegate.delete(url, new BodyAndStatusResponseHandler(), HTTP_OK, HTTP_NOT_FOUND);
        if (log.isDebugEnabled()) {
            logRemoveResponse(new JSONArray(response.getBody()));
        }
        return response.getStatusCode() == HTTP_OK;
    } catch (IOException e) {
        throw new DockerAccessException(e, "Unable to remove image [%s]", image);
    }
}
Also used : BodyAndStatusResponseHandler(io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.BodyAndStatusResponseHandler) JSONArray(org.json.JSONArray) HttpBodyAndStatus(io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.HttpBodyAndStatus)

Aggregations

BodyAndStatusResponseHandler (io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.BodyAndStatusResponseHandler)1 HttpBodyAndStatus (io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.HttpBodyAndStatus)1 JSONArray (org.json.JSONArray)1