diff --git a/gradle.properties b/gradle.properties index 4adefdd..a9f080b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ version=2.4.7 -awsJavaSdkVersion=1.11.714 -awsKinesisClientVersion=1.10.0 -gradleWrapperVersion=5.5.1 -grailsVersion=4.0.0 +awsJavaSdkVersion=1.11.874 +awsKinesisClientVersion=1.14.0 +gradleWrapperVersion=5.6.4 +grailsVersion=4.0.4 groovyVersion=2.5.6 logbackVersion=1.2.3 slf4jVersion=1.7.26 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 96c3001..f8280f7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip diff --git a/grails-aws-sdk-kinesis/grails-app/services/grails/plugin/awssdk/kinesis/AmazonKinesisService.groovy b/grails-aws-sdk-kinesis/grails-app/services/grails/plugin/awssdk/kinesis/AmazonKinesisService.groovy index 1e004c5..ecbb7c8 100644 --- a/grails-aws-sdk-kinesis/grails-app/services/grails/plugin/awssdk/kinesis/AmazonKinesisService.groovy +++ b/grails-aws-sdk-kinesis/grails-app/services/grails/plugin/awssdk/kinesis/AmazonKinesisService.groovy @@ -1,7 +1,6 @@ package grails.plugin.awssdk.kinesis -import agorapulse.libs.awssdk.util.AwsClientUtil -import com.amazonaws.regions.Region + import com.amazonaws.services.kinesis.AmazonKinesis import com.amazonaws.services.kinesis.AmazonKinesisClientBuilder import com.amazonaws.services.kinesis.model.* diff --git a/grails-aws-sdk-ses/src/integration-test/groovy/grails/plugin/awssdk/ses/AmazonSESServiceIntegrationSpec.groovy b/grails-aws-sdk-ses/src/integration-test/groovy/grails/plugin/awssdk/ses/AmazonSESServiceIntegrationSpec.groovy index 7b3fbea..10dc2b5 100644 --- a/grails-aws-sdk-ses/src/integration-test/groovy/grails/plugin/awssdk/ses/AmazonSESServiceIntegrationSpec.groovy +++ b/grails-aws-sdk-ses/src/integration-test/groovy/grails/plugin/awssdk/ses/AmazonSESServiceIntegrationSpec.groovy @@ -1,7 +1,7 @@ package grails.plugin.awssdk.ses import com.agorapulse.awssdk.ses.UnsupportedAttachmentTypeException -import grails.test.mixin.integration.Integration +import grails.testing.mixin.integration.Integration import grails.util.Environment import org.springframework.beans.factory.annotation.Autowired import spock.lang.IgnoreIf @@ -102,6 +102,7 @@ class AmazonSESServiceIntegrationSpec extends Specification { !emailFound } + @IgnoreIf({ !System.getenv('TEST_INBOX_EMAIL') }) void "test that if you try to send an unsupported attachment an exception is thrown "() { when: def subjectStr = 'GRAILS AWS SDK SES with Attachment' diff --git a/grails-aws-sdk-ses/src/integration-test/groovy/grails/plugin/awssdk/ses/AmazonSESTemplateServiceIntegrationSpec.groovy b/grails-aws-sdk-ses/src/integration-test/groovy/grails/plugin/awssdk/ses/AmazonSESTemplateServiceIntegrationSpec.groovy index aa59444..fb37d8d 100644 --- a/grails-aws-sdk-ses/src/integration-test/groovy/grails/plugin/awssdk/ses/AmazonSESTemplateServiceIntegrationSpec.groovy +++ b/grails-aws-sdk-ses/src/integration-test/groovy/grails/plugin/awssdk/ses/AmazonSESTemplateServiceIntegrationSpec.groovy @@ -1,6 +1,6 @@ package grails.plugin.awssdk.ses -import grails.test.mixin.integration.Integration +import grails.testing.mixin.integration.Integration import grails.util.Environment import org.springframework.beans.factory.annotation.Autowired import spock.lang.IgnoreIf diff --git a/groovy-aws-sdk-ses/src/main/groovy/com/agorapulse/awssdk/ses/AwsSesMailer.groovy b/groovy-aws-sdk-ses/src/main/groovy/com/agorapulse/awssdk/ses/AwsSesMailer.groovy index d155a50..34f6585 100644 --- a/groovy-aws-sdk-ses/src/main/groovy/com/agorapulse/awssdk/ses/AwsSesMailer.groovy +++ b/groovy-aws-sdk-ses/src/main/groovy/com/agorapulse/awssdk/ses/AwsSesMailer.groovy @@ -1,5 +1,9 @@ package com.agorapulse.awssdk.ses +import static com.agorapulse.awssdk.ses.AwsSdkSesEmailDeliveryStatus.STATUS_DELIVERED +import static com.agorapulse.awssdk.ses.AwsSdkSesEmailDeliveryStatus.STATUS_NOT_DELIVERED +import static com.agorapulse.awssdk.ses.AwsSdkSesEmailDeliveryStatus.STATUS_BLACKLISTED + import com.agorapulse.awssdk.AwsSdkUtils import com.amazonaws.AmazonClientException import com.amazonaws.AmazonServiceException @@ -12,7 +16,13 @@ import com.amazonaws.regions.RegionUtils import com.amazonaws.services.simpleemail.AmazonSimpleEmailService import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClientBuilder -import com.amazonaws.services.simpleemail.model.* +import com.amazonaws.services.simpleemail.model.Body +import com.amazonaws.services.simpleemail.model.Content +import com.amazonaws.services.simpleemail.model.Destination +import com.amazonaws.services.simpleemail.model.Message +import com.amazonaws.services.simpleemail.model.RawMessage +import com.amazonaws.services.simpleemail.model.SendEmailRequest +import com.amazonaws.services.simpleemail.model.SendRawEmailRequest import groovy.transform.CompileStatic import groovy.util.logging.Slf4j @@ -27,8 +37,6 @@ import javax.mail.internet.MimeMultipart import javax.mail.util.ByteArrayDataSource import java.nio.ByteBuffer -import static com.agorapulse.awssdk.ses.AwsSdkSesEmailDeliveryStatus.* - @Slf4j @CompileStatic class AwsSesMailer { @@ -44,7 +52,7 @@ class AwsSesMailer { ClientConfiguration clientConfiguration = AwsSdkUtils.clientConfigurationWithMap([:]) client = AmazonSimpleEmailServiceClientBuilder.standard() .withCredentials(new AWSCredentialsProvider() { - @Override AWSCredentials getCredentials() { return new BasicAWSCredentials(accessKey, secretKey) } + @Override AWSCredentials getCredentials() { new BasicAWSCredentials(accessKey, secretKey) } @Override void refresh() { } }) @@ -71,7 +79,7 @@ class AwsSesMailer { sendEmailWithAttachment(transactionalEmail) } - @SuppressWarnings(['LineLength', 'ElseBlockBraces', 'JavaIoPackageAccess']) + @SuppressWarnings(['LineLength', 'ElseBlockBraces', 'JavaIoPackageAccess', 'AbcMetric']) int sendEmailWithAttachment(TransactionalEmail transactionalEmail) throws UnsupportedAttachmentTypeException { int statusId = STATUS_NOT_DELIVERED diff --git a/groovy-aws-sdk-util/src/main/groovy/agorapulse/libs/awssdk/util/AwsClientUtil.groovy b/groovy-aws-sdk-util/src/main/groovy/agorapulse/libs/awssdk/util/AwsClientUtil.groovy index 0c3a55a..56bd9ba 100644 --- a/groovy-aws-sdk-util/src/main/groovy/agorapulse/libs/awssdk/util/AwsClientUtil.groovy +++ b/groovy-aws-sdk-util/src/main/groovy/agorapulse/libs/awssdk/util/AwsClientUtil.groovy @@ -6,11 +6,12 @@ import com.amazonaws.auth.AWSCredentialsProvider import com.amazonaws.auth.AWSStaticCredentialsProvider import com.amazonaws.auth.BasicAWSCredentials import com.amazonaws.auth.DefaultAWSCredentialsProviderChain -import com.amazonaws.client.builder.AwsClientBuilder import com.amazonaws.client.builder.AwsSyncClientBuilder +import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration import com.amazonaws.regions.Region import com.amazonaws.regions.RegionUtils +@SuppressWarnings(['FactoryMethodName']) class AwsClientUtil { static final String DEFAULT_REGION = 'us-east-1' @@ -19,7 +20,7 @@ class AwsClientUtil { Region region = buildRegion(config, serviceConfig) assert region.isServiceSupported(serviceName) - AwsClientBuilder.EndpointConfiguration endpointConfiguration = buildEndpointConfiguration(config, serviceConfig) + EndpointConfiguration endpointConfiguration = buildEndpointConfiguration(config, serviceConfig) if (endpointConfiguration) { builder.withEndpointConfiguration(endpointConfiguration) @@ -38,6 +39,7 @@ class AwsClientUtil { * @param serviceConfig * @return */ + @SuppressWarnings(['CyclomaticComplexity', 'AbcMetric', 'MethodSize']) static ClientConfiguration buildClientConfiguration(defaultConfig, serviceConfig) { Map config = [ connectionTimeout: defaultConfig.connectionTimeout ?: 0, @@ -54,36 +56,85 @@ class AwsClientUtil { proxyWorkstation: defaultConfig.proxyWorkstation ?: '' ] if (serviceConfig) { - if (serviceConfig.connectionTimeout) config.connectionTimeout = serviceConfig.connectionTimeout - if (serviceConfig.maxConnections) config.maxConnections = serviceConfig.maxConnections - if (serviceConfig.maxErrorRetry) config.maxErrorRetry = serviceConfig.maxErrorRetry - if (serviceConfig.protocol) config.protocol = serviceConfig.protocol - if (serviceConfig.socketTimeout) config.socketTimeout = serviceConfig.socketTimeout - if (serviceConfig.userAgent) config.userAgent = serviceConfig.userAgent - if (serviceConfig.proxyDomain) config.proxyDomain = serviceConfig.proxyDomain - if (serviceConfig.proxyHost) config.proxyHost = serviceConfig.proxyHost - if (serviceConfig.proxyPassword) config.proxyPassword = serviceConfig.proxyPassword - if (serviceConfig.proxyPort) config.proxyPort = serviceConfig.proxyPort - if (serviceConfig.proxyUsername) config.proxyUsername = serviceConfig.proxyUsername - if (serviceConfig.proxyWorkstation) config.proxyWorkstation = serviceConfig.proxyWorkstation + if (serviceConfig.connectionTimeout) { + config.connectionTimeout = serviceConfig.connectionTimeout + } + if (serviceConfig.maxConnections) { + config.maxConnections = serviceConfig.maxConnections + } + if (serviceConfig.maxErrorRetry) { + config.maxErrorRetry = serviceConfig.maxErrorRetry + } + if (serviceConfig.protocol) { + config.protocol = serviceConfig.protocol + } + if (serviceConfig.socketTimeout) { + config.socketTimeout = serviceConfig.socketTimeout + } + if (serviceConfig.userAgent) { + config.userAgent = serviceConfig.userAgent + } + if (serviceConfig.proxyDomain) { + config.proxyDomain = serviceConfig.proxyDomain + } + if (serviceConfig.proxyHost) { + config.proxyHost = serviceConfig.proxyHost + } + if (serviceConfig.proxyPassword) { + config.proxyPassword = serviceConfig.proxyPassword + } + if (serviceConfig.proxyPort) { + config.proxyPort = serviceConfig.proxyPort + } + if (serviceConfig.proxyUsername) { + config.proxyUsername = serviceConfig.proxyUsername + } + if (serviceConfig.proxyWorkstation) { + config.proxyWorkstation = serviceConfig.proxyWorkstation + } } ClientConfiguration clientConfiguration = new ClientConfiguration() - if (config.connectionTimeout) clientConfiguration.connectionTimeout = config.connectionTimeout - if (config.maxConnections) clientConfiguration.maxConnections = config.maxConnections - if (config.maxErrorRetry) clientConfiguration.maxErrorRetry = config.maxErrorRetry + if (config.connectionTimeout) { + clientConfiguration.connectionTimeout = config.connectionTimeout + } + if (config.maxConnections) { + clientConfiguration.maxConnections = config.maxConnections + } + if (config.maxErrorRetry) { + clientConfiguration.maxErrorRetry = config.maxErrorRetry + } if (config.protocol) { - if (config.protocol.toUpperCase() == 'HTTP') clientConfiguration.protocol = Protocol.HTTP - else clientConfiguration.protocol = Protocol.HTTPS - } - if (config.socketTimeout) clientConfiguration.socketTimeout = config.socketTimeout - if (config.userAgent) clientConfiguration.userAgent = config.userAgent - if (config.proxyDomain) clientConfiguration.proxyDomain = config.proxyDomain - if (config.proxyHost) clientConfiguration.proxyHost = config.proxyHost - if (config.proxyPassword) clientConfiguration.proxyPassword = config.proxyPassword - if (config.proxyPort) clientConfiguration.proxyPort = config.proxyPort - if (config.proxyUsername) clientConfiguration.proxyUsername = config.proxyUsername - if (config.proxyWorkstation) clientConfiguration.proxyWorkstation = config.proxyWorkstation + if (config.protocol.toUpperCase() == 'HTTP') { + clientConfiguration.protocol = Protocol.HTTP + } else { + clientConfiguration.protocol = Protocol.HTTPS + } + } + if (config.socketTimeout) { + clientConfiguration.socketTimeout = config.socketTimeout + } + if (config.userAgent) { + clientConfiguration.userAgent = config.userAgent + } + if (config.proxyDomain) { + clientConfiguration.proxyDomain = config.proxyDomain + } + if (config.proxyHost) { + clientConfiguration.proxyHost = config.proxyHost + } + if (config.proxyPassword) { + clientConfiguration.proxyPassword = config.proxyPassword + } + if (config.proxyPort) { + clientConfiguration.proxyPort = config.proxyPort + } + if (config.proxyUsername) { + clientConfiguration.proxyUsername = config.proxyUsername + } + if (config.proxyWorkstation) { + clientConfiguration.proxyWorkstation = config.proxyWorkstation + } clientConfiguration } @@ -99,8 +150,12 @@ class AwsClientUtil { secretKey: defaultConfig.secretKey ?: '' ] if (serviceConfig) { - if (serviceConfig.accessKey) config.accessKey = serviceConfig.accessKey - if (serviceConfig.secretKey) config.secretKey = serviceConfig.secretKey + if (serviceConfig.accessKey) { + config.accessKey = serviceConfig.accessKey + } + if (serviceConfig.secretKey) { + config.secretKey = serviceConfig.secretKey + } } if (!config.accessKey || !config.secretKey) { @@ -115,6 +170,7 @@ class AwsClientUtil { * @param defaultConfig * @param serviceConfig */ + @SuppressWarnings(['ElseBlockBraces']) static buildRegion(defaultConfig, serviceConfig) { String regionName = DEFAULT_REGION if (serviceConfig?.region) { @@ -125,15 +181,15 @@ class AwsClientUtil { RegionUtils.getRegion(regionName) } - static AwsClientBuilder.EndpointConfiguration buildEndpointConfiguration(defaultConfig, serviceConfig) { + @SuppressWarnings(['ElseBlockBraces']) + static EndpointConfiguration buildEndpointConfiguration(defaultConfig, serviceConfig) { Region region = buildRegion(defaultConfig, serviceConfig) if (serviceConfig?.endpoint) { - return new AwsClientBuilder.EndpointConfiguration(serviceConfig.endpoint as String, region.name) + return new EndpointConfiguration(serviceConfig.endpoint as String, region.name) } else if (defaultConfig?.endpoint) { - return new AwsClientBuilder.EndpointConfiguration(defaultConfig.endpoint as String, region.name) + return new EndpointConfiguration(defaultConfig.endpoint as String, region.name) } - return null + null } - }