@Test public void testMoveToExistingFile() throws Exception { final Path home = new DropboxHomeFinderFeature(session).find(); final Path folder = new DropboxDirectoryFeature(session).mkdir( new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), null, new TransferStatus()); assertTrue(new DefaultFindFeature(session).find(folder)); final Path test = new DropboxTouchFeature(session).touch( new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); assertTrue(new DefaultFindFeature(session).find(test)); final Path temp = new DropboxTouchFeature(session).touch( new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); assertTrue(new DefaultFindFeature(session).find(temp)); new DropboxMoveFeature(session).move(temp, test, new TransferStatus().exists(true), new Delete.DisabledCallback(), new DisabledConnectionCallback()); final AttributedList<Path> files = new DropboxListService(session).list(folder, new DisabledListProgressListener()); assertEquals(1, files.size()); assertFalse(new DropboxFindFeature(session).find(temp)); assertTrue(new DropboxFindFeature(session).find(test)); new DropboxDeleteFeature(session).delete(Collections.singletonList(folder), 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()) { new DropboxDeleteFeature(session).delete(Collections.singletonMap(renamed, status), connectionCallback, callback); } final RelocationResult result = new DbxUserFilesRequests(session.getClient(file)).moveV2(containerService.getKey(file), containerService.getKey(renamed)); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new DropboxAttributesFinderFeature(session).toAttributes(result.getMetadata())); } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Cannot move {0}", e, file); } }
DropboxMoveFeature 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()) { new DropboxDeleteFeature(session).delete(Collections.singletonMap(renamed, status), connectionCallback, callback); } final RelocationResult result = new DbxUserFilesRequests(session.getClient(file)).moveV2(containerService.getKey(file), containerService.getKey(renamed)); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new DropboxAttributesFinderFeature(session).toAttributes(result.getMetadata())); } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Cannot move {0}", e, file); } } }
DropboxMoveFeature 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()) { new DropboxDeleteFeature(session).delete(Collections.singletonMap(renamed, status), connectionCallback, callback); } final RelocationResult result = new DbxUserFilesRequests(session.getClient(file)).moveV2(containerService.getKey(file), containerService.getKey(renamed)); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new DropboxAttributesFinderFeature(session).toAttributes(result.getMetadata())); } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Cannot move {0}", e, file); } } DropboxMoveFeature(final DropboxSession session); }
DropboxMoveFeature 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()) { new DropboxDeleteFeature(session).delete(Collections.singletonMap(renamed, status), connectionCallback, callback); } final RelocationResult result = new DbxUserFilesRequests(session.getClient(file)).moveV2(containerService.getKey(file), containerService.getKey(renamed)); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new DropboxAttributesFinderFeature(session).toAttributes(result.getMetadata())); } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Cannot move {0}", e, file); } } DropboxMoveFeature(final DropboxSession 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); }
DropboxMoveFeature 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()) { new DropboxDeleteFeature(session).delete(Collections.singletonMap(renamed, status), connectionCallback, callback); } final RelocationResult result = new DbxUserFilesRequests(session.getClient(file)).moveV2(containerService.getKey(file), containerService.getKey(renamed)); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new DropboxAttributesFinderFeature(session).toAttributes(result.getMetadata())); } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Cannot move {0}", e, file); } } DropboxMoveFeature(final DropboxSession 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);  }