Search in sources :

Example 1 with JHttpCException

use of org.commonjava.util.jhttpc.JHttpCException in project galley by Commonjava.

the class HttpImpl method createClient.

@Override
public CloseableHttpClient createClient(final HttpLocation location) throws GalleyException {
    try {
        if (location != null) {
            locationLookup.register(location);
            int maxConnections = LocationUtils.getMaxConnections(location);
            SiteConfigBuilder configBuilder = new SiteConfigBuilder(location.getName(), location.getUri());
            configBuilder.withAttributes(location.getAttributes()).withKeyCertPem(location.getKeyCertPem()).withServerCertPem(location.getServerCertPem()).withProxyHost(location.getProxyHost()).withProxyPort(location.getProxyPort()).withProxyUser(location.getProxyUser()).withRequestTimeoutSeconds(LocationUtils.getTimeoutSeconds(location)).withUser(location.getUser()).withMaxConnections(maxConnections);
            if (location.getTrustType() != null) {
                configBuilder.withTrustType(SiteTrustType.getType(location.getTrustType().name()));
            }
            SiteConfig config = configBuilder.build();
            return httpFactory.createClient(config);
        } else {
            return httpFactory.createClient();
        }
    } catch (JHttpCException e) {
        throw new TransferLocationException(location, "Failed to initialize http client: %s", e, e.getMessage());
    } finally {
    }
}
Also used : SiteConfigBuilder(org.commonjava.util.jhttpc.model.SiteConfigBuilder) SiteConfig(org.commonjava.util.jhttpc.model.SiteConfig) JHttpCException(org.commonjava.util.jhttpc.JHttpCException) TransferLocationException(org.commonjava.maven.galley.TransferLocationException)

Aggregations

TransferLocationException (org.commonjava.maven.galley.TransferLocationException)1 JHttpCException (org.commonjava.util.jhttpc.JHttpCException)1 SiteConfig (org.commonjava.util.jhttpc.model.SiteConfig)1 SiteConfigBuilder (org.commonjava.util.jhttpc.model.SiteConfigBuilder)1