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 8e574b2..cef1800 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-2017 the original author or authors. + * Copyright 2016-2018 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. @@ -19,12 +19,10 @@ 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; import org.springframework.integration.file.remote.session.Session; import org.springframework.integration.file.remote.session.SessionFactory; import org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer; @@ -54,18 +52,8 @@ public class S3InboundFileSynchronizer extends AbstractInboundFileSynchronizer sessionFactory) { super(sessionFactory); - setRemoteDirectoryExpression(new LiteralExpression(null)); - setFilter(new S3PersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "s3MessageSource")); - } - - @Override - public final void setRemoteDirectoryExpression(Expression remoteDirectoryExpression) { - super.setRemoteDirectoryExpression(remoteDirectoryExpression); - } - - @Override - public final void setFilter(FileListFilter filter) { - super.setFilter(filter); + doSetRemoteDirectoryExpression(new LiteralExpression(null)); + doSetFilter(new S3PersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "s3MessageSource")); } @Override @@ -86,6 +74,7 @@ public class S3InboundFileSynchronizer extends AbstractInboundFileSynchronizer session) throws IOException { + return 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 6357735..d09e4f5 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-2017 the original author or authors. + * Copyright 2016-2018 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,16 +16,18 @@ package org.springframework.integration.aws.inbound; -import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.List; +import java.util.stream.Collectors; import org.springframework.integration.aws.support.S3FileInfo; import org.springframework.integration.aws.support.S3Session; +import org.springframework.integration.aws.support.filters.S3PersistentAcceptOnceFileListFilter; import org.springframework.integration.file.remote.AbstractFileInfo; import org.springframework.integration.file.remote.AbstractRemoteFileStreamingMessageSource; import org.springframework.integration.file.remote.RemoteFileTemplate; +import org.springframework.integration.metadata.SimpleMetadataStore; import com.amazonaws.services.s3.model.S3ObjectSummary; @@ -47,15 +49,15 @@ public class S3StreamingMessageSource extends AbstractRemoteFileStreamingMessage Comparator> comparator) { super(template, comparator); + + doSetFilter(new S3PersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "s3StreamingMessageSource")); } @Override protected List> asFileInfoList(Collection collection) { - List> canonicalFiles = new ArrayList>(); - for (S3ObjectSummary s3ObjectSummary : collection) { - canonicalFiles.add(new S3FileInfo(s3ObjectSummary)); - } - return canonicalFiles; + return collection.stream() + .map(S3FileInfo::new) + .collect(Collectors.toList()); } @Override