@Test public void testMoveOverride() throws Exception { final Path workdir = new SFTPHomeDirectoryService(session).find(); final Path test = new Path(workdir, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); new SFTPTouchFeature(session).touch(test, new TransferStatus()); final Path target = new Path(workdir, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); new SFTPTouchFeature(session).touch(target, new TransferStatus()); new SFTPMoveFeature(session).move(test, target, new TransferStatus().exists(true), new Delete.DisabledCallback(), new DisabledConnectionCallback()); assertFalse(new SFTPFindFeature(session).find(test)); assertTrue(new SFTPFindFeature(session).find(target)); new SFTPDeleteFeature(session).delete(Collections.<Path>singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { try { if(status.isExists()) { delete.delete(Collections.singletonMap(renamed, status), connectionCallback, callback); } session.sftp().rename(file.getAbsolute(), renamed.getAbsolute()); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new PathAttributes(file.attributes())); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot rename {0}", e, file); } }
SFTPMoveFeature implements Move { @Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { try { if(status.isExists()) { delete.delete(Collections.singletonMap(renamed, status), connectionCallback, callback); } session.sftp().rename(file.getAbsolute(), renamed.getAbsolute()); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new PathAttributes(file.attributes())); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot rename {0}", e, file); } } }
SFTPMoveFeature implements Move { @Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { try { if(status.isExists()) { delete.delete(Collections.singletonMap(renamed, status), connectionCallback, callback); } session.sftp().rename(file.getAbsolute(), renamed.getAbsolute()); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new PathAttributes(file.attributes())); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot rename {0}", e, file); } } SFTPMoveFeature(final SFTPSession session); }
SFTPMoveFeature implements Move { @Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { try { if(status.isExists()) { delete.delete(Collections.singletonMap(renamed, status), connectionCallback, callback); } session.sftp().rename(file.getAbsolute(), renamed.getAbsolute()); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new PathAttributes(file.attributes())); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot rename {0}", e, file); } } SFTPMoveFeature(final SFTPSession session); @Override Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback); @Override boolean isRecursive(final Path source, final Path target); }
SFTPMoveFeature implements Move { @Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { try { if(status.isExists()) { delete.delete(Collections.singletonMap(renamed, status), connectionCallback, callback); } session.sftp().rename(file.getAbsolute(), renamed.getAbsolute()); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new PathAttributes(file.attributes())); } catch(IOException e) { throw new SFTPExceptionMappingService().map("Cannot rename {0}", e, file); } } SFTPMoveFeature(final SFTPSession session); @Override Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback); @Override boolean isRecursive(final Path source, final Path target);  }