From e3099abb424cfe9e1f846be360af7abbe7776086 Mon Sep 17 00:00:00 2001 From: Ivan Nikolaev-Axenov Date: Thu, 21 Nov 2024 12:58:50 +0300 Subject: [PATCH] http://jira.mfd.msk:8088/browse/CLS-790 sftp folder path trailing slash bug fixed --- .../clearing/xml/importer/config/SFTPConfig.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/clearing-parent/xml-importer/src/main/java/ru/spcex/clearing/xml/importer/config/SFTPConfig.java b/clearing-parent/xml-importer/src/main/java/ru/spcex/clearing/xml/importer/config/SFTPConfig.java index 1c30485ed..1d7188a7c 100644 --- a/clearing-parent/xml-importer/src/main/java/ru/spcex/clearing/xml/importer/config/SFTPConfig.java +++ b/clearing-parent/xml-importer/src/main/java/ru/spcex/clearing/xml/importer/config/SFTPConfig.java @@ -100,8 +100,13 @@ public class SFTPConfig { @ServiceActivator(inputChannel = "listSftpChannelSdf") public MessageHandler handlerListSdf(@Qualifier("sftpSessionFactorySdf") SessionFactory sessionFactory, ImportXMLServiceSettings settings) { + String localDirLocation = settings.getStore().getSrcDir(); + if (!List.of("/", "\\").contains(localDirLocation.substring(localDirLocation.length() - 1))) { + localDirLocation += File.separator; + } + SftpOutboundGateway sftpOutboundGateway = new SftpOutboundGateway(sessionFactory, MGET.getCommand(), null); - sftpOutboundGateway.setLocalDirectory(new File(settings.getStore().getSrcDir())); + sftpOutboundGateway.setLocalDirectory(new File(localDirLocation)); sftpOutboundGateway.setAutoCreateLocalDirectory(true); sftpOutboundGateway.setOption(AbstractRemoteFileOutboundGateway.Option.DELETE); return sftpOutboundGateway; @@ -112,8 +117,13 @@ public class SFTPConfig { @ServiceActivator(inputChannel = "listSftpChannelLks") public MessageHandler handlerListLks(@Qualifier("sftpSessionFactoryLks") SessionFactory sessionFactory, ImportXMLServiceSettings settings) { + String localDirLocation = settings.getStore().getSrcDir(); + if (!List.of("/", "\\").contains(localDirLocation.substring(localDirLocation.length() - 1))) { + localDirLocation += File.separator; + } + SftpOutboundGateway sftpOutboundGateway = new SftpOutboundGateway(sessionFactory, MGET.getCommand(), null); - sftpOutboundGateway.setLocalDirectory(new File(settings.getStoreLks().getSrcDir())); + sftpOutboundGateway.setLocalDirectory(new File(localDirLocation)); sftpOutboundGateway.setAutoCreateLocalDirectory(true); sftpOutboundGateway.setOption(AbstractRemoteFileOutboundGateway.Option.DELETE); return sftpOutboundGateway;