@Test(expected = NotfoundException.class) public void testDeleteNotFound() throws Exception { final Path test = new Path(new SFTPHomeDirectoryService(session).find(), "t", EnumSet.of(Path.Type.file)); try { new SFTPDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); } catch(NotfoundException e) { assertEquals("Cannot delete t.", e.getMessage()); throw e; } }
@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);  }