diff --git a/build.gradle b/build.gradle index 9881b01..43ec23f 100644 --- a/build.gradle +++ b/build.gradle @@ -3,12 +3,8 @@ buildscript { maven { url 'http://repo.spring.io/plugins-release' } } dependencies { - classpath 'io.spring.gradle:spring-io-plugin:0.0.6.RELEASE' - } - configurations.classpath.resolutionStrategy.eachDependency { - if (it.requested.name == 'dependency-management-plugin') { - it.useVersion '1.0.0.RELEASE' - } + classpath 'io.spring.gradle:dependency-management-plugin:1.0.2.RELEASE' + classpath 'io.spring.gradle:spring-io-plugin:0.0.8.RELEASE' } } @@ -17,7 +13,7 @@ plugins { id 'eclipse' id 'idea' id 'jacoco' - id 'org.sonarqube' version '2.2.1' + id 'org.sonarqube' version '2.5' id 'checkstyle' } description = 'Spring Integration AWS Support' @@ -37,7 +33,7 @@ repositories { ext { assertjVersion = '3.6.2' servletApiVersion = '3.1.0' - slf4jVersion = '1.7.22' + slf4jVersion = '1.7.25' springCloudAwsVersion = '1.2.1.RELEASE' springIntegrationVersion = '4.3.10.RELEASE' @@ -95,12 +91,12 @@ dependencyManagement { } jacoco { - toolVersion = "0.7.8" + toolVersion = "0.7.9" } checkstyle { configFile = file("${rootDir}/src/checkstyle/checkstyle.xml") - toolVersion = "6.16.1" + toolVersion = "8.0" } dependencies { @@ -167,7 +163,7 @@ jacocoTestReport { reports { xml.enabled false csv.enabled false - html.destination "${buildDir}/reports/jacoco/html" + html.destination file("${buildDir}/reports/jacoco/html") } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index cd66b87..c8bf763 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8b9defb..4ba4026 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue May 30 10:53:11 EDT 2017 +#Mon Jul 10 20:22:20 EDT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-bin.zip diff --git a/gradlew b/gradlew index 4453cce..cccdd3d 100755 --- a/gradlew +++ b/gradlew @@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS="" # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -155,7 +155,7 @@ if $cygwin ; then fi # Escape application args -save ( ) { +save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } diff --git a/src/main/java/org/springframework/integration/aws/inbound/S3InboundFileSynchronizer.java b/src/main/java/org/springframework/integration/aws/inbound/S3InboundFileSynchronizer.java index da05bbc..9e51231 100644 --- a/src/main/java/org/springframework/integration/aws/inbound/S3InboundFileSynchronizer.java +++ b/src/main/java/org/springframework/integration/aws/inbound/S3InboundFileSynchronizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,12 @@ package org.springframework.integration.aws.inbound; +import java.io.File; +import java.io.IOException; + import org.springframework.expression.Expression; import org.springframework.expression.common.LiteralExpression; +import org.springframework.integration.aws.support.S3Session; import org.springframework.integration.aws.support.S3SessionFactory; import org.springframework.integration.aws.support.filters.S3PersistentAcceptOnceFileListFilter; import org.springframework.integration.file.filters.FileListFilter; @@ -79,4 +83,11 @@ public class S3InboundFileSynchronizer extends AbstractInboundFileSynchronizer session) throws IOException { + super.copyFileToLocalDirectory(((S3Session) session).normalizeBucketName(remoteDirectoryPath), + remoteFile, localDirectory, session); + } + } diff --git a/src/main/java/org/springframework/integration/aws/inbound/S3StreamingMessageSource.java b/src/main/java/org/springframework/integration/aws/inbound/S3StreamingMessageSource.java index 62c07a4..6357735 100644 --- a/src/main/java/org/springframework/integration/aws/inbound/S3StreamingMessageSource.java +++ b/src/main/java/org/springframework/integration/aws/inbound/S3StreamingMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import java.util.Comparator; import java.util.List; import org.springframework.integration.aws.support.S3FileInfo; +import org.springframework.integration.aws.support.S3Session; import org.springframework.integration.file.remote.AbstractFileInfo; import org.springframework.integration.file.remote.AbstractRemoteFileStreamingMessageSource; import org.springframework.integration.file.remote.RemoteFileTemplate; @@ -32,6 +33,8 @@ import com.amazonaws.services.s3.model.S3ObjectSummary; * A {@link AbstractRemoteFileStreamingMessageSource} implementation for the Amazon S3. * * @author Christian Tzolov + * @author Artem Bilan + * * @since 1.1 */ public class S3StreamingMessageSource extends AbstractRemoteFileStreamingMessageSource { @@ -41,13 +44,13 @@ public class S3StreamingMessageSource extends AbstractRemoteFileStreamingMessage } public S3StreamingMessageSource(RemoteFileTemplate template, - Comparator> comparator) { + Comparator> comparator) { + super(template, comparator); } @Override protected List> asFileInfoList(Collection collection) { - List> canonicalFiles = new ArrayList>(); for (S3ObjectSummary s3ObjectSummary : collection) { canonicalFiles.add(new S3FileInfo(s3ObjectSummary)); @@ -60,4 +63,14 @@ public class S3StreamingMessageSource extends AbstractRemoteFileStreamingMessage return "aws:s3-inbound-streaming-channel-adapter"; } + @Override + protected AbstractFileInfo poll() { + AbstractFileInfo file = super.poll(); + if (file != null) { + S3Session s3Session = (S3Session) getRemoteFileTemplate().getSession(); + file.setRemoteDirectory(s3Session.normalizeBucketName(file.getRemoteDirectory())); + } + return file; + } + } diff --git a/src/main/java/org/springframework/integration/aws/support/S3Session.java b/src/main/java/org/springframework/integration/aws/support/S3Session.java index 7477991..d8d6ab3 100644 --- a/src/main/java/org/springframework/integration/aws/support/S3Session.java +++ b/src/main/java/org/springframework/integration/aws/support/S3Session.java @@ -228,6 +228,10 @@ public class S3Session implements Session { return this.amazonS3; } + public String normalizeBucketName(String path) { + return splitPathToBucketAndKey(path, false)[0]; + } + private String[] splitPathToBucketAndKey(String path, boolean requireKey) { Assert.hasText(path, "'path' must not be empty String."); diff --git a/src/test/java/org/springframework/integration/aws/inbound/S3StreamingChannelAdapterTests.java b/src/test/java/org/springframework/integration/aws/inbound/S3StreamingChannelAdapterTests.java index 04f22be..e658a01 100644 --- a/src/test/java/org/springframework/integration/aws/inbound/S3StreamingChannelAdapterTests.java +++ b/src/test/java/org/springframework/integration/aws/inbound/S3StreamingChannelAdapterTests.java @@ -162,7 +162,7 @@ public class S3StreamingChannelAdapterTests { S3RemoteFileTemplate s3FileTemplate = new S3RemoteFileTemplate(s3SessionFactory); S3StreamingMessageSource s3MessageSource = new S3StreamingMessageSource(s3FileTemplate, Comparator.comparing(FileInfo::getFilename)); - s3MessageSource.setRemoteDirectory("/" + S3_BUCKET); + s3MessageSource.setRemoteDirectory("/" + S3_BUCKET + "/subdir"); s3MessageSource.setFilter(new S3PersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "streaming")); return s3MessageSource;