Search in sources :

Example 1 with FTPFileRef

use of nl.nn.adapterframework.ftp.FTPFileRef in project iaf by ibissource.

the class FtpFileSystem method findFile.

private FTPFile findFile(FTPFile file) throws IOException {
    FTPFile[] files = null;
    if (file instanceof FTPFileRef) {
        FTPFileRef fileRef = (FTPFileRef) file;
        files = ftpClient.listFiles(fileRef.getFolder(), f -> f.getName().equals(fileRef.getFileName()));
    } else {
        files = ftpClient.listFiles(file.getName(), f -> f.getName().equals(file.getName()));
    }
    if (files != null && files.length > 0) {
        return files[0];
    }
    return null;
}
Also used : OutputStream(java.io.OutputStream) NotImplementedException(org.apache.commons.lang3.NotImplementedException) Message(nl.nn.adapterframework.stream.Message) Iterator(java.util.Iterator) FtpSession(nl.nn.adapterframework.ftp.FtpSession) Date(java.util.Date) FTPFileRef(nl.nn.adapterframework.ftp.FTPFileRef) FilterOutputStream(java.io.FilterOutputStream) IOException(java.io.IOException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DirectoryStream(java.nio.file.DirectoryStream) List(java.util.List) Map(java.util.Map) FTPFile(org.apache.commons.net.ftp.FTPFile) NoSuchElementException(java.util.NoSuchElementException) FtpConnectException(nl.nn.adapterframework.ftp.FtpConnectException) InputStream(java.io.InputStream) FTPReply(org.apache.commons.net.ftp.FTPReply) FTPFile(org.apache.commons.net.ftp.FTPFile) FTPFileRef(nl.nn.adapterframework.ftp.FTPFileRef)

Example 2 with FTPFileRef

use of nl.nn.adapterframework.ftp.FTPFileRef in project iaf by ibissource.

the class FtpFileSystemTest method testFTPFileRefWindowsSlash.

@Test
public void testFTPFileRefWindowsSlash() {
    FTPFileRef ref2 = new FTPFileRef("folder1\\test123");
    ref2.setFolder("folder2");
    assertEquals("folder2/folder1/test123", ref2.getName());
}
Also used : FTPFileRef(nl.nn.adapterframework.ftp.FTPFileRef) Test(org.junit.Test)

Example 3 with FTPFileRef

use of nl.nn.adapterframework.ftp.FTPFileRef in project iaf by ibissource.

the class FtpFileSystemTest method testFTPFileRefSetFolder.

@Test
public void testFTPFileRefSetFolder() {
    FTPFileRef ref1 = new FTPFileRef("test123");
    ref1.setFolder("folder");
    assertEquals("folder/test123", ref1.getName());
}
Also used : FTPFileRef(nl.nn.adapterframework.ftp.FTPFileRef) Test(org.junit.Test)

Example 4 with FTPFileRef

use of nl.nn.adapterframework.ftp.FTPFileRef in project iaf by ibissource.

the class FtpFileSystemTest method testFTPFileRefRelativeWithSetFolder.

@Test
public void testFTPFileRefRelativeWithSetFolder() {
    FTPFileRef ref2 = new FTPFileRef("folder1/test123");
    ref2.setFolder("folder2");
    assertEquals("folder2/folder1/test123", ref2.getName());
}
Also used : FTPFileRef(nl.nn.adapterframework.ftp.FTPFileRef) Test(org.junit.Test)

Example 5 with FTPFileRef

use of nl.nn.adapterframework.ftp.FTPFileRef in project iaf by ibissource.

the class FtpFileSystem method toFile.

@Override
public FTPFile toFile(String folder, String filename) throws FileSystemException {
    FTPFileRef ftpFile = new FTPFileRef();
    ftpFile.setName(filename);
    ftpFile.setFolder(folder);
    return ftpFile;
}
Also used : FTPFileRef(nl.nn.adapterframework.ftp.FTPFileRef)

Aggregations

FTPFileRef (nl.nn.adapterframework.ftp.FTPFileRef)5 Test (org.junit.Test)3 FilterOutputStream (java.io.FilterOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 DirectoryStream (java.nio.file.DirectoryStream)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 NoSuchElementException (java.util.NoSuchElementException)1 FtpConnectException (nl.nn.adapterframework.ftp.FtpConnectException)1 FtpSession (nl.nn.adapterframework.ftp.FtpSession)1 Message (nl.nn.adapterframework.stream.Message)1 NotImplementedException (org.apache.commons.lang3.NotImplementedException)1 FTPFile (org.apache.commons.net.ftp.FTPFile)1 FTPReply (org.apache.commons.net.ftp.FTPReply)1