use of com.adaptris.filetransfer.FileTransferException in project interlok by adaptris.
the class ApacheFtpClientImpl method setKeepAliveTimeout.
@Override
public void setKeepAliveTimeout(long seconds) throws FileTransferException {
try {
acquireLock();
ftpClient().setControlKeepAliveTimeout(seconds);
} catch (IOException e) {
throw new FileTransferException(e);
} finally {
releaseLock();
}
}
use of com.adaptris.filetransfer.FileTransferException in project interlok by adaptris.
the class SftpClient method listFiles.
private List<ChannelSftp.LsEntry> listFiles(String dirname) throws IOException, FileTransferException {
checkConnected();
List<ChannelSftp.LsEntry> result = new ArrayList<>();
try {
acquireLock();
String path = defaultIfBlank(dirname, CURRENT_DIR);
log("DIR {}", path);
Vector<LsEntry> v = sessionWrapper.getSftpChannel().ls(path);
for (LsEntry entry : v) {
if (!(entry.getFilename().equals(CURRENT_DIR) || entry.getFilename().equals(PARENT_DIR))) {
result.add(entry);
}
}
} catch (Exception e) {
throw SftpException.wrapException("Could not list files in " + dirname, e);
} finally {
releaseLock();
}
return result;
}
use of com.adaptris.filetransfer.FileTransferException in project interlok by adaptris.
the class SftpClient method lastModified.
/**
* @see FileTransferClient#lastModified(java.lang.String)
*/
@Override
public long lastModified(String remoteFile) throws IOException, FileTransferException {
long mtime;
checkConnected();
try {
acquireLock();
log("STAT {}", remoteFile);
SftpATTRS attr = sessionWrapper.getSftpChannel().stat(remoteFile);
mtime = (long) attr.getMTime() * 1000;
} catch (Exception e) {
throw SftpException.wrapException("Could not get lastModified on [" + remoteFile + "]", e);
} finally {
releaseLock();
}
return mtime;
}
use of com.adaptris.filetransfer.FileTransferException in project interlok by adaptris.
the class RelaxedFtpConsumerTest method testSingleFileConsumeDeleteFails.
@Test
public void testSingleFileConsumeDeleteFails() throws Exception {
setFilesToConsume(new String[] { "/MySingleFile.txt" }, new String[] { "My file payload" }, new long[] { calendarOneYearAgo.getTimeInMillis() });
doThrow(new FileTransferException("expected")).when(mockFileTransferClient).delete(anyString());
LifecycleHelper.init(consumer);
LifecycleHelper.start(consumer);
waitForConsumer(1, 3000);
assertEquals(1, messageListener.getMessages().size());
}
use of com.adaptris.filetransfer.FileTransferException in project interlok by adaptris.
the class RelaxedFtpConsumerTest method testDirFailsIncorrectPathConsume.
@Test
public void testDirFailsIncorrectPathConsume() throws Exception {
setFilesToConsume(new String[] { "/MySingleFile.txt" }, new String[] { "My file payload" }, new long[] { calendarOneYearAgo.getTimeInMillis() });
when(mockFileTransferClient.dir(DIR_ROOT)).thenThrow(new FileTransferException("testDirFailsIncorrectPathConsume"));
when(mockFileTransferClient.dir(eq(DIR_ROOT), isA(FileFilter.class))).thenThrow(new FileTransferException("testDirFailsIncorrectPathConsume"));
LifecycleHelper.init(consumer);
LifecycleHelper.start(consumer);
waitForConsumer(1, 1000);
assertEquals(0, messageListener.getMessages().size());
}
Aggregations