List of usage examples for org.apache.commons.net.ftp FTPSClient initiateListParsing
public FTPListParseEngine initiateListParsing() throws IOException
From source file:org.mule.transport.ftps.FtpsMessageReceiver.java
protected FTPFile[] listFiles() throws Exception { FTPSClient client = null; try {// w ww .jav a2s . c o m client = connector.createFTPSClient(endpoint); FTPListParseEngine engine = client.initiateListParsing(); FTPFile[] files = null; List<FTPFile> v = new ArrayList<FTPFile>(); while (engine.hasNext()) { if (getLifecycleState().isStopping()) { break; } files = engine.getNext(FTP_LIST_PAGE_SIZE); if (files == null || files.length == 0) { return files; } for (FTPFile file : files) { if (file.isFile()) { if (filenameFilter == null || filenameFilter.accept(null, file.getName())) { v.add(file); } } } } if (!FTPReply.isPositiveCompletion(client.getReplyCode())) { throw new IOException("Failed to list files. Ftp error: " + client.getReplyCode()); } return v.toArray(new FTPFile[v.size()]); } finally { if (client != null) { connector.releaseFtp(endpoint.getEndpointURI(), client); } } }
From source file:org.mule.transport.ftps.FtpsMessageRequester.java
protected FTPFile findFileToProcess(FTPSClient client) throws Exception { //Checking if it is a file or a directory boolean isFile = connector.isFile(endpoint, client); FTPListParseEngine engine = client.initiateListParsing(); FTPFile[] files = null;//from ww w . ja v a2 s.c o m while (engine.hasNext()) { files = engine.getNext(FTP_LIST_PAGE_SIZE); if (files == null) { break; } FilenameFilter filenameFilter = getFilenameFilter(); for (int i = 0; i < files.length; i++) { FTPFile file = files[i]; if (file.isFile() && isValid(file, filenameFilter)) { // only read the first one return file; } } } if (!FTPReply.isPositiveCompletion(client.getReplyCode())) { throw new IOException("Ftp error: " + client.getReplyCode()); } return null; }