List of usage examples for java.util Vector stream
default Stream<E> stream()
From source file:com.qpark.eip.core.sftp.SftpGatewayImpl.java
private void getTreeOfEmptyDirectories(final List<String> emptyDirectories, final String parent, final String currentDirectory) throws Exception { String remotePath = parent;/*from w w w . ja v a 2 s .c o m*/ if (Objects.nonNull(currentDirectory)) { remotePath = String.format("%s%s%s", parent, this.getRemoteFileSeparator(), currentDirectory); } this.logger.trace("getTreeOfEmptyDirectories {} {}", parent, currentDirectory); final LsClientCallback callback = new LsClientCallback(remotePath, null); final Vector<LsEntry> entries = this.template.executeWithClient(callback); if (callback.getSftpException() != null) { this.logger.error("ls {} {}", remotePath, callback.getSftpException().getMessage()); throw callback.getSftpException(); } else if (Objects.nonNull(entries)) { final List<LsEntry> content = entries.stream() .filter(lsEntry -> !lsEntry.getFilename().equals(".") && !lsEntry.getFilename().equals("..")) .collect(Collectors.toList()); if (content.isEmpty()) { emptyDirectories.add(remotePath); this.logger.trace("getTreeOfEmptyDirectories {} {} added {}", parent, currentDirectory, remotePath); } else { final String rPath = remotePath; content.stream().filter(lsEntry -> lsEntry.getAttrs().isDir()).forEach(lsEntry -> { try { this.getTreeOfEmptyDirectories(emptyDirectories, rPath, lsEntry.getFilename()); } catch (final Exception e) { } }); } } }
From source file:com.qpark.eip.core.sftp.SftpGatewayImpl.java
private void getTreeOfFiles(final List<String> filePathes, final String parent, final String currentDirectory, final String fileNamePattern) throws Exception { String remotePath = parent;//from w ww. j ava2 s . c om if (currentDirectory != null) { remotePath = String.format("%s%s%s", parent, this.getRemoteFileSeparator(), currentDirectory); } this.logger.trace("getTreeOfFiles {} {}", parent, currentDirectory); final LsClientCallback callback = new LsClientCallback(remotePath, null); final Vector<LsEntry> entries = this.template.executeWithClient(callback); if (callback.getSftpException() != null) { this.logger.error("ls {} {}", remotePath, callback.getSftpException().getMessage()); throw callback.getSftpException(); } else if (Objects.nonNull(entries)) { final String rPath = remotePath; entries.stream() .filter(lsEntry -> !lsEntry.getFilename().equals(".") && !lsEntry.getFilename().equals("..")) .forEach(lsEntry -> { if (lsEntry.getAttrs().isDir()) { try { this.getTreeOfFiles(filePathes, rPath, lsEntry.getFilename(), fileNamePattern); } catch (final Exception e) { } } else if (lsEntry.getFilename().matches(fileNamePattern)) { filePathes.add( new StringBuffer().append(rPath).append(this.template.getRemoteFileSeparator()) .append(lsEntry.getFilename()).toString()); this.logger.trace("getTreeOfFiles {} {} added {}", parent, currentDirectory, lsEntry.getFilename()); } }); } }