Search in sources :

Example 1 with FileSystemException

use of org.apache.commons.vfs.FileSystemException in project symmetric-ds by JumpMind.

the class FtpDataWriter method sendFiles.

protected void sendFiles() {
    if (fileInfoByTable.size() > 0) {
        try {
            String sftpUri = buildUri();
            FileSystemOptions opts = new FileSystemOptions();
            FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, true);
            SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no");
            SftpFileSystemConfigBuilder.getInstance().setTimeout(opts, 60000);
            Collection<FileInfo> fileInfos = fileInfoByTable.values();
            for (FileInfo fileInfo : fileInfos) {
                FileObject fileObject = manager.resolveFile(sftpUri + "/" + fileInfo.outputFile.getName(), opts);
                FileObject localFileObject = manager.resolveFile(fileInfo.outputFile.getAbsolutePath());
                fileObject.copyFrom(localFileObject, Selectors.SELECT_SELF);
                fileObject.close();
            }
        } catch (FileSystemException e) {
            logger.warn("If you have not configured your ftp connection it should be configured in conf/ftp-extensions.xml");
            throw new IoException(e);
        } catch (Exception e) {
            throw new IoException(e);
        } finally {
            manager.close();
        }
    }
}
Also used : FileSystemException(org.apache.commons.vfs.FileSystemException) IoException(org.jumpmind.exception.IoException) FileObject(org.apache.commons.vfs.FileObject) IoException(org.jumpmind.exception.IoException) IOException(java.io.IOException) FileSystemException(org.apache.commons.vfs.FileSystemException) FileSystemOptions(org.apache.commons.vfs.FileSystemOptions)

Aggregations

IOException (java.io.IOException)1 FileObject (org.apache.commons.vfs.FileObject)1 FileSystemException (org.apache.commons.vfs.FileSystemException)1 FileSystemOptions (org.apache.commons.vfs.FileSystemOptions)1 IoException (org.jumpmind.exception.IoException)1