@Test public void testDeleteFolder() throws Exception { final Path folder = new Path(new SFTPHomeDirectoryService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)); new SFTPDirectoryFeature(session).mkdir(folder, null, new TransferStatus()); final Path file = new Path(folder, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); new SFTPTouchFeature(session).touch(file, new TransferStatus()); final Path subdir = new Path(folder, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)); new SFTPDirectoryFeature(session).mkdir(subdir, null, new TransferStatus()); new SFTPDeleteFeature(session).delete(Arrays.asList(subdir, file, folder), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Path file : files.keySet()) { if(file.isFile() || file.isSymbolicLink()) { callback.delete(file); try { session.sftp().remove(file.getAbsolute()); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot delete {0}", e, file); } } } for(Path file : files.keySet()) { if(file.isDirectory() && !file.isSymbolicLink()) { callback.delete(file); try { session.sftp().removeDir(file.getAbsolute()); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot delete {0}", e, file); } } } }
SFTPDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Path file : files.keySet()) { if(file.isFile() || file.isSymbolicLink()) { callback.delete(file); try { session.sftp().remove(file.getAbsolute()); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot delete {0}", e, file); } } } for(Path file : files.keySet()) { if(file.isDirectory() && !file.isSymbolicLink()) { callback.delete(file); try { session.sftp().removeDir(file.getAbsolute()); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot delete {0}", e, file); } } } } }
SFTPDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Path file : files.keySet()) { if(file.isFile() || file.isSymbolicLink()) { callback.delete(file); try { session.sftp().remove(file.getAbsolute()); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot delete {0}", e, file); } } } for(Path file : files.keySet()) { if(file.isDirectory() && !file.isSymbolicLink()) { callback.delete(file); try { session.sftp().removeDir(file.getAbsolute()); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot delete {0}", e, file); } } } } SFTPDeleteFeature(final SFTPSession session); }
SFTPDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Path file : files.keySet()) { if(file.isFile() || file.isSymbolicLink()) { callback.delete(file); try { session.sftp().remove(file.getAbsolute()); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot delete {0}", e, file); } } } for(Path file : files.keySet()) { if(file.isDirectory() && !file.isSymbolicLink()) { callback.delete(file); try { session.sftp().removeDir(file.getAbsolute()); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot delete {0}", e, file); } } } } SFTPDeleteFeature(final SFTPSession session); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback); }
SFTPDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Path file : files.keySet()) { if(file.isFile() || file.isSymbolicLink()) { callback.delete(file); try { session.sftp().remove(file.getAbsolute()); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot delete {0}", e, file); } } } for(Path file : files.keySet()) { if(file.isDirectory() && !file.isSymbolicLink()) { callback.delete(file); try { session.sftp().removeDir(file.getAbsolute()); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot delete {0}", e, file); } } } } SFTPDeleteFeature(final SFTPSession session); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback);  }