Search in sources :

Example 1 with DockerCredentialsException

use of com.epam.pipeline.exception.docker.DockerCredentialsException in project cloud-pipeline by epam.

the class DockerClient method checkAvailability.

public void checkAvailability() {
    HttpEntity entity = getAuthHeaders();
    String uri = String.format(HEALTH_ENTRY_POINT, hostName);
    try {
        getRestTemplate().exchange(uri, HttpMethod.GET, entity, String.class);
    } catch (HTTPException | ResourceAccessException e) {
        if (e.getCause() instanceof SSLHandshakeException) {
            throw new DockerCertificateException(hostName, e.getCause());
        } else {
            throw new DockerConnectionException(hostName, e.getMessage(), e);
        }
    } catch (HttpClientErrorException e) {
        if (e.getStatusCode() == HttpStatus.UNAUTHORIZED) {
            throw new DockerCredentialsException(hostName, userName, password, e);
        } else {
            throw new DockerConnectionException(hostName, e.getMessage(), e);
        }
    }
}
Also used : HTTPException(javax.xml.ws.http.HTTPException) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) DockerCredentialsException(com.epam.pipeline.exception.docker.DockerCredentialsException) HttpEntity(org.springframework.http.HttpEntity) DockerCertificateException(com.epam.pipeline.exception.docker.DockerCertificateException) ResourceAccessException(org.springframework.web.client.ResourceAccessException) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) DockerConnectionException(com.epam.pipeline.exception.docker.DockerConnectionException)

Aggregations

DockerCertificateException (com.epam.pipeline.exception.docker.DockerCertificateException)1 DockerConnectionException (com.epam.pipeline.exception.docker.DockerConnectionException)1 DockerCredentialsException (com.epam.pipeline.exception.docker.DockerCredentialsException)1 SSLHandshakeException (javax.net.ssl.SSLHandshakeException)1 HTTPException (javax.xml.ws.http.HTTPException)1 HttpEntity (org.springframework.http.HttpEntity)1 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)1 ResourceAccessException (org.springframework.web.client.ResourceAccessException)1