@Test @Ignore public void testAppend() throws Exception { final ProtocolFactory factory = new ProtocolFactory(new HashSet<>(Collections.singleton(new IRODSProtocol()))); final Profile profile = new ProfilePlistReader(factory).read( new Local("../profiles/iRODS (iPlant Collaborative).cyberduckprofile")); final Host host = new Host(profile, profile.getDefaultHostname(), new Credentials( System.getProperties().getProperty("irods.key"), System.getProperties().getProperty("irods.secret") )); final IRODSSession session = new IRODSSession(host); session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); final int length = 32770; final byte[] content = RandomUtils.nextBytes(length); final OutputStream out = local.getOutputStream(false); IOUtils.write(content, out); out.close(); final Checksum checksumPart1; final Checksum checksumPart2; final Path test = new Path(new IRODSHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); { final TransferStatus status = new TransferStatus().length(content.length / 2); checksumPart1 = new IRODSUploadFeature(session).upload( test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledConnectionCallback()); assertEquals(content.length / 2, status.getOffset()); } { final TransferStatus status = new TransferStatus().length(content.length / 2).skip(content.length / 2).append(true); checksumPart2 = new IRODSUploadFeature(session).upload( test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledConnectionCallback()); assertEquals(content.length / 2, status.getOffset()); } assertNotEquals(checksumPart1, checksumPart2); final byte[] buffer = new byte[content.length]; final InputStream in = new IRODSReadFeature(session).read(test, new TransferStatus().length(content.length), new DisabledConnectionCallback()); IOUtils.readFully(in, buffer); in.close(); assertArrayEquals(content, buffer); new IRODSDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); local.delete(); session.close(); }
@Override public Write.Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(new DefaultFindFeature(session).withCache(cache).find(file)) { return Write.override; } return Write.notfound; }
IRODSUploadFeature implements Upload<Checksum> { @Override public Write.Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(new DefaultFindFeature(session).withCache(cache).find(file)) { return Write.override; } return Write.notfound; } }
IRODSUploadFeature implements Upload<Checksum> { @Override public Write.Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(new DefaultFindFeature(session).withCache(cache).find(file)) { return Write.override; } return Write.notfound; } IRODSUploadFeature(final IRODSSession session); }
IRODSUploadFeature implements Upload<Checksum> { @Override public Write.Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(new DefaultFindFeature(session).withCache(cache).find(file)) { return Write.override; } return Write.notfound; } IRODSUploadFeature(final IRODSSession session); @Override Checksum upload(final Path file, final Local local, final BandwidthThrottle throttle,
                           final StreamListener listener, final TransferStatus status,
                           final ConnectionCallback callback); @Override Write.Append append(final Path file, final Long length, final Cache<Path> cache); @Override Upload<Checksum> withWriter(final Write<Checksum> writer); }
IRODSUploadFeature implements Upload<Checksum> { @Override public Write.Append append(final Path file, final Long length, final Cache<Path> cache) throws BackgroundException { if(new DefaultFindFeature(session).withCache(cache).find(file)) { return Write.override; } return Write.notfound; } IRODSUploadFeature(final IRODSSession session); @Override Checksum upload(final Path file, final Local local, final BandwidthThrottle throttle,
                           final StreamListener listener, final TransferStatus status,
                           final ConnectionCallback callback); @Override Write.Append append(final Path file, final Long length, final Cache<Path> cache); @Override Upload<Checksum> withWriter(final Write<Checksum> writer);  }