Skip to content

Commit

Permalink
revert sftp back to 5.2.3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
jianmingtu committed Jan 19, 2024
1 parent a3bb44a commit f340504
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions jrcc-access-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<properties>
<log4j2.version>2.17.1</log4j2.version>
<spring-integration-sftp.version>5.2.3.RELEASE</spring-integration-sftp.version>
<default-package>ca.bc.gov.open</default-package>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version> <!-- suppress error in eclipse https://github.com/spring-projects/spring-boot/issues/16846 -->
</properties>
Expand Down
2 changes: 2 additions & 0 deletions jrcc-access-spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<properties>
<log4j2.version>2.17.1</log4j2.version>
<spring-integration-sftp.version>5.2.3.RELEASE</spring-integration-sftp.version>
<java.version>17</java.version>
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
Expand All @@ -42,6 +43,7 @@
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-sftp</artifactId>
<version>5.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
import ca.bc.gov.open.jrccaccess.autoconfigure.config.exceptions.KnownHostFileNotFoundException;
import com.jcraft.jsch.ChannelSftp;
import org.apache.commons.lang3.StringUtils;
import org.apache.sshd.sftp.client.SftpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.integration.annotation.InboundChannelAdapter;
import org.springframework.integration.annotation.Poller;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.file.filters.ChainFileListFilter;
import org.springframework.integration.file.remote.session.CachingSessionFactory;
import org.springframework.integration.file.remote.session.SessionFactory;
import org.springframework.integration.metadata.ConcurrentMetadataStore;
import org.springframework.integration.sftp.filters.SftpPersistentAcceptOnceFileListFilter;
import org.springframework.integration.sftp.filters.SftpRegexPatternFileListFilter;
Expand Down Expand Up @@ -56,7 +56,7 @@ public AutoConfiguration(SftpInputProperties sftpInputProperties) {
}

@Bean
public DefaultSftpSessionFactory sftpSessionFactory() throws InvalidConfigException {
public SessionFactory<ChannelSftp.LsEntry> sftpSessionFactory() throws InvalidConfigException {

DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(true);
factory.setHost(properties.getHost());
Expand All @@ -81,9 +81,14 @@ public DefaultSftpSessionFactory sftpSessionFactory() throws InvalidConfigExcept
if (!knownHostFile.exists())
throw new KnownHostFileNotFoundException("Cannot find known_hosts file when allow-unknown-keys is false.");

factory.setKnownHostsResource(new ByteArrayResource(properties.getKnownHostFile().getBytes()));
factory.setKnownHosts(properties.getKnownHostFile());
}

properties.getServerAliveInterval().ifPresent(serverAliveInterval -> factory.setServerAliveInterval(serverAliveInterval));

this.properties.getCachingSessionMaxPoolSize().ifPresent(poolSize -> factory.setServerAliveCountMax(poolSize));
this.properties.getCachingSessionWaitTimeout().ifPresent(timeout -> factory.setServerAliveInterval(timeout));

return factory;

}
Expand All @@ -101,13 +106,14 @@ public SftpRemoteFileTemplate template() {
@Bean
@InboundChannelAdapter(channel = "sftpChannel", poller = @Poller(cron = "${bcgov.access.input.sftp.cron}", maxMessagesPerPoll = "${bcgov.access.input.sftp.max-message-per-poll}"))
public MessageSource<InputStream> sftpMessageSource(ConcurrentMetadataStore concurrentMetadataStore) {
ChainFileListFilter<SftpClient.DirEntry> filterChain = new ChainFileListFilter<>();
ChainFileListFilter<ChannelSftp.LsEntry> filterChain = new ChainFileListFilter<>();
if (properties.getFilterPattern() != null && !"".equals(properties.getFilterPattern()))
filterChain.addFilter(new SftpRegexPatternFileListFilter(properties.getFilterPattern()));
filterChain.addFilter(new SftpPersistentAcceptOnceFileListFilter(concurrentMetadataStore, "sftpSource"));
SftpStreamingMessageSource messageSource = new SftpStreamingMessageSource(template());
messageSource.setRemoteDirectory(properties.getRemoteDirectory());
messageSource.setFilter(filterChain);

return messageSource;
}

Expand All @@ -117,4 +123,5 @@ public MessageHandler handler(SftpDocumentInput sftpDocumentInput) {
return sftpDocumentInput;
}


}
6 changes: 6 additions & 0 deletions jrcc-access-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<properties>
<log4j2.version>2.17.1</log4j2.version>
<spring-integration-sftp.version>5.2.3.RELEASE</spring-integration-sftp.version>
<java.version>17</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version> <!-- suppress error in eclipse https://github.com/spring-projects/spring-boot/issues/16846 -->
</properties>
Expand All @@ -40,6 +41,11 @@
<artifactId>jrcc-access-spring-boot-autoconfigure</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-sftp</artifactId>
<version>5.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>ca.bc.gov.open</groupId>
<artifactId>jrcc-document-access-libs</artifactId>
Expand Down
1 change: 1 addition & 0 deletions jrcc-document-access-libs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

<properties>
<log4j2.version>2.17.1</log4j2.version>
<spring-integration-sftp.version>5.2.3.RELEASE</spring-integration-sftp.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

<properties>
<log4j2.version>2.17.1</log4j2.version>
<spring-integration-sftp.version>5.2.3.RELEASE</spring-integration-sftp.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
Expand Down

0 comments on commit f340504

Please sign in to comment.