@Test public void testCopyDifferentBucket() throws Exception { final B2FileidProvider fileid = new B2FileidProvider(session).withCache(cache); final Path container = new Path("test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path target = new B2DirectoryFeature(session, fileid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus()); final String name = new AlphanumericRandomStringService().random(); final Path test = new B2TouchFeature(session, fileid).touch(new Path(container, name, EnumSet.of(Path.Type.file)), new TransferStatus()); assertTrue(new B2FindFeature(session, fileid).find(test)); final Path copy = new B2CopyFeature(session, fileid).copy(test, new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus(), new DisabledConnectionCallback()); assertTrue(new B2FindFeature(session, fileid).find(new Path(container, name, EnumSet.of(Path.Type.file)))); assertTrue(new B2FindFeature(session, fileid).find(copy)); new B2DeleteFeature(session, fileid).delete(Arrays.asList(test, copy, target), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
@Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final B2FileResponse response = session.getClient().copyFile(fileid.getFileid(source, new DisabledListProgressListener()), fileid.getFileid(containerService.getContainer(target), new DisabledListProgressListener()), containerService.getKey(target)); return new Path(target.getParent(), target.getName(), target.getType(), new B2AttributesFinderFeature(session, fileid).toAttributes(response)); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Cannot copy {0}", e, source); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } }
B2CopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final B2FileResponse response = session.getClient().copyFile(fileid.getFileid(source, new DisabledListProgressListener()), fileid.getFileid(containerService.getContainer(target), new DisabledListProgressListener()), containerService.getKey(target)); return new Path(target.getParent(), target.getName(), target.getType(), new B2AttributesFinderFeature(session, fileid).toAttributes(response)); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Cannot copy {0}", e, source); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } }
B2CopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final B2FileResponse response = session.getClient().copyFile(fileid.getFileid(source, new DisabledListProgressListener()), fileid.getFileid(containerService.getContainer(target), new DisabledListProgressListener()), containerService.getKey(target)); return new Path(target.getParent(), target.getName(), target.getType(), new B2AttributesFinderFeature(session, fileid).toAttributes(response)); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Cannot copy {0}", e, source); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } B2CopyFeature(final B2Session session, final B2FileidProvider fileid); }
B2CopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final B2FileResponse response = session.getClient().copyFile(fileid.getFileid(source, new DisabledListProgressListener()), fileid.getFileid(containerService.getContainer(target), new DisabledListProgressListener()), containerService.getKey(target)); return new Path(target.getParent(), target.getName(), target.getType(), new B2AttributesFinderFeature(session, fileid).toAttributes(response)); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Cannot copy {0}", e, source); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } B2CopyFeature(final B2Session session, final B2FileidProvider fileid); @Override Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback); @Override boolean isSupported(final Path source, final Path target); }
B2CopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final B2FileResponse response = session.getClient().copyFile(fileid.getFileid(source, new DisabledListProgressListener()), fileid.getFileid(containerService.getContainer(target), new DisabledListProgressListener()), containerService.getKey(target)); return new Path(target.getParent(), target.getName(), target.getType(), new B2AttributesFinderFeature(session, fileid).toAttributes(response)); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Cannot copy {0}", e, source); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } B2CopyFeature(final B2Session session, final B2FileidProvider fileid); @Override Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback); @Override boolean isSupported(final Path source, final Path target);  }