@Test public void testCopyDirectory() throws Exception { final Path directory = new DropboxDirectoryFeature(session).mkdir( new Path(new DropboxHomeFinderFeature(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), null, new TransferStatus()); final String name = new AlphanumericRandomStringService().random(); final Path file = new DropboxTouchFeature(session).touch( new Path(directory, name, EnumSet.of(Path.Type.file)), new TransferStatus()); assertTrue(new DropboxFindFeature(session).find(file)); final Path copy = new Path(new DropboxHomeFinderFeature(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); new DropboxCopyFeature(session).copy(directory, copy, new TransferStatus(), new DisabledConnectionCallback()); assertTrue(new DropboxFindFeature(session).find(file)); assertTrue(new DropboxFindFeature(session).find(copy)); assertTrue(new DropboxFindFeature(session).find(new Path(copy, name, EnumSet.of(Path.Type.file)))); new DropboxDeleteFeature(session).delete(Arrays.asList(directory, copy), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { if(status.isExists()) { new DropboxDeleteFeature(session).delete(Collections.singletonMap(target, status), callback, new Delete.DisabledCallback()); } new DbxUserFilesRequests(session.getClient(source)).copyV2(containerService.getKey(source), containerService.getKey(target)); return target; } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Cannot copy {0}", e, source); } }
DropboxCopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { if(status.isExists()) { new DropboxDeleteFeature(session).delete(Collections.singletonMap(target, status), callback, new Delete.DisabledCallback()); } new DbxUserFilesRequests(session.getClient(source)).copyV2(containerService.getKey(source), containerService.getKey(target)); return target; } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Cannot copy {0}", e, source); } } }
DropboxCopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { if(status.isExists()) { new DropboxDeleteFeature(session).delete(Collections.singletonMap(target, status), callback, new Delete.DisabledCallback()); } new DbxUserFilesRequests(session.getClient(source)).copyV2(containerService.getKey(source), containerService.getKey(target)); return target; } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Cannot copy {0}", e, source); } } DropboxCopyFeature(DropboxSession session); }
DropboxCopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { if(status.isExists()) { new DropboxDeleteFeature(session).delete(Collections.singletonMap(target, status), callback, new Delete.DisabledCallback()); } new DbxUserFilesRequests(session.getClient(source)).copyV2(containerService.getKey(source), containerService.getKey(target)); return target; } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Cannot copy {0}", e, source); } } DropboxCopyFeature(DropboxSession session); @Override Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback); @Override boolean isRecursive(final Path source, final Path target); }
DropboxCopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { if(status.isExists()) { new DropboxDeleteFeature(session).delete(Collections.singletonMap(target, status), callback, new Delete.DisabledCallback()); } new DbxUserFilesRequests(session.getClient(source)).copyV2(containerService.getKey(source), containerService.getKey(target)); return target; } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Cannot copy {0}", e, source); } } DropboxCopyFeature(DropboxSession session); @Override Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback); @Override boolean isRecursive(final Path source, final Path target);  }