sftp добавил лог для OutDir

This commit is contained in:
AKurakin 2024-04-09 18:44:59 +03:00
parent 60deeca9b9
commit fe84a88781
6 changed files with 24 additions and 0 deletions

View file

@ -1,6 +1,8 @@
package ru.spcex.clearing.dbf.exporter.config;
import com.jcraft.jsch.ChannelSftp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.expression.common.LiteralExpression;
@ -27,6 +29,7 @@ import static org.springframework.integration.file.remote.gateway.AbstractRemote
@Configuration
public class SFTPConfig {
protected Logger log = LoggerFactory.getLogger(getClass());
@Bean
public SessionFactory<ChannelSftp.LsEntry> sftpSessionFactory(ExportDBFServiceSettings settings) {
@ -44,6 +47,7 @@ public class SFTPConfig {
public MessageHandler handler(SessionFactory<ChannelSftp.LsEntry> sessionFactory, ExportDBFServiceSettings settings) {
SftpMessageHandler handler = new SftpMessageHandler(sessionFactory);
handler.setRemoteDirectoryExpression(new LiteralExpression(settings.getStore().getOutDir()));
log.info("Configure sftp output directory \"{}\"", settings.getStore().getOutDir());
handler.setAutoCreateDirectory(true);
handler.setFileNameGenerator(message -> {
if (message.getPayload() instanceof File) {

View file

@ -1,6 +1,8 @@
package ru.spcex.clearing.lim.exporter.config;
import com.jcraft.jsch.ChannelSftp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.expression.common.LiteralExpression;
@ -20,6 +22,7 @@ import java.io.File;
@Configuration
public class SFTPConfig {
protected Logger log = LoggerFactory.getLogger(getClass());
@Bean
public SessionFactory<ChannelSftp.LsEntry> sftpSessionFactory(ExportLimServiceSettings settings) {
@ -37,6 +40,7 @@ public class SFTPConfig {
public MessageHandler handler(SessionFactory<ChannelSftp.LsEntry> sessionFactory, ExportLimServiceSettings settings) {
SftpMessageHandler handler = new SftpMessageHandler(sessionFactory);
handler.setRemoteDirectoryExpression(new LiteralExpression(settings.getStore().getOutDir()));
log.info("Configure sftp output directory \"{}\"", settings.getStore().getOutDir());
handler.setAutoCreateDirectory(true);
handler.setFileNameGenerator(message -> {
if (message.getPayload() instanceof File) {

View file

@ -1,6 +1,8 @@
package ru.spcex.clearing.registry.config;
import com.jcraft.jsch.ChannelSftp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -28,6 +30,7 @@ import static org.springframework.integration.file.remote.gateway.AbstractRemote
@Configuration
public class SFTPReportsConfig {
protected Logger log = LoggerFactory.getLogger(getClass());
private final RegistryServiceSettings settings;
public SFTPReportsConfig(RegistryServiceSettings settings) {
@ -50,6 +53,7 @@ public class SFTPReportsConfig {
public MessageHandler handler(@Qualifier("reportsSftpSessionFactory") SessionFactory<ChannelSftp.LsEntry> sessionFactory) {
SftpMessageHandler handler = new SftpMessageHandler(sessionFactory);
handler.setRemoteDirectoryExpression(new LiteralExpression(settings.getReportsStore().getOutDir()));
log.info("Configure sftp output directory \"{}\"", settings.getReportsStore().getOutDir());
handler.setAutoCreateDirectory(true);
handler.setFileNameGenerator(message -> {
if (message.getPayload() instanceof File) {

View file

@ -1,6 +1,8 @@
package ru.spcex.clearing.reports.config;
import com.jcraft.jsch.ChannelSftp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -28,6 +30,7 @@ import static org.springframework.integration.file.remote.gateway.AbstractRemote
@Configuration
public class SFTPNotificationsConfig {
protected Logger log = LoggerFactory.getLogger(getClass());
private final ReportsServiceSettings settings;
public SFTPNotificationsConfig(ReportsServiceSettings settings) {
@ -50,6 +53,7 @@ public class SFTPNotificationsConfig {
public MessageHandler handler(@Qualifier("notificationsSftpSessionFactory") SessionFactory<ChannelSftp.LsEntry> sessionFactory) {
SftpMessageHandler handler = new SftpMessageHandler(sessionFactory);
handler.setRemoteDirectoryExpression(new LiteralExpression(settings.getNotificationsStore().getOutDir()));
log.info("Configure sftp output directory \"{}\"", settings.getNotificationsStore().getOutDir());
handler.setAutoCreateDirectory(true);
handler.setFileNameGenerator(message -> {
if (message.getPayload() instanceof File) {

View file

@ -1,6 +1,8 @@
package ru.spcex.clearing.reports.config;
import com.jcraft.jsch.ChannelSftp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -28,6 +30,7 @@ import static org.springframework.integration.file.remote.gateway.AbstractRemote
@Configuration
public class SFTPReportsConfig {
protected Logger log = LoggerFactory.getLogger(getClass());
private final ReportsServiceSettings settings;
public SFTPReportsConfig(ReportsServiceSettings settings) {
@ -50,6 +53,7 @@ public class SFTPReportsConfig {
public MessageHandler handler(@Qualifier("reportsSftpSessionFactory") SessionFactory<ChannelSftp.LsEntry> sessionFactory) {
SftpMessageHandler handler = new SftpMessageHandler(sessionFactory);
handler.setRemoteDirectoryExpression(new LiteralExpression(settings.getReportsStore().getOutDir()));
log.info("Configure sftp output directory \"{}\"", settings.getReportsStore().getOutDir());
handler.setAutoCreateDirectory(true);
handler.setFileNameGenerator(message -> {
if (message.getPayload() instanceof File) {

View file

@ -1,6 +1,8 @@
package ru.spcex.clearing.swt.exporter.config;
import com.jcraft.jsch.ChannelSftp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
@ -30,6 +32,7 @@ import static org.springframework.integration.file.remote.gateway.AbstractRemote
@Configuration
@ConditionalOnProperty(value="export-swt-service.sftp-out.sftp-out-dir")
public class SFTPConfig {
protected Logger log = LoggerFactory.getLogger(getClass());
private final ExportSwtServiceSettings settings;
public SFTPConfig(ExportSwtServiceSettings settings) {
@ -52,6 +55,7 @@ public class SFTPConfig {
public MessageHandler handler(@Qualifier("sftpSessionFactory") SessionFactory<ChannelSftp.LsEntry> sessionFactory) {
SftpMessageHandler handler = new SftpMessageHandler(sessionFactory);
handler.setRemoteDirectoryExpression(new LiteralExpression(settings.getSftpOut().getSftpOutDir()));
log.info("Configure sftp output directory \"{}\"", settings.getSftpOut().getSftpOutDir());
handler.setAutoCreateDirectory(true);
handler.setFileNameGenerator(message -> {
if (message.getPayload() instanceof File) {