@Test public void testMoveFile() throws Exception { final Path home = new DropboxHomeFinderFeature(session).find(); final Path file = new DropboxTouchFeature(session).touch(new Path(home, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)), new TransferStatus()); assertTrue(new DropboxFindFeature(session).find(file)); assertTrue(new DefaultFindFeature(session).find(file)); final Path target = new DropboxMoveFeature(session).move(file, new Path(home, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)), new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback()); assertFalse(new DropboxFindFeature(session).find(file)); assertTrue(new DropboxFindFeature(session).find(target)); assertTrue(new DefaultFindFeature(session).find(target)); assertEquals(target.attributes(), file.attributes()); assertEquals(target.attributes(), new DropboxAttributesFinderFeature(session).find(target)); new DropboxDeleteFeature(session).delete(Collections.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()) { 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);  }