@Test public void testDeleteNotFound() throws Exception { final Path test = new Path(new FTPWorkdirService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); try { new FTPDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); fail(); } catch(NotfoundException | AccessDeniedException e) { } }
@Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Path file : files.keySet()) { callback.delete(file); try { if(file.isFile() || file.isSymbolicLink()) { if(!session.getClient().deleteFile(file.getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } else if(file.isDirectory()) { if(!session.getClient().changeWorkingDirectory(file.getParent().getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } if(!session.getClient().removeDirectory(file.getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } } catch(IOException e) { throw new FTPExceptionMappingService().map("Cannot delete {0}", e, file); } } }
FTPDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Path file : files.keySet()) { callback.delete(file); try { if(file.isFile() || file.isSymbolicLink()) { if(!session.getClient().deleteFile(file.getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } else if(file.isDirectory()) { if(!session.getClient().changeWorkingDirectory(file.getParent().getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } if(!session.getClient().removeDirectory(file.getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } } catch(IOException e) { throw new FTPExceptionMappingService().map("Cannot delete {0}", e, file); } } } }
FTPDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Path file : files.keySet()) { callback.delete(file); try { if(file.isFile() || file.isSymbolicLink()) { if(!session.getClient().deleteFile(file.getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } else if(file.isDirectory()) { if(!session.getClient().changeWorkingDirectory(file.getParent().getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } if(!session.getClient().removeDirectory(file.getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } } catch(IOException e) { throw new FTPExceptionMappingService().map("Cannot delete {0}", e, file); } } } FTPDeleteFeature(final FTPSession session); }
FTPDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Path file : files.keySet()) { callback.delete(file); try { if(file.isFile() || file.isSymbolicLink()) { if(!session.getClient().deleteFile(file.getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } else if(file.isDirectory()) { if(!session.getClient().changeWorkingDirectory(file.getParent().getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } if(!session.getClient().removeDirectory(file.getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } } catch(IOException e) { throw new FTPExceptionMappingService().map("Cannot delete {0}", e, file); } } } FTPDeleteFeature(final FTPSession session); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback); @Override boolean isSupported(final Path file); }
FTPDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Path file : files.keySet()) { callback.delete(file); try { if(file.isFile() || file.isSymbolicLink()) { if(!session.getClient().deleteFile(file.getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } else if(file.isDirectory()) { if(!session.getClient().changeWorkingDirectory(file.getParent().getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } if(!session.getClient().removeDirectory(file.getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } } catch(IOException e) { throw new FTPExceptionMappingService().map("Cannot delete {0}", e, file); } } } FTPDeleteFeature(final FTPSession session); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback); @Override boolean isSupported(final Path file);  }