List of usage examples for org.springframework.integration.sftp.session DefaultSftpSessionFactory getSession
@Override
public SftpSession getSession()
From source file:com.st.si.Main.java
/** * Load the Spring Integration Application Context * * @param args - command line arguments/*from w w w . j a v a 2s . c o m*/ */ public static void main(final String... args) { final AbstractApplicationContext context = new ClassPathXmlApplicationContext( "classpath:META-INF/spring/integration/*-context.xml"); context.registerShutdownHook(); DefaultSftpSessionFactory sftpSessionFactory = context.getBean(DefaultSftpSessionFactory.class); SftpSession session = sftpSessionFactory.getSession(); final DirectChannel requestChannel = (DirectChannel) context.getBean("inboundMGetRecursive"); //final PollableChannel replyChannel = (PollableChannel) context.getBean("output"); try { String dir = "/HVAC - Files For Testing/"; requestChannel.send(new GenericMessage<Object>(dir + "*")); /*if (!session.exists(sftpConfiguration.getOtherRemoteDirectory())) { throw new FileNotFoundException("Remote directory does not exists... Continuing"); }*/ rename(session, dir); dir = "/HPwES - Files For Testing/"; requestChannel.send(new GenericMessage<Object>(dir + "*")); rename(session, dir); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } /*final DirectChannel requestChannel = (DirectChannel) context.getBean("inboundMGetRecursive"); final PollableChannel replyChannel = (PollableChannel) context.getBean("output"); String dir = "/HVAC - Files For Testing/"; requestChannel.send(new GenericMessage<Object>(dir + "*")); Message<?> result = replyChannel.receive(1000); List<File> localFiles = (List<File>) result.getPayload(); for (File file : localFiles) { System.out.println(file.getName()); }*/ System.exit(0); }
From source file:org.oscarehr.integration.born.BornFtpManager.java
public static boolean upload18MEWBVDataToRepository(byte[] xmlFile, String filename) { String remotePath = OscarProperties.getInstance().getProperty("born18m_sftp_remote_dir", ""); DefaultSftpSessionFactory ftpFactory = (DefaultSftpSessionFactory) SpringUtils .getBean("ftpClientFactoryBORN18M"); Session session = null;/* w w w . j av a 2s . co m*/ boolean success = false; try { session = ftpFactory.getSession(); if (session.isOpen()) { session.write(new ByteArrayInputStream(xmlFile), remotePath + File.separator + filename); success = true; } } catch (Exception e) { MiscUtils.getLogger().warn("Failed uploading to repository", e); } finally { if (session != null && session.isOpen()) session.close(); } return success; }