Example usage for com.amazonaws ClientConfiguration getProtocol

List of usage examples for com.amazonaws ClientConfiguration getProtocol

Introduction

In this page you can find the example usage for com.amazonaws ClientConfiguration getProtocol.

Prototype

public Protocol getProtocol() 

Source Link

Document

Returns the protocol (HTTP or HTTPS) to use when connecting to Amazon Web Services.

Usage

From source file:com.cloud.utils.S3Utils.java

License:Apache License

private static AmazonS3 acquireClient(final ClientOptions clientOptions) {

    final AWSCredentials credentials = new BasicAWSCredentials(clientOptions.getAccessKey(),
            clientOptions.getSecretKey());

    final ClientConfiguration configuration = new ClientConfiguration();

    if (clientOptions.isHttps() != null) {
        configuration.setProtocol(clientOptions.isHttps() == true ? HTTPS : HTTP);
    }/*from   w  ww  .  j  a v  a 2  s.  com*/

    if (clientOptions.getConnectionTimeout() != null) {
        configuration.setConnectionTimeout(clientOptions.getConnectionTimeout());
    }

    if (clientOptions.getMaxErrorRetry() != null) {
        configuration.setMaxErrorRetry(clientOptions.getMaxErrorRetry());
    }

    if (clientOptions.getSocketTimeout() != null) {
        configuration.setSocketTimeout(clientOptions.getSocketTimeout());
    }

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(format(
                "Creating S3 client with configuration: [protocol: %1$s, connectionTimeOut: "
                        + "%2$s, maxErrorRetry: %3$s, socketTimeout: %4$s]",
                configuration.getProtocol(), configuration.getConnectionTimeout(),
                configuration.getMaxErrorRetry(), configuration.getSocketTimeout()));
    }

    final AmazonS3Client client = new AmazonS3Client(credentials, configuration);

    if (isNotBlank(clientOptions.getEndPoint())) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(format("Setting the end point for S3 client %1$s to %2$s.", client,
                    clientOptions.getEndPoint()));
        }
        client.setEndpoint(clientOptions.getEndPoint());
    }

    return client;

}

From source file:de.taimos.pipeline.aws.ProxyConfiguration.java

License:Apache License

static void configure(EnvVars vars, ClientConfiguration config) {
    useJenkinsProxy(config);/*w  w  w. j a  v  a2  s  .  co  m*/

    if (config.getProtocol() == Protocol.HTTP) {
        configureHTTP(vars, config);
    } else {
        configureHTTPS(vars, config);
    }
    configureNonProxyHosts(vars, config);
}